Fix IRQ name
[AROS.git] / workbench / hidds / hidd.vmwaresvga / vmwaresvgaoffbitmap.c
blob4bf01c3dfb8c80838a0702909979b3a68a389cd2
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Offscreen bitmap class for VMWare 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/alerts.h>
18 #include <exec/lists.h>
19 #include <exec/memory.h>
20 #include <aros/symbolsets.h>
21 #include <graphics/gfx.h>
22 #include <graphics/rastport.h>
23 #include <hidd/graphics.h>
24 #include <oop/oop.h>
26 #include "vmwaresvgabitmap.h"
27 #include "vmwaresvgaclass.h"
29 #include LC_LIBDEFS_FILE
31 /* Don't initialize them with "= 0", otherwise they end up in the DATA segment! */
33 static OOP_AttrBase HiddBitMapAttrBase;
34 static OOP_AttrBase HiddPixFmtAttrBase;
35 static OOP_AttrBase HiddGfxAttrBase;
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 /* Private bases */
45 {IID_Hidd_VMWareSVGA, &HiddVMWareSVGAAttrBase },
46 {IID_Hidd_VMWareSVGABitMap, &HiddVMWareSVGABitMapAttrBase },
47 {NULL, NULL }
50 #define MNAME_ROOT(x) VMWareSVGAOffBM__Root__ ## x
51 #define MNAME_BM(x) VMWareSVGAOffBM__Hidd_BitMap__ ## x
53 #include "vmwaresvgabitmap_common.c"
55 /*********** BitMap::New() *************************************/
57 OOP_Object *MNAME_ROOT(New)(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
59 EnterFunc(bug("VMWareSVGA.BitMap::New()\n"));
60 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg) msg);
61 if (o)
63 struct BitmapData *data;
64 LONG multi=1;
65 IPTR width, height, depth;
66 OOP_Object *friend, *pf;
67 data = OOP_INST_DATA(cl, o);
68 /* clear all data */
69 memset(data, 0, sizeof(struct BitmapData));
70 /* Get attr values */
71 OOP_GetAttr(o, aHidd_BitMap_Width, &width);
72 OOP_GetAttr(o, aHidd_BitMap_Height, &height);
73 OOP_GetAttr(o, aHidd_BitMap_PixFmt, (IPTR *)&pf);
74 OOP_GetAttr(pf, aHidd_PixFmt_Depth, &depth);
75 /* Get the friend bitmap. This should be a displayable bitmap */
76 OOP_GetAttr(o, aHidd_BitMap_Friend, (IPTR *)&friend);
77 /* If you got a friend bitmap, copy its colormap */
78 if (friend)
80 struct BitmapData *src = OOP_INST_DATA(cl, friend);
81 CopyMem(&src->cmap, &data->cmap, 4*16);
83 ASSERT (width != 0 && height != 0 && depth != 0);
84 width=(width+15) & ~15;
85 data->width = width;
86 data->height = height;
87 data->bpp = depth;
88 data->disp = 0;
89 if (depth>16)
90 multi = 4;
91 else if (depth>8)
92 multi = 2;
93 data->bytesperpix = multi;
94 data->VideoData = AllocVec(width*height*multi, MEMF_PUBLIC | MEMF_CLEAR);
95 if (data->VideoData)
97 data->data = &XSD(cl)->data;
98 if (XSD(cl)->activecallback)
99 XSD(cl)->activecallback(XSD(cl)->callbackdata, o, TRUE);
100 ReturnPtr("VMWareSVGA.BitMap::New()", OOP_Object *, o);
101 } /* if got data->VideoData */
103 OOP_MethodID disp_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose);
104 OOP_CoerceMethod(cl, o, (OOP_Msg) &disp_mid);
106 o = NULL;
107 } /* if created object */
108 ReturnPtr("VMWareSVGA.BitMap::New()", OOP_Object *, o);
111 /********** Bitmap::Dispose() ***********************************/
113 VOID MNAME_ROOT(Dispose)(OOP_Class *cl, OOP_Object *o, OOP_Msg msg)
115 struct BitmapData *data = OOP_INST_DATA(cl, o);
117 EnterFunc(bug("VMWareSVGA.BitMap::Dispose()\n"));
118 if (data->VideoData)
119 FreeVec(data->VideoData);
120 OOP_DoSuperMethod(cl, o, msg);
121 ReturnVoid("VMWareSVGA.BitMap::Dispose");
124 /*** init_bmclass *********************************************************/
126 static int VMWareSVGAOffBM_Init(LIBBASETYPEPTR LIBBASE)
128 EnterFunc(bug("VMWareSVGAOffBM_Init\n"));
130 ReturnInt("VMWareSVGAOffBM_Init", ULONG, OOP_ObtainAttrBases(attrbases));
133 /*** free_offbitmapclass *********************************************************/
135 static int VMWareSVGAOffBM_Expunge(LIBBASETYPEPTR LIBBASE)
137 EnterFunc(bug("VMWareSVGAOffBM_Expunge\n"));
139 OOP_ReleaseAttrBases(attrbases);
141 ReturnInt("VMWareSVGAOffBM_Expunge", int, TRUE);
144 ADD2INITLIB(VMWareSVGAOffBM_Init, 0)
145 ADD2EXPUNGELIB(VMWareSVGAOffBM_Expunge, 0)