2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: GDI Driver Paint Functions
5 * FILE: subsys/win32k/eng/paint.c
6 * PROGRAMER: Jason Filby
11 #include <ddk/winddi.h>
12 #include <include/object.h>
13 #include <include/paint.h>
14 #include <include/surface.h>
17 #include <include/mouse.h>
18 #include "../dib/dib.h"
24 #include <win32k/debug1.h>
26 BOOL
FillSolid(SURFOBJ
*Surface
, PRECTL pRect
, ULONG iColor
)
28 // These functions are assigned if we're working with a DIB
29 // The assigned functions depend on the bitsPerPixel of the DIB
30 PFN_DIB_PutPixel DIB_PutPixel
;
31 PFN_DIB_HLine DIB_HLine
;
32 PFN_DIB_VLine DIB_VLine
;
34 ULONG x
, LineWidth
, leftOfBitmap
;
37 SurfaceGDI
= (SURFGDI
*)AccessInternalObjectFromUserObject(Surface
);
38 MouseSafetyOnDrawStart(Surface
, SurfaceGDI
, pRect
->left
, pRect
->top
, pRect
->right
, pRect
->bottom
);
40 if(Surface->iType!=STYPE_BITMAP)
42 // Call the driver's DrvLineTo
43 ret = SurfGDI->LineTo(Surface, Clip, Brush, x1, y1, x2, y2, RectBounds, mix);
44 MouseSafetyOnDrawEnd(Surface, SurfGDI);
48 // Assign DIB functions according to bytes per pixel
49 DPRINT("BPF: %d\n", BitsPerFormat(Surface
->iBitmapFormat
));
50 switch(BitsPerFormat(Surface
->iBitmapFormat
))
53 DIB_PutPixel
= (PFN_DIB_PutPixel
)DIB_4BPP_PutPixel
;
54 DIB_HLine
= (PFN_DIB_HLine
)DIB_4BPP_HLine
;
55 DIB_VLine
= (PFN_DIB_VLine
)DIB_4BPP_VLine
;
59 DIB_PutPixel
= (PFN_DIB_PutPixel
)DIB_24BPP_PutPixel
;
60 DIB_HLine
= (PFN_DIB_HLine
)DIB_24BPP_HLine
;
61 DIB_VLine
= (PFN_DIB_VLine
)DIB_24BPP_VLine
;
65 DbgPrint("EngLineTo: unsupported DIB format %u (bitsPerPixel:%u)\n", Surface
->iBitmapFormat
,
66 BitsPerFormat(Surface
->iBitmapFormat
));
68 MouseSafetyOnDrawEnd(Surface
, SurfaceGDI
);
72 LineWidth
= pRect
->right
- pRect
->left
;
73 DPRINT(" LineWidth: %d, top: %d, bottom: %d\n", LineWidth
, pRect
->top
, pRect
->bottom
);
74 for (y
= pRect
->top
; y
< pRect
->bottom
; y
++)
76 //EngLineTo(Surface, SurfaceGDI, Dimensions->left, y, LineWidth, iColor);
77 DIB_HLine(Surface
, pRect
->left
, pRect
->right
, y
, iColor
);
79 MouseSafetyOnDrawEnd(Surface
, SurfaceGDI
);
84 BOOL
EngPaintRgn(SURFOBJ
*Surface
, CLIPOBJ
*ClipRegion
, ULONG iColor
, MIX Mix
,
85 BRUSHINST
*BrushInst
, POINTL
*BrushPoint
)
90 DPRINT("ClipRegion->iMode:%d, ClipRegion->iDComplexity: %d\n Color: %d", ClipRegion
->iMode
, ClipRegion
->iDComplexity
, iColor
);
91 switch(ClipRegion
->iMode
) {
95 /* Rectangular clipping can be handled without enumeration.
96 Note that trivial clipping is not possible, since the clipping
97 region defines the area to fill */
99 if (ClipRegion
->iDComplexity
== DC_RECT
)
101 FillSolid(Surface
, &(ClipRegion
->rclBounds
), iColor
);
104 /* Enumerate all the rectangles and draw them */
105 CLIPOBJ_cEnumStart(ClipRegion
, FALSE
, CT_RECTANGLES
, CD_ANY
, ENUM_RECT_LIMIT
);
108 EnumMore
= CLIPOBJ_bEnum(ClipRegion
, sizeof(RectEnum
), (PVOID
) &RectEnum
);
109 FillSolid(Surface
, &RectEnum
.arcl
[0], iColor
);
121 EngPaint(IN SURFOBJ
*Surface
,
122 IN CLIPOBJ
*ClipRegion
,
124 IN POINTL
*BrushOrigin
,
129 // FIXME: We only support a brush's solid color attribute
130 ret
= EngPaintRgn(Surface
, ClipRegion
, Brush
->iSolidColor
, Mix
, NULL
, BrushOrigin
);
136 IntEngPaint(IN SURFOBJ
*Surface
,
137 IN CLIPOBJ
*ClipRegion
,
139 IN POINTL
*BrushOrigin
,
145 // Is the surface's Paint function hooked?
146 SurfGDI
= (SURFGDI
*)AccessInternalObjectFromUserObject(Surface
);
148 DPRINT("SurfGDI type: %d, sgdi paint: %x\n", Surface
->iType
, SurfGDI
->Paint
);
149 if((Surface
->iType
!=STYPE_BITMAP
) && (SurfGDI
->Paint
!=NULL
))
151 // Call the driver's DrvPaint
152 MouseSafetyOnDrawStart(Surface
, SurfGDI
, ClipRegion
->rclBounds
.left
,
153 ClipRegion
->rclBounds
.top
, ClipRegion
->rclBounds
.right
,
154 ClipRegion
->rclBounds
.bottom
);
156 ret
= SurfGDI
->Paint(Surface
, ClipRegion
, Brush
, BrushOrigin
, Mix
);
157 MouseSafetyOnDrawEnd(Surface
, SurfGDI
);
160 return EngPaint( Surface
, ClipRegion
, Brush
, BrushOrigin
, Mix
);