From: Zhiyi Zhang <zzhang@codeweavers.com> --- dlls/d2d1/d2d1_private.h | 1 + dlls/d2d1/device.c | 24 +++++++++++++++++++----- dlls/d2d1/tests/d2d1.c | 2 -- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 51bf830fc0a..674d32fd581 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -211,6 +211,7 @@ struct d2d_device_context [D2D_SAMPLER_EXTEND_MODE_COUNT] [D2D_SAMPLER_EXTEND_MODE_COUNT]; + BOOL is_drawing; struct d2d_error_state error; D2D1_DRAWING_STATE_DESCRIPTION1 drawing_state; IDWriteRenderingParams *text_rendering_params; diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index ac1220bc9b3..3a23833df9a 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -2055,6 +2055,13 @@ static void STDMETHODCALLTYPE d2d_device_context_BeginDraw(ID2D1DeviceContext6 * TRACE("iface %p.\n", iface); + if (context->is_drawing) + { + d2d_device_context_set_error(context, D2DERR_WRONG_STATE); + return; + } + context->is_drawing = TRUE; + if (context->target.type == D2D_TARGET_COMMAND_LIST) d2d_command_list_begin_draw(context->target.command_list, context); @@ -2069,17 +2076,24 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_EndDraw(ID2D1DeviceContext6 TRACE("iface %p, tag1 %p, tag2 %p.\n", iface, tag1, tag2); + if (tag1) + *tag1 = context->error.tag1; + if (tag2) + *tag2 = context->error.tag2; + + if (!context->is_drawing) + { + d2d_device_context_set_error(context, D2DERR_WRONG_STATE); + return context->error.code; + } + context->is_drawing = FALSE; + if (context->target.type == D2D_TARGET_COMMAND_LIST) { FIXME("Unimplemented for command list target.\n"); return E_NOTIMPL; } - if (tag1) - *tag1 = context->error.tag1; - if (tag2) - *tag2 = context->error.tag2; - if (context->ops && context->ops->device_context_present) { if (FAILED(hr = context->ops->device_context_present(context->outer_unknown))) diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 86832aae5da..644e291bb03 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -17806,14 +17806,12 @@ static void test_begin_end_draw(BOOL d3d11) /* EndDraw() without BeginDraw() */ hr = ID2D1DeviceContext_EndDraw(context, NULL, NULL); - todo_wine ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#lx.\n", hr); /* BeginDraw() twice */ ID2D1DeviceContext_BeginDraw(context); ID2D1DeviceContext_BeginDraw(context); hr = ID2D1DeviceContext_EndDraw(context, NULL, NULL); - todo_wine ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#lx.\n", hr); /* Normal */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9961