[v2 PATCH 1/4] d2d1: Implement GetSurface() for bitmaps.

Nikolay Sivov nsivov at codeweavers.com
Sun Sep 16 10:51:19 CDT 2018


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/d2d1/bitmap.c       | 64 +++++++++++++++++++++-----------------
 dlls/d2d1/d2d1_private.h | 12 +++++--
 dlls/d2d1/device.c       |  9 ++----
 dlls/d2d1/tests/d2d1.c   | 67 ++++++++++++++++++++++++----------------
 4 files changed, 88 insertions(+), 64 deletions(-)

diff --git a/dlls/d2d1/bitmap.c b/dlls/d2d1/bitmap.c
index 8b5b6aa0a9..01dc829a1c 100644
--- a/dlls/d2d1/bitmap.c
+++ b/dlls/d2d1/bitmap.c
@@ -70,6 +70,8 @@ static ULONG STDMETHODCALLTYPE d2d_bitmap_Release(ID2D1Bitmap1 *iface)
     if (!refcount)
     {
         ID3D10ShaderResourceView_Release(bitmap->view);
+        if (bitmap->surface)
+            IDXGISurface_Release(bitmap->surface);
         ID2D1Factory_Release(bitmap->factory);
         heap_free(bitmap);
     }
@@ -188,9 +190,15 @@ static D2D1_BITMAP_OPTIONS STDMETHODCALLTYPE d2d_bitmap_GetOptions(ID2D1Bitmap1
 
 static HRESULT STDMETHODCALLTYPE d2d_bitmap_GetSurface(ID2D1Bitmap1 *iface, IDXGISurface **surface)
 {
-    FIXME("iface %p, surface %p stub!\n", iface, surface);
+    struct d2d_bitmap *bitmap = impl_from_ID2D1Bitmap1(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, surface %p.\n", iface, surface);
+
+    *surface = bitmap->surface;
+    if (*surface)
+        IDXGISurface_AddRef(*surface);
+
+    return *surface ? S_OK : D2DERR_INVALID_CALL;
 }
 
 static HRESULT STDMETHODCALLTYPE d2d_bitmap_Map(ID2D1Bitmap1 *iface, D2D1_MAP_OPTIONS options,
@@ -263,18 +271,26 @@ static BOOL format_supported(const D2D1_PIXEL_FORMAT *format)
     return FALSE;
 }
 
-static void d2d_bitmap_init(struct d2d_bitmap *bitmap, ID2D1Factory *factory,
+static void d2d_bitmap_init(struct d2d_bitmap *bitmap, struct d2d_device_context *context,
         ID3D10ShaderResourceView *view, D2D1_SIZE_U size, const D2D1_BITMAP_PROPERTIES1 *desc)
 {
     bitmap->ID2D1Bitmap1_iface.lpVtbl = &d2d_bitmap_vtbl;
     bitmap->refcount = 1;
-    ID2D1Factory_AddRef(bitmap->factory = factory);
+    ID2D1Factory_AddRef(bitmap->factory = context->factory);
     ID3D10ShaderResourceView_AddRef(bitmap->view = view);
     bitmap->pixel_size = size;
     bitmap->format = desc->pixelFormat;
     bitmap->dpi_x = desc->dpiX;
     bitmap->dpi_y = desc->dpiY;
     bitmap->options = desc->bitmapOptions;
+    if (d2d_device_context_is_dxgi_target(context))
+    {
+        ID3D10Resource *resource;
+
+        ID3D10ShaderResourceView_GetResource(bitmap->view, &resource);
+        ID3D10Resource_QueryInterface(resource, &IID_IDXGISurface, (void **)&bitmap->surface);
+        ID3D10Resource_Release(resource);
+    }
 
     if (bitmap->dpi_x == 0.0f && bitmap->dpi_y == 0.0f)
     {
@@ -283,7 +299,7 @@ static void d2d_bitmap_init(struct d2d_bitmap *bitmap, ID2D1Factory *factory,
     }
 }
 
-HRESULT d2d_bitmap_create(ID2D1Factory *factory, ID3D10Device *device, D2D1_SIZE_U size, const void *src_data,
+HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size, const void *src_data,
         UINT32 pitch, const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap)
 {
     D3D10_SUBRESOURCE_DATA resource_data;
@@ -314,14 +330,14 @@ HRESULT d2d_bitmap_create(ID2D1Factory *factory, ID3D10Device *device, D2D1_SIZE
     resource_data.pSysMem = src_data;
     resource_data.SysMemPitch = pitch;
 
-    if (FAILED(hr = ID3D10Device_CreateTexture2D(device, &texture_desc,
+    if (FAILED(hr = ID3D10Device_CreateTexture2D(context->device, &texture_desc,
             src_data ? &resource_data : NULL, &texture)))
     {
         ERR("Failed to create texture, hr %#x.\n", hr);
         return hr;
     }
 
-    hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)texture, NULL, &view);
+    hr = ID3D10Device_CreateShaderResourceView(context->device, (ID3D10Resource *)texture, NULL, &view);
     ID3D10Texture2D_Release(texture);
     if (FAILED(hr))
     {
@@ -331,7 +347,7 @@ HRESULT d2d_bitmap_create(ID2D1Factory *factory, ID3D10Device *device, D2D1_SIZE
 
     if ((*bitmap = heap_alloc_zero(sizeof(**bitmap))))
     {
-        d2d_bitmap_init(*bitmap, factory, view, size, desc);
+        d2d_bitmap_init(*bitmap, context, view, size, desc);
         TRACE("Created bitmap %p.\n", *bitmap);
     }
 
@@ -340,11 +356,10 @@ HRESULT d2d_bitmap_create(ID2D1Factory *factory, ID3D10Device *device, D2D1_SIZE
     return *bitmap ? S_OK : E_OUTOFMEMORY;
 }
 
-HRESULT d2d_bitmap_create_shared(ID2D1DeviceContext *context, ID3D10Device *target_device,
-        REFIID iid, void *data, const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap)
+HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid, void *data,
+        const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap)
 {
     D2D1_BITMAP_PROPERTIES1 d;
-    ID2D1Factory *factory;
 
     if (IsEqualGUID(iid, &IID_ID2D1Bitmap))
     {
@@ -352,8 +367,7 @@ HRESULT d2d_bitmap_create_shared(ID2D1DeviceContext *context, ID3D10Device *targ
         ID3D10Device *device;
         HRESULT hr = S_OK;
 
-        ID2D1DeviceContext_GetFactory(context, &factory);
-        if (src_impl->factory != factory)
+        if (src_impl->factory != context->factory)
         {
             hr = D2DERR_WRONG_FACTORY;
             goto failed;
@@ -361,7 +375,7 @@ HRESULT d2d_bitmap_create_shared(ID2D1DeviceContext *context, ID3D10Device *targ
 
         ID3D10ShaderResourceView_GetDevice(src_impl->view, &device);
         ID3D10Device_Release(device);
-        if (device != target_device)
+        if (device != context->device)
         {
             hr = D2DERR_UNSUPPORTED_OPERATION;
             goto failed;
@@ -391,11 +405,10 @@ HRESULT d2d_bitmap_create_shared(ID2D1DeviceContext *context, ID3D10Device *targ
             goto failed;
         }
 
-        d2d_bitmap_init(*bitmap, factory, src_impl->view, src_impl->pixel_size, desc);
+        d2d_bitmap_init(*bitmap, context, src_impl->view, src_impl->pixel_size, desc);
         TRACE("Created bitmap %p.\n", *bitmap);
 
     failed:
-        ID2D1Factory_Release(factory);
         return hr;
     }
 
@@ -417,13 +430,13 @@ HRESULT d2d_bitmap_create_shared(ID2D1DeviceContext *context, ID3D10Device *targ
 
         ID3D10Resource_GetDevice(resource, &device);
         ID3D10Device_Release(device);
-        if (device != target_device)
+        if (device != context->device)
         {
             ID3D10Resource_Release(resource);
             return D2DERR_UNSUPPORTED_OPERATION;
         }
 
-        hr = ID3D10Device_CreateShaderResourceView(target_device, resource, NULL, &view);
+        hr = ID3D10Device_CreateShaderResourceView(context->device, resource, NULL, &view);
         ID3D10Resource_Release(resource);
         if (FAILED(hr))
         {
@@ -455,22 +468,17 @@ HRESULT d2d_bitmap_create_shared(ID2D1DeviceContext *context, ID3D10Device *targ
 
         if (d.dpiX == 0.0f || d.dpiY == 0.0f)
         {
-            float dpi_x, dpi_y;
-
-            ID2D1DeviceContext_GetDpi(context, &dpi_x, &dpi_y);
             if (d.dpiX == 0.0f)
-                d.dpiX = dpi_x;
+                d.dpiX = context->desc.dpiX;
             if (d.dpiY == 0.0f)
-                d.dpiY = dpi_y;
+                d.dpiY = context->desc.dpiY;
         }
 
         pixel_size.width = surface_desc.Width;
         pixel_size.height = surface_desc.Height;
 
-        ID2D1DeviceContext_GetFactory(context, &factory);
-        d2d_bitmap_init(*bitmap, factory, view, pixel_size, &d);
+        d2d_bitmap_init(*bitmap, context, view, pixel_size, &d);
         ID3D10ShaderResourceView_Release(view);
-        ID2D1Factory_Release(factory);
         TRACE("Created bitmap %p.\n", *bitmap);
 
         return S_OK;
@@ -481,7 +489,7 @@ HRESULT d2d_bitmap_create_shared(ID2D1DeviceContext *context, ID3D10Device *targ
     return E_INVALIDARG;
 }
 
-HRESULT d2d_bitmap_create_from_wic_bitmap(ID2D1Factory *factory, ID3D10Device *device, IWICBitmapSource *bitmap_source,
+HRESULT d2d_bitmap_create_from_wic_bitmap(struct d2d_device_context *context, IWICBitmapSource *bitmap_source,
         const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap)
 {
     const D2D1_PIXEL_FORMAT *d2d_format;
@@ -581,7 +589,7 @@ HRESULT d2d_bitmap_create_from_wic_bitmap(ID2D1Factory *factory, ID3D10Device *d
         return hr;
     }
 
-    hr = d2d_bitmap_create(factory, device, size, data, pitch, &bitmap_desc, bitmap);
+    hr = d2d_bitmap_create(context, size, data, pitch, &bitmap_desc, bitmap);
 
     heap_free(data);
 
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h
index 5b96a6050d..3fed59fa72 100644
--- a/dlls/d2d1/d2d1_private.h
+++ b/dlls/d2d1/d2d1_private.h
@@ -160,6 +160,11 @@ HRESULT d2d_d3d_create_render_target(ID2D1Factory *factory, IDXGISurface *surfac
         void **render_target) DECLSPEC_HIDDEN;
 HRESULT d2d_d3d_render_target_create_rtv(ID2D1RenderTarget *render_target, IDXGISurface1 *surface) DECLSPEC_HIDDEN;
 
+static inline BOOL d2d_device_context_is_dxgi_target(const struct d2d_device_context *context)
+{
+    return !context->ops;
+}
+
 struct d2d_wic_render_target
 {
     IUnknown IUnknown_iface;
@@ -339,6 +344,7 @@ struct d2d_bitmap
 
     ID2D1Factory *factory;
     ID3D10ShaderResourceView *view;
+    IDXGISurface *surface;
     D2D1_SIZE_U pixel_size;
     D2D1_PIXEL_FORMAT format;
     float dpi_x;
@@ -346,11 +352,11 @@ struct d2d_bitmap
     D2D1_BITMAP_OPTIONS options;
 };
 
-HRESULT d2d_bitmap_create(ID2D1Factory *factory, ID3D10Device *device, D2D1_SIZE_U size, const void *src_data,
+HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size, const void *src_data,
         UINT32 pitch, const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap) DECLSPEC_HIDDEN;
-HRESULT d2d_bitmap_create_shared(ID2D1DeviceContext *context, ID3D10Device *device, REFIID iid, void *data,
+HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid, void *data,
         const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap) DECLSPEC_HIDDEN;
-HRESULT d2d_bitmap_create_from_wic_bitmap(ID2D1Factory *factory, ID3D10Device *device, IWICBitmapSource *bitmap_source,
+HRESULT d2d_bitmap_create_from_wic_bitmap(struct d2d_device_context *context, IWICBitmapSource *bitmap_source,
         const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap) DECLSPEC_HIDDEN;
 struct d2d_bitmap *unsafe_impl_from_ID2D1Bitmap(ID2D1Bitmap *iface) DECLSPEC_HIDDEN;
 
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c
index 649fcc4311..041cb33c90 100644
--- a/dlls/d2d1/device.c
+++ b/dlls/d2d1/device.c
@@ -343,8 +343,7 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateBitmap(ID2D1DeviceCont
         bitmap_desc.colorContext = NULL;
     }
 
-    if (SUCCEEDED(hr = d2d_bitmap_create(context->factory, context->device,
-            size, src_data, pitch, desc ? &bitmap_desc : NULL, &object)))
+    if (SUCCEEDED(hr = d2d_bitmap_create(context, size, src_data, pitch, desc ? &bitmap_desc : NULL, &object)))
         *bitmap = (ID2D1Bitmap *)&object->ID2D1Bitmap1_iface;
 
     return hr;
@@ -368,8 +367,7 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateBitmapFromWicBitmap(ID
         bitmap_desc.colorContext = NULL;
     }
 
-    if (SUCCEEDED(hr = d2d_bitmap_create_from_wic_bitmap(context->factory, context->device,
-            bitmap_source, desc ? &bitmap_desc : NULL, &object)))
+    if (SUCCEEDED(hr = d2d_bitmap_create_from_wic_bitmap(context, bitmap_source, desc ? &bitmap_desc : NULL, &object)))
         *bitmap = (ID2D1Bitmap *)&object->ID2D1Bitmap1_iface;
 
     return hr;
@@ -393,8 +391,7 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateSharedBitmap(ID2D1Devi
         bitmap_desc.colorContext = NULL;
     }
 
-    if (SUCCEEDED(hr = d2d_bitmap_create_shared(iface, context->device,
-            iid, data, desc ? &bitmap_desc : NULL, &object)))
+    if (SUCCEEDED(hr = d2d_bitmap_create_shared(context, iid, data, desc ? &bitmap_desc : NULL, &object)))
         *bitmap = (ID2D1Bitmap *)&object->ID2D1Bitmap1_iface;
 
     return hr;
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index 1753d6282f..6419df23d8 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -774,29 +774,31 @@ static ID2D1RenderTarget *create_render_target(IDXGISurface *surface)
 }
 
 #define check_bitmap_surface(b, s, o) check_bitmap_surface_(__LINE__, b, s, o)
-static void check_bitmap_surface_(unsigned int line, ID2D1Bitmap1 *bitmap, BOOL has_surface, DWORD expected_options)
+static void check_bitmap_surface_(unsigned int line, ID2D1Bitmap *bitmap, BOOL has_surface, DWORD expected_options)
 {
     D2D1_BITMAP_OPTIONS options;
     IDXGISurface *surface;
+    ID2D1Bitmap1 *bitmap1;
     HRESULT hr;
 
-    options = ID2D1Bitmap1_GetOptions(bitmap);
+    hr = ID2D1Bitmap_QueryInterface(bitmap, &IID_ID2D1Bitmap1, (void **)&bitmap1);
+    if (FAILED(hr))
+        return;
+
+    options = ID2D1Bitmap1_GetOptions(bitmap1);
     ok_(__FILE__, line)(options == expected_options, "Unexpected bitmap options %#x, expected %#x.\n",
             options, expected_options);
 
     surface = (void *)0xdeadbeef;
-    hr = ID2D1Bitmap1_GetSurface(bitmap, &surface);
+    hr = ID2D1Bitmap1_GetSurface(bitmap1, &surface);
     if (has_surface)
     {
         D3D10_TEXTURE2D_DESC desc;
         ID3D10Texture2D *texture;
 
-    todo_wine
         ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to get bitmap surface, hr %#x.\n", hr);
         ok_(__FILE__, line)(!!surface, "Expected surface instance.\n");
 
-    if (SUCCEEDED(hr))
-    {
         /* Correlate with resource configuration. */
         hr = IDXGISurface_QueryInterface(surface, &IID_ID3D10Texture2D, (void **)&texture);
         ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to get texture pointer, hr %#x.\n", hr);
@@ -813,14 +815,13 @@ static void check_bitmap_surface_(unsigned int line, ID2D1Bitmap1 *bitmap, BOOL
 
         IDXGISurface_Release(surface);
     }
-    }
     else
     {
-    todo_wine {
         ok_(__FILE__, line)(hr == D2DERR_INVALID_CALL, "Unexpected hr %#x.\n", hr);
         ok_(__FILE__, line)(!surface, "Unexpected surface instance.\n");
     }
-    }
+
+    ID2D1Bitmap1_Release(bitmap1);
 }
 
 static inline struct geometry_sink *impl_from_ID2D1SimplifiedGeometrySink(ID2D1SimplifiedGeometrySink *iface)
@@ -4132,12 +4133,14 @@ static void test_shared_bitmap(void)
     hr = ID2D1Factory_CreateDxgiSurfaceRenderTarget(factory1, surface1, &desc, &rt1);
     ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
     hr = ID2D1RenderTarget_CreateBitmap(rt1, size, NULL, 0, &bitmap_desc, &bitmap1);
+    check_bitmap_surface(bitmap1, TRUE, 0);
     ok(SUCCEEDED(hr), "Failed to create bitmap, hr %#x.\n", hr);
 
     hr = ID2D1Factory_CreateDxgiSurfaceRenderTarget(factory1, surface2, &desc, &rt2);
     ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
     hr = ID2D1RenderTarget_CreateSharedBitmap(rt2, &IID_ID2D1Bitmap, bitmap1, NULL, &bitmap2);
     ok(SUCCEEDED(hr), "Failed to create bitmap, hr %#x.\n", hr);
+    check_bitmap_surface(bitmap2, TRUE, 0);
     ID2D1Bitmap_Release(bitmap2);
     hr = ID2D1RenderTarget_CreateSharedBitmap(rt2, &IID_IUnknown, bitmap1, NULL, &bitmap2);
     ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
@@ -4206,6 +4209,7 @@ static void test_shared_bitmap(void)
     ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
     hr = ID2D1RenderTarget_CreateSharedBitmap(rt2, &IID_ID2D1Bitmap, bitmap1, NULL, &bitmap2);
     ok(SUCCEEDED(hr), "Failed to create bitmap, hr %#x.\n", hr);
+    check_bitmap_surface(bitmap2, FALSE, 0);
     ID2D1Bitmap_Release(bitmap2);
     ID2D1RenderTarget_Release(rt2);
 
@@ -4231,18 +4235,12 @@ static void test_shared_bitmap(void)
 
     if (SUCCEEDED(hr))
     {
-        ID2D1Bitmap1 *bitmap3;
-
         size = ID2D1Bitmap_GetPixelSize(bitmap2);
         hr = IDXGISurface_GetDesc(surface2, &surface_desc);
         ok(SUCCEEDED(hr), "Failed to get surface description, hr %#x.\n", hr);
         ok(size.width == surface_desc.Width && size.height == surface_desc.Height, "Got wrong bitmap size.\n");
 
-        hr = ID2D1Bitmap_QueryInterface(bitmap2, &IID_ID2D1Bitmap1, (void **)&bitmap3);
-        ok(SUCCEEDED(hr), "Failed to get ID2D1Bitmap1 pointer, hr %#x.\n", hr);
-
-        check_bitmap_surface(bitmap3, TRUE, D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW);
-        ID2D1Bitmap1_Release(bitmap3);
+        check_bitmap_surface(bitmap2, TRUE, D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW);
 
         ID2D1Bitmap_Release(bitmap2);
 
@@ -6661,8 +6659,9 @@ static void check_rt_bitmap_surface_(unsigned int line, ID2D1RenderTarget *rt, B
 {
     D2D1_BITMAP_PROPERTIES bitmap_desc;
     ID2D1RenderTarget *compatible_rt;
+    IWICImagingFactory *wic_factory;
     ID2D1DeviceContext *context;
-    ID2D1Bitmap1 *bitmap1;
+    IWICBitmap *wic_bitmap;
     ID2D1Bitmap *bitmap;
     D2D1_SIZE_U size;
     HRESULT hr;
@@ -6672,6 +6671,7 @@ static void check_rt_bitmap_surface_(unsigned int line, ID2D1RenderTarget *rt, B
         0x7f7f0000,
     };
 
+    /* Raw data bitmap. */
     set_size_u(&size, 1, 1);
     bitmap_desc.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM;
     bitmap_desc.pixelFormat.alphaMode = D2D1_ALPHA_MODE_IGNORE;
@@ -6680,14 +6680,31 @@ static void check_rt_bitmap_surface_(unsigned int line, ID2D1RenderTarget *rt, B
     hr = ID2D1RenderTarget_CreateBitmap(rt, size, bitmap_data, sizeof(*bitmap_data), &bitmap_desc, &bitmap);
     ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create bitmap, hr %#x.\n", hr);
 
-    hr = ID2D1Bitmap_QueryInterface(bitmap, &IID_ID2D1Bitmap1, (void **)&bitmap1);
-    ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to get ID2D1Bitmap1 interface, hr %#x.\n", hr);
+    check_bitmap_surface_(line, bitmap, has_surface, options);
 
-    check_bitmap_surface_(line, bitmap1, has_surface, options);
+    ID2D1Bitmap_Release(bitmap);
+
+    /* WIC bitmap. */
+    CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+
+    hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
+            &IID_IWICImagingFactory, (void **)&wic_factory);
+    ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create WIC imaging factory, hr %#x.\n", hr);
+
+    hr = IWICImagingFactory_CreateBitmap(wic_factory, 16, 16,
+            &GUID_WICPixelFormat32bppPBGRA, WICBitmapCacheOnDemand, &wic_bitmap);
+    ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create WIC bitmap, hr %#x.\n", hr);
+    IWICImagingFactory_Release(wic_factory);
+
+    hr = ID2D1RenderTarget_CreateBitmapFromWicBitmap(rt, (IWICBitmapSource *)wic_bitmap, NULL, &bitmap);
+    ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create bitmap from WIC source, hr %#x.\n", hr);
+
+    check_bitmap_surface_(line, bitmap, has_surface, options);
 
-    ID2D1Bitmap1_Release(bitmap1);
     ID2D1Bitmap_Release(bitmap);
 
+    CoUninitialize();
+
     if (FAILED(ID2D1RenderTarget_QueryInterface(rt, &IID_ID2D1DeviceContext, (void **)&context)))
     {
         /* Compatible target follows its parent. */
@@ -6698,13 +6715,9 @@ static void check_rt_bitmap_surface_(unsigned int line, ID2D1RenderTarget *rt, B
         hr = ID2D1RenderTarget_CreateBitmap(compatible_rt, size, bitmap_data, sizeof(*bitmap_data), &bitmap_desc, &bitmap);
         ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to create bitmap, hr %#x.\n", hr);
 
-        hr = ID2D1Bitmap_QueryInterface(bitmap, &IID_ID2D1Bitmap1, (void **)&bitmap1);
-        ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to get ID2D1Bitmap1 interface, hr %#x.\n", hr);
-
-        check_bitmap_surface_(line, bitmap1, has_surface, options);
+        check_bitmap_surface_(line, bitmap, has_surface, options);
         ID2D1RenderTarget_Release(compatible_rt);
 
-        ID2D1Bitmap1_Release(bitmap1);
         ID2D1Bitmap_Release(bitmap);
     }
     else
@@ -6776,7 +6789,7 @@ if (SUCCEEDED(hr))
     hr = ID2D1DeviceContext_CreateBitmapFromDxgiSurface(device_context, surface, NULL, &bitmap);
     ok(SUCCEEDED(hr), "Failed to create a bitmap, hr %#x.\n", hr);
 
-    check_bitmap_surface(bitmap, TRUE, D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW);
+    check_bitmap_surface((ID2D1Bitmap *)bitmap, TRUE, D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW);
     check_rt_bitmap_surface((ID2D1RenderTarget *)device_context, TRUE, D2D1_BITMAP_OPTIONS_NONE);
 
     ID2D1DeviceContext_Release(device_context);
-- 
2.18.0




More information about the wine-devel mailing list