2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
10 #include <aros/debug.h>
12 #include <exec/alerts.h>
13 #include <string.h> // memset() prototype
15 #include "vmwaresvgahardware.h"
18 /********* BitMap::Clear() *************************************/
19 VOID
MNAME_BM(Clear
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_Clear
*msg
)
21 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
24 D(bug("[VMWareSVGA] Clear()\n"));
26 /* Get width & height from bitmap */
28 OOP_GetAttr(o
, aHidd_BitMap_Width
, &width
);
29 OOP_GetAttr(o
, aHidd_BitMap_Height
, &height
);
31 writeVMWareSVGAFIFO(data
->data
, SVGA_CMD_RECT_FILL
);
32 writeVMWareSVGAFIFO(data
->data
, GC_FG(msg
->gc
));
33 writeVMWareSVGAFIFO(data
->data
, 0);
34 writeVMWareSVGAFIFO(data
->data
, 0);
35 writeVMWareSVGAFIFO(data
->data
, width
);
36 writeVMWareSVGAFIFO(data
->data
, height
);
37 syncVMWareSVGAFIFO(data
->data
);
42 /* this function does not really make sense for LUT bitmaps */
44 HIDDT_Pixel
MNAME_BM(MapColor
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_MapColor
*msg
)
46 D(bug("[VMWareSVGA] MapColor()\n"));
50 /* this function does not really make sense for LUT bitmaps */
52 VOID
MNAME_BM(UnMapPixel
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_UnmapPixel
*msg
)
54 D(bug("[VMWareSVGA] UnMapPixel()\n"));
59 BOOL
MNAME_BM(SetColors
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_SetColors
*msg
)
61 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
62 HIDDT_PixelFormat
*pf
;
71 (vHidd_ColorModel_StaticPalette
== HIDD_PF_COLMODEL(pf
)) ||
72 (vHidd_ColorModel_TrueColor
== HIDD_PF_COLMODEL(pf
))
74 return OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
75 if (!OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
))
77 if ((msg
->firstColor
+ msg
->numColors
) > (1<<data
->bpp
))
79 for (xc_i
= msg
->firstColor
, col_i
= 0; col_i
< msg
->numColors
; xc_i
++, col_i
++)
81 red
= msg
->colors
[col_i
].red
>> 8;
82 green
= msg
->colors
[col_i
].green
>> 8;
83 blue
= msg
->colors
[col_i
].blue
>> 8;
84 data
->cmap
[xc_i
] = 0x01000000 | red
| (green
<< 8) | (blue
<< 16);
86 vmwareWriteReg(data
->data
, SVGA_PALETTE_BASE
+ xc_i
*3+0, msg
->colors
[col_i
].red
);
87 vmwareWriteReg(data
->data
, SVGA_PALETTE_BASE
+ xc_i
*3+1, msg
->colors
[col_i
].green
);
88 vmwareWriteReg(data
->data
, SVGA_PALETTE_BASE
+ xc_i
*3+2, msg
->colors
[col_i
].blue
);
90 msg
->colors
[col_i
].pixval
= xc_i
;
95 /********* BitMap::PutPixel() ***************************/
97 STATIC VOID
putpixel(struct BitmapData
*data
, LONG x
, LONG y
, HIDDT_Pixel pixel
)
102 offset
= (x
*data
->bytesperpix
)+(y
*data
->data
->bytesperline
);
104 (x
>=data
->mouse
->x
) && (x
<(data
->mouse
->x
+data
->mouse
->width
)) &&
105 (y
>=data
->mouse
->y
) && (y
<(data
->mouse
->y
+data
->mouse
->height
))
108 displayCursorVMWareSVGA(data
->data
, 0);
109 data
->mouse
->visible
= 0;
112 offset
= (x
+ (y
*data
->width
))*data
->bytesperpix
;
114 if (data
->bytesperpix
== 1)
115 *((UBYTE
*)(data
->VideoData
+ offset
)) = pixel
;
116 else if (data
->bytesperpix
== 2)
117 *((UWORD
*)(data
->VideoData
+ offset
)) = pixel
;
118 else if (data
->bytesperpix
== 4)
119 *((ULONG
*)(data
->VideoData
+ offset
)) = pixel
;
121 if (data
->mouse
->visible
== 0)
123 displayCursorVMWareSVGA(data
->data
, 1);
124 data
->mouse
->visible
= 1;
129 VOID
MNAME_BM(PutPixel
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutPixel
*msg
)
131 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
136 putpixel(data
, msg
->x
, msg
->y
, msg
->pixel
);
138 box
.x1
= box
.x2
= msg
->x
;
139 box
.y1
= box
.y2
= msg
->y
;
140 refreshAreaVMWareSVGA(data
->data
, &box
);
145 /********* BitMap::GetPixel() *********************************/
146 HIDDT_Pixel
MNAME_BM(GetPixel
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetPixel
*msg
)
148 HIDDT_Pixel pixel
= 0;
149 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
153 offset
= (msg
->x
*data
->bytesperpix
)+(msg
->y
*data
->data
->bytesperline
);
155 offset
= (msg
->x
+ (msg
->y
*data
->width
))*data
->bytesperpix
;
157 if (data
->bytesperpix
== 1)
158 pixel
= *((UBYTE
*)(data
->VideoData
+ offset
));
159 else if (data
->bytesperpix
== 2)
160 pixel
= *((UWORD
*)(data
->VideoData
+ offset
));
161 else if (data
->bytesperpix
== 4)
162 pixel
= *((ULONG
*)(data
->VideoData
+ offset
));
168 /********* BitMap::DrawPixel() ***************************/
170 VOID
MNAME_BM(DrawPixel
)(OOP_Class
*cl
,OOP_ Object
*o
, struct pHidd_BitMap_DrawPixel
*msg
)
177 /********* BitMap::PutImage() ***************************/
179 VOID
MNAME_BM(PutImage
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutImage
*msg
)
181 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
190 UBYTE
*src
=(UBYTE
*)msg
->pixels
;
192 if (msg
->pixFmt
== vHidd_StdPixFmt_Native32
)
195 offset
= (msg
->x
*data
->bytesperpix
)+(msg
->y
*data
->data
->bytesperline
);
196 restadd
= (data
->data
->bytesperline
- (msg
->width
*data
->bytesperpix
));
198 offset
= (msg
->x
+ (msg
->y
*data
->width
))*data
->bytesperpix
;
199 restadd
= (data
->width
-msg
->width
)*data
->bytesperpix
;
201 buffer
= data
->VideoData
+offset
;
205 HIDDT_Pixel
*p
= (HIDDT_Pixel
*)src
;
209 if (data
->bytesperpix
== 1)
211 *((UBYTE
*)buffer
) = (UBYTE
)*p
++;
214 else if (data
->bytesperpix
== 2)
216 *((UWORD
*)buffer
) = (UWORD
)*p
++;
219 else if (data
->bytesperpix
== 4)
221 *((ULONG
*)buffer
) = (ULONG
)*p
++;
233 box
.x2
= box
.x1
+msg
->width
-1;
234 box
.y2
= box
.y1
+msg
->height
-1;
235 refreshAreaVMWareSVGA(data
->data
, &box
);
240 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
244 /********* BitMap::GetImage() ***************************/
246 VOID
MNAME_BM(GetImage
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetImage
*msg
)
248 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
254 UBYTE
*src
=msg
->pixels
;
256 if (msg
->pixFmt
== vHidd_StdPixFmt_Native32
)
259 offset
= (msg
->x
*data
->bytesperpix
)+(msg
->y
*data
->data
->bytesperline
);
260 restadd
= (data
->data
->bytesperline
- (msg
->width
*data
->bytesperpix
));
262 offset
= (msg
->x
+ (msg
->y
*data
->width
))*data
->bytesperpix
;
263 restadd
= (data
->width
-msg
->width
)*data
->bytesperpix
;
265 buffer
= data
->VideoData
+offset
;
269 HIDDT_Pixel
*p
= (HIDDT_Pixel
*)src
;
273 if (data
->bytesperpix
== 1)
275 *p
++ = (HIDDT_Pixel
)*((UBYTE
*)buffer
);
278 else if (data
->bytesperpix
== 2)
280 *p
++ = (HIDDT_Pixel
)*((UWORD
*)buffer
);
283 else if (data
->bytesperpix
== 4)
285 *p
++ = (HIDDT_Pixel
)*((ULONG
*)buffer
);
297 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
301 /********* BitMap::PutImageLUT() ***************************/
303 VOID
MNAME_BM(PutImageLUT
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutImageLUT
*msg
)
305 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
314 UBYTE
*src
=msg
->pixels
;
317 offset
= (msg
->x
*data
->bytesperpix
)+(msg
->y
*data
->data
->bytesperline
);
318 restadd
= (data
->data
->bytesperline
- (msg
->width
*data
->bytesperpix
));
320 offset
= (msg
->x
+ (msg
->y
*data
->width
))*data
->bytesperpix
;
321 restadd
= (data
->width
-msg
->width
)*data
->bytesperpix
;
323 buffer
= data
->VideoData
+offset
;
330 if (data
->bytesperpix
== 1)
332 *((UBYTE
*)buffer
) = (UBYTE
)msg
->pixlut
->pixels
[*src
++];
335 else if (data
->bytesperpix
== 2)
337 *((UWORD
*)buffer
) = (UWORD
)msg
->pixlut
->pixels
[*src
++];
340 else if (data
->bytesperpix
== 4)
342 *((ULONG
*)buffer
) = (ULONG
)msg
->pixlut
->pixels
[*src
++];
348 src
+= (msg
->modulo
- msg
->width
);
354 box
.x2
= box
.x1
+msg
->width
-1;
355 box
.y2
= box
.y1
+msg
->height
-1;
356 refreshAreaVMWareSVGA(data
->data
, &box
);
360 /********* BitMap::GetImageLUT() ***************************/
362 VOID
MNAME_BM(GetImageLUT
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetImageLUT
*msg
)
364 D(bug("[VMWareSVGA] GetImageLUT()\n"));
365 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
368 /********* BitMap::FillRect() ***************************/
370 VOID
MNAME_BM(FillRect
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_DrawRect
*msg
)
373 struct BitmapData
*data
=OOP_INST_DATA(cl
, o
);
378 pixel
= GC_FG(msg
->gc
);
379 mode
= GC_DRMD(msg
->gc
);
381 if (hw
->capabilities
& SVGA_CAP_RASTER_OP
)
385 case vHidd_GC_DrawMode_Clear
:
386 clearFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
388 case vHidd_GC_DrawMode_And
:
389 andFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
391 case vHidd_GC_DrawMode_AndReverse
:
392 andReverseFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
394 case vHidd_GC_DrawMode_Copy
:
395 copyFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
397 case vHidd_GC_DrawMode_AndInverted
:
398 andInvertedFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
400 case vHidd_GC_DrawMode_NoOp
:
401 noOpFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
403 case vHidd_GC_DrawMode_Xor
:
404 xorFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
406 case vHidd_GC_DrawMode_Or
:
407 orFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
409 case vHidd_GC_DrawMode_Nor
:
410 norFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
412 case vHidd_GC_DrawMode_Equiv
:
413 equivFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
415 case vHidd_GC_DrawMode_Invert
:
416 invertFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
418 case vHidd_GC_DrawMode_OrReverse
:
419 orReverseFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
421 case vHidd_GC_DrawMode_CopyInverted
:
422 copyInvertedFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
424 case vHidd_GC_DrawMode_OrInverted
:
425 orInvertedFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
427 case vHidd_GC_DrawMode_Nand
:
428 nandFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
430 case vHidd_GC_DrawMode_Set
:
431 setFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
434 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
440 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
443 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
447 /*** BitMap::BlitColorExpansion() **********************************************/
448 VOID
MNAME_BM(BlitColorExpansion
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_BlitColorExpansion
*msg
)
450 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
462 cemd
= GC_COLEXP(msg
->gc
);
463 if (cemd
& vHidd_GC_ColExp_Opaque
)
465 for (y
=0; y
<msg
->height
; y
++)
467 for (x
=0;x
<msg
->width
;x
++)
470 is_set
= HIDD_BM_GetPixel(msg
->srcBitMap
, x
+msg
->srcX
, y
+msg
->srcY
);
471 putpixel(data
, x
+msg
->destX
, y
+msg
->destY
, is_set
? fg
: bg
);
477 for (y
=0; y
<msg
->height
; y
++)
479 for (x
=0;x
<msg
->width
; x
++)
481 if (HIDD_BM_GetPixel(msg
->srcBitMap
, x
+msg
->srcX
, y
+msg
->srcY
))
482 putpixel(data
, x
+msg
->destX
, y
+msg
->destY
, fg
);
489 box
.x2
= msg
->destX
+msg
->width
-1;
490 box
.y2
= msg
->destY
+msg
->height
-1;
491 refreshAreaVMWareSVGA(data
->data
, &box
);
495 /*** BitMap::Get() *******************************************/
497 VOID
MNAME_ROOT(Get
)(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
499 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
502 if (IS_VMWareSVGABM_ATTR(msg
->attrID
, idx
))
506 case aoHidd_VMWareSVGABitMap_Drawable
:
507 *msg
->storage
= (IPTR
)data
->VideoData
;
510 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
515 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);