Merge trunk HEAD (r44067)
[reactos.git] / reactos / subsystems / win32 / win32k / eng / paint.c
1 /*
2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 /* $Id$
20 *
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * PURPOSE: GDI Driver Paint Functions
24 * FILE: subsys/win32k/eng/paint.c
25 * PROGRAMER: Jason Filby
26 * REVISION HISTORY:
27 * 3/7/1999: Created
28 */
29
30 #include <w32k.h>
31
32 #define NDEBUG
33 #include <debug.h>
34
35 static BOOL APIENTRY FillSolidUnlocked(SURFOBJ *pso, PRECTL pRect, ULONG iColor)
36 {
37 LONG y;
38 ULONG LineWidth;
39 SURFACE *psurf;
40
41 ASSERT(pso);
42 ASSERT(pRect);
43 psurf = CONTAINING_RECORD(pso, SURFACE, SurfObj);
44 MouseSafetyOnDrawStart(pso, pRect->left, pRect->top, pRect->right, pRect->bottom);
45 LineWidth = pRect->right - pRect->left;
46 DPRINT(" LineWidth: %d, top: %d, bottom: %d\n", LineWidth, pRect->top, pRect->bottom);
47 for (y = pRect->top; y < pRect->bottom; y++)
48 {
49 DibFunctionsForBitmapFormat[pso->iBitmapFormat].DIB_HLine(
50 pso, pRect->left, pRect->right, y, iColor);
51 }
52 MouseSafetyOnDrawEnd(pso);
53
54 return TRUE;
55 }
56
57 BOOL APIENTRY FillSolid(SURFOBJ *pso, PRECTL pRect, ULONG iColor)
58 {
59 SURFACE *psurf;
60 BOOL Result;
61 psurf = CONTAINING_RECORD(pso, SURFACE, SurfObj);
62 SURFACE_LockBitmapBits(psurf);
63 Result = FillSolidUnlocked(pso, pRect, iColor);
64 SURFACE_UnlockBitmapBits(psurf);
65 return Result;
66 }
67
68 BOOL APIENTRY
69 EngPaintRgn(SURFOBJ *pso, CLIPOBJ *ClipRegion, ULONG iColor, MIX Mix,
70 BRUSHOBJ *BrushObj, POINTL *BrushPoint)
71 {
72 RECT_ENUM RectEnum;
73 BOOL EnumMore;
74 ULONG i;
75
76 ASSERT(pso);
77 ASSERT(ClipRegion);
78
79 DPRINT("ClipRegion->iMode:%d, ClipRegion->iDComplexity: %d\n Color: %d", ClipRegion->iMode, ClipRegion->iDComplexity, iColor);
80 switch(ClipRegion->iMode) {
81
82 case TC_RECTANGLES:
83
84 /* Rectangular clipping can be handled without enumeration.
85 Note that trivial clipping is not possible, since the clipping
86 region defines the area to fill */
87
88 if (ClipRegion->iDComplexity == DC_RECT)
89 {
90 FillSolidUnlocked(pso, &(ClipRegion->rclBounds), iColor);
91 } else {
92
93 /* Enumerate all the rectangles and draw them */
94 CLIPOBJ_cEnumStart(ClipRegion, FALSE, CT_RECTANGLES, CD_ANY, 0);
95
96 do {
97 EnumMore = CLIPOBJ_bEnum(ClipRegion, sizeof(RectEnum), (PVOID) &RectEnum);
98 for (i = 0; i < RectEnum.c; i++) {
99 FillSolidUnlocked(pso, RectEnum.arcl + i, iColor);
100 }
101 } while (EnumMore);
102 }
103
104 return(TRUE);
105
106 default:
107 return(FALSE);
108 }
109 }
110
111 /*
112 * @unimplemented
113 */
114 BOOL APIENTRY
115 EngPaint(IN SURFOBJ *pso,
116 IN CLIPOBJ *ClipRegion,
117 IN BRUSHOBJ *Brush,
118 IN POINTL *BrushOrigin,
119 IN MIX Mix)
120 {
121 BOOLEAN ret;
122
123 // FIXME: We only support a brush's solid color attribute
124 ret = EngPaintRgn(pso, ClipRegion, Brush->iSolidColor, Mix, Brush, BrushOrigin);
125
126 return ret;
127 }
128
129 BOOL APIENTRY
130 IntEngPaint(IN SURFOBJ *pso,
131 IN CLIPOBJ *ClipRegion,
132 IN BRUSHOBJ *Brush,
133 IN POINTL *BrushOrigin,
134 IN MIX Mix)
135 {
136 SURFACE *psurf = CONTAINING_RECORD(pso, SURFACE, SurfObj);
137 BOOL ret;
138
139 DPRINT("pso->iType == %d\n", pso->iType);
140 /* Is the surface's Paint function hooked? */
141 if((pso->iType!=STYPE_BITMAP) && (psurf->flHooks & HOOK_PAINT))
142 {
143 // Call the driver's DrvPaint
144 SURFACE_LockBitmapBits(psurf);
145 MouseSafetyOnDrawStart(pso, ClipRegion->rclBounds.left,
146 ClipRegion->rclBounds.top, ClipRegion->rclBounds.right,
147 ClipRegion->rclBounds.bottom);
148
149 ret = GDIDEVFUNCS(pso).Paint(
150 pso, ClipRegion, Brush, BrushOrigin, Mix);
151 MouseSafetyOnDrawEnd(pso);
152 SURFACE_UnlockBitmapBits(psurf);
153 return ret;
154 }
155 return EngPaint(pso, ClipRegion, Brush, BrushOrigin, Mix );
156
157 }
158 /* EOF */