From: Akihiro Sagawa sagawa.aki@gmail.com
--- dlls/d2d1/device.c | 21 +++++++++++++++++++++ dlls/d2d1/tests/d2d1.c | 24 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index f6ff44cd32c..e06bbb32cb1 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -586,6 +586,9 @@ static void STDMETHODCALLTYPE d2d_device_context_DrawLine(ID2D1DeviceContext6 *i TRACE("iface %p, p0 %s, p1 %s, brush %p, stroke_width %.8e, stroke_style %p.\n", iface, debug_d2d_point_2f(&p0), debug_d2d_point_2f(&p1), brush, stroke_width, stroke_style);
+ if (FAILED(context->error.code)) + return; + if (context->target.type == D2D_TARGET_COMMAND_LIST) { d2d_command_list_draw_line(context->target.command_list, context, p0, p1, brush, stroke_width, stroke_style); @@ -626,6 +629,9 @@ static void STDMETHODCALLTYPE d2d_device_context_DrawRectangle(ID2D1DeviceContex TRACE("iface %p, rect %s, brush %p, stroke_width %.8e, stroke_style %p.\n", iface, debug_d2d_rect_f(rect), brush, stroke_width, stroke_style);
+ if (FAILED(context->error.code)) + return; + if (context->target.type == D2D_TARGET_COMMAND_LIST) { d2d_command_list_draw_rectangle(context->target.command_list, context, rect, brush, stroke_width, stroke_style); @@ -677,6 +683,9 @@ static void STDMETHODCALLTYPE d2d_device_context_DrawRoundedRectangle(ID2D1Devic TRACE("iface %p, rect %p, brush %p, stroke_width %.8e, stroke_style %p.\n", iface, rect, brush, stroke_width, stroke_style);
+ if (FAILED(render_target->error.code)) + return; + if (FAILED(hr = ID2D1Factory_CreateRoundedRectangleGeometry(render_target->factory, rect, &geometry))) { ERR("Failed to create geometry, hr %#lx.\n", hr); @@ -716,6 +725,9 @@ static void STDMETHODCALLTYPE d2d_device_context_DrawEllipse(ID2D1DeviceContext6 TRACE("iface %p, ellipse %p, brush %p, stroke_width %.8e, stroke_style %p.\n", iface, ellipse, brush, stroke_width, stroke_style);
+ if (FAILED(render_target->error.code)) + return; + if (FAILED(hr = ID2D1Factory_CreateEllipseGeometry(render_target->factory, ellipse, &geometry))) { ERR("Failed to create geometry, hr %#lx.\n", hr); @@ -961,6 +973,15 @@ static void STDMETHODCALLTYPE d2d_device_context_DrawGeometry(ID2D1DeviceContext TRACE("iface %p, geometry %p, brush %p, stroke_width %.8e, stroke_style %p.\n", iface, geometry, brush, stroke_width, stroke_style);
+ if (FAILED(context->error.code)) + return; + + if (context->target.type == D2D_TARGET_UNKNOWN) + { + d2d_device_context_set_error(context, D2DERR_WRONG_STATE); + return; + } + if (context->target.type == D2D_TARGET_COMMAND_LIST) { d2d_command_list_draw_geometry(context->target.command_list, context, geometry, brush, diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 8e2faf47c42..fe993d11ad1 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -15719,12 +15719,15 @@ static void test_no_target(BOOL d3d11) { D2D1_BITMAP_PROPERTIES bitmap_desc; struct d2d1_test_context ctx; + ID2D1SolidColorBrush *brush; ID2D1DeviceContext *context; D2D1_MATRIX_3X2_F matrix; ID2D1RenderTarget *rt; ID2D1Bitmap *bitmap; ID2D1Device *device; + D2D1_COLOR_F color; D2D1_SIZE_U size; + D2D1_RECT_F rect; D2D1_TAG t1, t2; HRESULT hr;
@@ -15792,6 +15795,27 @@ static void test_no_target(BOOL d3d11)
ID2D1Bitmap_Release(bitmap);
+ /* DrawRectagnle method */ + set_color(&color, 0.0f, 0.0f, 0.0f, 0.0f); + hr = ID2D1RenderTarget_CreateSolidColorBrush(rt, &color, NULL, &brush); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + set_rect(&rect, 0.0f, 0.0f, 1.0f, 1.0f); + + ID2D1RenderTarget_BeginDraw(rt); + + ID2D1RenderTarget_SetTags(rt, 0x30, 0x10); + ID2D1RenderTarget_DrawRectangle(rt, &rect, (ID2D1Brush *)brush, 1.0f, NULL); + + ID2D1RenderTarget_SetTags(rt, 0x30, 0x20); + ID2D1RenderTarget_DrawRectangle(rt, &rect, (ID2D1Brush *)brush, 1.0f, NULL); + + hr = ID2D1RenderTarget_EndDraw(rt, &t1, &t2); + ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#lx.\n", hr); + ok(t1 == 0x30 && t2 == 0x10, "Unexpected tags %s:%s.\n", wine_dbgstr_longlong(t1), wine_dbgstr_longlong(t2)); + + ID2D1SolidColorBrush_Release(brush); + ID2D1RenderTarget_Release(rt); ID2D1DeviceContext_Release(context); ID2D1Device_Release(device);