2 * uxtheme Double-buffered Drawing API
4 * Copyright (C) 2008 Reece H. Dunn
5 * Copyright 2017 Nikolay Sivov for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wine/debug.h"
33 #include "wine/heap.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(uxtheme
);
46 static void free_paintbuffer(struct paintbuffer
*buffer
)
48 DeleteObject(buffer
->bitmap
);
49 DeleteDC(buffer
->memorydc
);
53 static struct paintbuffer
*get_buffer_obj(HPAINTBUFFER handle
)
58 /***********************************************************************
59 * BufferedPaintInit (UXTHEME.@)
61 HRESULT WINAPI
BufferedPaintInit(VOID
)
67 /***********************************************************************
68 * BufferedPaintUnInit (UXTHEME.@)
70 HRESULT WINAPI
BufferedPaintUnInit(VOID
)
76 /***********************************************************************
77 * BeginBufferedPaint (UXTHEME.@)
79 HPAINTBUFFER WINAPI
BeginBufferedPaint(HDC targetdc
, const RECT
*rect
,
80 BP_BUFFERFORMAT format
, BP_PAINTPARAMS
*params
, HDC
*retdc
)
82 char bmibuf
[FIELD_OFFSET(BITMAPINFO
, bmiColors
[256])];
83 BITMAPINFO
*bmi
= (BITMAPINFO
*)bmibuf
;
84 struct paintbuffer
*buffer
;
86 TRACE("(%p %s %d %p %p)\n", targetdc
, wine_dbgstr_rect(rect
), format
,
92 if (!targetdc
|| IsRectEmpty(rect
))
96 FIXME("painting parameters are ignored\n");
98 buffer
= heap_alloc(sizeof(*buffer
));
99 buffer
->targetdc
= targetdc
;
100 buffer
->rect
= *rect
;
101 buffer
->memorydc
= CreateCompatibleDC(targetdc
);
105 case BPBF_COMPATIBLEBITMAP
:
106 buffer
->bitmap
= CreateCompatibleBitmap(targetdc
, rect
->right
- rect
->left
, rect
->bottom
- rect
->top
);
110 case BPBF_TOPDOWNDIB
:
111 case BPBF_TOPDOWNMONODIB
:
112 /* create DIB section */
113 memset(bmi
, 0, sizeof(bmibuf
));
114 bmi
->bmiHeader
.biSize
= sizeof(bmi
->bmiHeader
);
115 bmi
->bmiHeader
.biHeight
= format
== BPBF_DIB
? rect
->bottom
- rect
->top
:
116 -(rect
->bottom
- rect
->top
);
117 bmi
->bmiHeader
.biWidth
= rect
->right
- rect
->left
;
118 bmi
->bmiHeader
.biBitCount
= format
== BPBF_TOPDOWNMONODIB
? 1 : 32;
119 bmi
->bmiHeader
.biPlanes
= 1;
120 bmi
->bmiHeader
.biCompression
= BI_RGB
;
121 buffer
->bitmap
= CreateDIBSection(buffer
->memorydc
, bmi
, DIB_RGB_COLORS
, &buffer
->bits
, NULL
, 0);
124 WARN("Unknown buffer format %d\n", format
);
125 buffer
->bitmap
= NULL
;
126 free_paintbuffer(buffer
);
132 WARN("Failed to create buffer bitmap\n");
133 free_paintbuffer(buffer
);
137 SetWindowOrgEx(buffer
->memorydc
, rect
->left
, rect
->top
, NULL
);
138 IntersectClipRect(buffer
->memorydc
, rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
139 DeleteObject(SelectObject(buffer
->memorydc
, buffer
->bitmap
));
141 *retdc
= buffer
->memorydc
;
143 return (HPAINTBUFFER
)buffer
;
146 /***********************************************************************
147 * EndBufferedPaint (UXTHEME.@)
149 HRESULT WINAPI
EndBufferedPaint(HPAINTBUFFER bufferhandle
, BOOL update
)
151 struct paintbuffer
*buffer
= get_buffer_obj(bufferhandle
);
153 TRACE("(%p %d)\n", bufferhandle
, update
);
160 if (!BitBlt(buffer
->targetdc
, buffer
->rect
.left
, buffer
->rect
.top
,
161 buffer
->rect
.right
- buffer
->rect
.left
, buffer
->rect
.bottom
- buffer
->rect
.top
,
162 buffer
->memorydc
, buffer
->rect
.left
, buffer
->rect
.top
, SRCCOPY
))
164 WARN("BitBlt() failed\n");
168 free_paintbuffer(buffer
);
172 /***********************************************************************
173 * BufferedPaintClear (UXTHEME.@)
175 HRESULT WINAPI
BufferedPaintClear(HPAINTBUFFER hBufferedPaint
, const RECT
*prc
)
177 FIXME("Stub (%p %p)\n", hBufferedPaint
, prc
);
181 /***********************************************************************
182 * BufferedPaintSetAlpha (UXTHEME.@)
184 HRESULT WINAPI
BufferedPaintSetAlpha(HPAINTBUFFER hBufferedPaint
, const RECT
*prc
, BYTE alpha
)
186 FIXME("Stub (%p %p %u)\n", hBufferedPaint
, prc
, alpha
);
190 /***********************************************************************
191 * GetBufferedPaintBits (UXTHEME.@)
193 HRESULT WINAPI
GetBufferedPaintBits(HPAINTBUFFER bufferhandle
, RGBQUAD
**bits
, int *width
)
195 struct paintbuffer
*buffer
= get_buffer_obj(bufferhandle
);
197 TRACE("(%p %p %p)\n", buffer
, bits
, width
);
202 if (!buffer
|| !buffer
->bits
)
205 *bits
= buffer
->bits
;
206 *width
= buffer
->rect
.right
- buffer
->rect
.left
;
211 /***********************************************************************
212 * GetBufferedPaintDC (UXTHEME.@)
214 HDC WINAPI
GetBufferedPaintDC(HPAINTBUFFER bufferhandle
)
216 struct paintbuffer
*buffer
= get_buffer_obj(bufferhandle
);
218 TRACE("(%p)\n", buffer
);
220 return buffer
? buffer
->memorydc
: NULL
;
223 /***********************************************************************
224 * GetBufferedPaintTargetDC (UXTHEME.@)
226 HDC WINAPI
GetBufferedPaintTargetDC(HPAINTBUFFER bufferhandle
)
228 struct paintbuffer
*buffer
= get_buffer_obj(bufferhandle
);
230 TRACE("(%p)\n", buffer
);
232 return buffer
? buffer
->targetdc
: NULL
;
235 /***********************************************************************
236 * GetBufferedPaintTargetRect (UXTHEME.@)
238 HRESULT WINAPI
GetBufferedPaintTargetRect(HPAINTBUFFER bufferhandle
, RECT
*rect
)
240 struct paintbuffer
*buffer
= get_buffer_obj(bufferhandle
);
242 TRACE("(%p %p)\n", buffer
, rect
);
250 *rect
= buffer
->rect
;
254 /***********************************************************************
255 * BeginBufferedAnimation (UXTHEME.@)
257 HANIMATIONBUFFER WINAPI
BeginBufferedAnimation(HWND hwnd
, HDC hdcTarget
, const RECT
*rcTarget
,
258 BP_BUFFERFORMAT dwFormat
, BP_PAINTPARAMS
*pPaintParams
,
259 BP_ANIMATIONPARAMS
*pAnimationParams
, HDC
*phdcFrom
,
262 FIXME("Stub (%p %p %p %u %p %p %p %p)\n", hwnd
, hdcTarget
, rcTarget
, dwFormat
,
263 pPaintParams
, pAnimationParams
, phdcFrom
, phdcTo
);
268 /***********************************************************************
269 * BufferedPaintRenderAnimation (UXTHEME.@)
271 BOOL WINAPI
BufferedPaintRenderAnimation(HWND hwnd
, HDC hdcTarget
)
273 FIXME("Stub (%p %p)\n", hwnd
, hdcTarget
);
278 /***********************************************************************
279 * BufferedPaintStopAllAnimations (UXTHEME.@)
281 HRESULT WINAPI
BufferedPaintStopAllAnimations(HWND hwnd
)
283 FIXME("Stub (%p)\n", hwnd
);
288 /***********************************************************************
289 * EndBufferedAnimation (UXTHEME.@)
291 HRESULT WINAPI
EndBufferedAnimation(HANIMATIONBUFFER hbpAnimation
, BOOL fUpdateTarget
)
293 FIXME("Stub (%p %u)\n", hbpAnimation
, fUpdateTarget
);