Check for SYS/GL during library init. Reason is that
[AROS.git] / rom / intuition / changescreenbuffer.c
blob91f0821572099cd3fe7c470a599580e249468c60
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
6 Desc: Intuition function ChangeScreenBuffer()
7 Lang: english
8 */
9 #include <proto/graphics.h>
10 #include "intuition_intern.h"
11 #include "inputhandler.h"
12 #include "menus.h"
14 /*****************************************************************************
16 NAME */
17 #include <intuition/screens.h>
18 #include <proto/intuition.h>
20 AROS_LH2(ULONG, ChangeScreenBuffer,
22 /* SYNOPSIS */
23 AROS_LHA(struct Screen * , screen, A0),
24 AROS_LHA(struct ScreenBuffer *, screenbuffer, A1),
26 /* LOCATION */
27 struct IntuitionBase *, IntuitionBase, 130, Intuition)
29 /* FUNCTION
30 Do double or multiple buffering on an intuition screen in an
31 intuition-cooperative way. The ScreenBuffer's BitMap will be
32 installed on the specified screen, if possible. After a signal from
33 graphics.library, the previously installed BitMap will be available
34 for re-use. Consult graphics.library/AllocDBufInfo() and
35 graphics.library/ChangeVPBitMap() for further information.
37 INPUTS
38 screen - The screen this screenbuffer belongs to
39 screenbuffer - The screenbuffer obtained by AllocScreenBuffer()
41 RESULT
42 Non-zero if fuction succeeded, or zero if operation could not be
43 performed, e.g. if user selects menus or gadgets.
45 NOTES
46 You need not re-install the original ScreenBuffer before closing
47 a screen. Just FreeScreenBuffer() all buffers used for that screen.
49 EXAMPLE
51 BUGS
53 SEE ALSO
54 AllocScreenBuffer(), FreeScreenBuffer(),
55 graphics.library/ChangeVPBitMap()
57 INTERNALS
59 *****************************************************************************/
61 AROS_LIBFUNC_INIT
63 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
64 //struct IIHData *iihdata;
65 ULONG lock;
67 if (!screen) return 0;
68 if (!screenbuffer) return 0;
70 #if 0
71 if (MENUS_ACTIVE) return 0;
72 iihdata = (struct IIHData *)((struct IntIntuitionBase *)(IntuitionBase))->InputHandler->is_Data;
73 if (iihdata->ActiveGadget) return 0;
74 #endif
76 lock = LockIBase(0);
78 ChangeVPBitMap(&screen->ViewPort,screenbuffer->sb_BitMap,screenbuffer->sb_DBufInfo);
80 screen->RastPort.BitMap = screenbuffer->sb_BitMap;
81 UpdateScreenBitMap(screen, IntuitionBase);
83 UnlockIBase(lock);
85 return TRUE;
87 AROS_LIBFUNC_EXIT
88 } /* ChangeScreenBuffer */
90 void UpdateScreenBitMap(struct Screen *screen, struct IntuitionBase *IntuitionBase)
92 int i;
93 struct BitMap *bm = screen->RastPort.BitMap;
94 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
96 /* Patch up the obsolete screen bitmap as best we can for old programs
98 screen->BitMap_OBSOLETE.BytesPerRow = GetBitMapAttr(bm, BMA_WIDTH) / 8;
99 screen->BitMap_OBSOLETE.Rows = GetBitMapAttr(bm, BMA_HEIGHT);
100 screen->BitMap_OBSOLETE.Flags = BMF_INVALID | (GetBitMapAttr(bm, BMA_FLAGS) & BMF_STANDARD);
101 screen->BitMap_OBSOLETE.pad = 0;
102 screen->BitMap_OBSOLETE.Depth = GetBitMapAttr(bm, BMA_DEPTH);
103 for (i = 0; i < 8; i++) {
104 /* And for *really* old programs, copy the plane pointers,
105 * if possible
107 if (screen->BitMap_OBSOLETE.Flags & BMF_STANDARD)
108 screen->BitMap_OBSOLETE.Planes[i] = bm->Planes[i];
109 else
110 screen->BitMap_OBSOLETE.Planes[i] = NULL;