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
);
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
);
134 putpixel(data
, msg
->x
, msg
->y
, msg
->pixel
);
136 box
.x1
= box
.x2
= msg
->x
;
137 box
.y1
= box
.y2
= msg
->y
;
138 refreshAreaVMWareSVGA(data
->data
, &box
);
143 /********* BitMap::GetPixel() *********************************/
144 HIDDT_Pixel
MNAME_BM(GetPixel
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetPixel
*msg
)
147 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
151 offset
= (msg
->x
*data
->bytesperpix
)+(msg
->y
*data
->data
->bytesperline
);
153 offset
= (msg
->x
+ (msg
->y
*data
->width
))*data
->bytesperpix
;
155 if (data
->bytesperpix
== 1)
156 pixel
= *((UBYTE
*)(data
->VideoData
+ offset
));
157 else if (data
->bytesperpix
== 2)
158 pixel
= *((UWORD
*)(data
->VideoData
+ offset
));
159 else if (data
->bytesperpix
== 4)
160 pixel
= *((ULONG
*)(data
->VideoData
+ offset
));
166 /********* BitMap::DrawPixel() ***************************/
168 VOID
MNAME_BM(DrawPixel
)(OOP_Class
*cl
,OOP_ Object
*o
, struct pHidd_BitMap_DrawPixel
*msg
)
175 /********* BitMap::PutImage() ***************************/
177 VOID
MNAME_BM(PutImage
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutImage
*msg
)
179 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
186 UBYTE
*src
=(UBYTE
*)msg
->pixels
;
188 if (msg
->pixFmt
== vHidd_StdPixFmt_Native32
)
191 offset
= (msg
->x
*data
->bytesperpix
)+(msg
->y
*data
->data
->bytesperline
);
192 restadd
= (data
->data
->bytesperline
- (msg
->width
*data
->bytesperpix
));
194 offset
= (msg
->x
+ (msg
->y
*data
->width
))*data
->bytesperpix
;
195 restadd
= (data
->width
-msg
->width
)*data
->bytesperpix
;
197 buffer
= data
->VideoData
+offset
;
201 HIDDT_Pixel
*p
= (HIDDT_Pixel
*)src
;
205 if (data
->bytesperpix
== 1)
207 *((UBYTE
*)buffer
) = (UBYTE
)*p
++;
210 else if (data
->bytesperpix
== 2)
212 *((UWORD
*)buffer
) = (UWORD
)*p
++;
215 else if (data
->bytesperpix
== 4)
217 *((ULONG
*)buffer
) = (ULONG
)*p
++;
229 box
.x2
= box
.x1
+msg
->width
-1;
230 box
.y2
= box
.y1
+msg
->height
-1;
231 refreshAreaVMWareSVGA(data
->data
, &box
);
236 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
240 /********* BitMap::GetImage() ***************************/
242 VOID
MNAME_BM(GetImage
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetImage
*msg
)
244 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
250 UBYTE
*src
=msg
->pixels
;
252 if (msg
->pixFmt
== vHidd_StdPixFmt_Native32
)
255 offset
= (msg
->x
*data
->bytesperpix
)+(msg
->y
*data
->data
->bytesperline
);
256 restadd
= (data
->data
->bytesperline
- (msg
->width
*data
->bytesperpix
));
258 offset
= (msg
->x
+ (msg
->y
*data
->width
))*data
->bytesperpix
;
259 restadd
= (data
->width
-msg
->width
)*data
->bytesperpix
;
261 buffer
= data
->VideoData
+offset
;
265 HIDDT_Pixel
*p
= (HIDDT_Pixel
*)src
;
269 if (data
->bytesperpix
== 1)
271 *p
++ = (HIDDT_Pixel
)*((UBYTE
*)buffer
);
274 else if (data
->bytesperpix
== 2)
276 *p
++ = (HIDDT_Pixel
)*((UWORD
*)buffer
);
279 else if (data
->bytesperpix
== 4)
281 *p
++ = (HIDDT_Pixel
)*((ULONG
*)buffer
);
293 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
297 /********* BitMap::PutImageLUT() ***************************/
299 VOID
MNAME_BM(PutImageLUT
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutImageLUT
*msg
)
301 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
308 UBYTE
*src
=msg
->pixels
;
311 offset
= (msg
->x
*data
->bytesperpix
)+(msg
->y
*data
->data
->bytesperline
);
312 restadd
= (data
->data
->bytesperline
- (msg
->width
*data
->bytesperpix
));
314 offset
= (msg
->x
+ (msg
->y
*data
->width
))*data
->bytesperpix
;
315 restadd
= (data
->width
-msg
->width
)*data
->bytesperpix
;
317 buffer
= data
->VideoData
+offset
;
324 if (data
->bytesperpix
== 1)
326 *((UBYTE
*)buffer
) = (UBYTE
)msg
->pixlut
->pixels
[*src
++];
329 else if (data
->bytesperpix
== 2)
331 *((UWORD
*)buffer
) = (UWORD
)msg
->pixlut
->pixels
[*src
++];
334 else if (data
->bytesperpix
== 4)
336 *((ULONG
*)buffer
) = (ULONG
)msg
->pixlut
->pixels
[*src
++];
342 src
+= (msg
->modulo
- msg
->width
);
348 box
.x2
= box
.x1
+msg
->width
-1;
349 box
.y2
= box
.y1
+msg
->height
-1;
350 refreshAreaVMWareSVGA(data
->data
, &box
);
354 /********* BitMap::GetImageLUT() ***************************/
356 VOID
MNAME_BM(GetImageLUT
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetImageLUT
*msg
)
358 D(bug("[VMWareSVGA] GetImageLUT()\n"));
359 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
362 /********* BitMap::FillRect() ***************************/
364 VOID
MNAME_BM(FillRect
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_DrawRect
*msg
)
366 struct BitmapData
*data
=OOP_INST_DATA(cl
, o
);
372 pixel
= GC_FG(msg
->gc
);
373 mode
= GC_DRMD(msg
->gc
);
375 if (hw
->capabilities
& SVGA_CAP_RASTER_OP
)
379 case vHidd_GC_DrawMode_Clear
:
380 clearFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
382 case vHidd_GC_DrawMode_And
:
383 andFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
385 case vHidd_GC_DrawMode_AndReverse
:
386 andReverseFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
388 case vHidd_GC_DrawMode_Copy
:
389 copyFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
391 case vHidd_GC_DrawMode_AndInverted
:
392 andInvertedFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
394 case vHidd_GC_DrawMode_NoOp
:
395 noOpFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
397 case vHidd_GC_DrawMode_Xor
:
398 xorFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
400 case vHidd_GC_DrawMode_Or
:
401 orFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
403 case vHidd_GC_DrawMode_Nor
:
404 norFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
406 case vHidd_GC_DrawMode_Equiv
:
407 equivFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
409 case vHidd_GC_DrawMode_Invert
:
410 invertFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
412 case vHidd_GC_DrawMode_OrReverse
:
413 orReverseFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
415 case vHidd_GC_DrawMode_CopyInverted
:
416 copyInvertedFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
418 case vHidd_GC_DrawMode_OrInverted
:
419 orInvertedFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
421 case vHidd_GC_DrawMode_Nand
:
422 nandFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
424 case vHidd_GC_DrawMode_Set
:
425 setFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
428 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
434 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
437 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
441 /*** BitMap::BlitColorExpansion() **********************************************/
442 VOID
MNAME_BM(BlitColorExpansion
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_BlitColorExpansion
*msg
)
444 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
454 cemd
= GC_COLEXP(msg
->gc
);
455 if (cemd
& vHidd_GC_ColExp_Opaque
)
457 for (y
=0; y
<msg
->height
; y
++)
459 for (x
=0;x
<msg
->width
;x
++)
462 is_set
= HIDD_BM_GetPixel(msg
->srcBitMap
, x
+msg
->srcX
, y
+msg
->srcY
);
463 putpixel(data
, x
+msg
->destX
, y
+msg
->destY
, is_set
? fg
: bg
);
469 for (y
=0; y
<msg
->height
; y
++)
471 for (x
=0;x
<msg
->width
; x
++)
473 if (HIDD_BM_GetPixel(msg
->srcBitMap
, x
+msg
->srcX
, y
+msg
->srcY
))
474 putpixel(data
, x
+msg
->destX
, y
+msg
->destY
, fg
);
481 box
.x2
= msg
->destX
+msg
->width
-1;
482 box
.y2
= msg
->destY
+msg
->height
-1;
483 refreshAreaVMWareSVGA(data
->data
, &box
);
487 /*** BitMap::Get() *******************************************/
489 VOID
MNAME_ROOT(Get
)(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
491 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
494 if (IS_VMWareSVGABM_ATTR(msg
->attrID
, idx
))
498 case aoHidd_VMWareSVGABitMap_Drawable
:
499 *msg
->storage
= (ULONG
)data
->VideoData
;
502 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
507 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);