2 * IDirect3DSurface8 implementation
4 * Copyright 2002 Jason Edmeades
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include "wine/debug.h"
30 #include "d3d8_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface
);
34 /* IDirect3DVolume IUnknown parts follow: */
35 HRESULT WINAPI
IDirect3DSurface8Impl_QueryInterface(LPDIRECT3DSURFACE8 iface
,REFIID riid
,LPVOID
*ppobj
)
37 ICOM_THIS(IDirect3DSurface8Impl
,iface
);
39 if (IsEqualGUID(riid
, &IID_IUnknown
)
40 || IsEqualGUID(riid
, &IID_IDirect3DSurface8
)) {
41 IDirect3DSurface8Impl_AddRef(iface
);
46 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
50 ULONG WINAPI
IDirect3DSurface8Impl_AddRef(LPDIRECT3DSURFACE8 iface
) {
51 ICOM_THIS(IDirect3DSurface8Impl
,iface
);
52 TRACE("(%p) : AddRef from %ld\n", This
, This
->ref
);
56 ULONG WINAPI
IDirect3DSurface8Impl_Release(LPDIRECT3DSURFACE8 iface
) {
57 ICOM_THIS(IDirect3DSurface8Impl
,iface
);
58 ULONG ref
= --This
->ref
;
59 TRACE("(%p) : ReleaseRef to %ld\n", This
, This
->ref
);
61 HeapFree(GetProcessHeap(), 0, This
->allocatedMemory
);
62 HeapFree(GetProcessHeap(), 0, This
);
67 /* IDirect3DSurface8: */
68 HRESULT WINAPI
IDirect3DSurface8Impl_GetDevice(LPDIRECT3DSURFACE8 iface
, IDirect3DDevice8
** ppDevice
) {
69 ICOM_THIS(IDirect3DSurface8Impl
,iface
);
70 TRACE("(%p) : returning %p\n", This
, This
->Device
);
71 *ppDevice
= (LPDIRECT3DDEVICE8
) This
->Device
;
73 * Note Calling this method will increase the internal reference count
74 * on the IDirect3DDevice8 interface.
76 IDirect3DDevice8Impl_AddRef(*ppDevice
);
79 HRESULT WINAPI
IDirect3DSurface8Impl_SetPrivateData(LPDIRECT3DSURFACE8 iface
, REFGUID refguid
, CONST
void* pData
, DWORD SizeOfData
, DWORD Flags
) {
80 ICOM_THIS(IDirect3DSurface8Impl
,iface
);
81 FIXME("(%p) : stub\n", This
);
84 HRESULT WINAPI
IDirect3DSurface8Impl_GetPrivateData(LPDIRECT3DSURFACE8 iface
, REFGUID refguid
, void* pData
, DWORD
* pSizeOfData
) {
85 ICOM_THIS(IDirect3DSurface8Impl
,iface
);
86 FIXME("(%p) : stub\n", This
);
89 HRESULT WINAPI
IDirect3DSurface8Impl_FreePrivateData(LPDIRECT3DSURFACE8 iface
, REFGUID refguid
) {
90 ICOM_THIS(IDirect3DSurface8Impl
,iface
);
91 FIXME("(%p) : stub\n", This
);
94 HRESULT WINAPI
IDirect3DSurface8Impl_GetContainer(LPDIRECT3DSURFACE8 iface
, REFIID riid
, void** ppContainer
) {
95 ICOM_THIS(IDirect3DSurface8Impl
,iface
);
97 res
= IUnknown_QueryInterface(This
->Container
, riid
, ppContainer
);
98 if (E_NOINTERFACE
== res
) {
100 * If the surface is created using CreateImageSurface, CreateRenderTarget,
101 * or CreateDepthStencilSurface, the surface is considered stand alone. In this case,
102 * GetContainer will return the Direct3D device used to create the surface.
104 res
= IUnknown_QueryInterface(This
->Container
, &IID_IDirect3DDevice8
, ppContainer
);
106 TRACE("(%p) : returning %p\n", This
, *ppContainer
);
109 HRESULT WINAPI
IDirect3DSurface8Impl_GetDesc(LPDIRECT3DSURFACE8 iface
, D3DSURFACE_DESC
*pDesc
) {
110 ICOM_THIS(IDirect3DSurface8Impl
,iface
);
112 TRACE("(%p) : copying into %p\n", This
, pDesc
);
113 memcpy(pDesc
, &This
->myDesc
, sizeof(D3DSURFACE_DESC
));
116 HRESULT WINAPI
IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface
, D3DLOCKED_RECT
* pLockedRect
, CONST RECT
* pRect
, DWORD Flags
) {
118 ICOM_THIS(IDirect3DSurface8Impl
,iface
);
120 /* fixme: should we really lock as such? */
122 if (FALSE
== This
->lockable
) {
123 ERR("trying to lock unlockable surf@%p\n", This
);
124 return D3DERR_INVALIDCALL
;
127 if (This
== This
->Device
->backBuffer
|| This
== This
->Device
->renderTarget
|| This
== This
->Device
->frontBuffer
|| This
->Device
->depthStencilBuffer
) {
128 if (This
== This
->Device
->backBuffer
) {
129 TRACE("(%p, backBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This
, pRect
, Flags
, pLockedRect
, This
->allocatedMemory
);
130 } else if (This
== This
->Device
->frontBuffer
) {
131 TRACE("(%p, frontBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This
, pRect
, Flags
, pLockedRect
, This
->allocatedMemory
);
132 } else if (This
== This
->Device
->renderTarget
) {
133 TRACE("(%p, renderTarget) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This
, pRect
, Flags
, pLockedRect
, This
->allocatedMemory
);
134 } else if (This
== This
->Device
->depthStencilBuffer
) {
135 TRACE("(%p, stencilBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This
, pRect
, Flags
, pLockedRect
, This
->allocatedMemory
);
138 TRACE("(%p) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This
, pRect
, Flags
, pLockedRect
, This
->allocatedMemory
);
141 pLockedRect
->Pitch
= This
->bytesPerPixel
* This
->myDesc
.Width
; /* Bytes / row */
144 pLockedRect
->pBits
= This
->allocatedMemory
;
145 This
->lockedRect
.left
= 0;
146 This
->lockedRect
.top
= 0;
147 This
->lockedRect
.right
= This
->myDesc
.Width
;
148 This
->lockedRect
.bottom
= This
->myDesc
.Height
;
149 TRACE("Locked Rect (%p) = l %ld, t %ld, r %ld, b %ld\n", &This
->lockedRect
, This
->lockedRect
.left
, This
->lockedRect
.top
, This
->lockedRect
.right
, This
->lockedRect
.bottom
);
151 TRACE("Lock Rect (%p) = l %ld, t %ld, r %ld, b %ld\n", pRect
, pRect
->left
, pRect
->top
, pRect
->right
, pRect
->bottom
);
152 pLockedRect
->pBits
= This
->allocatedMemory
+ (pLockedRect
->Pitch
* pRect
->top
) + (pRect
->left
* This
->bytesPerPixel
);
153 This
->lockedRect
.left
= pRect
->left
;
154 This
->lockedRect
.top
= pRect
->top
;
155 This
->lockedRect
.right
= pRect
->right
;
156 This
->lockedRect
.bottom
= pRect
->bottom
;
160 if (0 == This
->myDesc
.Usage
) { /* classic surface */
162 /* Nothing to do ;) */
164 } else if (D3DUSAGE_RENDERTARGET
& This
->myDesc
.Usage
) { /* render surfaces */
166 if (This
== This
->Device
->backBuffer
|| This
== This
->Device
->renderTarget
|| This
== This
->Device
->frontBuffer
) {
173 * for render->surface copy begin to begin of allocatedMemory
174 * unlock can be more easy
176 pLockedRect
->pBits
= This
->allocatedMemory
;
179 vcheckGLcall("glFlush");
180 glGetIntegerv(GL_READ_BUFFER
, &prev_read
);
181 vcheckGLcall("glIntegerv");
182 glGetIntegerv(GL_PACK_SWAP_BYTES
, &prev_store
);
183 vcheckGLcall("glIntegerv");
185 if (This
== This
->Device
->backBuffer
) {
186 glReadBuffer(GL_BACK
);
187 } else if (This
== This
->Device
->frontBuffer
|| This
== This
->Device
->renderTarget
) {
188 glReadBuffer(GL_FRONT
);
189 } else if (This
== This
->Device
->depthStencilBuffer
) {
190 ERR("Stencil Buffer lock unsupported for now\n");
192 vcheckGLcall("glReadBuffer");
196 for (j
= This
->lockedRect
.top
; j
< This
->lockedRect
.bottom
- This
->lockedRect
.top
; ++j
) {
197 glReadPixels(This
->lockedRect
.left
,
198 This
->lockedRect
.bottom
- j
- 1,
199 This
->lockedRect
.right
- This
->lockedRect
.left
,
201 D3DFmt2GLFmt(This
->Device
, This
->myDesc
.Format
),
202 D3DFmt2GLType(This
->Device
, This
->myDesc
.Format
),
203 (char *)pLockedRect
->pBits
+ (pLockedRect
->Pitch
* (j
-This
->lockedRect
.top
)));
204 vcheckGLcall("glReadPixels");
208 glReadBuffer(prev_read
);
209 vcheckGLcall("glReadBuffer");
212 FIXME("unsupported locking to Rendering surface surf@%p usage(%lu)\n", This
, This
->myDesc
.Usage
);
215 } else if (D3DUSAGE_DEPTHSTENCIL
& This
->myDesc
.Usage
) { /* stencil surfaces */
217 FIXME("TODO stencil depth surface locking surf@%p usage(%lu)\n", This
, This
->myDesc
.Usage
);
220 FIXME("unsupported locking to surface surf@%p usage(%lu)\n", This
, This
->myDesc
.Usage
);
223 if (Flags
& (D3DLOCK_NO_DIRTY_UPDATE
| D3DLOCK_READONLY
)) {
228 * as seen in msdn docs
230 IDirect3DSurface8Impl_AddDirtyRect(iface
, &This
->lockedRect
);
232 /** Dirtify Container if needed */
233 if (NULL
!= This
->Container
) {
234 IDirect3DBaseTexture8
* cont
= NULL
;
235 hr
= IUnknown_QueryInterface(This
->Container
, &IID_IDirect3DBaseTexture8
, (void**) &cont
);
237 if (SUCCEEDED(hr
) && NULL
!= cont
) {
238 IDirect3DBaseTexture8Impl_SetDirty(cont
, TRUE
);
239 IDirect3DBaseTexture8_Release(cont
);
245 TRACE("returning memory@%p, pitch(%d) dirtyfied(%d)\n", pLockedRect
->pBits
, pLockedRect
->Pitch
, This
->Dirty
);
250 HRESULT WINAPI
IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface
) {
251 ICOM_THIS(IDirect3DSurface8Impl
,iface
);
253 if (FALSE
== This
->locked
) {
254 ERR("trying to lock unlocked surf@%p\n", This
);
255 return D3DERR_INVALIDCALL
;
258 if (This
== This
->Device
->backBuffer
|| This
== This
->Device
->frontBuffer
|| This
->Device
->depthStencilBuffer
) {
259 if (This
== This
->Device
->backBuffer
) {
260 TRACE("(%p, backBuffer) : dirtyfied(%d)\n", This
, This
->Dirty
);
261 } else if (This
== This
->Device
->frontBuffer
) {
262 TRACE("(%p, frontBuffer) : dirtyfied(%d)\n", This
, This
->Dirty
);
263 } else if (This
== This
->Device
->depthStencilBuffer
) {
264 TRACE("(%p, stencilBuffer) : dirtyfied(%d)\n", This
, This
->Dirty
);
267 TRACE("(%p) : dirtyfied(%d)\n", This
, This
->Dirty
);
269 /*TRACE("(%p) see if behavior is correct\n", This);*/
271 if (FALSE
== This
->Dirty
) {
272 TRACE("(%p) : Not Dirtified so nothing to do, return now\n", This
);
276 if (0 == This
->myDesc
.Usage
) { /* classic surface */
279 * waiting to reload the surface via IDirect3DDevice8::UpdateTexture
281 } else if (D3DUSAGE_RENDERTARGET
& This
->myDesc
.Usage
) { /* render surfaces */
283 if (This
== This
->Device
->backBuffer
|| This
== This
->Device
->frontBuffer
) {
286 GLint prev_rasterpos
[4];
291 vcheckGLcall("glFlush");
292 glGetIntegerv(GL_DRAW_BUFFER
, &prev_draw
);
293 vcheckGLcall("glIntegerv");
294 glGetIntegerv(GL_PACK_SWAP_BYTES
, &prev_store
);
295 vcheckGLcall("glIntegerv");
296 glGetIntegerv(GL_CURRENT_RASTER_POSITION
, &prev_rasterpos
[0]);
297 vcheckGLcall("glIntegerv");
299 if (This
== This
->Device
->backBuffer
) {
300 glDrawBuffer(GL_BACK
);
301 } else if (This
== This
->Device
->frontBuffer
) {
302 glDrawBuffer(GL_FRONT
);
304 vcheckGLcall("glDrawBuffer");
306 glRasterPos2i(This
->lockedRect
.left
, This
->lockedRect
.top
);
307 vcheckGLcall("glRasterPos2f");
308 switch (This
->myDesc
.Format
) {
311 glDrawPixels(This
->lockedRect
.right
- This
->lockedRect
.left
, This
->lockedRect
.bottom
- This
->lockedRect
.top
,
312 GL_RGB
, GL_UNSIGNED_SHORT_5_6_5
, This
->allocatedMemory
);
313 vcheckGLcall("glDrawPixels");
318 glDrawPixels(This
->lockedRect
.right
- This
->lockedRect
.left
, This
->lockedRect
.bottom
- This
->lockedRect
.top
,
319 GL_RGB
, GL_UNSIGNED_BYTE
, This
->allocatedMemory
);
320 vcheckGLcall("glDrawPixels");
323 case D3DFMT_A8R8G8B8
:
325 glPixelStorei(GL_PACK_SWAP_BYTES
, TRUE
);
326 vcheckGLcall("glPixelStorei");
327 glDrawPixels(This
->lockedRect
.right
- This
->lockedRect
.left
, This
->lockedRect
.bottom
- This
->lockedRect
.top
,
328 GL_BGRA
, GL_UNSIGNED_BYTE
, This
->allocatedMemory
);
329 vcheckGLcall("glDrawPixels");
330 glPixelStorei(GL_PACK_SWAP_BYTES
, prev_store
);
331 vcheckGLcall("glPixelStorei");
335 FIXME("Unsupported Format %u in locking func\n", This
->myDesc
.Format
);
338 glDrawBuffer(prev_draw
);
339 vcheckGLcall("glDrawBuffer");
340 glRasterPos3iv(&prev_rasterpos
[0]);
341 vcheckGLcall("glRasterPos3iv");
344 /** restore clean dirty state */
345 IDirect3DSurface8Impl_CleanDirtyRect(iface
);
348 FIXME("unsupported unlocking to Rendering surface surf@%p usage(%lu)\n", This
, This
->myDesc
.Usage
);
351 } else if (D3DUSAGE_DEPTHSTENCIL
& This
->myDesc
.Usage
) { /* stencil surfaces */
353 if (This
== This
->Device
->depthStencilBuffer
) {
354 FIXME("TODO stencil depth surface unlocking surf@%p usage(%lu)\n", This
, This
->myDesc
.Usage
);
356 FIXME("unsupported unlocking to StencilDepth surface surf@%p usage(%lu)\n", This
, This
->myDesc
.Usage
);
360 FIXME("unsupported unlocking to surface surf@%p usage(%lu)\n", This
, This
->myDesc
.Usage
);
364 This
->locked
= FALSE
;
365 memset(&This
->lockedRect
, 0, sizeof(RECT
));
369 ICOM_VTABLE(IDirect3DSurface8
) Direct3DSurface8_Vtbl
=
371 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
372 IDirect3DSurface8Impl_QueryInterface
,
373 IDirect3DSurface8Impl_AddRef
,
374 IDirect3DSurface8Impl_Release
,
375 IDirect3DSurface8Impl_GetDevice
,
376 IDirect3DSurface8Impl_SetPrivateData
,
377 IDirect3DSurface8Impl_GetPrivateData
,
378 IDirect3DSurface8Impl_FreePrivateData
,
379 IDirect3DSurface8Impl_GetContainer
,
380 IDirect3DSurface8Impl_GetDesc
,
381 IDirect3DSurface8Impl_LockRect
,
382 IDirect3DSurface8Impl_UnlockRect
,
385 HRESULT WINAPI
IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface
, GLenum gl_target
, GLenum gl_level
) {
386 ICOM_THIS(IDirect3DSurface8Impl
,iface
);
388 if ((This
->myDesc
.Format
== D3DFMT_P8
|| This
->myDesc
.Format
== D3DFMT_A8P8
)
389 #if defined(GL_EXT_paletted_texture)
390 && !GL_SUPPORT_DEV(EXT_PALETTED_TEXTURE
, This
->Device
)
394 * wanted a paletted texture and not really support it in HW
395 * so software emulation code begin
398 PALETTEENTRY
* pal
= This
->Device
->palettes
[This
->Device
->currentPalette
];
399 VOID
* surface
= (VOID
*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, This
->myDesc
.Width
* This
->myDesc
.Height
* sizeof(DWORD
));
400 BYTE
* dst
= (BYTE
*) surface
;
401 BYTE
* src
= (BYTE
*) This
->allocatedMemory
;
403 for (i
= 0; i
< This
->myDesc
.Width
* This
->myDesc
.Height
; i
++) {
405 *dst
++ = pal
[color
].peRed
;
406 *dst
++ = pal
[color
].peGreen
;
407 *dst
++ = pal
[color
].peBlue
;
408 if (This
->myDesc
.Format
== D3DFMT_A8P8
)
409 *dst
++ = pal
[color
].peFlags
;
414 TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
424 glTexImage2D(gl_target
,
433 checkGLcall("glTexImage2D");
434 HeapFree(GetProcessHeap(), 0, surface
);
439 if (This
->myDesc
.Format
== D3DFMT_DXT1
||
440 This
->myDesc
.Format
== D3DFMT_DXT3
||
441 This
->myDesc
.Format
== D3DFMT_DXT5
) {
442 #if defined(GL_EXT_texture_compression_s3tc)
443 if (GL_SUPPORT_DEV(EXT_TEXTURE_COMPRESSION_S3TC
, This
->Device
)) {
444 TRACE("Calling glCompressedTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, sz=%d, Mem=%p\n",
447 D3DFmt2GLIntFmt(This
->Device
, This
->myDesc
.Format
),
452 This
->allocatedMemory
);
453 glCompressedTexImage2DARB(gl_target
,
455 D3DFmt2GLIntFmt(This
->Device
, This
->myDesc
.Format
),
460 This
->allocatedMemory
);
461 checkGLcall("glCommpressedTexTexImage2D");
465 TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
468 D3DFmt2GLIntFmt(This
->Device
, This
->myDesc
.Format
),
472 D3DFmt2GLFmt(This
->Device
, This
->myDesc
.Format
),
473 D3DFmt2GLType(This
->Device
, This
->myDesc
.Format
),
474 This
->allocatedMemory
);
475 glTexImage2D(gl_target
,
477 D3DFmt2GLIntFmt(This
->Device
, This
->myDesc
.Format
),
481 D3DFmt2GLFmt(This
->Device
, This
->myDesc
.Format
),
482 D3DFmt2GLType(This
->Device
, This
->myDesc
.Format
),
483 This
->allocatedMemory
);
484 checkGLcall("glTexImage2D");
488 static unsigned int gen
= 0;
491 if ((gen
% 10) == 0) {
492 snprintf(buffer
, sizeof(buffer
), "/tmp/surface%u_level%u_%u.ppm", gl_target
, gl_level
, gen
);
493 IDirect3DSurface8Impl_SaveSnapshot((LPDIRECT3DSURFACE8
) This
, buffer
);
503 HRESULT WINAPI
IDirect3DSurface8Impl_SaveSnapshot(LPDIRECT3DSURFACE8 iface
, const char* filename
) {
506 ICOM_THIS(IDirect3DSurface8Impl
,iface
);
508 f
= fopen(filename
, "w+");
510 ERR("opening of %s failed with: %s\n", filename
, strerror(errno
));
511 return D3DERR_INVALIDCALL
;
514 TRACE("opened %s with format %s\n", filename
, debug_d3dformat(This
->myDesc
.Format
));
516 fprintf(f
, "P6\n%u %u\n255\n", This
->myDesc
.Width
, This
->myDesc
.Height
);
517 switch (This
->myDesc
.Format
) {
518 case D3DFMT_X8R8G8B8
:
519 case D3DFMT_A8R8G8B8
:
522 for (i
= 0; i
< This
->myDesc
.Width
* This
->myDesc
.Height
; i
++) {
523 color
= ((DWORD
*) This
->allocatedMemory
)[i
];
524 fputc((color
>> 16) & 0xFF, f
);
525 fputc((color
>> 8) & 0xFF, f
);
526 fputc((color
>> 0) & 0xFF, f
);
533 for (i
= 0; i
< This
->myDesc
.Width
* This
->myDesc
.Height
; i
++) {
534 color
= ((BYTE
*) This
->allocatedMemory
) + (3 * i
);
535 fputc((color
[0]) & 0xFF, f
);
536 fputc((color
[1]) & 0xFF, f
);
537 fputc((color
[2]) & 0xFF, f
);
541 case D3DFMT_A1R5G5B5
:
544 for (i
= 0; i
< This
->myDesc
.Width
* This
->myDesc
.Height
; i
++) {
545 color
= ((WORD
*) This
->allocatedMemory
)[i
];
546 fputc(((color
>> 10) & 0x1F) * 255 / 31, f
);
547 fputc(((color
>> 5) & 0x1F) * 255 / 31, f
);
548 fputc(((color
>> 0) & 0x1F) * 255 / 31, f
);
552 case D3DFMT_A4R4G4B4
:
555 for (i
= 0; i
< This
->myDesc
.Width
* This
->myDesc
.Height
; i
++) {
556 color
= ((WORD
*) This
->allocatedMemory
)[i
];
557 fputc(((color
>> 8) & 0x0F) * 255 / 15, f
);
558 fputc(((color
>> 4) & 0x0F) * 255 / 15, f
);
559 fputc(((color
>> 0) & 0x0F) * 255 / 15, f
);
567 for (i
= 0; i
< This
->myDesc
.Width
* This
->myDesc
.Height
; i
++) {
568 color
= ((WORD
*) This
->allocatedMemory
)[i
];
569 fputc(((color
>> 11) & 0x1F) * 255 / 31, f
);
570 fputc(((color
>> 5) & 0x3F) * 255 / 63, f
);
571 fputc(((color
>> 0) & 0x1F) * 255 / 31, f
);
576 FIXME("Unimplemented dump mode format(%u,%s)\n", This
->myDesc
.Format
, debug_d3dformat(This
->myDesc
.Format
));
582 HRESULT WINAPI
IDirect3DSurface8Impl_CleanDirtyRect(LPDIRECT3DSURFACE8 iface
) {
583 ICOM_THIS(IDirect3DSurface8Impl
,iface
);
585 This
->dirtyRect
.left
= This
->myDesc
.Width
;
586 This
->dirtyRect
.top
= This
->myDesc
.Height
;
587 This
->dirtyRect
.right
= 0;
588 This
->dirtyRect
.bottom
= 0;
594 * very stupid way to handle multiple dirty rects but it works :)
596 extern HRESULT WINAPI
IDirect3DSurface8Impl_AddDirtyRect(LPDIRECT3DSURFACE8 iface
, CONST RECT
* pDirtyRect
) {
597 ICOM_THIS(IDirect3DSurface8Impl
,iface
);
599 This
->dirtyRect
.left
= min(This
->dirtyRect
.left
, pDirtyRect
->left
);
600 This
->dirtyRect
.top
= min(This
->dirtyRect
.top
, pDirtyRect
->top
);
601 This
->dirtyRect
.right
= max(This
->dirtyRect
.right
, pDirtyRect
->right
);
602 This
->dirtyRect
.bottom
= max(This
->dirtyRect
.bottom
, pDirtyRect
->bottom
);