2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
9 #include <exec/alerts.h>
10 #include <string.h> // memset() prototype
16 #include <aros/debug.h>
19 /********* BitMap::Clear() *************************************/
20 VOID
MNAME_BM(Clear
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_Clear
*msg
) {
22 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
27 /* this function does not really make sense for LUT bitmaps */
29 HIDDT_Pixel
MNAME_BM(MapColor
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_MapColor
*msg
)
38 /* this function does not really make sense for LUT bitmaps */
40 VOID
MNAME_BM(UnMapPixel
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_UnmapPixel
*msg
)
46 BOOL
MNAME_BM(SetColors
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_SetColors
*msg
) {
47 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
48 HIDDT_PixelFormat
*pf
;
57 (vHidd_ColorModel_StaticPalette
== HIDD_PF_COLMODEL(pf
)) ||
58 (vHidd_ColorModel_TrueColor
== HIDD_PF_COLMODEL(pf
))
60 return OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
61 if (!OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
))
63 if ((msg
->firstColor
+ msg
->numColors
) > (1<<data
->bpp
))
65 for (xc_i
= msg
->firstColor
, col_i
= 0; col_i
< msg
->numColors
; xc_i
++, col_i
++)
67 red
= msg
->colors
[col_i
].red
>> 8;
68 green
= msg
->colors
[col_i
].green
>> 8;
69 blue
= msg
->colors
[col_i
].blue
>> 8;
70 data
->cmap
[xc_i
] = 0x01000000 | red
| (green
<< 8) | (blue
<< 16);
72 vmwareWriteReg(data
->data
, SVGA_PALETTE_BASE
+ xc_i
*3+0, msg
->colors
[col_i
].red
);
73 vmwareWriteReg(data
->data
, SVGA_PALETTE_BASE
+ xc_i
*3+1, msg
->colors
[col_i
].green
);
74 vmwareWriteReg(data
->data
, SVGA_PALETTE_BASE
+ xc_i
*3+2, msg
->colors
[col_i
].blue
);
76 msg
->colors
[col_i
].pixval
= xc_i
;
81 /********* BitMap::PutPixel() ***************************/
83 STATIC VOID
putpixel(struct BitmapData
*data
, LONG x
, LONG y
, HIDDT_Pixel pixel
) {
87 offset
= (x
*data
->bytesperpix
)+(y
*data
->data
->bytesperline
);
89 (x
>=data
->mouse
->x
) && (x
<(data
->mouse
->x
+data
->mouse
->width
)) &&
90 (y
>=data
->mouse
->y
) && (y
<(data
->mouse
->y
+data
->mouse
->height
))
93 displayCursorVMWareGfx(data
->data
, 0);
94 data
->mouse
->visible
= 0;
97 offset
= (x
+ (y
*data
->width
))*data
->bytesperpix
;
99 if (data
->bytesperpix
== 1)
100 *((UBYTE
*)(data
->VideoData
+ offset
)) = pixel
;
101 else if (data
->bytesperpix
== 2)
102 *((UWORD
*)(data
->VideoData
+ offset
)) = pixel
;
103 else if (data
->bytesperpix
== 4)
104 *((ULONG
*)(data
->VideoData
+ offset
)) = pixel
;
106 if (data
->mouse
->visible
== 0)
108 displayCursorVMWareGfx(data
->data
, 1);
109 data
->mouse
->visible
= 1;
114 VOID
MNAME_BM(PutPixel
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutPixel
*msg
) {
115 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
118 putpixel(data
, msg
->x
, msg
->y
, msg
->pixel
);
120 box
.x1
= box
.x2
= msg
->x
;
121 box
.y1
= box
.y2
= msg
->y
;
122 refreshAreaVMWareGfx(data
->data
, &box
);
127 /********* BitMap::GetPixel() *********************************/
128 HIDDT_Pixel
MNAME_BM(GetPixel
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetPixel
*msg
) {
130 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
134 offset
= (msg
->x
*data
->bytesperpix
)+(msg
->y
*data
->data
->bytesperline
);
136 offset
= (msg
->x
+ (msg
->y
*data
->width
))*data
->bytesperpix
;
138 if (data
->bytesperpix
== 1)
139 pixel
= *((UBYTE
*)(data
->VideoData
+ offset
));
140 else if (data
->bytesperpix
== 2)
141 pixel
= *((UWORD
*)(data
->VideoData
+ offset
));
142 else if (data
->bytesperpix
== 4)
143 pixel
= *((ULONG
*)(data
->VideoData
+ offset
));
149 /********* BitMap::DrawPixel() ***************************/
151 VOID
MNAME_BM(DrawPixel
)(OOP_Class
*cl
,OOP_ Object
*o
, struct pHidd_BitMap_DrawPixel
*msg
)
158 /********* BitMap::PutImage() ***************************/
160 VOID
MNAME_BM(PutImage
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutImage
*msg
) {
161 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
168 UBYTE
*src
=(UBYTE
*)msg
->pixels
;
170 if (msg
->pixFmt
== vHidd_StdPixFmt_Native32
)
173 offset
= (msg
->x
*data
->bytesperpix
)+(msg
->y
*data
->data
->bytesperline
);
174 restadd
= (data
->data
->bytesperline
- (msg
->width
*data
->bytesperpix
));
176 offset
= (msg
->x
+ (msg
->y
*data
->width
))*data
->bytesperpix
;
177 restadd
= (data
->width
-msg
->width
)*data
->bytesperpix
;
179 buffer
= data
->VideoData
+offset
;
183 HIDDT_Pixel
*p
= (HIDDT_Pixel
*)src
;
187 if (data
->bytesperpix
== 1)
189 *((UBYTE
*)buffer
) = (UBYTE
)*p
++;
192 else if (data
->bytesperpix
== 2)
194 *((UWORD
*)buffer
) = (UWORD
)*p
++;
197 else if (data
->bytesperpix
== 4)
199 *((ULONG
*)buffer
) = (ULONG
)*p
++;
211 box
.x2
= box
.x1
+msg
->width
-1;
212 box
.y2
= box
.y1
+msg
->height
-1;
213 refreshAreaVMWareGfx(data
->data
, &box
);
218 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
222 /********* BitMap::GetImage() ***************************/
224 VOID
MNAME_BM(GetImage
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetImage
*msg
) {
225 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
231 UBYTE
*src
=msg
->pixels
;
233 if (msg
->pixFmt
== vHidd_StdPixFmt_Native32
)
236 offset
= (msg
->x
*data
->bytesperpix
)+(msg
->y
*data
->data
->bytesperline
);
237 restadd
= (data
->data
->bytesperline
- (msg
->width
*data
->bytesperpix
));
239 offset
= (msg
->x
+ (msg
->y
*data
->width
))*data
->bytesperpix
;
240 restadd
= (data
->width
-msg
->width
)*data
->bytesperpix
;
242 buffer
= data
->VideoData
+offset
;
246 HIDDT_Pixel
*p
= (HIDDT_Pixel
*)src
;
250 if (data
->bytesperpix
== 1)
252 *p
++ = (HIDDT_Pixel
)*((UBYTE
*)buffer
);
255 else if (data
->bytesperpix
== 2)
257 *p
++ = (HIDDT_Pixel
)*((UWORD
*)buffer
);
260 else if (data
->bytesperpix
== 4)
262 *p
++ = (HIDDT_Pixel
)*((ULONG
*)buffer
);
274 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
278 /********* BitMap::PutImageLUT() ***************************/
280 VOID
MNAME_BM(PutImageLUT
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutImageLUT
*msg
) {
281 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
288 UBYTE
*src
=msg
->pixels
;
291 offset
= (msg
->x
*data
->bytesperpix
)+(msg
->y
*data
->data
->bytesperline
);
292 restadd
= (data
->data
->bytesperline
- (msg
->width
*data
->bytesperpix
));
294 offset
= (msg
->x
+ (msg
->y
*data
->width
))*data
->bytesperpix
;
295 restadd
= (data
->width
-msg
->width
)*data
->bytesperpix
;
297 buffer
= data
->VideoData
+offset
;
304 if (data
->bytesperpix
== 1)
306 *((UBYTE
*)buffer
) = (UBYTE
)msg
->pixlut
->pixels
[*src
++];
309 else if (data
->bytesperpix
== 2)
311 *((UWORD
*)buffer
) = (UWORD
)msg
->pixlut
->pixels
[*src
++];
314 else if (data
->bytesperpix
== 4)
316 *((ULONG
*)buffer
) = (ULONG
)msg
->pixlut
->pixels
[*src
++];
322 src
+= (msg
->modulo
- msg
->width
);
328 box
.x2
= box
.x1
+msg
->width
-1;
329 box
.y2
= box
.y1
+msg
->height
-1;
330 refreshAreaVMWareGfx(data
->data
, &box
);
334 /********* BitMap::GetImageLUT() ***************************/
336 VOID
MNAME_BM(GetImageLUT
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetImageLUT
*msg
)
338 D(bug("get image lut\n"));
339 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
342 /********* BitMap::FillRect() ***************************/
344 VOID
MNAME_BM(FillRect
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_DrawRect
*msg
)
346 struct BitmapData
*data
=OOP_INST_DATA(cl
, o
);
352 pixel
= GC_FG(msg
->gc
);
353 mode
= GC_DRMD(msg
->gc
);
355 if (hw
->capabilities
& SVGA_CAP_RASTER_OP
)
359 case vHidd_GC_DrawMode_Clear
:
360 clearFillVMWareGfx(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
362 case vHidd_GC_DrawMode_And
:
363 andFillVMWareGfx(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
365 case vHidd_GC_DrawMode_AndReverse
:
366 andReverseFillVMWareGfx(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
368 case vHidd_GC_DrawMode_Copy
:
369 copyFillVMWareGfx(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
371 case vHidd_GC_DrawMode_AndInverted
:
372 andInvertedFillVMWareGfx(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
374 case vHidd_GC_DrawMode_NoOp
:
375 noOpFillVMWareGfx(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
377 case vHidd_GC_DrawMode_Xor
:
378 xorFillVMWareGfx(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
380 case vHidd_GC_DrawMode_Or
:
381 orFillVMWareGfx(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
383 case vHidd_GC_DrawMode_Nor
:
384 norFillVMWareGfx(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
386 case vHidd_GC_DrawMode_Equiv
:
387 equivFillVMWareGfx(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
389 case vHidd_GC_DrawMode_Invert
:
390 invertFillVMWareGfx(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
392 case vHidd_GC_DrawMode_OrReverse
:
393 orReverseFillVMWareGfx(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
395 case vHidd_GC_DrawMode_CopyInverted
:
396 copyInvertedFillVMWareGfx(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
398 case vHidd_GC_DrawMode_OrInverted
:
399 orInvertedFillVMWareGfx(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
401 case vHidd_GC_DrawMode_Nand
:
402 nandFillVMWareGfx(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
404 case vHidd_GC_DrawMode_Set
:
405 setFillVMWareGfx(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
408 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
414 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
417 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
421 /*** BitMap::BlitColorExpansion() **********************************************/
422 VOID
MNAME_BM(BlitColorExpansion
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_BlitColorExpansion
*msg
) {
423 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
433 cemd
= GC_COLEXP(msg
->gc
);
434 if (cemd
& vHidd_GC_ColExp_Opaque
)
436 for (y
=0; y
<msg
->height
; y
++)
438 for (x
=0;x
<msg
->width
;x
++)
441 is_set
= HIDD_BM_GetPixel(msg
->srcBitMap
, x
+msg
->srcX
, y
+msg
->srcY
);
442 putpixel(data
, x
+msg
->destX
, y
+msg
->destY
, is_set
? fg
: bg
);
448 for (y
=0; y
<msg
->height
; y
++)
450 for (x
=0;x
<msg
->width
; x
++)
452 if (HIDD_BM_GetPixel(msg
->srcBitMap
, x
+msg
->srcX
, y
+msg
->srcY
))
453 putpixel(data
, x
+msg
->destX
, y
+msg
->destY
, fg
);
460 box
.x2
= msg
->destX
+msg
->width
-1;
461 box
.y2
= msg
->destY
+msg
->height
-1;
462 refreshAreaVMWareGfx(data
->data
, &box
);
466 /*** BitMap::Get() *******************************************/
468 VOID
MNAME_ROOT(Get
)(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
) {
469 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
472 if (IS_VMWareGfxBM_ATTR(msg
->attrID
, idx
))
476 case aoHidd_VMWareGfxBitMap_Drawable
:
477 *msg
->storage
= (ULONG
)data
->VideoData
;
480 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
485 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);