From: Akihiro Sagawa sagawa.aki@gmail.com
--- dlls/d2d1/device.c | 27 +++++++++++++++++++++++++++ dlls/d2d1/tests/d2d1.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 58 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 70bb53d3bad..8674a403023 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -15717,10 +15717,13 @@ static void test_get_dxgi_device(BOOL d3d11)
static void test_no_target(BOOL d3d11) { + D2D1_BITMAP_PROPERTIES1 bitmap_desc; ID2D1DeviceContext *context; D2D1_MATRIX_3X2_F matrix; IDXGIDevice *dxgi_device; + ID2D1Bitmap1 *bitmap; ID2D1Device *device; + D2D1_SIZE_U size; D2D1_TAG t1, t2; HRESULT hr;
@@ -15756,6 +15759,34 @@ 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; + bitmap_desc.bitmapOptions = D2D1_BITMAP_OPTIONS_NONE; + bitmap_desc.colorContext = NULL; + hr = ID2D1DeviceContext_CreateBitmap(context, size, NULL, 0, &bitmap_desc, &bitmap); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + ID2D1DeviceContext_BeginDraw(context); + + ID2D1DeviceContext_SetTags(context, 0x20, 0x10); + ID2D1DeviceContext_SetPrimitiveBlend(context, D2D1_PRIMITIVE_BLEND_SOURCE_OVER); + + ID2D1DeviceContext_SetTags(context, 0x20, 0x20); + ID2D1DeviceContext_DrawBitmap(context, (ID2D1Bitmap *)bitmap, NULL, 1.0f, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, NULL, NULL); + + ID2D1DeviceContext_SetTags(context, 0x20, 0x30); + ID2D1DeviceContext_DrawBitmap(context, (ID2D1Bitmap *)bitmap, NULL, 1.0f, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, NULL, NULL); + + hr = ID2D1DeviceContext_EndDraw(context, &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)); + + ID2D1Bitmap1_Release(bitmap); + ID2D1DeviceContext_Release(context); ID2D1Device_Release(device); IDXGIDevice_Release(dxgi_device);