2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
5 Desc: Offscreen bitmap class for VMWare hidd.
10 #include <aros/debug.h>
12 #define __OOP_NOATTRBASES__
14 #include <proto/oop.h>
15 #include <proto/utility.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>
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
},
45 {IID_Hidd_VMWareSVGA
, &HiddVMWareSVGAAttrBase
},
46 {IID_Hidd_VMWareSVGABitMap
, &HiddVMWareSVGABitMapAttrBase
},
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
);
63 struct BitmapData
*data
;
65 IPTR width
, height
, depth
;
66 OOP_Object
*friend, *pf
;
67 data
= OOP_INST_DATA(cl
, o
);
69 memset(data
, 0, sizeof(struct BitmapData
));
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 */
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;
86 data
->height
= height
;
93 data
->bytesperpix
= multi
;
94 data
->VideoData
= AllocVec(width
*height
*multi
, MEMF_PUBLIC
| MEMF_CLEAR
);
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
);
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 FreeVec(data
->VideoData
);
119 OOP_DoSuperMethod(cl
, o
, msg
);
120 ReturnVoid("VMWareSVGA.BitMap::Dispose");
123 /*** init_bmclass *********************************************************/
125 static int VMWareSVGAOffBM_Init(LIBBASETYPEPTR LIBBASE
)
127 EnterFunc(bug("VMWareSVGAOffBM_Init\n"));
129 ReturnInt("VMWareSVGAOffBM_Init", ULONG
, OOP_ObtainAttrBases(attrbases
));
132 /*** free_offbitmapclass *********************************************************/
134 static int VMWareSVGAOffBM_Expunge(LIBBASETYPEPTR LIBBASE
)
136 EnterFunc(bug("VMWareSVGAOffBM_Expunge\n"));
138 OOP_ReleaseAttrBases(attrbases
);
140 ReturnInt("VMWareSVGAOffBM_Expunge", int, TRUE
);
143 ADD2INITLIB(VMWareSVGAOffBM_Init
, 0)
144 ADD2EXPUNGELIB(VMWareSVGAOffBM_Expunge
, 0)