r4493@vps: verhaegs | 2007-04-19 14:44:00 -0400
[AROS.git] / rom / graphics / setfrontbitmap.c
blob1f4486c1c5973a78e3028194d28cdc9b332cdc7c
1 /*
2 Copyright © 1995-2001, 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
61 AROS_LIBBASE_EXT_DECL(struct GfxBase *,GfxBase)
63 #warning THIS IS NOT THREADSAFE
65 /* To make this threadsafe we have to lock
66 all gfx access in all the rendering calls
68 OOP_Object *cmap, *pf;
69 HIDDT_ColorModel colmod;
70 OOP_Object *fb;
71 BOOL ok = FALSE;
72 ULONG showflags = 0;
74 //if (bitmap && (BMF_DISPLAYABLE != (bitmap->Flags & BMF_DISPLAYABLE)))
75 if (bitmap && (!(bitmap->Flags & BMF_AROS_HIDD) || !(HIDD_BM_FLAGS(bitmap) & HIDD_BMF_SCREEN_BITMAP)))
77 D(bug("!!! SetFrontBitMap: TRYING TO SET NON-DISPLAYABLE BITMAP !!!\n"));
78 return FALSE;
81 if ( SDD(GfxBase)->frontbm == bitmap)
83 D(bug("!!!!!!!!!!!!!!! SHOWING BITMAP %p TWICE !!!!!!!!!!!\n", bitmap));
84 return TRUE;
87 if (copyback)
89 showflags |= fHidd_Gfx_Show_CopyBack;
92 fb = HIDD_Gfx_Show(SDD(GfxBase)->gfxhidd, (bitmap ? HIDD_BM_OBJ(bitmap) : NULL), showflags);
94 if (NULL == fb)
96 D(bug("!!! SetFrontBitMap: HIDD_Gfx_Show() FAILED !!!\n"));
98 else
100 Forbid();
102 /* Set this as the active screen */
103 if (NULL != SDD(GfxBase)->frontbm)
105 struct BitMap *oldbm;
106 /* Put back the old values into the old bitmap */
107 oldbm = SDD(GfxBase)->frontbm;
108 HIDD_BM_OBJ(oldbm) = SDD(GfxBase)->bm_bak;
109 HIDD_BM_COLMOD(oldbm) = SDD(GfxBase)->colmod_bak;
110 HIDD_BM_COLMAP(oldbm) = SDD(GfxBase)->colmap_bak;
114 SDD(GfxBase)->frontbm = bitmap;
115 SDD(GfxBase)->bm_bak = bitmap ? HIDD_BM_OBJ(bitmap) : NULL;
116 SDD(GfxBase)->colmod_bak = bitmap ? HIDD_BM_COLMOD(bitmap) : NULL;
117 SDD(GfxBase)->colmap_bak = bitmap ? HIDD_BM_COLMAP(bitmap) : NULL;
119 if (bitmap)
121 /* Insert the framebuffer in its place */
122 OOP_GetAttr(fb, aHidd_BitMap_ColorMap, (IPTR *)&cmap);
123 OOP_GetAttr(fb, aHidd_BitMap_PixFmt, (IPTR *)&pf);
124 OOP_GetAttr(pf, aHidd_PixFmt_ColorModel, &colmod);
126 HIDD_BM_OBJ(bitmap) = fb;
127 HIDD_BM_COLMOD(bitmap) = colmod;
128 HIDD_BM_COLMAP(bitmap) = cmap;
130 Permit();
132 ok = TRUE;
135 return ok;
137 AROS_LIBFUNC_EXIT
139 } /* AllocScreenBitMap */