ReactOS 0.4.16-dev-297-gc569aee
paint.c File Reference
#include <vgaddi.h>
#include "brush.h"
Include dependency graph for paint.c:

Go to the source code of this file.

Functions

BOOL VGADDIFillSolid (SURFOBJ *Surface, RECTL Dimensions, ULONG iColor)
 
BOOL VGADDIPaintRgn (IN SURFOBJ *Surface, IN CLIPOBJ *ClipRegion, IN ULONG iColor, IN MIX Mix, IN BRUSHINST *BrushInst, IN POINTL *BrushPoint)
 
BOOL APIENTRY DrvPaint (IN SURFOBJ *Surface, IN CLIPOBJ *ClipRegion, IN BRUSHOBJ *Brush, IN POINTL *BrushOrigin, IN MIX Mix)
 

Function Documentation

◆ DrvPaint()

BOOL APIENTRY DrvPaint ( IN SURFOBJ Surface,
IN CLIPOBJ ClipRegion,
IN BRUSHOBJ Brush,
IN POINTL BrushOrigin,
IN MIX  Mix 
)

Definition at line 184 of file paint.c.

190{
191 ULONG iSolidColor;
192
193 iSolidColor = Brush->iSolidColor; // FIXME: Realizations and the like
194
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
198
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));
202
203 if ((Mix & 0xFF) == ((Mix >> 8) & 0xFF))
204 {
205 switch (Mix & 0xFF)
206 {
207 case 0:
208 break;
209
210 // FIXME: Implement all these millions of ROPs
211 // For now we don't support brushes -- everything is solid
212
213 case R2_MASKNOTPEN:
214 case R2_NOTCOPYPEN:
215 case R2_XORPEN:
216 case R2_MASKPEN:
217 case R2_NOTXORPEN:
218 case R2_MERGENOTPEN:
219 case R2_COPYPEN:
220 case R2_MERGEPEN:
221 case R2_NOTMERGEPEN:
222 case R2_MASKPENNOT:
223 case R2_NOTMASKPEN:
224 case R2_MERGEPENNOT:
225
226 // Rops that are implicit solid colors
227 case R2_NOT:
228 case R2_WHITE:
229 case R2_BLACK:
230
231
232 // FIXME: The Paint region belongs HERE
233
234 case R2_NOP:
235 return TRUE;
236
237 default:
238 break;
239 }
240 }
241
242/*
243doBitBlt:
244
245 // If VGADDIPaint can't do it, VGADDIBitBlt can.. or it might just loop back
246 // here and we have a nice infinite loop
247
248 return( VGADDIBitBlt(Surface, NULL, NULL, ClipRegion,
249 NULL, &ClipRegion->rclBounds,
250 NULL, NULL, Brush, BrushOrigin,
251 NULL) ); UNIMPLEMENTED */
252}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
uint32_t ULONG
Definition: typedefs.h:59
BOOL VGADDIPaintRgn(IN SURFOBJ *Surface, IN CLIPOBJ *ClipRegion, IN ULONG iColor, IN MIX Mix, IN BRUSHINST *BrushInst, IN POINTL *BrushPoint)
Definition: paint.c:132
#define R2_BLACK
Definition: wingdi.h:338
#define R2_NOTCOPYPEN
Definition: wingdi.h:348
#define R2_MERGEPENNOT
Definition: wingdi.h:345
#define R2_MASKPENNOT
Definition: wingdi.h:342
#define R2_NOTXORPEN
Definition: wingdi.h:351
#define R2_NOP
Definition: wingdi.h:346
#define R2_XORPEN
Definition: wingdi.h:353
#define R2_MERGENOTPEN
Definition: wingdi.h:343
#define R2_MASKNOTPEN
Definition: wingdi.h:340
#define R2_NOT
Definition: wingdi.h:347
#define R2_NOTMASKPEN
Definition: wingdi.h:349
#define R2_NOTMERGEPEN
Definition: wingdi.h:350
#define R2_MASKPEN
Definition: wingdi.h:341
#define R2_COPYPEN
Definition: wingdi.h:339
#define R2_MERGEPEN
Definition: wingdi.h:344
#define R2_WHITE
Definition: wingdi.h:352

◆ VGADDIFillSolid()

BOOL VGADDIFillSolid ( SURFOBJ Surface,
RECTL  Dimensions,
ULONG  iColor 
)

Definition at line 13 of file paint.c.

14{
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;*/
20
21 /* Swap dimensions so that x, y are at topmost left */
22 if ( Dimensions.right < Dimensions.left )
23 {
24 x = Dimensions.right;
25 x2 = Dimensions.left;
26 }
27 else
28 {
29 x2 = Dimensions.right;
30 x = Dimensions.left;
31 }
32 if ( Dimensions.bottom < Dimensions.top )
33 {
34 y = Dimensions.bottom;
35 y2 = Dimensions.top;
36 }
37 else
38 {
39 y2 = Dimensions.bottom;
40 y = Dimensions.top;
41 }
42
43 /* Calculate the width and height */
44 w = x2 - x;
45 h = y2 - y;
46
47 DPRINT("VGADDIFillSolid: x:%d, y:%d, w:%d, h:%d\n", x, y, w, h);
48
49 /* Calculate the starting offset */
50 //offset = xconv[x]+y80[y];
51
52 /* Make a note of original x */
53 orgx = x;
54
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;
59
60 pre1 = xconv[(x-1)&~7] + y80[y];
61 //orgpre1=pre1;
62
63 /* check for overlap ( very horizontally skinny rect ) */
64 if ( (ileftpix+irightpix) > w )
65 {
66 int mask = startmasks[ileftpix] & endmasks[irightpix];
67
68 WRITE_PORT_UCHAR((PUCHAR)GRA_I,0x08); // set the mask
70
71 tmppre1 = pre1;
72 for ( j = y; j < y+h; j++ )
73 {
74 READ_REGISTER_UCHAR ( vidmem+tmppre1 );
76 tmppre1 += 80;
77 }
78 return TRUE;
79 }
80
81 if ( ileftpix > 0 )
82 {
83 /* Write left pixels */
84 WRITE_PORT_UCHAR((PUCHAR)GRA_I,0x08); // set the mask
86
87 tmppre1 = pre1;
88 for ( j = y; j < y+h; j++ )
89 {
90 READ_REGISTER_UCHAR(vidmem + tmppre1);
92 tmppre1 += 80;
93 }
94
95 /* Prepare new x for the middle */
96 x = orgx + 8;
97 }
98
99 if ( imidpix > 0 )
100 {
101 midpre1=xconv[x] + y80[y];
102
103 /* Set mask to all pixels in byte */
105
107
108 for ( j = y; j < y+h; j++ )
109 {
110 memset(vidmem+midpre1, iColor, imidpix); // write middle pixels, no need to read in latch because of the width
111 midpre1 += 80;
112 }
113 }
114
115 x = orgx + w - irightpix;
116 pre1 = xconv[x] + y80[y];
117
118 /* Write right pixels */
119 WRITE_PORT_UCHAR((PUCHAR)GRA_I,0x08); // set the mask bits
121
122 for ( j = y; j < y+h; j++ )
123 {
126 pre1 += 80;
127 }
128
129 return TRUE;
130}
#define GRA_D
Definition: vgavideo.h:60
#define mod8(n)
Definition: vgavideo.h:70
#define GRA_I
Definition: vgavideo.h:59
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLenum GLint GLuint mask
Definition: glext.h:6028
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
#define memset(x, y, z)
Definition: compat.h:39
#define DPRINT
Definition: sndvol32.h:73
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
unsigned char * PUCHAR
Definition: typedefs.h:53
int endmasks[8]
Definition: vgavideo.c:17
int xconv[640]
Definition: vgavideo.c:14
PBYTE vidmem
Definition: vgavideo.c:18
int y80[480]
Definition: vgavideo.c:13
int startmasks[8]
Definition: vgavideo.c:16
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3710
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG _In_ LONG y2
Definition: winddi.h:3711
NTKERNELAPI VOID NTAPI WRITE_REGISTER_UCHAR(IN PUCHAR Register, IN UCHAR Value)
NTKERNELAPI UCHAR NTAPI READ_REGISTER_UCHAR(IN PUCHAR Register)
_In_ ULONG iColor
Definition: xlateobj.h:17

Referenced by VGADDIPaintRgn().

◆ VGADDIPaintRgn()

BOOL VGADDIPaintRgn ( IN SURFOBJ Surface,
IN CLIPOBJ ClipRegion,
IN ULONG  iColor,
IN MIX  Mix,
IN BRUSHINST BrushInst,
IN POINTL BrushPoint 
)

Definition at line 132 of file paint.c.

139{
140 RECT_ENUM RectEnum;
141 BOOL EnumMore;
142
143 DPRINT("VGADDIPaintRgn: iMode: %d, iDComplexity: %d\n Color:%d\n", ClipRegion->iMode, ClipRegion->iDComplexity, iColor);
144 switch(ClipRegion->iMode)
145 {
146 case TC_RECTANGLES:
147
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 */
151
152 if (ClipRegion->iDComplexity == DC_RECT)
153 {
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);
156 }
157 else
158 {
159 /* Enumerate all the rectangles and draw them */
160
162
163 do
164 {
165 UINT i;
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++)
169 {
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);
172 }
173 } while (EnumMore);
174 }
175 return TRUE;
176
177 default:
178 return FALSE;
179 }
180}
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
ULONG c
Definition: vgaddi.h:78
RECTL arcl[ENUM_RECT_LIMIT]
Definition: vgaddi.h:79
BOOL VGADDIFillSolid(SURFOBJ *Surface, RECTL Dimensions, ULONG iColor)
Definition: paint.c:13
#define CT_RECTANGLES
Definition: winddi.h:1317
ENGAPI BOOL APIENTRY CLIPOBJ_bEnum(_In_ CLIPOBJ *pco, _In_ ULONG cj, _Out_bytecap_(cj) ULONG *pul)
Definition: clip.c:319
ENGAPI ULONG APIENTRY CLIPOBJ_cEnumStart(_Inout_ CLIPOBJ *pco, _In_ BOOL bAll, _In_ ULONG iType, _In_ ULONG iDirection, _In_ ULONG cLimit)
Definition: clip.c:255
#define DC_RECT
Definition: winddi.h:260
#define CD_ANY
Definition: winddi.h:1326
#define TC_RECTANGLES
Definition: winddi.h:269

Referenced by DrvPaint().