[WIN32SS]
[reactos.git] / reactos / subsystems / win32 / win32k / eng / paint.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: GDI Driver Paint Functions
5 * FILE: subsys/win32k/eng/paint.c
6 * PROGRAMER: Jason Filby
7 */
8
9 #include <win32k.h>
10
11 #define NDEBUG
12 #include <debug.h>
13
14 BOOL APIENTRY FillSolid(SURFOBJ *pso, PRECTL pRect, ULONG iColor)
15 {
16 LONG y;
17 ULONG LineWidth;
18
19 ASSERT(pso);
20 ASSERT(pRect);
21 LineWidth = pRect->right - pRect->left;
22 DPRINT(" LineWidth: %d, top: %d, bottom: %d\n", LineWidth, pRect->top, pRect->bottom);
23 for (y = pRect->top; y < pRect->bottom; y++)
24 {
25 DibFunctionsForBitmapFormat[pso->iBitmapFormat].DIB_HLine(
26 pso, pRect->left, pRect->right, y, iColor);
27 }
28 return TRUE;
29 }
30
31 BOOL APIENTRY
32 EngPaintRgn(SURFOBJ *pso, CLIPOBJ *ClipRegion, ULONG iColor, MIX Mix,
33 BRUSHOBJ *BrushObj, POINTL *BrushPoint)
34 {
35 RECT_ENUM RectEnum;
36 BOOL EnumMore;
37 ULONG i;
38
39 ASSERT(pso);
40 ASSERT(ClipRegion);
41
42 DPRINT("ClipRegion->iMode:%d, ClipRegion->iDComplexity: %d\n Color: %d", ClipRegion->iMode, ClipRegion->iDComplexity, iColor);
43 switch(ClipRegion->iMode) {
44
45 case TC_RECTANGLES:
46
47 /* Rectangular clipping can be handled without enumeration.
48 Note that trivial clipping is not possible, since the clipping
49 region defines the area to fill */
50
51 if (ClipRegion->iDComplexity == DC_RECT)
52 {
53 FillSolid(pso, &(ClipRegion->rclBounds), iColor);
54 } else {
55
56 /* Enumerate all the rectangles and draw them */
57 CLIPOBJ_cEnumStart(ClipRegion, FALSE, CT_RECTANGLES, CD_ANY, 0);
58
59 do {
60 EnumMore = CLIPOBJ_bEnum(ClipRegion, sizeof(RectEnum), (PVOID) &RectEnum);
61 for (i = 0; i < RectEnum.c; i++) {
62 FillSolid(pso, RectEnum.arcl + i, iColor);
63 }
64 } while (EnumMore);
65 }
66
67 return(TRUE);
68
69 default:
70 return(FALSE);
71 }
72 }
73
74 /*
75 * @unimplemented
76 */
77 BOOL APIENTRY
78 EngPaint(IN SURFOBJ *pso,
79 IN CLIPOBJ *ClipRegion,
80 IN BRUSHOBJ *Brush,
81 IN POINTL *BrushOrigin,
82 IN MIX Mix)
83 {
84 BOOLEAN ret;
85
86 // FIXME: We only support a brush's solid color attribute
87 ret = EngPaintRgn(pso, ClipRegion, Brush->iSolidColor, Mix, Brush, BrushOrigin);
88
89 return ret;
90 }
91
92 BOOL APIENTRY
93 IntEngPaint(IN SURFOBJ *pso,
94 IN CLIPOBJ *ClipRegion,
95 IN BRUSHOBJ *Brush,
96 IN POINTL *BrushOrigin,
97 IN MIX Mix)
98 {
99 SURFACE *psurf = CONTAINING_RECORD(pso, SURFACE, SurfObj);
100 BOOL ret;
101
102 DPRINT("pso->iType == %d\n", pso->iType);
103 /* Is the surface's Paint function hooked? */
104 if((pso->iType!=STYPE_BITMAP) && (psurf->flags & HOOK_PAINT))
105 {
106 // Call the driver's DrvPaint
107 ret = GDIDEVFUNCS(pso).Paint(
108 pso, ClipRegion, Brush, BrushOrigin, Mix);
109 return ret;
110 }
111 return EngPaint(pso, ClipRegion, Brush, BrushOrigin, Mix );
112
113 }
114 /* EOF */