Signed-off-by: Nikolay Sivov nsivov@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);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- include/d2d1_1.idl | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/include/d2d1_1.idl b/include/d2d1_1.idl index ff283f8f1a..284bd60ece 100644 --- a/include/d2d1_1.idl +++ b/include/d2d1_1.idl @@ -286,6 +286,19 @@ interface ID2D1Bitmap1 : ID2D1Bitmap HRESULT Unmap(); }
+[ + object, + uuid(41343a53-e41a-49a2-91cd-21793bbb62e5), + local, +] +interface ID2D1BitmapBrush1 : ID2D1BitmapBrush +{ + void SetInterpolationMode1( + [in] D2D1_INTERPOLATION_MODE mode + ); + D2D1_INTERPOLATION_MODE GetInterpolationMode1(); +} + [ object, uuid(47dd575d-ac05-4cdd-8049-9b02cd16f44c),
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/brush.c | 132 ++++++++++++++++++++++++++++----------- dlls/d2d1/d2d1_private.h | 2 +- dlls/d2d1/tests/d2d1.c | 44 +++++++++++++ 3 files changed, 140 insertions(+), 38 deletions(-)
diff --git a/dlls/d2d1/brush.c b/dlls/d2d1/brush.c index 450507cef6..f2c13d4788 100644 --- a/dlls/d2d1/brush.c +++ b/dlls/d2d1/brush.c @@ -816,22 +816,23 @@ HRESULT d2d_radial_gradient_brush_create(ID2D1Factory *factory, return S_OK; }
-static inline struct d2d_brush *impl_from_ID2D1BitmapBrush(ID2D1BitmapBrush *iface) +static inline struct d2d_brush *impl_from_ID2D1BitmapBrush1(ID2D1BitmapBrush1 *iface) { return CONTAINING_RECORD(iface, struct d2d_brush, ID2D1Brush_iface); }
-static HRESULT STDMETHODCALLTYPE d2d_bitmap_brush_QueryInterface(ID2D1BitmapBrush *iface, +static HRESULT STDMETHODCALLTYPE d2d_bitmap_brush_QueryInterface(ID2D1BitmapBrush1 *iface, REFIID iid, void **out) { TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
- if (IsEqualGUID(iid, &IID_ID2D1BitmapBrush) + if (IsEqualGUID(iid, &IID_ID2D1BitmapBrush1) + || IsEqualGUID(iid, &IID_ID2D1BitmapBrush) || IsEqualGUID(iid, &IID_ID2D1Brush) || IsEqualGUID(iid, &IID_ID2D1Resource) || IsEqualGUID(iid, &IID_IUnknown)) { - ID2D1BitmapBrush_AddRef(iface); + ID2D1BitmapBrush1_AddRef(iface); *out = iface; return S_OK; } @@ -842,9 +843,9 @@ static HRESULT STDMETHODCALLTYPE d2d_bitmap_brush_QueryInterface(ID2D1BitmapBrus return E_NOINTERFACE; }
-static ULONG STDMETHODCALLTYPE d2d_bitmap_brush_AddRef(ID2D1BitmapBrush *iface) +static ULONG STDMETHODCALLTYPE d2d_bitmap_brush_AddRef(ID2D1BitmapBrush1 *iface) { - struct d2d_brush *brush = impl_from_ID2D1BitmapBrush(iface); + struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface); ULONG refcount = InterlockedIncrement(&brush->refcount);
TRACE("%p increasing refcount to %u.\n", iface, refcount); @@ -852,9 +853,9 @@ static ULONG STDMETHODCALLTYPE d2d_bitmap_brush_AddRef(ID2D1BitmapBrush *iface) return refcount; }
-static ULONG STDMETHODCALLTYPE d2d_bitmap_brush_Release(ID2D1BitmapBrush *iface) +static ULONG STDMETHODCALLTYPE d2d_bitmap_brush_Release(ID2D1BitmapBrush1 *iface) { - struct d2d_brush *brush = impl_from_ID2D1BitmapBrush(iface); + struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface); ULONG refcount = InterlockedDecrement(&brush->refcount);
TRACE("%p decreasing refcount to %u.\n", iface, refcount); @@ -871,57 +872,57 @@ static ULONG STDMETHODCALLTYPE d2d_bitmap_brush_Release(ID2D1BitmapBrush *iface) return refcount; }
-static void STDMETHODCALLTYPE d2d_bitmap_brush_GetFactory(ID2D1BitmapBrush *iface, +static void STDMETHODCALLTYPE d2d_bitmap_brush_GetFactory(ID2D1BitmapBrush1 *iface, ID2D1Factory **factory) { - struct d2d_brush *brush = impl_from_ID2D1BitmapBrush(iface); + struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
TRACE("iface %p, factory %p.\n", iface, factory);
ID2D1Factory_AddRef(*factory = brush->factory); }
-static void STDMETHODCALLTYPE d2d_bitmap_brush_SetOpacity(ID2D1BitmapBrush *iface, float opacity) +static void STDMETHODCALLTYPE d2d_bitmap_brush_SetOpacity(ID2D1BitmapBrush1 *iface, float opacity) { - struct d2d_brush *brush = impl_from_ID2D1BitmapBrush(iface); + struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
TRACE("iface %p, opacity %.8e.\n", iface, opacity);
brush->opacity = opacity; }
-static void STDMETHODCALLTYPE d2d_bitmap_brush_SetTransform(ID2D1BitmapBrush *iface, +static void STDMETHODCALLTYPE d2d_bitmap_brush_SetTransform(ID2D1BitmapBrush1 *iface, const D2D1_MATRIX_3X2_F *transform) { - struct d2d_brush *brush = impl_from_ID2D1BitmapBrush(iface); + struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
TRACE("iface %p, transform %p.\n", iface, transform);
brush->transform = *transform; }
-static float STDMETHODCALLTYPE d2d_bitmap_brush_GetOpacity(ID2D1BitmapBrush *iface) +static float STDMETHODCALLTYPE d2d_bitmap_brush_GetOpacity(ID2D1BitmapBrush1 *iface) { - struct d2d_brush *brush = impl_from_ID2D1BitmapBrush(iface); + struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
TRACE("iface %p.\n", iface);
return brush->opacity; }
-static void STDMETHODCALLTYPE d2d_bitmap_brush_GetTransform(ID2D1BitmapBrush *iface, +static void STDMETHODCALLTYPE d2d_bitmap_brush_GetTransform(ID2D1BitmapBrush1 *iface, D2D1_MATRIX_3X2_F *transform) { - struct d2d_brush *brush = impl_from_ID2D1BitmapBrush(iface); + struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
TRACE("iface %p, transform %p.\n", iface, transform);
*transform = brush->transform; }
-static void STDMETHODCALLTYPE d2d_bitmap_brush_SetExtendModeX(ID2D1BitmapBrush *iface, D2D1_EXTEND_MODE mode) +static void STDMETHODCALLTYPE d2d_bitmap_brush_SetExtendModeX(ID2D1BitmapBrush1 *iface, D2D1_EXTEND_MODE mode) { - struct d2d_brush *brush = impl_from_ID2D1BitmapBrush(iface); + struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
TRACE("iface %p, mode %#x.\n", iface, mode);
@@ -933,9 +934,9 @@ static void STDMETHODCALLTYPE d2d_bitmap_brush_SetExtendModeX(ID2D1BitmapBrush * } }
-static void STDMETHODCALLTYPE d2d_bitmap_brush_SetExtendModeY(ID2D1BitmapBrush *iface, D2D1_EXTEND_MODE mode) +static void STDMETHODCALLTYPE d2d_bitmap_brush_SetExtendModeY(ID2D1BitmapBrush1 *iface, D2D1_EXTEND_MODE mode) { - struct d2d_brush *brush = impl_from_ID2D1BitmapBrush(iface); + struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
TRACE("iface %p, mode %#x.\n", iface, mode);
@@ -947,13 +948,23 @@ static void STDMETHODCALLTYPE d2d_bitmap_brush_SetExtendModeY(ID2D1BitmapBrush * } }
-static void STDMETHODCALLTYPE d2d_bitmap_brush_SetInterpolationMode(ID2D1BitmapBrush *iface, +static void STDMETHODCALLTYPE d2d_bitmap_brush_SetInterpolationMode(ID2D1BitmapBrush1 *iface, D2D1_BITMAP_INTERPOLATION_MODE mode) { - struct d2d_brush *brush = impl_from_ID2D1BitmapBrush(iface); + struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
TRACE("iface %p, mode %#x.\n", iface, mode);
+ switch (mode) + { + case D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR: + case D2D1_BITMAP_INTERPOLATION_MODE_LINEAR: + break; + default: + WARN("Unknown interpolation mode %#x.\n", mode); + return; + } + brush->u.bitmap.interpolation_mode = mode; if (brush->u.bitmap.sampler_state) { @@ -962,9 +973,9 @@ static void STDMETHODCALLTYPE d2d_bitmap_brush_SetInterpolationMode(ID2D1BitmapB } }
-static void STDMETHODCALLTYPE d2d_bitmap_brush_SetBitmap(ID2D1BitmapBrush *iface, ID2D1Bitmap *bitmap) +static void STDMETHODCALLTYPE d2d_bitmap_brush_SetBitmap(ID2D1BitmapBrush1 *iface, ID2D1Bitmap *bitmap) { - struct d2d_brush *brush = impl_from_ID2D1BitmapBrush(iface); + struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
TRACE("iface %p, bitmap %p.\n", iface, bitmap);
@@ -975,36 +986,43 @@ static void STDMETHODCALLTYPE d2d_bitmap_brush_SetBitmap(ID2D1BitmapBrush *iface brush->u.bitmap.bitmap = unsafe_impl_from_ID2D1Bitmap(bitmap); }
-static D2D1_EXTEND_MODE STDMETHODCALLTYPE d2d_bitmap_brush_GetExtendModeX(ID2D1BitmapBrush *iface) +static D2D1_EXTEND_MODE STDMETHODCALLTYPE d2d_bitmap_brush_GetExtendModeX(ID2D1BitmapBrush1 *iface) { - struct d2d_brush *brush = impl_from_ID2D1BitmapBrush(iface); + struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
TRACE("iface %p.\n", iface);
return brush->u.bitmap.extend_mode_x; }
-static D2D1_EXTEND_MODE STDMETHODCALLTYPE d2d_bitmap_brush_GetExtendModeY(ID2D1BitmapBrush *iface) +static D2D1_EXTEND_MODE STDMETHODCALLTYPE d2d_bitmap_brush_GetExtendModeY(ID2D1BitmapBrush1 *iface) { - struct d2d_brush *brush = impl_from_ID2D1BitmapBrush(iface); + struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
TRACE("iface %p.\n", iface);
return brush->u.bitmap.extend_mode_y; }
-static D2D1_BITMAP_INTERPOLATION_MODE STDMETHODCALLTYPE d2d_bitmap_brush_GetInterpolationMode(ID2D1BitmapBrush *iface) +static D2D1_BITMAP_INTERPOLATION_MODE STDMETHODCALLTYPE d2d_bitmap_brush_GetInterpolationMode(ID2D1BitmapBrush1 *iface) { - struct d2d_brush *brush = impl_from_ID2D1BitmapBrush(iface); + struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
TRACE("iface %p.\n", iface);
- return brush->u.bitmap.interpolation_mode; + switch (brush->u.bitmap.interpolation_mode) + { + case D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR: + case D2D1_INTERPOLATION_MODE_LINEAR: + return brush->u.bitmap.interpolation_mode; + default: + return D2D1_BITMAP_INTERPOLATION_MODE_LINEAR; + } }
-static void STDMETHODCALLTYPE d2d_bitmap_brush_GetBitmap(ID2D1BitmapBrush *iface, ID2D1Bitmap **bitmap) +static void STDMETHODCALLTYPE d2d_bitmap_brush_GetBitmap(ID2D1BitmapBrush1 *iface, ID2D1Bitmap **bitmap) { - struct d2d_brush *brush = impl_from_ID2D1BitmapBrush(iface); + struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
TRACE("iface %p, bitmap %p.\n", iface, bitmap);
@@ -1012,7 +1030,45 @@ static void STDMETHODCALLTYPE d2d_bitmap_brush_GetBitmap(ID2D1BitmapBrush *iface ID2D1Bitmap_AddRef(*bitmap); }
-static const struct ID2D1BitmapBrushVtbl d2d_bitmap_brush_vtbl = +static void STDMETHODCALLTYPE d2d_bitmap_brush_SetInterpolationMode1(ID2D1BitmapBrush1 *iface, + D2D1_INTERPOLATION_MODE mode) +{ + struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface); + + TRACE("iface %p, mode %#x.\n", iface, mode); + + switch (mode) + { + case D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR: + case D2D1_INTERPOLATION_MODE_LINEAR: + case D2D1_INTERPOLATION_MODE_CUBIC: + case D2D1_INTERPOLATION_MODE_MULTI_SAMPLE_LINEAR: + case D2D1_INTERPOLATION_MODE_ANISOTROPIC: + case D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC: + break; + default: + WARN("Unknown interpolation mode %#x.\n", mode); + return; + } + + brush->u.bitmap.interpolation_mode = mode; + if (brush->u.bitmap.sampler_state) + { + ID3D10SamplerState_Release(brush->u.bitmap.sampler_state); + brush->u.bitmap.sampler_state = NULL; + } +} + +static D2D1_INTERPOLATION_MODE STDMETHODCALLTYPE d2d_bitmap_brush_GetInterpolationMode1(ID2D1BitmapBrush1 *iface) +{ + struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface); + + TRACE("iface %p.\n", iface); + + return brush->u.bitmap.interpolation_mode; +} + +static const struct ID2D1BitmapBrush1Vtbl d2d_bitmap_brush_vtbl = { d2d_bitmap_brush_QueryInterface, d2d_bitmap_brush_AddRef, @@ -1030,6 +1086,8 @@ static const struct ID2D1BitmapBrushVtbl d2d_bitmap_brush_vtbl = d2d_bitmap_brush_GetExtendModeY, d2d_bitmap_brush_GetInterpolationMode, d2d_bitmap_brush_GetBitmap, + d2d_bitmap_brush_SetInterpolationMode1, + d2d_bitmap_brush_GetInterpolationMode1, };
HRESULT d2d_bitmap_brush_create(ID2D1Factory *factory, ID2D1Bitmap *bitmap, const D2D1_BITMAP_BRUSH_PROPERTIES *bitmap_brush_desc, @@ -1242,7 +1300,7 @@ static void d2d_brush_bind_bitmap(struct d2d_brush *brush, ID3D10Device *device, { D3D10_SAMPLER_DESC sampler_desc;
- if (brush->u.bitmap.interpolation_mode == D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR) + if (brush->u.bitmap.interpolation_mode == D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR) sampler_desc.Filter = D3D10_FILTER_MIN_MAG_MIP_POINT; else sampler_desc.Filter = D3D10_FILTER_MIN_MAG_MIP_LINEAR; diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 3fed59fa72..c8515eaa12 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -280,7 +280,7 @@ struct d2d_brush struct d2d_bitmap *bitmap; D2D1_EXTEND_MODE extend_mode_x; D2D1_EXTEND_MODE extend_mode_y; - D2D1_BITMAP_INTERPOLATION_MODE interpolation_mode; + D2D1_INTERPOLATION_MODE interpolation_mode; ID3D10SamplerState *sampler_state; } bitmap; } u; diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 6419df23d8..8584e69d3e 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -1656,6 +1656,7 @@ static void test_bitmap_brush(void) D2D1_RECT_F src_rect, dst_rect; D2D1_EXTEND_MODE extend_mode; IDXGISwapChain *swapchain; + ID2D1BitmapBrush1 *brush1; ID2D1BitmapBrush *brush; ID2D1RenderTarget *rt; ID3D10Device1 *device; @@ -1877,6 +1878,49 @@ static void test_bitmap_brush(void) match = compare_surface(surface, "cf7b90ba7b139fdfbe9347e1907d635cfb4ed197"); ok(match, "Surface does not match.\n");
+ if (SUCCEEDED(ID2D1BitmapBrush_QueryInterface(brush, &IID_ID2D1BitmapBrush1, (void **)&brush1))) + { + D2D1_INTERPOLATION_MODE interpolation_mode1; + + interpolation_mode = ID2D1BitmapBrush1_GetInterpolationMode(brush1); + ok(interpolation_mode == D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, + "Unexpected interpolation mode %#x.\n", interpolation_mode); + + interpolation_mode1 = ID2D1BitmapBrush1_GetInterpolationMode1(brush1); + ok(interpolation_mode1 == D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR, + "Unexpected interpolation mode %#x.\n", interpolation_mode1); + + ID2D1BitmapBrush1_SetInterpolationMode1(brush1, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC); + interpolation_mode = ID2D1BitmapBrush1_GetInterpolationMode(brush1); + ok(interpolation_mode == D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, + "Unexpected interpolation mode %#x.\n", interpolation_mode); + + interpolation_mode1 = ID2D1BitmapBrush1_GetInterpolationMode1(brush1); + ok(interpolation_mode1 == D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC, + "Unexpected interpolation mode %#x.\n", interpolation_mode1); + + ID2D1BitmapBrush1_SetInterpolationMode1(brush1, 100); + interpolation_mode1 = ID2D1BitmapBrush1_GetInterpolationMode1(brush1); + ok(interpolation_mode1 == D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC, + "Unexpected interpolation mode %#x.\n", interpolation_mode1); + + ID2D1BitmapBrush1_SetInterpolationMode(brush1, 100); + interpolation_mode1 = ID2D1BitmapBrush1_GetInterpolationMode1(brush1); + ok(interpolation_mode1 == D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC, + "Unexpected interpolation mode %#x.\n", interpolation_mode1); + + ID2D1BitmapBrush1_SetInterpolationMode(brush1, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR); + interpolation_mode = ID2D1BitmapBrush1_GetInterpolationMode(brush1); + ok(interpolation_mode == D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, + "Unexpected interpolation mode %#x.\n", interpolation_mode); + + interpolation_mode1 = ID2D1BitmapBrush1_GetInterpolationMode1(brush1); + ok(interpolation_mode1 == D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR, + "Unexpected interpolation mode %#x.\n", interpolation_mode1); + + ID2D1BitmapBrush1_Release(brush1); + } + ID2D1BitmapBrush_Release(brush); refcount = ID2D1Bitmap_Release(bitmap); ok(!refcount, "Bitmap has %u references left.\n", refcount);
On 16 September 2018 at 20:21, Nikolay Sivov nsivov@codeweavers.com wrote:
- switch (mode)
- {
- case D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR:
- case D2D1_BITMAP_INTERPOLATION_MODE_LINEAR:
break;
- default:
WARN("Unknown interpolation mode %#x.\n", mode);
return;
- }
We indent case labels in d2d1.
@@ -1242,7 +1300,7 @@ static void d2d_brush_bind_bitmap(struct d2d_brush *brush, ID3D10Device *device, { D3D10_SAMPLER_DESC sampler_desc;
if (brush->u.bitmap.interpolation_mode == D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR)
if (brush->u.bitmap.interpolation_mode == D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR) sampler_desc.Filter = D3D10_FILTER_MIN_MAG_MIP_POINT; else sampler_desc.Filter = D3D10_FILTER_MIN_MAG_MIP_LINEAR;
I think it would be helpful to print a FIXME for unimplemented interpolation modes. Either here, or in SetInterpolationMode1().
ID2D1BitmapBrush1_SetInterpolationMode1(brush1, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC);
interpolation_mode = ID2D1BitmapBrush1_GetInterpolationMode(brush1);
ok(interpolation_mode == D2D1_BITMAP_INTERPOLATION_MODE_LINEAR,
"Unexpected interpolation mode %#x.\n", interpolation_mode);
interpolation_mode1 = ID2D1BitmapBrush1_GetInterpolationMode1(brush1);
ok(interpolation_mode1 == D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC,
"Unexpected interpolation mode %#x.\n", interpolation_mode1);
ID2D1BitmapBrush1_SetInterpolationMode1(brush1, 100);
interpolation_mode1 = ID2D1BitmapBrush1_GetInterpolationMode1(brush1);
ok(interpolation_mode1 == D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC,
"Unexpected interpolation mode %#x.\n", interpolation_mode1);
I think the choice of interpolation modes and ordering of these is a little unfortunate. It's not clear from the test whether "SetInterpolationMode1(..., 100);" is ignored as you'd expect, or clamped to D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/brush.c | 5 +++-- dlls/d2d1/d2d1_private.h | 2 +- dlls/d2d1/device.c | 20 ++++++++++++++------ 3 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/dlls/d2d1/brush.c b/dlls/d2d1/brush.c index f2c13d4788..cbc59d15d3 100644 --- a/dlls/d2d1/brush.c +++ b/dlls/d2d1/brush.c @@ -1090,8 +1090,9 @@ static const struct ID2D1BitmapBrush1Vtbl d2d_bitmap_brush_vtbl = d2d_bitmap_brush_GetInterpolationMode1, };
-HRESULT d2d_bitmap_brush_create(ID2D1Factory *factory, ID2D1Bitmap *bitmap, const D2D1_BITMAP_BRUSH_PROPERTIES *bitmap_brush_desc, - const D2D1_BRUSH_PROPERTIES *brush_desc, struct d2d_brush **brush) +HRESULT d2d_bitmap_brush_create(ID2D1Factory *factory, ID2D1Bitmap *bitmap, + const D2D1_BITMAP_BRUSH_PROPERTIES1 *bitmap_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc, + struct d2d_brush **brush) { if (!(*brush = heap_alloc_zero(sizeof(**brush)))) return E_OUTOFMEMORY; diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index c8515eaa12..d7989f93a2 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -295,7 +295,7 @@ HRESULT d2d_radial_gradient_brush_create(ID2D1Factory *factory, const D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES *gradient_desc, const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1GradientStopCollection *gradient, struct d2d_brush **brush) DECLSPEC_HIDDEN; HRESULT d2d_bitmap_brush_create(ID2D1Factory *factory, ID2D1Bitmap *bitmap, - const D2D1_BITMAP_BRUSH_PROPERTIES *bitmap_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc, + const D2D1_BITMAP_BRUSH_PROPERTIES1 *bitmap_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc, struct d2d_brush **brush) DECLSPEC_HIDDEN; void d2d_brush_bind_resources(struct d2d_brush *brush, ID3D10Device *device, unsigned int brush_idx) DECLSPEC_HIDDEN; HRESULT d2d_brush_get_ps_cb(struct d2d_brush *brush, struct d2d_brush *opacity_brush, BOOL outline, diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 041cb33c90..d779fb0a97 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -401,14 +401,15 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateBitmapBrush(ID2D1Devic ID2D1Bitmap *bitmap, const D2D1_BITMAP_BRUSH_PROPERTIES *bitmap_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1BitmapBrush **brush) { - struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface); + struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface); struct d2d_brush *object; HRESULT hr;
TRACE("iface %p, bitmap %p, bitmap_brush_desc %p, brush_desc %p, brush %p.\n", iface, bitmap, bitmap_brush_desc, brush_desc, brush);
- if (SUCCEEDED(hr = d2d_bitmap_brush_create(render_target->factory, bitmap, bitmap_brush_desc, brush_desc, &object))) + if (SUCCEEDED(hr = d2d_bitmap_brush_create(context->factory, bitmap, (const D2D1_BITMAP_BRUSH_PROPERTIES1 *)bitmap_brush_desc, + brush_desc, &object))) *brush = (ID2D1BitmapBrush *)&object->ID2D1Brush_iface;
return hr; @@ -1863,12 +1864,19 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateImageBrush(ID2D1Device
static HRESULT STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_CreateBitmapBrush(ID2D1DeviceContext *iface, ID2D1Bitmap *bitmap, const D2D1_BITMAP_BRUSH_PROPERTIES1 *bitmap_brush_desc, - const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1BitmapBrush1 **bitmap_brush) + const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1BitmapBrush1 **brush) { - FIXME("iface %p, bitmap %p, bitmap_brush_desc %p, brush_desc %p, bitmap_brush %p stub!\n", iface, bitmap, - bitmap_brush_desc, brush_desc, bitmap_brush); + struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface); + struct d2d_brush *object; + HRESULT hr;
- return E_NOTIMPL; + TRACE("iface %p, bitmap %p, bitmap_brush_desc %p, brush_desc %p, brush %p.\n", iface, bitmap, bitmap_brush_desc, + brush_desc, brush); + + if (SUCCEEDED(hr = d2d_bitmap_brush_create(context->factory, bitmap, bitmap_brush_desc, brush_desc, &object))) + *brush = (ID2D1BitmapBrush1 *)&object->ID2D1Brush_iface; + + return hr; }
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateCommandList(ID2D1DeviceContext *iface,