Workaround for includes conflict that stopped compilation with GCC 3.
[tangerine.git] / rom / graphics / setfrontbitmap.c
blobda727948d868c058a033a1c6419cceaf900598fc
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Private graphics function for allocating screen bitmaps
6 Lang: english
7 */
8 #include <aros/debug.h>
9 #include "graphics_intern.h"
10 #include "gfxfuncsupport.h"
11 #include <exec/memory.h>
12 #include <graphics/rastport.h>
13 #include <proto/exec.h>
14 #include <proto/oop.h>
15 #include <oop/oop.h>
17 /*****************************************************************************
19 NAME */
20 #include <graphics/rastport.h>
21 #include <proto/graphics.h>
23 AROS_LH2(BOOL , SetFrontBitMap,
25 /* SYNOPSIS */
26 AROS_LHA(struct BitMap *, bitmap, A0),
27 AROS_LHA(BOOL, copyback, D0),
29 /* LOCATION */
30 struct GfxBase *, GfxBase, 184, Graphics)
32 /* FUNCTION
33 Sets the supplied screen as the frontmost, e.g. shows it in the display.
35 INPUTS
36 bitmap - The bitmap to put in front. Must be a displayable bitmap.
37 copyback - Whether to copy back from the framebuffer into
38 the previously front bitmap. !!!! Only set this to TRUE
39 this if you are 100% SURE that
40 the previously shown bitmap has not been disposed
42 RESULT
43 success - TRUE if successful, FALSE otherwise.
45 NOTES
46 This function is private and AROS specific.
48 EXAMPLE
50 BUGS
52 SEE ALSO
54 INTERNALS
56 HISTORY
58 *****************************************************************************/
60 AROS_LIBFUNC_INIT
62 #warning THIS IS NOT THREADSAFE
64 /* To make this threadsafe we have to lock
65 all gfx access in all the rendering calls
67 OOP_Object *cmap, *pf;
68 HIDDT_ColorModel colmod;
69 OOP_Object *fb;
70 BOOL ok = FALSE;
71 ULONG showflags = 0;
73 //if (bitmap && (BMF_DISPLAYABLE != (bitmap->Flags & BMF_DISPLAYABLE)))
74 if (bitmap && (!(bitmap->Flags & BMF_AROS_HIDD) || !(HIDD_BM_FLAGS(bitmap) & HIDD_BMF_SCREEN_BITMAP)))
76 D(bug("!!! SetFrontBitMap: TRYING TO SET NON-DISPLAYABLE BITMAP !!!\n"));
77 return FALSE;
80 if ( SDD(GfxBase)->frontbm == bitmap)
82 D(bug("!!!!!!!!!!!!!!! SHOWING BITMAP %p TWICE !!!!!!!!!!!\n", bitmap));
83 return TRUE;
86 if (copyback)
88 showflags |= fHidd_Gfx_Show_CopyBack;
91 fb = HIDD_Gfx_Show(SDD(GfxBase)->gfxhidd, (bitmap ? HIDD_BM_OBJ(bitmap) : NULL), showflags);
93 if (NULL == fb)
95 D(bug("!!! SetFrontBitMap: HIDD_Gfx_Show() FAILED !!!\n"));
97 else
99 Forbid();
101 /* Set this as the active screen */
102 if (NULL != SDD(GfxBase)->frontbm)
104 struct BitMap *oldbm;
105 /* Put back the old values into the old bitmap */
106 oldbm = SDD(GfxBase)->frontbm;
107 HIDD_BM_OBJ(oldbm) = SDD(GfxBase)->bm_bak;
108 HIDD_BM_COLMOD(oldbm) = SDD(GfxBase)->colmod_bak;
109 HIDD_BM_COLMAP(oldbm) = SDD(GfxBase)->colmap_bak;
113 SDD(GfxBase)->frontbm = bitmap;
114 SDD(GfxBase)->bm_bak = bitmap ? HIDD_BM_OBJ(bitmap) : NULL;
115 SDD(GfxBase)->colmod_bak = bitmap ? HIDD_BM_COLMOD(bitmap) : NULL;
116 SDD(GfxBase)->colmap_bak = bitmap ? HIDD_BM_COLMAP(bitmap) : NULL;
118 if (bitmap)
120 /* Insert the framebuffer in its place */
121 OOP_GetAttr(fb, aHidd_BitMap_ColorMap, (IPTR *)&cmap);
122 OOP_GetAttr(fb, aHidd_BitMap_PixFmt, (IPTR *)&pf);
123 OOP_GetAttr(pf, aHidd_PixFmt_ColorModel, &colmod);
125 HIDD_BM_OBJ(bitmap) = fb;
126 HIDD_BM_COLMOD(bitmap) = colmod;
127 HIDD_BM_COLMAP(bitmap) = cmap;
129 Permit();
131 ok = TRUE;
134 return ok;
136 AROS_LIBFUNC_EXIT
138 } /* AllocScreenBitMap */