Module: wine Branch: master Commit: 56703ff9a6ac6104e692b34544d8c3be572404de URL: https://source.winehq.org/git/wine.git/?a=commit;h=56703ff9a6ac6104e692b3454...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Thu Oct 4 14:37:33 2018 +0300
d2d1: Handle invalid interpolation mode in DrawBitmap().
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/d2d1/device.c | 8 ++++++++ dlls/d2d1/tests/d2d1.c | 13 +++++++++++++ 2 files changed, 21 insertions(+)
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 45b2258..75357b6 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -1006,6 +1006,7 @@ static void STDMETHODCALLTYPE d2d_device_context_DrawBitmap(ID2D1DeviceContext * ID2D1Bitmap *bitmap, const D2D1_RECT_F *dst_rect, float opacity, D2D1_BITMAP_INTERPOLATION_MODE interpolation_mode, const D2D1_RECT_F *src_rect) { + struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface); D2D1_BITMAP_BRUSH_PROPERTIES bitmap_brush_desc; D2D1_BRUSH_PROPERTIES brush_desc; ID2D1BitmapBrush *brush; @@ -1015,6 +1016,13 @@ static void STDMETHODCALLTYPE d2d_device_context_DrawBitmap(ID2D1DeviceContext * 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 (interpolation_mode != D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR + && interpolation_mode != D2D1_BITMAP_INTERPOLATION_MODE_LINEAR) + { + context->error.code = E_INVALIDARG; + return; + } + if (src_rect) { s = *src_rect; diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 0bea1c8..3b82470 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -1815,6 +1815,19 @@ static void test_bitmap_brush(void) match = compare_surface(surface, "9437f4447d98feaad41a1c4202ee90aadc718ee6"); ok(match, "Surface does not match.\n");
+ /* Invalid interpolation mode. */ + ID2D1RenderTarget_BeginDraw(rt); + + set_rect(&dst_rect, 1.0f, 8.0f, 4.0f, 12.0f); + set_rect(&src_rect, 2.0f, 1.0f, 4.0f, 3.0f); + ID2D1RenderTarget_DrawBitmap(rt, bitmap, &dst_rect, 1.0f, + D2D1_BITMAP_INTERPOLATION_MODE_LINEAR + 1, &src_rect); + + hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + match = compare_surface(surface, "9437f4447d98feaad41a1c4202ee90aadc718ee6"); + ok(match, "Surface does not match.\n"); + ID2D1RenderTarget_BeginDraw(rt);
ID2D1RenderTarget_Clear(rt, &color);