Revert, thx Thomas, wasnt sure.
[reactos.git] / reactos / subsys / 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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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 BOOL STDCALL FillSolid(SURFOBJ *Surface, PRECTL pRect, ULONG iColor)
36 {
37 LONG y;
38 ULONG LineWidth;
39 BITMAPOBJ *BitmapObj;
40
41 ASSERT ( Surface );
42 ASSERT ( pRect );
43 BitmapObj = CONTAINING_RECORD(Surface, BITMAPOBJ, SurfObj);
44 BITMAPOBJ_LockBitmapBits(BitmapObj);
45 MouseSafetyOnDrawStart(Surface, pRect->left, pRect->top, pRect->right, pRect->bottom);
46 LineWidth = pRect->right - pRect->left;
47 DPRINT(" LineWidth: %d, top: %d, bottom: %d\n", LineWidth, pRect->top, pRect->bottom);
48 for (y = pRect->top; y < pRect->bottom; y++)
49 {
50 DibFunctionsForBitmapFormat[Surface->iBitmapFormat].DIB_HLine(
51 Surface, pRect->left, pRect->right, y, iColor);
52 }
53 MouseSafetyOnDrawEnd(Surface);
54 BITMAPOBJ_UnlockBitmapBits(BitmapObj);
55
56 return TRUE;
57 }
58
59 BOOL STDCALL
60 EngPaintRgn(SURFOBJ *Surface, CLIPOBJ *ClipRegion, ULONG iColor, MIX Mix,
61 BRUSHOBJ *BrushObj, POINTL *BrushPoint)
62 {
63 RECT_ENUM RectEnum;
64 BOOL EnumMore;
65 ULONG i;
66
67 ASSERT(Surface);
68 ASSERT(ClipRegion);
69
70 DPRINT("ClipRegion->iMode:%d, ClipRegion->iDComplexity: %d\n Color: %d", ClipRegion->iMode, ClipRegion->iDComplexity, iColor);
71 switch(ClipRegion->iMode) {
72
73 case TC_RECTANGLES:
74
75 /* Rectangular clipping can be handled without enumeration.
76 Note that trivial clipping is not possible, since the clipping
77 region defines the area to fill */
78
79 if (ClipRegion->iDComplexity == DC_RECT)
80 {
81 FillSolid(Surface, &(ClipRegion->rclBounds), iColor);
82 } else {
83
84 /* Enumerate all the rectangles and draw them */
85 CLIPOBJ_cEnumStart(ClipRegion, FALSE, CT_RECTANGLES, CD_ANY, 0);
86
87 do {
88 EnumMore = CLIPOBJ_bEnum(ClipRegion, sizeof(RectEnum), (PVOID) &RectEnum);
89 for (i = 0; i < RectEnum.c; i++) {
90 FillSolid(Surface, RectEnum.arcl + i, iColor);
91 }
92 } while (EnumMore);
93 }
94
95 return(TRUE);
96
97 default:
98 return(FALSE);
99 }
100 }
101
102 /*
103 * @unimplemented
104 */
105 BOOL STDCALL
106 EngPaint(IN SURFOBJ *Surface,
107 IN CLIPOBJ *ClipRegion,
108 IN BRUSHOBJ *Brush,
109 IN POINTL *BrushOrigin,
110 IN MIX Mix)
111 {
112 BOOLEAN ret;
113
114 // FIXME: We only support a brush's solid color attribute
115 ret = EngPaintRgn(Surface, ClipRegion, Brush->iSolidColor, Mix, Brush, BrushOrigin);
116
117 return ret;
118 }
119
120 BOOL STDCALL
121 IntEngPaint(IN SURFOBJ *Surface,
122 IN CLIPOBJ *ClipRegion,
123 IN BRUSHOBJ *Brush,
124 IN POINTL *BrushOrigin,
125 IN MIX Mix)
126 {
127 BITMAPOBJ *BitmapObj = CONTAINING_RECORD(Surface, BITMAPOBJ, SurfObj);
128 BOOL ret;
129
130 DPRINT("SurfGDI type: %d\n", Surface->iType);
131 /* Is the surface's Paint function hooked? */
132 if((Surface->iType!=STYPE_BITMAP) && (BitmapObj->flHooks & HOOK_PAINT))
133 {
134 // Call the driver's DrvPaint
135 BITMAPOBJ_LockBitmapBits(BitmapObj);
136 MouseSafetyOnDrawStart(Surface, ClipRegion->rclBounds.left,
137 ClipRegion->rclBounds.top, ClipRegion->rclBounds.right,
138 ClipRegion->rclBounds.bottom);
139
140 ret = GDIDEVFUNCS(Surface).Paint(
141 Surface, ClipRegion, Brush, BrushOrigin, Mix);
142 MouseSafetyOnDrawEnd(Surface);
143 BITMAPOBJ_UnlockBitmapBits(BitmapObj);
144 return ret;
145 }
146 return EngPaint( Surface, ClipRegion, Brush, BrushOrigin, Mix );
147
148 }
149 /* EOF */