2 * PROJECT: ReactOS VGA display driver
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/video/displays/vga/objects/paint.c
13 BOOL
VGADDIFillSolid(SURFOBJ
*Surface
, RECTL Dimensions
, ULONG iColor
)
15 int x
, y
, x2
, y2
, w
, h
, j
;
16 ULONG orgx
, pre1
, midpre1
, tmppre1
;
17 //ULONG offset, orgpre1;
18 int ileftpix
, imidpix
, irightpix
;
19 /* double leftpix, midpix, rightpix;*/
21 /* Swap dimensions so that x, y are at topmost left */
22 if ( Dimensions
.right
< Dimensions
.left
)
29 x2
= Dimensions
.right
;
32 if ( Dimensions
.bottom
< Dimensions
.top
)
34 y
= Dimensions
.bottom
;
39 y2
= Dimensions
.bottom
;
43 /* Calculate the width and height */
47 DPRINT("VGADDIFillSolid: x:%d, y:%d, w:%d, h:%d\n", x
, y
, w
, h
);
49 /* Calculate the starting offset */
50 //offset = xconv[x]+y80[y];
52 /* Make a note of original x */
55 /* Calculate the left mask pixels, middle bytes and right mask pixel */
56 ileftpix
= 7 - mod8(x
-1);
57 irightpix
= mod8(x
+w
);
58 imidpix
= (w
-ileftpix
-irightpix
) / 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 READ_REGISTER_UCHAR ( vidmem
+tmppre1
);
75 WRITE_REGISTER_UCHAR ( vidmem
+tmppre1
, iColor
);
83 /* Write left pixels */
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 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 READ_REGISTER_UCHAR(vidmem
+ pre1
);
125 WRITE_REGISTER_UCHAR(vidmem
+ pre1
, iColor
);
134 IN CLIPOBJ
*ClipRegion
,
137 IN BRUSHINST
*BrushInst
,
138 IN POINTL
*BrushPoint
)
143 DPRINT("VGADDIPaintRgn: iMode: %d, iDComplexity: %d\n Color:%d\n", ClipRegion
->iMode
, ClipRegion
->iDComplexity
, iColor
);
144 switch(ClipRegion
->iMode
)
148 /* Rectangular clipping can be handled without enumeration.
149 Note that trivial clipping is not possible, since the clipping
150 region defines the area to fill */
152 if (ClipRegion
->iDComplexity
== DC_RECT
)
154 DPRINT("VGADDIPaintRgn Rect:%d %d %d %d\n", ClipRegion
->rclBounds
.left
, ClipRegion
->rclBounds
.top
, ClipRegion
->rclBounds
.right
, ClipRegion
->rclBounds
.bottom
);
155 VGADDIFillSolid(Surface
, ClipRegion
->rclBounds
, iColor
);
159 /* Enumerate all the rectangles and draw them */
161 CLIPOBJ_cEnumStart(ClipRegion
, FALSE
, CT_RECTANGLES
, CD_ANY
, 0);
166 EnumMore
= CLIPOBJ_bEnum(ClipRegion
, sizeof(RectEnum
), (PVOID
) &RectEnum
);
167 DPRINT("EnumMore: %d, count: %d\n", EnumMore
, RectEnum
.c
);
168 for( i
=0; i
<RectEnum
.c
; i
++)
170 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
);
171 VGADDIFillSolid(Surface
, RectEnum
.arcl
[i
], iColor
);
186 IN CLIPOBJ
*ClipRegion
,
188 IN POINTL
*BrushOrigin
,
193 iSolidColor
= Brush
->iSolidColor
; // FIXME: Realizations and the like
195 // If the foreground and background Mixes are the same,
196 // (LATER or if there's no brush mask)
197 // then see if we can use the solid brush accelerators
199 // FIXME: Put in the mix switch below
200 // Brush color parameter doesn't matter for these rops
201 return(VGADDIPaintRgn(Surface
, ClipRegion
, iSolidColor
, Mix
, NULL
, BrushOrigin
));
203 if ((Mix
& 0xFF) == ((Mix
>> 8) & 0xFF))
210 // FIXME: Implement all these millions of ROPs
211 // For now we don't support brushes -- everything is solid
226 // Rops that are implicit solid colors
232 // FIXME: The Paint region belongs HERE
245 // If VGADDIPaint can't do it, VGADDIBitBlt can.. or it might just loop back
246 // here and we have a nice infinite loop
248 return( VGADDIBitBlt(Surface, (SURFOBJ *)NULL, (SURFOBJ *)NULL, ClipRegion,
249 (XLATEOBJ *)NULL, &ClipRegion->rclBounds,
250 NULL, (POINTL *)NULL, Brush, BrushOrigin,
251 NULL) ); UNIMPLEMENTED */