Sync with trunk (r47116), hopefully without breaking anything.
[reactos.git] / 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 <win32k.h>
31
32 #define NDEBUG
33 #include <debug.h>
34
35 BOOL APIENTRY FillSolid(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 LineWidth = pRect->right - pRect->left;
45 DPRINT(" LineWidth: %d, top: %d, bottom: %d\n", LineWidth, pRect->top, pRect->bottom);
46 for (y = pRect->top; y < pRect->bottom; y++)
47 {
48 DibFunctionsForBitmapFormat[pso->iBitmapFormat].DIB_HLine(
49 pso, pRect->left, pRect->right, y, iColor);
50 }
51 return TRUE;
52 }
53
54 BOOL APIENTRY
55 EngPaintRgn(SURFOBJ *pso, CLIPOBJ *ClipRegion, ULONG iColor, MIX Mix,
56 BRUSHOBJ *BrushObj, POINTL *BrushPoint)
57 {
58 RECT_ENUM RectEnum;
59 BOOL EnumMore;
60 ULONG i;
61
62 ASSERT(pso);
63 ASSERT(ClipRegion);
64
65 DPRINT("ClipRegion->iMode:%d, ClipRegion->iDComplexity: %d\n Color: %d", ClipRegion->iMode, ClipRegion->iDComplexity, iColor);
66 switch(ClipRegion->iMode) {
67
68 case TC_RECTANGLES:
69
70 /* Rectangular clipping can be handled without enumeration.
71 Note that trivial clipping is not possible, since the clipping
72 region defines the area to fill */
73
74 if (ClipRegion->iDComplexity == DC_RECT)
75 {
76 FillSolid(pso, &(ClipRegion->rclBounds), iColor);
77 } else {
78
79 /* Enumerate all the rectangles and draw them */
80 CLIPOBJ_cEnumStart(ClipRegion, FALSE, CT_RECTANGLES, CD_ANY, 0);
81
82 do {
83 EnumMore = CLIPOBJ_bEnum(ClipRegion, sizeof(RectEnum), (PVOID) &RectEnum);
84 for (i = 0; i < RectEnum.c; i++) {
85 FillSolid(pso, RectEnum.arcl + i, iColor);
86 }
87 } while (EnumMore);
88 }
89
90 return(TRUE);
91
92 default:
93 return(FALSE);
94 }
95 }
96
97 /*
98 * @unimplemented
99 */
100 BOOL APIENTRY
101 EngPaint(IN SURFOBJ *pso,
102 IN CLIPOBJ *ClipRegion,
103 IN BRUSHOBJ *Brush,
104 IN POINTL *BrushOrigin,
105 IN MIX Mix)
106 {
107 BOOLEAN ret;
108
109 // FIXME: We only support a brush's solid color attribute
110 ret = EngPaintRgn(pso, ClipRegion, Brush->iSolidColor, Mix, Brush, BrushOrigin);
111
112 return ret;
113 }
114
115 BOOL APIENTRY
116 IntEngPaint(IN SURFOBJ *pso,
117 IN CLIPOBJ *ClipRegion,
118 IN BRUSHOBJ *Brush,
119 IN POINTL *BrushOrigin,
120 IN MIX Mix)
121 {
122 SURFACE *psurf = CONTAINING_RECORD(pso, SURFACE, SurfObj);
123 BOOL ret;
124
125 DPRINT("pso->iType == %d\n", pso->iType);
126 /* Is the surface's Paint function hooked? */
127 if((pso->iType!=STYPE_BITMAP) && (psurf->flHooks & HOOK_PAINT))
128 {
129 // Call the driver's DrvPaint
130 ret = GDIDEVFUNCS(pso).Paint(
131 pso, ClipRegion, Brush, BrushOrigin, Mix);
132 return ret;
133 }
134 return EngPaint(pso, ClipRegion, Brush, BrushOrigin, Mix );
135
136 }
137 /* EOF */