Commit 798d659f authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d2d1: Silently ignore non-default state block implementations.

parent f63f0d3b
...@@ -1735,11 +1735,12 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_Flush(ID2D1DeviceContext1 *i ...@@ -1735,11 +1735,12 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_Flush(ID2D1DeviceContext1 *i
static void STDMETHODCALLTYPE d2d_device_context_SaveDrawingState(ID2D1DeviceContext1 *iface, static void STDMETHODCALLTYPE d2d_device_context_SaveDrawingState(ID2D1DeviceContext1 *iface,
ID2D1DrawingStateBlock *state_block) ID2D1DrawingStateBlock *state_block)
{ {
struct d2d_state_block *state_block_impl = unsafe_impl_from_ID2D1DrawingStateBlock(state_block);
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface); struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
struct d2d_state_block *state_block_impl;
TRACE("iface %p, state_block %p.\n", iface, state_block); TRACE("iface %p, state_block %p.\n", iface, state_block);
if (!(state_block_impl = unsafe_impl_from_ID2D1DrawingStateBlock(state_block))) return;
state_block_impl->drawing_state = render_target->drawing_state; state_block_impl->drawing_state = render_target->drawing_state;
if (render_target->text_rendering_params) if (render_target->text_rendering_params)
IDWriteRenderingParams_AddRef(render_target->text_rendering_params); IDWriteRenderingParams_AddRef(render_target->text_rendering_params);
...@@ -1751,11 +1752,12 @@ static void STDMETHODCALLTYPE d2d_device_context_SaveDrawingState(ID2D1DeviceCon ...@@ -1751,11 +1752,12 @@ static void STDMETHODCALLTYPE d2d_device_context_SaveDrawingState(ID2D1DeviceCon
static void STDMETHODCALLTYPE d2d_device_context_RestoreDrawingState(ID2D1DeviceContext1 *iface, static void STDMETHODCALLTYPE d2d_device_context_RestoreDrawingState(ID2D1DeviceContext1 *iface,
ID2D1DrawingStateBlock *state_block) ID2D1DrawingStateBlock *state_block)
{ {
struct d2d_state_block *state_block_impl = unsafe_impl_from_ID2D1DrawingStateBlock(state_block);
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface); struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
struct d2d_state_block *state_block_impl;
TRACE("iface %p, state_block %p.\n", iface, state_block); TRACE("iface %p, state_block %p.\n", iface, state_block);
if (!(state_block_impl = unsafe_impl_from_ID2D1DrawingStateBlock(state_block))) return;
if (context->target.type == D2D_TARGET_COMMAND_LIST) if (context->target.type == D2D_TARGET_COMMAND_LIST)
{ {
struct d2d_command_list *command_list = context->target.command_list; struct d2d_command_list *command_list = context->target.command_list;
......
...@@ -186,6 +186,10 @@ struct d2d_state_block *unsafe_impl_from_ID2D1DrawingStateBlock(ID2D1DrawingStat ...@@ -186,6 +186,10 @@ struct d2d_state_block *unsafe_impl_from_ID2D1DrawingStateBlock(ID2D1DrawingStat
{ {
if (!iface) if (!iface)
return NULL; return NULL;
assert(iface->lpVtbl == (ID2D1DrawingStateBlockVtbl *)&d2d_state_block_vtbl); if (iface->lpVtbl != (ID2D1DrawingStateBlockVtbl *)&d2d_state_block_vtbl)
{
WARN("Unexpected state block vtbl %p.\n", iface->lpVtbl);
return NULL;
}
return CONTAINING_RECORD(iface, struct d2d_state_block, ID2D1DrawingStateBlock1_iface); return CONTAINING_RECORD(iface, struct d2d_state_block, ID2D1DrawingStateBlock1_iface);
} }
...@@ -1835,6 +1835,7 @@ static void test_state_block(BOOL d3d11) ...@@ -1835,6 +1835,7 @@ static void test_state_block(BOOL d3d11)
ID2D1Factory *factory; ID2D1Factory *factory;
ULONG refcount; ULONG refcount;
HRESULT hr; HRESULT hr;
void *ptr;
static const D2D1_MATRIX_3X2_F identity = static const D2D1_MATRIX_3X2_F identity =
{{{ {{{
1.0f, 0.0f, 1.0f, 0.0f,
...@@ -2078,6 +2079,15 @@ static void test_state_block(BOOL d3d11) ...@@ -2078,6 +2079,15 @@ static void test_state_block(BOOL d3d11)
refcount = IDWriteRenderingParams_Release(text_rendering_params1); refcount = IDWriteRenderingParams_Release(text_rendering_params1);
ok(!refcount, "Rendering params %lu references left.\n", refcount); ok(!refcount, "Rendering params %lu references left.\n", refcount);
/* State block object pointer is validated, but does not result in an error state. */
ptr = (void *)0xdeadbeef;
ID2D1RenderTarget_BeginDraw(rt);
ID2D1RenderTarget_SaveDrawingState(rt, (ID2D1DrawingStateBlock *)&ptr);
ID2D1RenderTarget_RestoreDrawingState(rt, (ID2D1DrawingStateBlock *)&ptr);
hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
release_test_context(&ctx); release_test_context(&ctx);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment