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