Stefan Dösinger : wined3d: Give GDI surfaces their own GetDC copy.
Alexandre Julliard
julliard at winehq.org
Tue Sep 18 05:31:03 CDT 2007
Module: wine
Branch: master
Commit: 9701f118508b8cd7ff03247f4405e6ca74797501
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9701f118508b8cd7ff03247f4405e6ca74797501
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Mon Sep 17 14:23:13 2007 +0200
wined3d: Give GDI surfaces their own GetDC copy.
---
dlls/wined3d/surface_gdi.c | 72 +++++++++++++++++++++++++++++++++++++++-
dlls/wined3d/wined3d_private.h | 2 -
2 files changed, 71 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/surface_gdi.c b/dlls/wined3d/surface_gdi.c
index 3dd9483..9cc8a99 100644
--- a/dlls/wined3d/surface_gdi.c
+++ b/dlls/wined3d/surface_gdi.c
@@ -1490,6 +1490,76 @@ const char* filename)
return WINED3D_OK;
}
+HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
+ IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
+ WINED3DLOCKED_RECT lock;
+ HRESULT hr;
+ RGBQUAD col[256];
+
+ TRACE("(%p)->(%p)\n",This,pHDC);
+
+ if(This->Flags & SFLAG_USERPTR) {
+ ERR("Not supported on surfaces with an application-provided surfaces\n");
+ return WINEDDERR_NODC;
+ }
+
+ /* Give more detailed info for ddraw */
+ if (This->Flags & SFLAG_DCINUSE)
+ return WINEDDERR_DCALREADYCREATED;
+
+ /* Can't GetDC if the surface is locked */
+ if (This->Flags & SFLAG_LOCKED)
+ return WINED3DERR_INVALIDCALL;
+
+ memset(&lock, 0, sizeof(lock)); /* To be sure */
+
+ /* Should have a DIB section already */
+
+ /* Lock the surface */
+ hr = IWineD3DSurface_LockRect(iface,
+ &lock,
+ NULL,
+ 0);
+ if(FAILED(hr)) {
+ ERR("IWineD3DSurface_LockRect failed with hr = %08x\n", hr);
+ /* keep the dib section */
+ return hr;
+ }
+
+ if(This->resource.format == WINED3DFMT_P8 ||
+ This->resource.format == WINED3DFMT_A8P8) {
+ unsigned int n;
+ if(This->palette) {
+ PALETTEENTRY ent[256];
+
+ GetPaletteEntries(This->palette->hpal, 0, 256, ent);
+ for (n=0; n<256; n++) {
+ col[n].rgbRed = ent[n].peRed;
+ col[n].rgbGreen = ent[n].peGreen;
+ col[n].rgbBlue = ent[n].peBlue;
+ col[n].rgbReserved = 0;
+ }
+ } else {
+ IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
+
+ for (n=0; n<256; n++) {
+ col[n].rgbRed = device->palettes[device->currentPalette][n].peRed;
+ col[n].rgbGreen = device->palettes[device->currentPalette][n].peGreen;
+ col[n].rgbBlue = device->palettes[device->currentPalette][n].peBlue;
+ col[n].rgbReserved = 0;
+ }
+
+ }
+ SetDIBColorTable(This->hDC, 0, 256, col);
+ }
+
+ *pHDC = This->hDC;
+ TRACE("returning %p\n",*pHDC);
+ This->Flags |= SFLAG_DCINUSE;
+
+ return WINED3D_OK;
+}
+
HRESULT WINAPI IWineGDISurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
@@ -1644,7 +1714,7 @@ const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl =
IWineD3DBaseSurfaceImpl_GetDesc,
IWineGDISurfaceImpl_LockRect,
IWineGDISurfaceImpl_UnlockRect,
- IWineD3DSurfaceImpl_GetDC,
+ IWineGDISurfaceImpl_GetDC,
IWineGDISurfaceImpl_ReleaseDC,
IWineGDISurfaceImpl_Flip,
IWineGDISurfaceImpl_Blt,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 86860cb..1c17f2d 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1172,9 +1172,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3D
HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface);
ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface);
-HRESULT WINAPI IWineD3DSurfaceImpl_SetPixelFormat(IWineD3DSurface *iface, WINED3DFORMAT Format, BYTE *Surface, DWORD Size);
const void *WINAPI IWineD3DSurfaceImpl_GetData(IWineD3DSurface *iface);
-HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC);
HRESULT WINAPI IWineGDISurfaceImpl_Blt(IWineD3DSurface *iface, RECT *DestRect, IWineD3DSurface *SrcSurface, RECT *SrcRect, DWORD Flags, WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter);
HRESULT WINAPI IWineGDISurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty, IWineD3DSurface *Source, RECT *rsrc, DWORD trans);
More information about the wine-cvs
mailing list