3 #include "../vgavideo/vgavideo.h"
8 BOOL VGADDIFillSolid(SURFOBJ *Surface, RECTL Dimensions, ULONG iColor)
10 int x, y, x2, y2, w, h;
11 ULONG offset, i, j, pre1;
12 ULONG orgpre1, orgx, midpre1, tmppre1;
13 ULONG ileftpix, imidpix, irightpix;
14 double leftpix, midpix, rightpix, temp;
17 DPRINT("VGADDIFillSolid: x:%d, y:%d, w:%d, h:%d\n", x, y, w, h);
19 // Swap dimensions so that x, y are at topmost left
20 if ( Dimensions.right < Dimensions.left )
27 x2 = Dimensions.right;
30 if ( Dimensions.bottom < Dimensions.top )
32 y = Dimensions.bottom;
37 y2 = Dimensions.bottom;
41 // Calculate the width and height
45 // Calculate the starting offset
46 offset = xconv[x]+y80[y];
48 // Make a note of original x
51 // Calculate the left mask pixels, middle bytes and right mask pixel
52 ileftpix = 7 - mod8(x-1);
54 midpix = (w-leftpix-rightpix) / 8;
60 pre1 = xconv[(x-1)&~7] + y80[y];
63 // check for overlap ( very horizontally skinny rect )
64 if ( (ileftpix+irightpix) > w )
66 int mask = startmasks[ileftpix] & endmasks[irightpix];
68 WRITE_PORT_UCHAR((PUCHAR)GRA_I,0x08); // set the mask
69 WRITE_PORT_UCHAR((PUCHAR)GRA_D,mask);
72 for ( j = y; j < y+h; j++ )
74 a = READ_REGISTER_UCHAR ( vidmem+tmppre1 );
75 WRITE_REGISTER_UCHAR ( vidmem+tmppre1, iColor );
84 WRITE_PORT_UCHAR((PUCHAR)GRA_I,0x08); // set the mask
85 WRITE_PORT_UCHAR((PUCHAR)GRA_D,startmasks[ileftpix]);
88 for ( j = y; j < y+h; j++ )
90 a = READ_REGISTER_UCHAR(vidmem + tmppre1);
91 WRITE_REGISTER_UCHAR(vidmem + tmppre1, iColor);
95 // Prepare new x for the middle
101 midpre1=xconv[x] + y80[y];
103 // Set mask to all pixels in byte
104 WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x08);
106 WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0xff);
108 for ( j = y; j < y+h; j++ )
110 memset(vidmem+midpre1, iColor, imidpix); // write middle pixels, no need to read in latch because of the width
115 x = orgx + w - irightpix;
116 pre1 = xconv[x] + y80[y];
118 // Write right pixels
119 WRITE_PORT_UCHAR((PUCHAR)GRA_I,0x08); // set the mask bits
120 WRITE_PORT_UCHAR((PUCHAR)GRA_D,endmasks[irightpix]);
122 for ( j = y; j < y+h; j++ )
124 a = READ_REGISTER_UCHAR(vidmem + pre1);
125 WRITE_REGISTER_UCHAR(vidmem + pre1, iColor);
132 BOOL VGADDIPaintRgn(SURFOBJ *Surface, CLIPOBJ *ClipRegion, ULONG iColor, MIX Mix,
133 BRUSHINST *BrushInst, POINTL *BrushPoint)
138 DPRINT("VGADDIPaintRgn: iMode: %d, iDComplexity: %d\n Color:%d\n", ClipRegion->iMode, ClipRegion->iDComplexity, iColor);
139 switch(ClipRegion->iMode) {
143 /* Rectangular clipping can be handled without enumeration.
144 Note that trivial clipping is not possible, since the clipping
145 region defines the area to fill */
147 if (ClipRegion->iDComplexity == DC_RECT)
149 DPRINT("VGADDIPaintRgn Rect:%d %d %d %d\n", ClipRegion->rclBounds.left, ClipRegion->rclBounds.top, ClipRegion->rclBounds.right, ClipRegion->rclBounds.bottom);
150 VGADDIFillSolid(Surface, ClipRegion->rclBounds, iColor);
152 /* Enumerate all the rectangles and draw them */
154 CLIPOBJ_cEnumStart(ClipRegion, FALSE, CT_RECTANGLES, CD_ANY,
159 EnumMore = CLIPOBJ_bEnum(ClipRegion, sizeof(RectEnum), (PVOID) &RectEnum);
160 DPRINT("EnumMore: %d, count: %d\n", EnumMore, RectEnum.c);
161 for( i=0; i<RectEnum.c; i++){
162 DPRINT("VGADDI enum Rect:%d %d %d %d\n", RectEnum.arcl[i].left, RectEnum.arcl[i].top, RectEnum.arcl[i].right, RectEnum.arcl[i].bottom);
163 VGADDIFillSolid(Surface, RectEnum.arcl[i], iColor);
179 DrvPaint(IN SURFOBJ *Surface,
180 IN CLIPOBJ *ClipRegion,
182 IN POINTL *BrushOrigin,
187 iSolidColor = Brush->iSolidColor; // FIXME: Realizations and the like
189 // If the foreground and background Mixes are the same,
190 // (LATER or if there's no brush mask)
191 // then see if we can use the solid brush accelerators
193 // FIXME: Put in the mix switch below
194 // Brush color parameter doesn't matter for these rops
195 return(VGADDIPaintRgn(Surface, ClipRegion, iSolidColor, Mix, NULL, BrushOrigin));
197 if ((Mix & 0xFF) == ((Mix >> 8) & 0xFF))
204 // FIXME: Implement all these millions of ROPs
205 // For now we don't support brushes -- everything is solid
220 // Rops that are implicit solid colors
226 // FIXME: The Paint region belongs HERE
238 // If VGADDIPaint can't do it, VGADDIBitBlt can.. or it might just loop back
239 // here and we have a nice infinite loop
241 /* return( VGADDIBitBlt(Surface, (SURFOBJ *)NULL, (SURFOBJ *)NULL, ClipRegion,
242 (XLATEOBJ *)NULL, &ClipRegion->rclBounds,
243 NULL, (POINTL *)NULL, Brush, BrushOrigin,
244 NULL) ); UNIMPLEMENTED */