2 Copyright © 1995-2019, The AROS Development Team. All rights reserved.
5 Desc: Offscreen bitmap class for VMWare hidd.
9 #define __OOP_NOATTRBASES__
11 #include <proto/oop.h>
12 #include <proto/utility.h>
14 #include <exec/alerts.h>
15 #include <exec/lists.h>
16 #include <exec/memory.h>
17 #include <aros/symbolsets.h>
18 #include <graphics/gfx.h>
19 #include <graphics/rastport.h>
23 #include "vmwaresvga_intern.h"
25 #include LC_LIBDEFS_FILE
27 /* Don't initialize them with "= 0", otherwise they end up in the DATA segment! */
29 static OOP_AttrBase HiddBitMapAttrBase
;
30 static OOP_AttrBase HiddPixFmtAttrBase
;
31 static OOP_AttrBase HiddGfxAttrBase
;
32 static OOP_AttrBase HiddVMWareSVGAAttrBase
;
33 static OOP_AttrBase HiddVMWareSVGABitMapAttrBase
;
35 static struct OOP_ABDescr attrbases
[] =
37 {IID_Hidd_BitMap
, &HiddBitMapAttrBase
},
38 {IID_Hidd_PixFmt
, &HiddPixFmtAttrBase
},
39 {IID_Hidd_Gfx
, &HiddGfxAttrBase
},
41 {IID_Hidd_VMWareSVGA
, &HiddVMWareSVGAAttrBase
},
42 {IID_Hidd_VMWareSVGABitMap
, &HiddVMWareSVGABitMapAttrBase
},
46 #define DEBUGNAME "[VMWareSVGA:OffBitMap]"
47 #define MNAME_ROOT(x) VMWareSVGAOffBM__Root__ ## x
48 #define MNAME_BM(x) VMWareSVGAOffBM__Hidd_BitMap__ ## x
50 #include "vmwaresvga_bitmap_common.c"
53 include our debug overides after bitmap_common incase it sets its own values...
59 #include <aros/debug.h>
61 /*********** BitMap::New() *************************************/
63 OOP_Object
*MNAME_ROOT(New
)(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
65 D(bug(DEBUGNAME
" %s()\n", __func__
);)
67 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
) msg
);
70 struct BitmapData
*data
;
72 IPTR width
, height
, depth
;
73 OOP_Object
*bmfriend
, *pf
;
75 data
= OOP_INST_DATA(cl
, o
);
78 memset(data
, 0, sizeof(struct BitmapData
));
81 OOP_GetAttr(o
, aHidd_BitMap_Width
, &width
);
82 OOP_GetAttr(o
, aHidd_BitMap_Height
, &height
);
83 OOP_GetAttr(o
, aHidd_BitMap_PixFmt
, (IPTR
*)&pf
);
84 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, &depth
);
86 /* Get the friend bitmap. This should be a displayable bitmap */
87 OOP_GetAttr(o
, aHidd_BitMap_Friend
, (IPTR
*)&bmfriend
);
89 /* If you got a friend bitmap, copy its colormap */
92 struct BitmapData
*src
= OOP_INST_DATA(cl
, bmfriend
);
93 CopyMem(&src
->cmap
, &data
->cmap
, 4*16);
95 ASSERT (width
!= 0 && height
!= 0 && depth
!= 0);
96 width
=(width
+15) & ~15;
98 data
->height
= height
;
105 data
->bytesperpix
= multi
;
107 data
->VideoData
= AllocVec(width
*height
*multi
, MEMF_PUBLIC
| MEMF_CLEAR
);
110 InitSemaphore(&data
->bmsem
);
111 data
->data
= &XSD(cl
)->data
;
112 if (XSD(cl
)->activecallback
)
113 XSD(cl
)->activecallback(XSD(cl
)->callbackdata
, o
, TRUE
);
114 } /* if got data->VideoData */
117 OOP_MethodID disp_mid
= OOP_GetMethodID(IID_Root
, moRoot_Dispose
);
118 OOP_CoerceMethod(cl
, o
, (OOP_Msg
) &disp_mid
);
121 } /* if created object */
123 D(bug(DEBUGNAME
" %s: returning 0x%p\n", __func__
, o
));
128 /********** Bitmap::Dispose() ***********************************/
130 VOID
MNAME_ROOT(Dispose
)(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
132 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
134 D(bug(DEBUGNAME
" %s()\n", __func__
);)
136 FreeVec(data
->VideoData
);
137 OOP_DoSuperMethod(cl
, o
, msg
);
138 ReturnVoid("VMWareSVGA.BitMap::Dispose");
141 /*** init_bmclass *********************************************************/
143 static int VMWareSVGAOffBM_Init(LIBBASETYPEPTR LIBBASE
)
145 D(bug(DEBUGNAME
" %s()\n", __func__
);)
147 ReturnInt("VMWareSVGAOffBM_Init", ULONG
, OOP_ObtainAttrBases(attrbases
));
150 /*** free_offbitmapclass *********************************************************/
152 static int VMWareSVGAOffBM_Expunge(LIBBASETYPEPTR LIBBASE
)
154 D(bug(DEBUGNAME
" %s()\n", __func__
);)
156 OOP_ReleaseAttrBases(attrbases
);
158 ReturnInt("VMWareSVGAOffBM_Expunge", int, TRUE
);
161 ADD2INITLIB(VMWareSVGAOffBM_Init
, 0)
162 ADD2EXPUNGELIB(VMWareSVGAOffBM_Expunge
, 0)