D3D8: Implement CopyRects with BltFast
Stefan Dösinger
stefan at codeweavers.com
Fri Oct 13 05:14:59 CDT 2006
The functionality of IDirect3DDevice8::CopyRects is a subset of
IDirectDrawSurface::BltFast, which is implemented in wined3d. This patch
removes the CopyRects implementation from wined3d and implements CopyRects in
d3d8 directly with the help of BltFast. This removes doubled functionality
from wined3d
-------------- next part --------------
From a48d51a304f1ad099b075595e859c6aeb4a573eb Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Fri, 13 Oct 2006 12:12:44 +0200
Subject: [PATCH] D3D8: Implement CopyRects with BltFast
---
dlls/d3d8/device.c | 59 +++++++++++++++-
dlls/wined3d/device.c | 144 --------------------------------------
include/wine/wined3d_interface.h | 2 -
3 files changed, 55 insertions(+), 150 deletions(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 380a8ff..1532d99 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -570,12 +570,63 @@ static HRESULT WINAPI IDirect3DDevice8Im
}
static HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8 *pSourceSurface, CONST RECT *pSourceRects, UINT cRects, IDirect3DSurface8 *pDestinationSurface, CONST POINT *pDestPoints) {
- IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
+ IDirect3DSurface8Impl *Source = (IDirect3DSurface8Impl *) pSourceSurface;
+ IDirect3DSurface8Impl *Dest = (IDirect3DSurface8Impl *) pDestinationSurface;
+
+ HRESULT hr = WINED3D_OK;
+ WINED3DFORMAT srcFormat, destFormat;
+ UINT srcWidth, destWidth;
+ UINT srcHeight, destHeight;
+ UINT srcSize;
+ WINED3DSURFACE_DESC winedesc;
+
+ TRACE("(%p) pSrcSur=%p, pSourceRects=%p, cRects=%d, pDstSur=%p, pDestPtsArr=%p\n", iface,
+ pSourceSurface, pSourceRects, cRects, pDestinationSurface, pDestPoints);
+
+
+ /* Check that the source texture is in WINED3DPOOL_SYSTEMMEM and the destination texture is in WINED3DPOOL_DEFAULT */
+ memset(&winedesc, 0, sizeof(winedesc));
+
+ winedesc.Format = &srcFormat;
+ winedesc.Width = &srcWidth;
+ winedesc.Height = &srcHeight;
+ winedesc.Size = &srcSize;
+ IWineD3DSurface_GetDesc(Source->wineD3DSurface, &winedesc);
+
+ winedesc.Format = &destFormat;
+ winedesc.Width = &destWidth;
+ winedesc.Height = &destHeight;
+ winedesc.Size = NULL;
+ IWineD3DSurface_GetDesc(Dest->wineD3DSurface, &winedesc);
+
+ /* Check that the source and destination formats match */
+ if (srcFormat != destFormat && WINED3DFMT_UNKNOWN != destFormat) {
+ WARN("(%p) source %p format must match the dest %p format, returning WINED3DERR_INVALIDCALL\n", iface, pSourceSurface, pDestinationSurface);
+ return WINED3DERR_INVALIDCALL;
+ } else if (WINED3DFMT_UNKNOWN == destFormat) {
+ TRACE("(%p) : Converting destination surface from WINED3DFMT_UNKNOWN to the source format\n", iface);
+ IWineD3DSurface_SetFormat(Dest->wineD3DSurface, srcFormat);
+ destFormat = srcFormat;
+ }
- TRACE("(%p) Relay\n" , This);
+ /* Quick if complete copy ... */
+ if (cRects == 0 && pSourceRects == NULL && pDestPoints == NULL) {
+ IWineD3DSurface_BltFast(Dest->wineD3DSurface, 0, 0, Source->wineD3DSurface, NULL, DDBLTFAST_NOCOLORKEY);
+ } else {
+ unsigned int i;
+ /* Copy rect by rect */
+ if (NULL != pSourceRects && NULL != pDestPoints) {
+ for (i = 0; i < cRects; ++i) {
+ IWineD3DSurface_BltFast(Dest->wineD3DSurface, pDestPoints[i].x, pDestPoints[i].y, Source->wineD3DSurface, (RECT *) &pSourceRects[i], DDBLTFAST_NOCOLORKEY);
+ }
+ } else {
+ for (i = 0; i < cRects; ++i) {
+ IWineD3DSurface_BltFast(Dest->wineD3DSurface, 0, 0, Source->wineD3DSurface, (RECT *) &pSourceRects[i], DDBLTFAST_NOCOLORKEY);
+ }
+ }
+ }
- return IWineD3DDevice_CopyRects(This->WineD3DDevice, pSourceSurface == NULL ? NULL : ((IDirect3DSurface8Impl *)pSourceSurface)->wineD3DSurface,
- pSourceRects, cRects, pDestinationSurface == NULL ? NULL : ((IDirect3DSurface8Impl *)pDestinationSurface)->wineD3DSurface, pDestPoints);
+ return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_UpdateTexture(LPDIRECT3DDEVICE8 iface, IDirect3DBaseTexture8* pSourceTexture, IDirect3DBaseTexture8* pDestinationTexture) {
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 83e9a83..4b60ba6 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -6821,149 +6821,6 @@ static HRESULT WINAPI IWineD3DDeviceIm
return WINED3D_OK;
}
-/* Used by DirectX 8 */
-static HRESULT WINAPI IWineD3DDeviceImpl_CopyRects(IWineD3DDevice *iface,
- IWineD3DSurface* pSourceSurface, CONST RECT* pSourceRectsArray, UINT cRects,
- IWineD3DSurface* pDestinationSurface, CONST POINT* pDestPointsArray) {
-
- IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
- HRESULT hr = WINED3D_OK;
- WINED3DFORMAT srcFormat, destFormat;
- UINT srcWidth, destWidth;
- UINT srcHeight, destHeight;
- UINT srcSize;
- WINED3DSURFACE_DESC winedesc;
-
- TRACE("(%p) pSrcSur=%p, pSourceRects=%p, cRects=%d, pDstSur=%p, pDestPtsArr=%p\n", This,
- pSourceSurface, pSourceRectsArray, cRects, pDestinationSurface, pDestPointsArray);
-
-
- /* Check that the source texture is in WINED3DPOOL_SYSTEMMEM and the destination texture is in WINED3DPOOL_DEFAULT */
- memset(&winedesc, 0, sizeof(winedesc));
-
- winedesc.Format = &srcFormat;
- winedesc.Width = &srcWidth;
- winedesc.Height = &srcHeight;
- winedesc.Size = &srcSize;
- IWineD3DSurface_GetDesc(pSourceSurface, &winedesc);
-
- winedesc.Format = &destFormat;
- winedesc.Width = &destWidth;
- winedesc.Height = &destHeight;
- winedesc.Size = NULL;
- IWineD3DSurface_GetDesc(pDestinationSurface, &winedesc);
-
- /* Check that the source and destination formats match */
- if (srcFormat != destFormat && WINED3DFMT_UNKNOWN != destFormat) {
- WARN("(%p) source %p format must match the dest %p format, returning WINED3DERR_INVALIDCALL\n", This, pSourceSurface, pDestinationSurface);
- return WINED3DERR_INVALIDCALL;
- } else if (WINED3DFMT_UNKNOWN == destFormat) {
- TRACE("(%p) : Converting destination surface from WINED3DFMT_UNKNOWN to the source format\n", This);
- IWineD3DSurface_SetFormat(pDestinationSurface, srcFormat);
- destFormat = srcFormat;
- }
-
- /* Quick if complete copy ... */
- if (cRects == 0 && pSourceRectsArray == NULL && pDestPointsArray == NULL) {
-
- if (srcWidth == destWidth && srcHeight == destHeight) {
- WINED3DLOCKED_RECT lrSrc;
- WINED3DLOCKED_RECT lrDst;
- IWineD3DSurface_LockRect(pSourceSurface, &lrSrc, NULL, WINED3DLOCK_READONLY);
- IWineD3DSurface_LockRect(pDestinationSurface, &lrDst, NULL, 0L);
- TRACE("Locked src and dst, Direct copy as surfaces are equal, w=%d, h=%d\n", srcWidth, srcHeight);
-
- memcpy(lrDst.pBits, lrSrc.pBits, srcSize);
-
- IWineD3DSurface_UnlockRect(pSourceSurface);
- IWineD3DSurface_UnlockRect(pDestinationSurface);
- TRACE("Unlocked src and dst\n");
-
- } else {
-
- FIXME("Wanted to copy all surfaces but size not compatible, returning WINED3DERR_INVALIDCALL\n");
- hr = WINED3DERR_INVALIDCALL;
- }
-
- } else {
-
- if (NULL != pSourceRectsArray && NULL != pDestPointsArray) {
-
- int bytesPerPixel = ((IWineD3DSurfaceImpl *) pSourceSurface)->bytesPerPixel;
- unsigned int i;
-
- /* Copy rect by rect */
- for (i = 0; i < cRects; ++i) {
- CONST RECT* r = &pSourceRectsArray[i];
- CONST POINT* p = &pDestPointsArray[i];
- int copyperline;
- int j;
- WINED3DLOCKED_RECT lrSrc;
- WINED3DLOCKED_RECT lrDst;
- RECT dest_rect;
-
- TRACE("Copying rect %d (%d,%d),(%d,%d) -> (%d,%d)\n", i, r->left, r->top, r->right, r->bottom, p->x, p->y);
- if (srcFormat == WINED3DFMT_DXT1) {
- copyperline = ((r->right - r->left) * bytesPerPixel) / 2; /* DXT1 is half byte per pixel */
- } else {
- copyperline = ((r->right - r->left) * bytesPerPixel);
- }
-
- IWineD3DSurface_LockRect(pSourceSurface, &lrSrc, r, WINED3DLOCK_READONLY);
- dest_rect.left = p->x;
- dest_rect.top = p->y;
- dest_rect.right = p->x + (r->right - r->left);
- dest_rect.bottom= p->y + (r->bottom - r->top);
- IWineD3DSurface_LockRect(pDestinationSurface, &lrDst, &dest_rect, 0L);
- TRACE("Locked src and dst\n");
-
- /* Find where to start */
- for (j = 0; j < (r->bottom - r->top - 1); ++j) {
- memcpy((char*) lrDst.pBits + (j * lrDst.Pitch), (char*) lrSrc.pBits + (j * lrSrc.Pitch), copyperline);
- }
- IWineD3DSurface_UnlockRect(pSourceSurface);
- IWineD3DSurface_UnlockRect(pDestinationSurface);
- TRACE("Unlocked src and dst\n");
- }
- } else {
- unsigned int i;
- int bytesPerPixel = ((IWineD3DSurfaceImpl *) pSourceSurface)->bytesPerPixel;
- int copyperline;
- int j;
- WINED3DLOCKED_RECT lrSrc;
- WINED3DLOCKED_RECT lrDst;
- RECT dest_rect;
-
- for(i=0; i < cRects; i++) {
- CONST RECT* r = &pSourceRectsArray[i];
-
- TRACE("Copying rect %d (%d,%d),(%d,%d) -> (0, 0)\n", i, r->left, r->top, r->right, r->bottom);
- if (srcFormat == WINED3DFMT_DXT1) {
- copyperline = ((r->right - r->left) * bytesPerPixel) / 2; /* DXT1 is half byte per pixel */
- } else {
- copyperline = ((r->right - r->left) * bytesPerPixel);
- }
- IWineD3DSurface_LockRect(pSourceSurface, &lrSrc, r, WINED3DLOCK_READONLY);
- dest_rect.left = 0;
- dest_rect.top = 0;
- dest_rect.right = r->right - r->left;
- dest_rect.bottom= r->bottom - r->top;
- IWineD3DSurface_LockRect(pDestinationSurface, &lrDst, &dest_rect, 0L);
- TRACE("Locked src and dst\n");
- /* Find where to start */
- for (j = 0; j < (r->bottom - r->top - 1); ++j) {
- memcpy((char*) lrDst.pBits + (j * lrDst.Pitch), (char*) lrSrc.pBits + (j * lrSrc.Pitch), copyperline);
- }
- IWineD3DSurface_UnlockRect(pSourceSurface);
- IWineD3DSurface_UnlockRect(pDestinationSurface);
- TRACE("Unlocked src and dst\n");
- }
- }
- }
-
- return hr;
-}
-
/* Implementation details at http://developer.nvidia.com/attach/6494
and
http://oss.sgi.com/projects/ogl-sample/registry/NV/evaluators.txt
@@ -8119,7 +7976,6 @@ const IWineD3DDeviceVtbl IWineD3DDevice_
IWineD3DDeviceImpl_ColorFill,
IWineD3DDeviceImpl_UpdateTexture,
IWineD3DDeviceImpl_UpdateSurface,
- IWineD3DDeviceImpl_CopyRects,
IWineD3DDeviceImpl_StretchRect,
IWineD3DDeviceImpl_GetRenderTargetData,
IWineD3DDeviceImpl_GetFrontBufferData,
diff --git a/include/wine/wined3d_interface.h b/include/wine/wined3d_interface.h
index 1b711a8..459f2da 100644
--- a/include/wine/wined3d_interface.h
+++ b/include/wine/wined3d_interface.h
@@ -455,7 +455,6 @@ DECLARE_INTERFACE_(IWineD3DDevice,IWineD
STDMETHOD(ColorFill)(THIS_ struct IWineD3DSurface* pSurface, CONST WINED3DRECT* pRect, WINED3DCOLOR color) PURE;
STDMETHOD(UpdateTexture)(THIS_ struct IWineD3DBaseTexture *pSourceTexture, struct IWineD3DBaseTexture *pDestinationTexture) PURE;
STDMETHOD(UpdateSurface)(THIS_ struct IWineD3DSurface* pSourceSurface, CONST RECT* pSourceRect, struct IWineD3DSurface* pDestinationSurface, CONST POINT* pDestPoint) PURE;
- STDMETHOD(CopyRects)(THIS_ struct IWineD3DSurface* pSourceSurface, CONST RECT* pSourceRectsArray, UINT cRects, struct IWineD3DSurface* pDestinationSurface, CONST POINT* pDestPointsArray);
STDMETHOD(StretchRect)(THIS_ struct IWineD3DSurface* pSourceSurface, CONST RECT* pSourceRect, struct IWineD3DSurface* pDestinationSurface, CONST RECT* pDestRect, WINED3DTEXTUREFILTERTYPE Filter) PURE;
STDMETHOD(GetRenderTargetData)(THIS_ struct IWineD3DSurface* pRenderTarget, struct IWineD3DSurface* pSurface) PURE;
STDMETHOD(GetFrontBufferData)(THIS_ UINT iSwapChain,struct IWineD3DSurface* pSurface) PURE;
@@ -596,7 +595,6 @@ #define IWineD3DDevice_DeletePatch(p,a)
#define IWineD3DDevice_ColorFill(p,a,b,c) (p)->lpVtbl->ColorFill(p,a,b,c)
#define IWineD3DDevice_UpdateTexture(p,a,b) (p)->lpVtbl->UpdateTexture(p,a,b)
#define IWineD3DDevice_UpdateSurface(p,a,b,c,d) (p)->lpVtbl->UpdateSurface(p,a,b,c,d)
-#define IWineD3DDevice_CopyRects(p,a,b,c,d,e) (p)->lpVtbl->CopyRects(p,a,b,c,d,e)
#define IWineD3DDevice_StretchRect(p,a,b,c,d,e) (p)->lpVtbl->StretchRect(p,a,b,c,d,e)
#define IWineD3DDevice_GetRenderTargetData(p,a,b) (p)->lpVtbl->GetRenderTargetData(p,a,b)
#define IWineD3DDevice_GetFrontBufferData(p,a,b) (p)->lpVtbl->GetFrontBufferData(p,a,b)
--
1.4.1.1
More information about the wine-patches
mailing list