server: Removed no longer needed user_arg from irp_call struct.
[wine.git] / dlls / uxtheme / buffer.c
blobce1fc9f6026d4b5572b5d8be6c7fb655f93a1232
1 /*
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
22 #include "config.h"
24 #include <stdlib.h>
25 #include <stdarg.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winuser.h"
30 #include "wingdi.h"
31 #include "vfwmsgs.h"
32 #include "uxtheme.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(uxtheme);
38 struct paintbuffer
40 HDC targetdc;
41 HDC memorydc;
42 RECT rect;
43 void *bits;
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)
54 if (!handle)
55 return NULL;
56 return handle;
59 /***********************************************************************
60 * BufferedPaintInit (UXTHEME.@)
62 HRESULT WINAPI BufferedPaintInit(VOID)
64 FIXME("Stub ()\n");
65 return S_OK;
68 /***********************************************************************
69 * BufferedPaintUnInit (UXTHEME.@)
71 HRESULT WINAPI BufferedPaintUnInit(VOID)
73 FIXME("Stub ()\n");
74 return S_OK;
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;
86 HBITMAP hbm;
88 TRACE("(%p %s %d %p %p)\n", targetdc, wine_dbgstr_rect(rect), format,
89 params, retdc);
91 if (retdc)
92 *retdc = NULL;
94 if (!targetdc || IsRectEmpty(rect))
95 return NULL;
97 if (params)
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);
105 switch (format)
107 case BPBF_COMPATIBLEBITMAP:
108 hbm = CreateCompatibleBitmap(buffer->memorydc, rect->right - rect->left, rect->bottom - rect->top);
109 buffer->bits = NULL;
110 break;
111 case BPBF_DIB:
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);
124 break;
125 default:
126 WARN("Unknown buffer format %d\n", format);
127 free_paintbuffer(buffer);
128 return NULL;
131 if (!hbm)
133 WARN("Failed to create buffer bitmap\n");
134 free_paintbuffer(buffer);
135 return NULL;
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);
154 if (!buffer)
155 return E_INVALIDARG;
157 if (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);
168 return S_OK;
171 /***********************************************************************
172 * BufferedPaintClear (UXTHEME.@)
174 HRESULT WINAPI BufferedPaintClear(HPAINTBUFFER hBufferedPaint, const RECT *prc)
176 FIXME("Stub (%p %p)\n", hBufferedPaint, prc);
177 return E_NOTIMPL;
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);
186 return E_NOTIMPL;
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);
198 if (!bits || !width)
199 return E_POINTER;
201 if (!buffer || !buffer->bits)
202 return E_FAIL;
204 *bits = buffer->bits;
205 *width = buffer->rect.right - buffer->rect.left;
207 return S_OK;
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);
243 if (!rect)
244 return E_POINTER;
246 if (!buffer)
247 return E_FAIL;
249 *rect = buffer->rect;
250 return S_OK;
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,
259 HDC *phdcTo)
261 FIXME("Stub (%p %p %p %u %p %p %p %p)\n", hwnd, hdcTarget, rcTarget, dwFormat,
262 pPaintParams, pAnimationParams, phdcFrom, phdcTo);
264 return NULL;
267 /***********************************************************************
268 * BufferedPaintRenderAnimation (UXTHEME.@)
270 BOOL WINAPI BufferedPaintRenderAnimation(HWND hwnd, HDC hdcTarget)
272 FIXME("Stub (%p %p)\n", hwnd, hdcTarget);
274 return FALSE;
277 /***********************************************************************
278 * BufferedPaintStopAllAnimations (UXTHEME.@)
280 HRESULT WINAPI BufferedPaintStopAllAnimations(HWND hwnd)
282 FIXME("Stub (%p)\n", hwnd);
284 return E_NOTIMPL;
287 /***********************************************************************
288 * EndBufferedAnimation (UXTHEME.@)
290 HRESULT WINAPI EndBufferedAnimation(HANIMATIONBUFFER hbpAnimation, BOOL fUpdateTarget)
292 FIXME("Stub (%p %u)\n", hbpAnimation, fUpdateTarget);
294 return E_NOTIMPL;