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"
35 #include "wine/heap.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(uxtheme
);
48 static void free_paintbuffer(struct paintbuffer
*buffer
)
50 DeleteObject(buffer
->bitmap
);
51 DeleteDC(buffer
->memorydc
);
55 static struct paintbuffer
*get_buffer_obj(HPAINTBUFFER handle
)
62 /***********************************************************************
63 * BufferedPaintInit (UXTHEME.@)
65 HRESULT WINAPI
BufferedPaintInit(VOID
)
71 /***********************************************************************
72 * BufferedPaintUnInit (UXTHEME.@)
74 HRESULT WINAPI
BufferedPaintUnInit(VOID
)
80 /***********************************************************************
81 * BeginBufferedPaint (UXTHEME.@)
83 HPAINTBUFFER WINAPI
BeginBufferedPaint(HDC targetdc
, const RECT
*rect
,
84 BP_BUFFERFORMAT format
, BP_PAINTPARAMS
*params
, HDC
*retdc
)
86 char bmibuf
[FIELD_OFFSET(BITMAPINFO
, bmiColors
[256])];
87 BITMAPINFO
*bmi
= (BITMAPINFO
*)bmibuf
;
88 struct paintbuffer
*buffer
;
90 TRACE("(%p %s %d %p %p)\n", targetdc
, wine_dbgstr_rect(rect
), format
,
96 if (!targetdc
|| IsRectEmpty(rect
))
100 FIXME("painting parameters are ignored\n");
102 buffer
= heap_alloc(sizeof(*buffer
));
103 buffer
->targetdc
= targetdc
;
104 buffer
->rect
= *rect
;
105 buffer
->memorydc
= CreateCompatibleDC(targetdc
);
109 case BPBF_COMPATIBLEBITMAP
:
110 buffer
->bitmap
= CreateCompatibleBitmap(targetdc
, rect
->right
- rect
->left
, rect
->bottom
- rect
->top
);
114 case BPBF_TOPDOWNDIB
:
115 case BPBF_TOPDOWNMONODIB
:
116 /* create DIB section */
117 memset(bmi
, 0, sizeof(bmibuf
));
118 bmi
->bmiHeader
.biSize
= sizeof(bmi
->bmiHeader
);
119 bmi
->bmiHeader
.biHeight
= format
== BPBF_DIB
? rect
->bottom
- rect
->top
:
120 -(rect
->bottom
- rect
->top
);
121 bmi
->bmiHeader
.biWidth
= rect
->right
- rect
->left
;
122 bmi
->bmiHeader
.biBitCount
= format
== BPBF_TOPDOWNMONODIB
? 1 : 32;
123 bmi
->bmiHeader
.biPlanes
= 1;
124 bmi
->bmiHeader
.biCompression
= BI_RGB
;
125 buffer
->bitmap
= CreateDIBSection(buffer
->memorydc
, bmi
, DIB_RGB_COLORS
, &buffer
->bits
, NULL
, 0);
128 WARN("Unknown buffer format %d\n", format
);
129 buffer
->bitmap
= NULL
;
130 free_paintbuffer(buffer
);
136 WARN("Failed to create buffer bitmap\n");
137 free_paintbuffer(buffer
);
141 SetWindowOrgEx(buffer
->memorydc
, rect
->left
, rect
->top
, NULL
);
142 IntersectClipRect(buffer
->memorydc
, rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
143 DeleteObject(SelectObject(buffer
->memorydc
, buffer
->bitmap
));
145 *retdc
= buffer
->memorydc
;
147 return (HPAINTBUFFER
)buffer
;
150 /***********************************************************************
151 * EndBufferedPaint (UXTHEME.@)
153 HRESULT WINAPI
EndBufferedPaint(HPAINTBUFFER bufferhandle
, BOOL update
)
155 struct paintbuffer
*buffer
= get_buffer_obj(bufferhandle
);
157 TRACE("(%p %d)\n", bufferhandle
, update
);
164 if (!BitBlt(buffer
->targetdc
, buffer
->rect
.left
, buffer
->rect
.top
,
165 buffer
->rect
.right
- buffer
->rect
.left
, buffer
->rect
.bottom
- buffer
->rect
.top
,
166 buffer
->memorydc
, buffer
->rect
.left
, buffer
->rect
.top
, SRCCOPY
))
168 WARN("BitBlt() failed\n");
172 free_paintbuffer(buffer
);
176 /***********************************************************************
177 * BufferedPaintClear (UXTHEME.@)
179 HRESULT WINAPI
BufferedPaintClear(HPAINTBUFFER hBufferedPaint
, const RECT
*prc
)
181 FIXME("Stub (%p %p)\n", hBufferedPaint
, prc
);
185 /***********************************************************************
186 * BufferedPaintSetAlpha (UXTHEME.@)
188 HRESULT WINAPI
BufferedPaintSetAlpha(HPAINTBUFFER hBufferedPaint
, const RECT
*prc
, BYTE alpha
)
190 FIXME("Stub (%p %p %u)\n", hBufferedPaint
, prc
, alpha
);
194 /***********************************************************************
195 * GetBufferedPaintBits (UXTHEME.@)
197 HRESULT WINAPI
GetBufferedPaintBits(HPAINTBUFFER bufferhandle
, RGBQUAD
**bits
, int *width
)
199 struct paintbuffer
*buffer
= get_buffer_obj(bufferhandle
);
201 TRACE("(%p %p %p)\n", buffer
, bits
, width
);
206 if (!buffer
|| !buffer
->bits
)
209 *bits
= buffer
->bits
;
210 *width
= buffer
->rect
.right
- buffer
->rect
.left
;
215 /***********************************************************************
216 * GetBufferedPaintDC (UXTHEME.@)
218 HDC WINAPI
GetBufferedPaintDC(HPAINTBUFFER bufferhandle
)
220 struct paintbuffer
*buffer
= get_buffer_obj(bufferhandle
);
222 TRACE("(%p)\n", buffer
);
224 return buffer
? buffer
->memorydc
: NULL
;
227 /***********************************************************************
228 * GetBufferedPaintTargetDC (UXTHEME.@)
230 HDC WINAPI
GetBufferedPaintTargetDC(HPAINTBUFFER bufferhandle
)
232 struct paintbuffer
*buffer
= get_buffer_obj(bufferhandle
);
234 TRACE("(%p)\n", buffer
);
236 return buffer
? buffer
->targetdc
: NULL
;
239 /***********************************************************************
240 * GetBufferedPaintTargetRect (UXTHEME.@)
242 HRESULT WINAPI
GetBufferedPaintTargetRect(HPAINTBUFFER bufferhandle
, RECT
*rect
)
244 struct paintbuffer
*buffer
= get_buffer_obj(bufferhandle
);
246 TRACE("(%p %p)\n", buffer
, rect
);
254 *rect
= buffer
->rect
;
258 /***********************************************************************
259 * BeginBufferedAnimation (UXTHEME.@)
261 HANIMATIONBUFFER WINAPI
BeginBufferedAnimation(HWND hwnd
, HDC hdcTarget
, const RECT
*rcTarget
,
262 BP_BUFFERFORMAT dwFormat
, BP_PAINTPARAMS
*pPaintParams
,
263 BP_ANIMATIONPARAMS
*pAnimationParams
, HDC
*phdcFrom
,
266 FIXME("Stub (%p %p %p %u %p %p %p %p)\n", hwnd
, hdcTarget
, rcTarget
, dwFormat
,
267 pPaintParams
, pAnimationParams
, phdcFrom
, phdcTo
);
272 /***********************************************************************
273 * BufferedPaintRenderAnimation (UXTHEME.@)
275 BOOL WINAPI
BufferedPaintRenderAnimation(HWND hwnd
, HDC hdcTarget
)
277 FIXME("Stub (%p %p)\n", hwnd
, hdcTarget
);
282 /***********************************************************************
283 * BufferedPaintStopAllAnimations (UXTHEME.@)
285 HRESULT WINAPI
BufferedPaintStopAllAnimations(HWND hwnd
)
287 FIXME("Stub (%p)\n", hwnd
);
292 /***********************************************************************
293 * EndBufferedAnimation (UXTHEME.@)
295 HRESULT WINAPI
EndBufferedAnimation(HANIMATIONBUFFER hbpAnimation
, BOOL fUpdateTarget
)
297 FIXME("Stub (%p %u)\n", hbpAnimation
, fUpdateTarget
);