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 "vmwaresvga_intern.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 offset
= (x
+ (y
*data
->width
))*data
->bytesperpix
;
106 if (data
->bytesperpix
== 1)
107 *((UBYTE
*)(data
->VideoData
+ offset
)) = pixel
;
108 else if (data
->bytesperpix
== 2)
109 *((UWORD
*)(data
->VideoData
+ offset
)) = pixel
;
110 else if (data
->bytesperpix
== 4)
111 *((ULONG
*)(data
->VideoData
+ offset
)) = pixel
;
114 VOID
MNAME_BM(PutPixel
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutPixel
*msg
)
116 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
121 putpixel(data
, msg
->x
, msg
->y
, msg
->pixel
);
123 box
.x1
= box
.x2
= msg
->x
;
124 box
.y1
= box
.y2
= msg
->y
;
125 refreshAreaVMWareSVGA(data
->data
, &box
);
130 /********* BitMap::GetPixel() *********************************/
131 HIDDT_Pixel
MNAME_BM(GetPixel
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetPixel
*msg
)
133 HIDDT_Pixel pixel
= 0;
134 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
138 offset
= (msg
->x
*data
->bytesperpix
)+(msg
->y
*data
->data
->bytesperline
);
140 offset
= (msg
->x
+ (msg
->y
*data
->width
))*data
->bytesperpix
;
142 if (data
->bytesperpix
== 1)
143 pixel
= *((UBYTE
*)(data
->VideoData
+ offset
));
144 else if (data
->bytesperpix
== 2)
145 pixel
= *((UWORD
*)(data
->VideoData
+ offset
));
146 else if (data
->bytesperpix
== 4)
147 pixel
= *((ULONG
*)(data
->VideoData
+ offset
));
153 /********* BitMap::DrawPixel() ***************************/
155 VOID
MNAME_BM(DrawPixel
)(OOP_Class
*cl
,OOP_ Object
*o
, struct pHidd_BitMap_DrawPixel
*msg
)
162 /********* BitMap::PutImage() ***************************/
164 VOID
MNAME_BM(PutImage
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutImage
*msg
)
166 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
175 UBYTE
*src
=(UBYTE
*)msg
->pixels
;
177 if (msg
->pixFmt
== vHidd_StdPixFmt_Native32
)
180 offset
= (msg
->x
*data
->bytesperpix
)+(msg
->y
*data
->data
->bytesperline
);
181 restadd
= (data
->data
->bytesperline
- (msg
->width
*data
->bytesperpix
));
183 offset
= (msg
->x
+ (msg
->y
*data
->width
))*data
->bytesperpix
;
184 restadd
= (data
->width
-msg
->width
)*data
->bytesperpix
;
186 buffer
= data
->VideoData
+offset
;
190 HIDDT_Pixel
*p
= (HIDDT_Pixel
*)src
;
193 CopyMem(p
, buffer
, xcnt
* data
->bytesperpix
);
195 buffer
+= (xcnt
* data
->bytesperpix
);
203 box
.x2
= box
.x1
+msg
->width
-1;
204 box
.y2
= box
.y1
+msg
->height
-1;
205 VMWareSVGA_Damage_DeltaAdd(data
->data
, box
);
210 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
214 /********* BitMap::GetImage() ***************************/
216 VOID
MNAME_BM(GetImage
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetImage
*msg
)
218 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
224 UBYTE
*src
=msg
->pixels
;
226 if (msg
->pixFmt
== vHidd_StdPixFmt_Native32
)
229 offset
= (msg
->x
*data
->bytesperpix
)+(msg
->y
*data
->data
->bytesperline
);
230 restadd
= (data
->data
->bytesperline
- (msg
->width
*data
->bytesperpix
));
232 offset
= (msg
->x
+ (msg
->y
*data
->width
))*data
->bytesperpix
;
233 restadd
= (data
->width
-msg
->width
)*data
->bytesperpix
;
235 buffer
= data
->VideoData
+offset
;
239 HIDDT_Pixel
*p
= (HIDDT_Pixel
*)src
;
242 CopyMem(buffer
, p
, xcnt
* data
->bytesperpix
);
244 buffer
+= (xcnt
* data
->bytesperpix
);
252 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
256 /********* BitMap::PutImageLUT() ***************************/
258 VOID
MNAME_BM(PutImageLUT
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_PutImageLUT
*msg
)
260 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
269 UBYTE
*src
=msg
->pixels
;
272 offset
= (msg
->x
*data
->bytesperpix
)+(msg
->y
*data
->data
->bytesperline
);
273 restadd
= (data
->data
->bytesperline
- (msg
->width
*data
->bytesperpix
));
275 offset
= (msg
->x
+ (msg
->y
*data
->width
))*data
->bytesperpix
;
276 restadd
= (data
->width
-msg
->width
)*data
->bytesperpix
;
278 buffer
= data
->VideoData
+offset
;
285 if (data
->bytesperpix
== 1)
287 *((UBYTE
*)buffer
) = (UBYTE
)msg
->pixlut
->pixels
[*src
++];
290 else if (data
->bytesperpix
== 2)
292 *((UWORD
*)buffer
) = (UWORD
)msg
->pixlut
->pixels
[*src
++];
295 else if (data
->bytesperpix
== 4)
297 *((ULONG
*)buffer
) = (ULONG
)msg
->pixlut
->pixels
[*src
++];
303 src
+= (msg
->modulo
- msg
->width
);
309 box
.x2
= box
.x1
+msg
->width
-1;
310 box
.y2
= box
.y1
+msg
->height
-1;
311 refreshAreaVMWareSVGA(data
->data
, &box
);
315 /********* BitMap::GetImageLUT() ***************************/
317 VOID
MNAME_BM(GetImageLUT
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_GetImageLUT
*msg
)
319 D(bug("[VMWareSVGA] GetImageLUT()\n"));
320 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
323 /********* BitMap::FillRect() ***************************/
325 VOID
MNAME_BM(FillRect
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_DrawRect
*msg
)
328 struct BitmapData
*data
=OOP_INST_DATA(cl
, o
);
333 pixel
= GC_FG(msg
->gc
);
334 mode
= GC_DRMD(msg
->gc
);
336 if (hw
->capabilities
& SVGA_CAP_RASTER_OP
)
340 case vHidd_GC_DrawMode_Clear
:
341 clearFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
343 case vHidd_GC_DrawMode_And
:
344 andFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
346 case vHidd_GC_DrawMode_AndReverse
:
347 andReverseFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
349 case vHidd_GC_DrawMode_Copy
:
350 copyFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
352 case vHidd_GC_DrawMode_AndInverted
:
353 andInvertedFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
355 case vHidd_GC_DrawMode_NoOp
:
356 noOpFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
358 case vHidd_GC_DrawMode_Xor
:
359 xorFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
361 case vHidd_GC_DrawMode_Or
:
362 orFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
364 case vHidd_GC_DrawMode_Nor
:
365 norFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
367 case vHidd_GC_DrawMode_Equiv
:
368 equivFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
370 case vHidd_GC_DrawMode_Invert
:
371 invertFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
373 case vHidd_GC_DrawMode_OrReverse
:
374 orReverseFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
376 case vHidd_GC_DrawMode_CopyInverted
:
377 copyInvertedFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
379 case vHidd_GC_DrawMode_OrInverted
:
380 orInvertedFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
382 case vHidd_GC_DrawMode_Nand
:
383 nandFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
385 case vHidd_GC_DrawMode_Set
:
386 setFillVMWareSVGA(data
->data
, pixel
, msg
->minX
, msg
->minY
, msg
->maxX
-msg
->minX
+1, msg
->maxY
-msg
->minY
+1);
389 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
395 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
398 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
402 /*** BitMap::BlitColorExpansion() **********************************************/
403 VOID
MNAME_BM(BlitColorExpansion
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_BlitColorExpansion
*msg
)
405 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
417 cemd
= GC_COLEXP(msg
->gc
);
418 if (cemd
& vHidd_GC_ColExp_Opaque
)
420 for (y
=0; y
<msg
->height
; y
++)
422 for (x
=0;x
<msg
->width
;x
++)
425 is_set
= HIDD_BM_GetPixel(msg
->srcBitMap
, x
+msg
->srcX
, y
+msg
->srcY
);
426 putpixel(data
, x
+msg
->destX
, y
+msg
->destY
, is_set
? fg
: bg
);
432 for (y
=0; y
<msg
->height
; y
++)
434 for (x
=0;x
<msg
->width
; x
++)
436 if (HIDD_BM_GetPixel(msg
->srcBitMap
, x
+msg
->srcX
, y
+msg
->srcY
))
437 putpixel(data
, x
+msg
->destX
, y
+msg
->destY
, fg
);
444 box
.x2
= msg
->destX
+msg
->width
-1;
445 box
.y2
= msg
->destY
+msg
->height
-1;
446 refreshAreaVMWareSVGA(data
->data
, &box
);
450 /*** BitMap::Get() *******************************************/
452 VOID
MNAME_ROOT(Get
)(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
454 struct BitmapData
*data
= OOP_INST_DATA(cl
, o
);
457 if (IS_VMWareSVGABM_ATTR(msg
->attrID
, idx
))
461 case aoHidd_VMWareSVGABitMap_Drawable
:
462 *msg
->storage
= (IPTR
)data
->VideoData
;
465 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
470 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
474 VOID
MNAME_BM(UpdateRect
)(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_UpdateRect
*msg
)
476 struct HWData
*pData
= &XSD(cl
)->data
;
477 struct Box box
= { msg
->x
, msg
->y
, msg
->x
+ msg
->width
+ 1, msg
->y
+ msg
->height
+ 1};
479 VMWareSVGA_Damage_DeltaAdd(pData
, box
);