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