ReactOS 0.4.16-dev-1453-g06343fa
buffer.c File Reference
#include "uxthemep.h"
#include <wine/heap.h>
Include dependency graph for buffer.c:

Go to the source code of this file.

Classes

struct  paintbuffer
 

Functions

static void free_paintbuffer (struct paintbuffer *buffer)
 
static struct paintbufferget_buffer_obj (HPAINTBUFFER handle)
 
HRESULT WINAPI BufferedPaintInit (VOID)
 
HRESULT WINAPI BufferedPaintUnInit (VOID)
 
HPAINTBUFFER WINAPI BeginBufferedPaint (HDC targetdc, const RECT *rect, BP_BUFFERFORMAT format, BP_PAINTPARAMS *params, HDC *retdc)
 
HRESULT WINAPI EndBufferedPaint (HPAINTBUFFER bufferhandle, BOOL update)
 
HRESULT WINAPI BufferedPaintClear (HPAINTBUFFER hBufferedPaint, const RECT *prc)
 
HRESULT WINAPI BufferedPaintSetAlpha (HPAINTBUFFER hBufferedPaint, const RECT *prc, BYTE alpha)
 
HRESULT WINAPI GetBufferedPaintBits (HPAINTBUFFER bufferhandle, RGBQUAD **bits, int *width)
 
HDC WINAPI GetBufferedPaintDC (HPAINTBUFFER bufferhandle)
 
HDC WINAPI GetBufferedPaintTargetDC (HPAINTBUFFER bufferhandle)
 
HRESULT WINAPI GetBufferedPaintTargetRect (HPAINTBUFFER bufferhandle, RECT *rect)
 
HANIMATIONBUFFER WINAPI BeginBufferedAnimation (HWND hwnd, HDC hdcTarget, const RECT *rcTarget, BP_BUFFERFORMAT dwFormat, BP_PAINTPARAMS *pPaintParams, BP_ANIMATIONPARAMS *pAnimationParams, HDC *phdcFrom, HDC *phdcTo)
 
BOOL WINAPI BufferedPaintRenderAnimation (HWND hwnd, HDC hdcTarget)
 
HRESULT WINAPI BufferedPaintStopAllAnimations (HWND hwnd)
 
HRESULT WINAPI EndBufferedAnimation (HANIMATIONBUFFER hbpAnimation, BOOL fUpdateTarget)
 

Function Documentation

◆ BeginBufferedAnimation()

HANIMATIONBUFFER WINAPI BeginBufferedAnimation ( HWND  hwnd,
HDC  hdcTarget,
const RECT rcTarget,
BP_BUFFERFORMAT  dwFormat,
BP_PAINTPARAMS *  pPaintParams,
BP_ANIMATIONPARAMS *  pAnimationParams,
HDC phdcFrom,
HDC phdcTo 
)

Definition at line 249 of file buffer.c.

253{
254 FIXME("Stub (%p %p %p %u %p %p %p %p)\n", hwnd, hdcTarget, rcTarget, dwFormat,
255 pPaintParams, pAnimationParams, phdcFrom, phdcTo);
256
257 return NULL;
258}
HDC hdcTarget
Definition: PatBlt.c:13
#define FIXME(fmt,...)
Definition: precomp.h:53
#define NULL
Definition: types.h:112
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

◆ BeginBufferedPaint()

HPAINTBUFFER WINAPI BeginBufferedPaint ( HDC  targetdc,
const RECT rect,
BP_BUFFERFORMAT  format,
BP_PAINTPARAMS *  params,
HDC retdc 
)

Definition at line 66 of file buffer.c.

68{
69#if (defined(_MSC_VER))
70 char bmibuf[FIELD_OFFSET(BITMAPINFO, bmiColors) + 256 * sizeof(RGBQUAD)];
71#else
72 char bmibuf[FIELD_OFFSET(BITMAPINFO, bmiColors[256])];
73#endif
74 BITMAPINFO *bmi = (BITMAPINFO *)bmibuf;
75 struct paintbuffer *buffer;
76
77 TRACE("(%p %s %d %p %p)\n", targetdc, wine_dbgstr_rect(rect), format,
78 params, retdc);
79
80 if (retdc)
81 *retdc = NULL;
82
83 if (!targetdc || IsRectEmpty(rect))
84 return NULL;
85
86 if (params)
87 FIXME("painting parameters are ignored\n");
88
89 buffer = heap_alloc(sizeof(*buffer));
90 buffer->targetdc = targetdc;
91 buffer->rect = *rect;
93
94 switch (format)
95 {
97 buffer->bitmap = CreateCompatibleBitmap(targetdc, rect->right - rect->left, rect->bottom - rect->top);
98 buffer->bits = NULL;
99 break;
100 case BPBF_DIB:
101 case BPBF_TOPDOWNDIB:
102 case BPBF_TOPDOWNMONODIB:
103 /* create DIB section */
104 memset(bmi, 0, sizeof(bmibuf));
105 bmi->bmiHeader.biSize = sizeof(bmi->bmiHeader);
106 bmi->bmiHeader.biHeight = format == BPBF_DIB ? rect->bottom - rect->top :
107 -(rect->bottom - rect->top);
108 bmi->bmiHeader.biWidth = rect->right - rect->left;
109 bmi->bmiHeader.biBitCount = format == BPBF_TOPDOWNMONODIB ? 1 : 32;
110 bmi->bmiHeader.biPlanes = 1;
112 buffer->bitmap = CreateDIBSection(buffer->memorydc, bmi, DIB_RGB_COLORS, &buffer->bits, NULL, 0);
113 break;
114 default:
115 WARN("Unknown buffer format %d\n", format);
116 buffer->bitmap = NULL;
118 return NULL;
119 }
120
121 if (!buffer->bitmap)
122 {
123 WARN("Failed to create buffer bitmap\n");
125 return NULL;
126 }
127
128 SetWindowOrgEx(buffer->memorydc, rect->left, rect->top, NULL);
129 IntersectClipRect(buffer->memorydc, rect->left, rect->top, rect->right, rect->bottom);
130 DeleteObject(SelectObject(buffer->memorydc, buffer->bitmap));
131
132 *retdc = buffer->memorydc;
133
134 return (HPAINTBUFFER)buffer;
135}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define WARN(fmt,...)
Definition: precomp.h:61
static void free_paintbuffer(struct paintbuffer *buffer)
Definition: buffer.c:33
#define BI_RGB
Definition: precomp.h:56
ULONG RGBQUAD
Definition: precomp.h:59
pKey DeleteObject()
GLuint buffer
Definition: glext.h:5915
GLenum const GLfloat * params
Definition: glext.h:5645
static HPAINTBUFFER(WINAPI *pBeginBufferedPaint)(HDC
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
& rect
Definition: startmenu.cpp:1413
Definition: format.c:58
HDC targetdc
Definition: buffer.c:26
USHORT biBitCount
Definition: precomp.h:46
ULONG biCompression
Definition: precomp.h:47
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
#define BPBF_COMPATIBLEBITMAP
Definition: treelist.c:133
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
#define DIB_RGB_COLORS
Definition: wingdi.h:367
BOOL WINAPI SetWindowOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:532
int WINAPI IntersectClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)

Referenced by init_funcs().

◆ BufferedPaintClear()

HRESULT WINAPI BufferedPaintClear ( HPAINTBUFFER  hBufferedPaint,
const RECT prc 
)

Definition at line 167 of file buffer.c.

168{
169 FIXME("Stub (%p %p)\n", hBufferedPaint, prc);
170 return E_NOTIMPL;
171}
#define E_NOTIMPL
Definition: ddrawi.h:99
_Out_ LPRECT prc
Definition: ntgdi.h:1658

Referenced by init_funcs().

◆ BufferedPaintInit()

HRESULT WINAPI BufferedPaintInit ( VOID  )

Definition at line 48 of file buffer.c.

49{
50 FIXME("Stub ()\n");
51 return S_OK;
52}
#define S_OK
Definition: intsafe.h:52

◆ BufferedPaintRenderAnimation()

BOOL WINAPI BufferedPaintRenderAnimation ( HWND  hwnd,
HDC  hdcTarget 
)

Definition at line 263 of file buffer.c.

264{
265 FIXME("Stub (%p %p)\n", hwnd, hdcTarget);
266
267 return FALSE;
268}
#define FALSE
Definition: types.h:117

◆ BufferedPaintSetAlpha()

HRESULT WINAPI BufferedPaintSetAlpha ( HPAINTBUFFER  hBufferedPaint,
const RECT prc,
BYTE  alpha 
)

Definition at line 176 of file buffer.c.

177{
178 FIXME("Stub (%p %p %u)\n", hBufferedPaint, prc, alpha);
179 return E_NOTIMPL;
180}
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740

◆ BufferedPaintStopAllAnimations()

HRESULT WINAPI BufferedPaintStopAllAnimations ( HWND  hwnd)

Definition at line 273 of file buffer.c.

274{
275 FIXME("Stub (%p)\n", hwnd);
276
277 return E_NOTIMPL;
278}

◆ BufferedPaintUnInit()

HRESULT WINAPI BufferedPaintUnInit ( VOID  )

Definition at line 57 of file buffer.c.

58{
59 FIXME("Stub ()\n");
60 return S_OK;
61}

◆ EndBufferedAnimation()

HRESULT WINAPI EndBufferedAnimation ( HANIMATIONBUFFER  hbpAnimation,
BOOL  fUpdateTarget 
)

Definition at line 283 of file buffer.c.

284{
285 FIXME("Stub (%p %u)\n", hbpAnimation, fUpdateTarget);
286
287 return E_NOTIMPL;
288}

◆ EndBufferedPaint()

HRESULT WINAPI EndBufferedPaint ( HPAINTBUFFER  bufferhandle,
BOOL  update 
)

Definition at line 141 of file buffer.c.

142{
143 struct paintbuffer *buffer = get_buffer_obj(bufferhandle);
144
145 TRACE("(%p %d)\n", bufferhandle, update);
146
147 if (!buffer)
148 return E_INVALIDARG;
149
150 if (update)
151 {
152 if (!BitBlt(buffer->targetdc, buffer->rect.left, buffer->rect.top,
153 buffer->rect.right - buffer->rect.left, buffer->rect.bottom - buffer->rect.top,
154 buffer->memorydc, buffer->rect.left, buffer->rect.top, SRCCOPY))
155 {
156 WARN("BitBlt() failed\n");
157 }
158 }
159
161 return S_OK;
162}
#define E_INVALIDARG
Definition: ddrawi.h:101
static struct paintbuffer * get_buffer_obj(HPAINTBUFFER handle)
Definition: buffer.c:40
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
#define SRCCOPY
Definition: wingdi.h:333

Referenced by init_funcs().

◆ free_paintbuffer()

static void free_paintbuffer ( struct paintbuffer buffer)
static

Definition at line 33 of file buffer.c.

34{
35 DeleteObject(buffer->bitmap);
36 DeleteDC(buffer->memorydc);
38}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
BOOL WINAPI DeleteDC(_In_ HDC)

Referenced by BeginBufferedPaint(), and EndBufferedPaint().

◆ get_buffer_obj()

static struct paintbuffer * get_buffer_obj ( HPAINTBUFFER  handle)
static

◆ GetBufferedPaintBits()

HRESULT WINAPI GetBufferedPaintBits ( HPAINTBUFFER  bufferhandle,
RGBQUAD **  bits,
int width 
)

Definition at line 185 of file buffer.c.

186{
187 struct paintbuffer *buffer = get_buffer_obj(bufferhandle);
188
189 TRACE("(%p %p %p)\n", buffer, bits, width);
190
191 if (!bits || !width)
192 return E_POINTER;
193
194 if (!buffer || !buffer->bits)
195 return E_FAIL;
196
197 *bits = buffer->bits;
198 *width = buffer->rect.right - buffer->rect.left;
199
200 return S_OK;
201}
#define E_FAIL
Definition: ddrawi.h:102
GLint GLint GLsizei width
Definition: gl.h:1546
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
#define E_POINTER
Definition: winerror.h:2365

Referenced by init_funcs().

◆ GetBufferedPaintDC()

HDC WINAPI GetBufferedPaintDC ( HPAINTBUFFER  bufferhandle)

Definition at line 206 of file buffer.c.

207{
208 struct paintbuffer *buffer = get_buffer_obj(bufferhandle);
209
210 TRACE("(%p)\n", buffer);
211
212 return buffer ? buffer->memorydc : NULL;
213}

Referenced by init_funcs().

◆ GetBufferedPaintTargetDC()

HDC WINAPI GetBufferedPaintTargetDC ( HPAINTBUFFER  bufferhandle)

Definition at line 218 of file buffer.c.

219{
220 struct paintbuffer *buffer = get_buffer_obj(bufferhandle);
221
222 TRACE("(%p)\n", buffer);
223
224 return buffer ? buffer->targetdc : NULL;
225}

Referenced by init_funcs().

◆ GetBufferedPaintTargetRect()

HRESULT WINAPI GetBufferedPaintTargetRect ( HPAINTBUFFER  bufferhandle,
RECT rect 
)

Definition at line 230 of file buffer.c.

231{
232 struct paintbuffer *buffer = get_buffer_obj(bufferhandle);
233
234 TRACE("(%p %p)\n", buffer, rect);
235
236 if (!rect)
237 return E_POINTER;
238
239 if (!buffer)
240 return E_FAIL;
241
242 *rect = buffer->rect;
243 return S_OK;
244}

Referenced by init_funcs().