416af2a0b605e8f55561b6ac3221ad7d051bfa2d
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
11 BOOL
VGADDIFillSolid(SURFOBJ
*Surface
, RECTL Dimensions
, ULONG iColor
)
13 int x
, y
, x2
, y2
, w
, h
, j
;
15 ULONG orgpre1
, orgx
, midpre1
, tmppre1
;
16 int ileftpix
, imidpix
, irightpix
;
17 /* double leftpix, midpix, rightpix;*/
20 /* Swap dimensions so that x, y are at topmost left */
21 if ( Dimensions
.right
< Dimensions
.left
)
28 x2
= Dimensions
.right
;
31 if ( Dimensions
.bottom
< Dimensions
.top
)
33 y
= Dimensions
.bottom
;
38 y2
= Dimensions
.bottom
;
42 /* Calculate the width and height */
46 DPRINT("VGADDIFillSolid: x:%d, y:%d, w:%d, h:%d\n", x
, y
, w
, h
);
48 /* Calculate the starting offset */
49 offset
= xconv
[x
]+y80
[y
];
51 /* Make a note of original x */
54 /* Calculate the left mask pixels, middle bytes and right mask pixel */
55 ileftpix
= 7 - mod8(x
-1);
56 irightpix
= mod8(x
+w
);
57 imidpix
= (w
-ileftpix
-irightpix
) / 8;
59 pre1
= xconv
[(x
-1)&~7] + y80
[y
];
62 /* check for overlap ( very horizontally skinny rect ) */
63 if ( (ileftpix
+irightpix
) > w
)
65 int mask
= startmasks
[ileftpix
] & endmasks
[irightpix
];
67 WRITE_PORT_UCHAR((PUCHAR
)GRA_I
,0x08); // set the mask
68 WRITE_PORT_UCHAR((PUCHAR
)GRA_D
,mask
);
71 for ( j
= y
; j
< y
+h
; j
++ )
73 a
= READ_REGISTER_UCHAR ( vidmem
+tmppre1
);
74 WRITE_REGISTER_UCHAR ( vidmem
+tmppre1
, iColor
);
82 /* Write left pixels */
83 WRITE_PORT_UCHAR((PUCHAR
)GRA_I
,0x08); // set the mask
84 WRITE_PORT_UCHAR((PUCHAR
)GRA_D
,startmasks
[ileftpix
]);
87 for ( j
= y
; j
< y
+h
; j
++ )
89 a
= READ_REGISTER_UCHAR(vidmem
+ tmppre1
);
90 WRITE_REGISTER_UCHAR(vidmem
+ tmppre1
, iColor
);
94 /* Prepare new x for the middle */
100 midpre1
=xconv
[x
] + y80
[y
];
102 /* Set mask to all pixels in byte */
103 WRITE_PORT_UCHAR((PUCHAR
)GRA_I
, 0x08);
105 WRITE_PORT_UCHAR((PUCHAR
)GRA_D
, 0xff);
107 for ( j
= y
; j
< y
+h
; j
++ )
109 memset(vidmem
+midpre1
, iColor
, imidpix
); // write middle pixels, no need to read in latch because of the width
114 x
= orgx
+ w
- irightpix
;
115 pre1
= xconv
[x
] + y80
[y
];
117 /* Write right pixels */
118 WRITE_PORT_UCHAR((PUCHAR
)GRA_I
,0x08); // set the mask bits
119 WRITE_PORT_UCHAR((PUCHAR
)GRA_D
,endmasks
[irightpix
]);
121 for ( j
= y
; j
< y
+h
; j
++ )
123 a
= READ_REGISTER_UCHAR(vidmem
+ pre1
);
124 WRITE_REGISTER_UCHAR(vidmem
+ pre1
, iColor
);
133 IN CLIPOBJ
*ClipRegion
,
136 IN BRUSHINST
*BrushInst
,
137 IN POINTL
*BrushPoint
)
142 DPRINT("VGADDIPaintRgn: iMode: %d, iDComplexity: %d\n Color:%d\n", ClipRegion
->iMode
, ClipRegion
->iDComplexity
, iColor
);
143 switch(ClipRegion
->iMode
)
147 /* Rectangular clipping can be handled without enumeration.
148 Note that trivial clipping is not possible, since the clipping
149 region defines the area to fill */
151 if (ClipRegion
->iDComplexity
== DC_RECT
)
153 DPRINT("VGADDIPaintRgn Rect:%d %d %d %d\n", ClipRegion
->rclBounds
.left
, ClipRegion
->rclBounds
.top
, ClipRegion
->rclBounds
.right
, ClipRegion
->rclBounds
.bottom
);
154 VGADDIFillSolid(Surface
, ClipRegion
->rclBounds
, iColor
);
158 /* Enumerate all the rectangles and draw them */
160 CLIPOBJ_cEnumStart(ClipRegion
, FALSE
, CT_RECTANGLES
, CD_ANY
, 0);
165 EnumMore
= CLIPOBJ_bEnum(ClipRegion
, sizeof(RectEnum
), (PVOID
) &RectEnum
);
166 DPRINT("EnumMore: %d, count: %d\n", EnumMore
, RectEnum
.c
);
167 for( i
=0; i
<RectEnum
.c
; i
++)
169 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
);
170 VGADDIFillSolid(Surface
, RectEnum
.arcl
[i
], iColor
);
185 IN CLIPOBJ
*ClipRegion
,
187 IN POINTL
*BrushOrigin
,
192 iSolidColor
= Brush
->iSolidColor
; // FIXME: Realizations and the like
194 // If the foreground and background Mixes are the same,
195 // (LATER or if there's no brush mask)
196 // then see if we can use the solid brush accelerators
198 // FIXME: Put in the mix switch below
199 // Brush color parameter doesn't matter for these rops
200 return(VGADDIPaintRgn(Surface
, ClipRegion
, iSolidColor
, Mix
, NULL
, BrushOrigin
));
202 if ((Mix
& 0xFF) == ((Mix
>> 8) & 0xFF))
209 // FIXME: Implement all these millions of ROPs
210 // For now we don't support brushes -- everything is solid
225 // Rops that are implicit solid colors
231 // FIXME: The Paint region belongs HERE
244 // If VGADDIPaint can't do it, VGADDIBitBlt can.. or it might just loop back
245 // here and we have a nice infinite loop
247 return( VGADDIBitBlt(Surface, (SURFOBJ *)NULL, (SURFOBJ *)NULL, ClipRegion,
248 (XLATEOBJ *)NULL, &ClipRegion->rclBounds,
249 NULL, (POINTL *)NULL, Brush, BrushOrigin,
250 NULL) ); UNIMPLEMENTED */