Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / hidds / vmwaresvga / vmwaresvgaonbitmap.c
blob513c1ea20ab25e0b80aa24151faa843eab1107ad
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Bitmap class for VMWareSVGA hidd.
6 Lang: English.
7 */
9 #define DEBUG 0
10 #include <aros/debug.h>
12 #define __OOP_NOATTRBASES__
14 #include <proto/oop.h>
15 #include <proto/utility.h>
16 #include <assert.h>
17 #include <exec/memory.h>
18 #include <exec/lists.h>
19 #include <aros/symbolsets.h>
20 #include <graphics/rastport.h>
21 #include <graphics/gfx.h>
22 #include <hidd/graphics.h>
23 #include <oop/oop.h>
25 #include "vmwaresvgabitmap.h"
26 #include "vmwaresvgaclass.h"
28 #include LC_LIBDEFS_FILE
30 /* Don't initialize static variables with "=0", otherwise they go into DATA segment */
32 static OOP_AttrBase HiddBitMapAttrBase;
33 static OOP_AttrBase HiddPixFmtAttrBase;
34 static OOP_AttrBase HiddGfxAttrBase;
35 static OOP_AttrBase HiddSyncAttrBase;
36 static OOP_AttrBase HiddVMWareSVGAAttrBase;
37 static OOP_AttrBase HiddVMWareSVGABitMapAttrBase;
39 static struct OOP_ABDescr attrbases[] =
41 { IID_Hidd_BitMap, &HiddBitMapAttrBase },
42 { IID_Hidd_PixFmt, &HiddPixFmtAttrBase },
43 { IID_Hidd_Gfx, &HiddGfxAttrBase },
44 { IID_Hidd_Sync, &HiddSyncAttrBase },
45 /* Private bases */
46 { IID_Hidd_VMWareSVGA, &HiddVMWareSVGAAttrBase },
47 { IID_Hidd_VMWareSVGABitMap, &HiddVMWareSVGABitMapAttrBase },
48 { NULL, NULL }
51 #define MNAME_ROOT(x) VMWareSVGAOnBM__Root__ ## x
52 #define MNAME_BM(x) VMWareSVGAOnBM__Hidd_BitMap__ ## x
54 #define OnBitmap 1
55 #include "vmwaresvgabitmap_common.c"
57 /*********** BitMap::New() *************************************/
59 OOP_Object *MNAME_ROOT(New)(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
61 EnterFunc(bug("VMWareSVGA.BitMap::New()\n"));
62 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg) msg);
63 if (o)
65 struct BitmapData *data;
66 LONG multi=1;
67 OOP_Object *pf;
68 IPTR width, height, depth;
69 HIDDT_ModeID modeid;
71 data = OOP_INST_DATA(cl, o);
72 /* clear all data */
73 memset(data, 0, sizeof(struct BitmapData));
74 /* Get attr values */
75 OOP_GetAttr(o, aHidd_BitMap_Width, &width);
76 OOP_GetAttr(o, aHidd_BitMap_Height, &height);
77 OOP_GetAttr(o, aHidd_BitMap_PixFmt, (IPTR *)&pf);
78 OOP_GetAttr(pf, aHidd_PixFmt_Depth, &depth);
79 ASSERT (width != 0 && height != 0 && depth != 0);
80 /*
81 We must only create depths that are supported by the friend drawable
82 Currently we only support the default depth
85 width=(width+15) & ~15;
86 data->width = width;
87 data->height = height;
88 data->bpp = depth;
89 data->disp = -1;
90 if (depth>16)
91 multi = 4;
92 else if (depth>8)
93 multi = 2;
94 data->bytesperpix = multi;
95 data->data = &XSD(cl)->data;
96 data->mouse = &XSD(cl)->mouse;
97 data->VideoData = data->data->vrambase;
98 /* We should be able to get modeID from the bitmap */
99 OOP_GetAttr(o, aHidd_BitMap_ModeID, &modeid);
100 if (modeid != vHidd_ModeID_Invalid)
103 Because of not defined BitMap_Show method show
104 bitmap immediately
106 setModeVMWareSVGA(&XSD(cl)->data, width, height);
107 XSD(cl)->visible = data; /* Set created object as visible */
108 ReturnPtr("VMWareSVGA.BitMap::New()", OOP_Object *, o);
111 OOP_MethodID disp_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose);
112 OOP_CoerceMethod(cl, o, (OOP_Msg) &disp_mid);
114 o = NULL;
115 } /* if created object */
116 ReturnPtr("VMWareSVGA.BitMap::New()", OOP_Object *, o);
119 /********** Bitmap::Dispose() ***********************************/
121 VOID MNAME_ROOT(Dispose)(OOP_Class *cl, OOP_Object *o, OOP_Msg msg)
123 EnterFunc(bug("VMWareSVGA.BitMap::Dispose()\n"));
124 OOP_DoSuperMethod(cl, o, msg);
125 ReturnVoid("VMWareSVGA.BitMap::Dispose");
128 /*** init_onbmclass *********************************************************/
130 static int VMWareSVGAOnBM_Init(LIBBASETYPEPTR LIBBASE)
132 EnterFunc(bug("VMWareSVGAOnBM_Init\n"));
134 ReturnInt("VMWareSVGAOnBM_Init", ULONG, OOP_ObtainAttrBases(attrbases));
137 /*** free_bitmapclass *********************************************************/
139 static int VMWareSVGAOnBM_Expunge(LIBBASETYPEPTR LIBBASE)
141 EnterFunc(bug("VMWareSVGAOnBM_Expunge\n"));
143 OOP_ReleaseAttrBases(attrbases);
145 ReturnInt("VMWareSVGAOnBM_Expunge", int, TRUE);
148 ADD2INITLIB(VMWareSVGAOnBM_Init, 0)
149 ADD2EXPUNGELIB(VMWareSVGAOnBM_Expunge, 0)