[PATCH 2/2] dxgi: Added partial implementation of GetDC()/ReleaseDC()

Nikolay Sivov nsivov at codeweavers.com
Wed Sep 7 13:50:40 CDT 2016


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/d3d11/tests/d3d11.c |  6 +++---
 dlls/dxgi/dxgi_private.h |  1 +
 dlls/dxgi/surface.c      | 32 ++++++++++++++++++++++++++++----
 3 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 43e43db..b53de3b 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -8426,10 +8426,10 @@ static void test_getdc(void)
     todo_wine ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#x.\n", hr);
 
     hr = IDXGISurface1_GetDC(surface, FALSE, &dc);
-    todo_wine ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr);
 
     hr = IDXGISurface1_ReleaseDC(surface, NULL);
-    todo_wine ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
+    ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr);
 
     IDXGISurface1_Release(surface);
     ID3D11Texture2D_Release(texture);
@@ -8481,7 +8481,7 @@ static void test_getdc(void)
 
         dc = (void *)0x1234;
         hr = IDXGISurface1_GetDC(surface, FALSE, &dc);
-        todo_wine ok(SUCCEEDED(hr), "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
+        ok(SUCCEEDED(hr), "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
 
         if (FAILED(hr))
         {
diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h
index 86ba34a..06892e2 100644
--- a/dlls/dxgi/dxgi_private.h
+++ b/dlls/dxgi/dxgi_private.h
@@ -184,6 +184,7 @@ struct dxgi_surface
     struct wined3d_private_store private_store;
     IDXGIDevice *device;
     struct wined3d_texture *wined3d_texture;
+    HDC dc;
 };
 
 HRESULT dxgi_surface_init(struct dxgi_surface *surface, IDXGIDevice *device,
diff --git a/dlls/dxgi/surface.c b/dlls/dxgi/surface.c
index 687caaa..36fc1e6 100644
--- a/dlls/dxgi/surface.c
+++ b/dlls/dxgi/surface.c
@@ -197,16 +197,39 @@ static HRESULT STDMETHODCALLTYPE dxgi_surface_Unmap(IDXGISurface1 *iface)
 /* IDXGISurface1 methods */
 static HRESULT STDMETHODCALLTYPE dxgi_surface_GetDC(IDXGISurface1 *iface, BOOL discard, HDC *hdc)
 {
-    FIXME("iface %p, discard %d, hdc %p stub!\n", iface, discard, hdc);
+    struct dxgi_surface *surface = impl_from_IDXGISurface1(iface);
+    HRESULT hr;
 
-    return E_NOTIMPL;
+    FIXME("iface %p, discard %d, hdc %p semi-stub!\n", iface, discard, hdc);
+
+    if (!hdc)
+        return E_INVALIDARG;
+
+    wined3d_mutex_lock();
+    hr = wined3d_texture_get_dc(surface->wined3d_texture, 0, hdc);
+    wined3d_mutex_unlock();
+
+    if (SUCCEEDED(hr))
+       surface->dc = *hdc;
+
+    return hr;
 }
 
 static HRESULT STDMETHODCALLTYPE dxgi_surface_ReleaseDC(IDXGISurface1 *iface, RECT *dirty_rect)
 {
-    FIXME("iface %p, rect %p stub!\n", iface, dirty_rect);
+    struct dxgi_surface *surface = impl_from_IDXGISurface1(iface);
+    HRESULT hr;
 
-    return E_NOTIMPL;
+    TRACE("iface %p, rect %s\n", iface, wine_dbgstr_rect(dirty_rect));
+
+    if (!IsRectEmpty(dirty_rect))
+        FIXME("dirty rectangle is ignored.\n");
+
+    wined3d_mutex_lock();
+    hr = wined3d_texture_release_dc(surface->wined3d_texture, 0, surface->dc);
+    wined3d_mutex_unlock();
+
+    return hr;
 }
 
 static const struct IDXGISurface1Vtbl dxgi_surface_vtbl =
@@ -249,6 +272,7 @@ HRESULT dxgi_surface_init(struct dxgi_surface *surface, IDXGIDevice *device,
     surface->outer_unknown = outer ? outer : &surface->IUnknown_iface;
     surface->device = device;
     surface->wined3d_texture = wined3d_texture;
+    surface->dc = NULL;
 
     return S_OK;
 }
-- 
2.9.3




More information about the wine-patches mailing list