From: Akihiro Sagawa sagawa.aki@gmail.com
--- dlls/d2d1/device.c | 27 +++++++++++++++++++++++++++ dlls/d2d1/tests/d2d1.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+)
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index d9494d4f90b..f6ff44cd32c 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -1216,6 +1216,15 @@ static void STDMETHODCALLTYPE d2d_device_context_DrawBitmap(ID2D1DeviceContext6 TRACE("iface %p, bitmap %p, dst_rect %s, opacity %.8e, interpolation_mode %#x, src_rect %s.\n", iface, bitmap, debug_d2d_rect_f(dst_rect), opacity, interpolation_mode, debug_d2d_rect_f(src_rect));
+ if (FAILED(context->error.code)) + return; + + if (context->target.type == D2D_TARGET_UNKNOWN) + { + d2d_device_context_set_error(context, D2DERR_WRONG_STATE); + return; + } + if (interpolation_mode != D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR && interpolation_mode != D2D1_BITMAP_INTERPOLATION_MODE_LINEAR) { @@ -2559,6 +2568,15 @@ static void STDMETHODCALLTYPE d2d_device_context_DrawImage(ID2D1DeviceContext6 * iface, image, debug_d2d_point_2f(target_offset), debug_d2d_rect_f(image_rect), interpolation_mode, composite_mode);
+ 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_image(context->target.command_list, image, target_offset, image_rect, @@ -2598,6 +2616,15 @@ static void STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_DrawBitmap(I iface, bitmap, debug_d2d_rect_f(dst_rect), opacity, interpolation_mode, debug_d2d_rect_f(src_rect), perspective_transform);
+ 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_bitmap(context->target.command_list, bitmap, dst_rect, opacity, interpolation_mode, diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 215e3f2bea7..8e2faf47c42 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -15717,11 +15717,14 @@ static void test_get_dxgi_device(BOOL d3d11)
static void test_no_target(BOOL d3d11) { + D2D1_BITMAP_PROPERTIES bitmap_desc; struct d2d1_test_context ctx; ID2D1DeviceContext *context; D2D1_MATRIX_3X2_F matrix; ID2D1RenderTarget *rt; + ID2D1Bitmap *bitmap; ID2D1Device *device; + D2D1_SIZE_U size; D2D1_TAG t1, t2; HRESULT hr;
@@ -15763,6 +15766,32 @@ static void test_no_target(BOOL d3d11) ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#lx.\n", hr); ok(t1 == 0x10 && t2 == 0x20, "Unexpected tags %s:%s.\n", wine_dbgstr_longlong(t1), wine_dbgstr_longlong(t2));
+ /* DrawBitmap method */ + set_size_u(&size, 4, 4); + bitmap_desc.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM; + bitmap_desc.pixelFormat.alphaMode = D2D1_ALPHA_MODE_IGNORE; + bitmap_desc.dpiX = 96.0f; + bitmap_desc.dpiY = 96.0f; + hr = ID2D1RenderTarget_CreateBitmap(rt, size, NULL, 0, &bitmap_desc, &bitmap); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + ID2D1RenderTarget_BeginDraw(rt); + + ID2D1DeviceContext_SetTags(context, 0x20, 0x10); + ID2D1DeviceContext_SetPrimitiveBlend(context, D2D1_PRIMITIVE_BLEND_SOURCE_OVER); + + ID2D1RenderTarget_SetTags(rt, 0x20, 0x20); + ID2D1RenderTarget_DrawBitmap(rt, bitmap, NULL, 1.0f, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, NULL); + + ID2D1RenderTarget_SetTags(rt, 0x20, 0x30); + ID2D1RenderTarget_DrawBitmap(rt, bitmap, NULL, 1.0f, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, NULL); + + hr = ID2D1RenderTarget_EndDraw(rt, &t1, &t2); + ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#lx.\n", hr); + ok(t1 == 0x20 && t2 == 0x20, "Unexpected tags %s:%s.\n", wine_dbgstr_longlong(t1), wine_dbgstr_longlong(t2)); + + ID2D1Bitmap_Release(bitmap); + ID2D1RenderTarget_Release(rt); ID2D1DeviceContext_Release(context); ID2D1Device_Release(device);