2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
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.
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.
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.
19 /* $Id: brush.c,v 1.23 2003/08/02 19:52:03 dwelch Exp $
23 #undef WIN32_LEAN_AND_MEAN
25 #include <ddk/ntddk.h>
26 #include <win32k/bitmaps.h>
27 #include <win32k/brush.h>
28 //#include <win32k/debug.h>
29 #include <include/object.h>
30 #include <include/inteng.h>
31 #include <include/error.h>
34 #include <win32k/debug1.h>
36 HBRUSH STDCALL
W32kCreateBrushIndirect(CONST LOGBRUSH
*lb
)
41 hBrush
= BRUSHOBJ_AllocBrush();
47 brushPtr
= BRUSHOBJ_LockBrush (hBrush
);
48 ASSERT( brushPtr
); //I want to know if this ever occurs
51 brushPtr
->iSolidColor
= lb
->lbColor
;
52 brushPtr
->logbrush
.lbStyle
= lb
->lbStyle
;
53 brushPtr
->logbrush
.lbColor
= lb
->lbColor
;
54 brushPtr
->logbrush
.lbHatch
= lb
->lbHatch
;
56 BRUSHOBJ_UnlockBrush( hBrush
);
62 HBRUSH STDCALL
W32kCreateDIBPatternBrush(HGLOBAL hDIBPacked
,
68 PBITMAPINFO info
, newInfo
;
71 DPRINT("%04x\n", hbitmap
);
73 logbrush
.lbStyle
= BS_DIBPATTERN
;
74 logbrush
.lbColor
= coloruse
;
77 /* Make a copy of the bitmap */
78 if (!(info
= (BITMAPINFO
*)GlobalLock( hbitmap
)))
84 if (info
->bmiHeader
.biCompression
) size
= info
->bmiHeader
.biSizeImage
;
86 size
= DIB_GetDIBImageBytes(info
->bmiHeader
.biWidth
, info
->bmiHeader
.biHeight
, info
->bmiHeader
.biBitCount
);
87 size
+= DIB_BitmapInfoSize(info
, coloruse
);
89 if (!(logbrush
.lbHatch
= (INT
)GlobalAlloc16( GMEM_MOVEABLE
, size
)))
91 GlobalUnlock16( hbitmap
);
94 newInfo
= (BITMAPINFO
*) GlobalLock16((HGLOBAL16
)logbrush
.lbHatch
);
95 memcpy(newInfo
, info
, size
);
96 GlobalUnlock16((HGLOBAL16
)logbrush
.lbHatch
);
97 GlobalUnlock(hbitmap
);
98 return W32kCreateBrushIndirect(&logbrush
);
102 HBRUSH STDCALL
W32kCreateDIBPatternBrushPt(CONST VOID
*PackedDIB
,
110 info
= (BITMAPINFO
*) PackedDIB
;
115 DPRINT ("%p %ldx%ld %dbpp\n",
117 info
->bmiHeader
.biWidth
,
118 info
->bmiHeader
.biHeight
,
119 info
->bmiHeader
.biBitCount
);
121 logbrush
.lbStyle
= BS_DIBPATTERN
;
122 logbrush
.lbColor
= Usage
;
123 logbrush
.lbHatch
= 0;
125 /* Make a copy of the bitmap */
127 if (info
->bmiHeader
.biCompression
)
129 size
= info
->bmiHeader
.biSizeImage
;
133 size
= DIB_GetDIBImageBytes (info
->bmiHeader
.biWidth
, info
->bmiHeader
.biHeight
, info
->bmiHeader
.biBitCount
);
135 size
+= DIB_BitmapInfoSize (info
, Usage
);
137 logbrush
.lbHatch
= (LONG
) GDIOBJ_AllocObj(size
, GO_MAGIC_DONTCARE
);
138 if (logbrush
.lbHatch
== 0)
142 newInfo
= (PBITMAPINFO
) GDIOBJ_LockObj ((HGDIOBJ
) logbrush
.lbHatch
, GO_MAGIC_DONTCARE
);
144 memcpy(newInfo
, info
, size
);
145 GDIOBJ_UnlockObj( (HGDIOBJ
) logbrush
.lbHatch
, GO_MAGIC_DONTCARE
);
147 return W32kCreateBrushIndirect (&logbrush
);
150 HBRUSH STDCALL
W32kCreateHatchBrush(INT Style
,
155 DPRINT("%d %06lx\n", Style
, Color
);
157 if (Style
< 0 || Style
>= NB_HATCH_STYLES
)
161 logbrush
.lbStyle
= BS_HATCHED
;
162 logbrush
.lbColor
= Color
;
163 logbrush
.lbHatch
= Style
;
165 return W32kCreateBrushIndirect (&logbrush
);
168 HBRUSH STDCALL
W32kCreatePatternBrush(HBITMAP hBitmap
)
170 LOGBRUSH logbrush
= { BS_PATTERN
, 0, 0 };
172 DPRINT ("%04x\n", hBitmap
);
173 logbrush
.lbHatch
= (INT
) BITMAPOBJ_CopyBitmap (hBitmap
);
174 if(!logbrush
.lbHatch
)
180 return W32kCreateBrushIndirect( &logbrush
);
184 HBRUSH STDCALL
W32kCreateSolidBrush(COLORREF Color
)
188 logbrush
.lbStyle
= BS_SOLID
;
189 logbrush
.lbColor
= Color
;
190 logbrush
.lbHatch
= 0;
192 return W32kCreateBrushIndirect(&logbrush
);
195 BOOL STDCALL
W32kFixBrushOrgEx(VOID
)
200 BOOL STDCALL
W32kPatBlt(HDC hDC
,
210 DC
*dc
= DC_HandleToPtr(hDC
);
215 SetLastWin32Error(ERROR_INVALID_HANDLE
);
219 SurfObj
= (SURFOBJ
*)AccessUserObject((ULONG
)dc
->Surface
);
221 BrushObj
= (BRUSHOBJ
*) GDIOBJ_LockObj(dc
->w
.hBrush
, GO_BRUSH_MAGIC
);
223 if (BrushObj
->logbrush
.lbStyle
!= BS_NULL
)
227 DestRect
.left
= XLeft
+ dc
->w
.DCOrgX
;
228 DestRect
.right
= XLeft
+ Width
+ dc
->w
.DCOrgX
;
232 DestRect
.left
= XLeft
+ Width
+ 1 + dc
->w
.DCOrgX
;
233 DestRect
.right
= XLeft
+ dc
->w
.DCOrgX
+ 1;
237 DestRect
.top
= YLeft
+ dc
->w
.DCOrgY
;
238 DestRect
.bottom
= YLeft
+ Height
+ dc
->w
.DCOrgY
;
242 DestRect
.top
= YLeft
+ Height
+ dc
->w
.DCOrgY
+ 1;
243 DestRect
.bottom
= YLeft
+ dc
->w
.DCOrgY
+ 1;
245 ret
= IntEngBitBlt(SurfObj
,
257 GDIOBJ_UnlockObj( dc
->w
.hBrush
, GO_BRUSH_MAGIC
);
258 DC_ReleasePtr( hDC
);
262 BOOL STDCALL
W32kSetBrushOrgEx(HDC hDC
,