Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53915 Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
From: Nikolay Sivov nsivov@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53915 Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/device.c | 6 ++++-- dlls/d2d1/state_block.c | 6 +++++- dlls/d2d1/tests/d2d1.c | 10 ++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 72781a48d10..89d17149ca4 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -1735,11 +1735,12 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_Flush(ID2D1DeviceContext1 *i static void STDMETHODCALLTYPE d2d_device_context_SaveDrawingState(ID2D1DeviceContext1 *iface, 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_state_block *state_block_impl;
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; if (render_target->text_rendering_params) IDWriteRenderingParams_AddRef(render_target->text_rendering_params); @@ -1751,11 +1752,12 @@ static void STDMETHODCALLTYPE d2d_device_context_SaveDrawingState(ID2D1DeviceCon static void STDMETHODCALLTYPE d2d_device_context_RestoreDrawingState(ID2D1DeviceContext1 *iface, 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_state_block *state_block_impl;
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) { struct d2d_command_list *command_list = context->target.command_list; diff --git a/dlls/d2d1/state_block.c b/dlls/d2d1/state_block.c index 7415471ce3a..770c165fd90 100644 --- a/dlls/d2d1/state_block.c +++ b/dlls/d2d1/state_block.c @@ -186,6 +186,10 @@ struct d2d_state_block *unsafe_impl_from_ID2D1DrawingStateBlock(ID2D1DrawingStat { if (!iface) 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); } diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 1dcce63381e..d16515480e9 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -1835,6 +1835,7 @@ static void test_state_block(BOOL d3d11) ID2D1Factory *factory; ULONG refcount; HRESULT hr; + void *ptr; static const D2D1_MATRIX_3X2_F identity = {{{ 1.0f, 0.0f, @@ -2078,6 +2079,15 @@ static void test_state_block(BOOL d3d11)
refcount = IDWriteRenderingParams_Release(text_rendering_params1); ok(!refcount, "Rendering params %lu references left.\n", refcount); + + /* State block object pointer is validated, but not does not result in 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); }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=126179
Your paranoid android.
=== debian11 (32 bit report) ===
d3drm: d3drm.c:4776: Test failed: Cannot create IDirect3DRMDevice2 interface, hr 0x8007000e. d3drm.c:4778: Test failed: expected ref3 > ref1, got ref1 = 1 , ref3 = 1. d3drm.c:4782: Test failed: Expected surface_ref2 > surface_ref1, got surface_ref1 = 1, surface_ref2 = 1. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x00410761).
=== debian11 (build log) ===
0544:err:winediag:d3d_device_create The application wants to create a Direct3D device, but the current DirectDrawRenderer does not support this.
Matteo Bruni (@Mystral) commented about dlls/d2d1/tests/d2d1.c:
refcount = IDWriteRenderingParams_Release(text_rendering_params1); ok(!refcount, "Rendering params %lu references left.\n", refcount);
- /* State block object pointer is validated, but not does not result in error state. */
Not that it matters, but typo :)