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
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(uxtheme
);
46 static void free_paintbuffer(struct paintbuffer
*buffer
)
48 DeleteDC(buffer
->memorydc
);
49 HeapFree(GetProcessHeap(), 0, buffer
);
52 static struct paintbuffer
*get_buffer_obj(HPAINTBUFFER handle
)
59 /***********************************************************************
60 * BufferedPaintInit (UXTHEME.@)
62 HRESULT WINAPI
BufferedPaintInit(VOID
)
68 /***********************************************************************
69 * BufferedPaintUnInit (UXTHEME.@)
71 HRESULT WINAPI
BufferedPaintUnInit(VOID
)
77 /***********************************************************************
78 * BeginBufferedPaint (UXTHEME.@)
80 HPAINTBUFFER WINAPI
BeginBufferedPaint(HDC targetdc
, const RECT
*rect
,
81 BP_BUFFERFORMAT format
, BP_PAINTPARAMS
*params
, HDC
*retdc
)
83 char bmibuf
[FIELD_OFFSET(BITMAPINFO
, bmiColors
[256])];
84 BITMAPINFO
*bmi
= (BITMAPINFO
*)bmibuf
;
85 struct paintbuffer
*buffer
;
88 TRACE("(%p %s %d %p %p)\n", targetdc
, wine_dbgstr_rect(rect
), format
,
94 if (!targetdc
|| IsRectEmpty(rect
))
98 FIXME("painting parameters are ignored\n");
100 buffer
= HeapAlloc(GetProcessHeap(), 0, sizeof(*buffer
));
101 buffer
->targetdc
= targetdc
;
102 buffer
->rect
= *rect
;
103 buffer
->memorydc
= CreateCompatibleDC(targetdc
);
107 case BPBF_COMPATIBLEBITMAP
:
108 hbm
= CreateCompatibleBitmap(buffer
->memorydc
, rect
->right
- rect
->left
, rect
->bottom
- rect
->top
);
112 case BPBF_TOPDOWNDIB
:
113 case BPBF_TOPDOWNMONODIB
:
114 /* create DIB section */
115 memset(bmi
, 0, sizeof(bmibuf
));
116 bmi
->bmiHeader
.biSize
= sizeof(bmi
->bmiHeader
);
117 bmi
->bmiHeader
.biHeight
= format
== BPBF_DIB
? rect
->bottom
- rect
->top
:
118 -(rect
->bottom
- rect
->top
);
119 bmi
->bmiHeader
.biWidth
= rect
->right
- rect
->left
;
120 bmi
->bmiHeader
.biBitCount
= format
== BPBF_TOPDOWNMONODIB
? 1 : 32;
121 bmi
->bmiHeader
.biPlanes
= 1;
122 bmi
->bmiHeader
.biCompression
= BI_RGB
;
123 hbm
= CreateDIBSection(buffer
->memorydc
, bmi
, DIB_RGB_COLORS
, &buffer
->bits
, NULL
, 0);
126 WARN("Unknown buffer format %d\n", format
);
127 free_paintbuffer(buffer
);
133 WARN("Failed to create buffer bitmap\n");
134 free_paintbuffer(buffer
);
138 DeleteObject(SelectObject(buffer
->memorydc
, hbm
));
140 *retdc
= buffer
->memorydc
;
142 return (HPAINTBUFFER
)buffer
;
145 /***********************************************************************
146 * EndBufferedPaint (UXTHEME.@)
148 HRESULT WINAPI
EndBufferedPaint(HPAINTBUFFER bufferhandle
, BOOL update
)
150 struct paintbuffer
*buffer
= get_buffer_obj(bufferhandle
);
152 TRACE("(%p %d)\n", bufferhandle
, update
);
159 if (!BitBlt(buffer
->targetdc
, buffer
->rect
.left
, buffer
->rect
.top
,
160 buffer
->rect
.right
- buffer
->rect
.left
, buffer
->rect
.bottom
- buffer
->rect
.top
,
161 buffer
->memorydc
, 0, 0, SRCCOPY
))
163 WARN("BitBlt() failed\n");
167 free_paintbuffer(buffer
);
171 /***********************************************************************
172 * BufferedPaintClear (UXTHEME.@)
174 HRESULT WINAPI
BufferedPaintClear(HPAINTBUFFER hBufferedPaint
, const RECT
*prc
)
176 FIXME("Stub (%p %p)\n", hBufferedPaint
, prc
);
180 /***********************************************************************
181 * BufferedPaintSetAlpha (UXTHEME.@)
183 HRESULT WINAPI
BufferedPaintSetAlpha(HPAINTBUFFER hBufferedPaint
, const RECT
*prc
, BYTE alpha
)
185 FIXME("Stub (%p %p %u)\n", hBufferedPaint
, prc
, alpha
);
189 /***********************************************************************
190 * GetBufferedPaintBits (UXTHEME.@)
192 HRESULT WINAPI
GetBufferedPaintBits(HPAINTBUFFER bufferhandle
, RGBQUAD
**bits
, int *width
)
194 struct paintbuffer
*buffer
= get_buffer_obj(bufferhandle
);
196 TRACE("(%p %p %p)\n", buffer
, bits
, width
);
201 if (!buffer
|| !buffer
->bits
)
204 *bits
= buffer
->bits
;
205 *width
= buffer
->rect
.right
- buffer
->rect
.left
;
210 /***********************************************************************
211 * GetBufferedPaintDC (UXTHEME.@)
213 HDC WINAPI
GetBufferedPaintDC(HPAINTBUFFER bufferhandle
)
215 struct paintbuffer
*buffer
= get_buffer_obj(bufferhandle
);
217 TRACE("(%p)\n", buffer
);
219 return buffer
? buffer
->memorydc
: NULL
;
222 /***********************************************************************
223 * GetBufferedPaintTargetDC (UXTHEME.@)
225 HDC WINAPI
GetBufferedPaintTargetDC(HPAINTBUFFER bufferhandle
)
227 struct paintbuffer
*buffer
= get_buffer_obj(bufferhandle
);
229 TRACE("(%p)\n", buffer
);
231 return buffer
? buffer
->targetdc
: NULL
;
234 /***********************************************************************
235 * GetBufferedPaintTargetRect (UXTHEME.@)
237 HRESULT WINAPI
GetBufferedPaintTargetRect(HPAINTBUFFER bufferhandle
, RECT
*rect
)
239 struct paintbuffer
*buffer
= get_buffer_obj(bufferhandle
);
241 TRACE("(%p %p)\n", buffer
, rect
);
249 *rect
= buffer
->rect
;
253 /***********************************************************************
254 * BeginBufferedAnimation (UXTHEME.@)
256 HANIMATIONBUFFER WINAPI
BeginBufferedAnimation(HWND hwnd
, HDC hdcTarget
, const RECT
*rcTarget
,
257 BP_BUFFERFORMAT dwFormat
, BP_PAINTPARAMS
*pPaintParams
,
258 BP_ANIMATIONPARAMS
*pAnimationParams
, HDC
*phdcFrom
,
261 FIXME("Stub (%p %p %p %u %p %p %p %p)\n", hwnd
, hdcTarget
, rcTarget
, dwFormat
,
262 pPaintParams
, pAnimationParams
, phdcFrom
, phdcTo
);
267 /***********************************************************************
268 * BufferedPaintRenderAnimation (UXTHEME.@)
270 BOOL WINAPI
BufferedPaintRenderAnimation(HWND hwnd
, HDC hdcTarget
)
272 FIXME("Stub (%p %p)\n", hwnd
, hdcTarget
);
277 /***********************************************************************
278 * BufferedPaintStopAllAnimations (UXTHEME.@)
280 HRESULT WINAPI
BufferedPaintStopAllAnimations(HWND hwnd
)
282 FIXME("Stub (%p)\n", hwnd
);
287 /***********************************************************************
288 * EndBufferedAnimation (UXTHEME.@)
290 HRESULT WINAPI
EndBufferedAnimation(HANIMATIONBUFFER hbpAnimation
, BOOL fUpdateTarget
)
292 FIXME("Stub (%p %u)\n", hbpAnimation
, fUpdateTarget
);