Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/brush.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/d2d1/brush.c b/dlls/d2d1/brush.c index 9c73ae1d88..dd3da32610 100644 --- a/dlls/d2d1/brush.c +++ b/dlls/d2d1/brush.c @@ -1113,7 +1113,7 @@ HRESULT d2d_bitmap_brush_create(ID2D1Factory *factory, ID2D1Bitmap *bitmap, { (*brush)->u.bitmap.extend_mode_x = D2D1_EXTEND_MODE_CLAMP; (*brush)->u.bitmap.extend_mode_y = D2D1_EXTEND_MODE_CLAMP; - (*brush)->u.bitmap.interpolation_mode = D2D1_BITMAP_INTERPOLATION_MODE_LINEAR; + (*brush)->u.bitmap.interpolation_mode = D2D1_INTERPOLATION_MODE_LINEAR; }
TRACE("Created brush %p.\n", *brush);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- 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 45b22584cb..75357b6e43 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 0bea1c80a8..3b824709f2 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);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
On Thu, 4 Oct 2018 at 15:08, Nikolay Sivov nsivov@codeweavers.com wrote:
@@ -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;
- }
I think a helper for setting an error on the context would be helpful. If I understood the way it's supposed to work correctly, we shouldn't overwrite any existing errors, and copy the current tags when we do set an error code. I think d2d_device_context_FillGeometry() is the only place that actually does that, so this patch isn't making things all that much worse, but it seems like a good thing to improve.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/device.c | 56 +++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 20 deletions(-)
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 75357b6e43..bfd14948b0 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -1002,26 +1002,18 @@ static void STDMETHODCALLTYPE d2d_device_context_FillOpacityMask(ID2D1DeviceCont iface, mask, brush, content, debug_d2d_rect_f(dst_rect), debug_d2d_rect_f(src_rect)); }
-static void STDMETHODCALLTYPE d2d_device_context_DrawBitmap(ID2D1DeviceContext *iface, - ID2D1Bitmap *bitmap, const D2D1_RECT_F *dst_rect, float opacity, - D2D1_BITMAP_INTERPOLATION_MODE interpolation_mode, const D2D1_RECT_F *src_rect) +static void d2d_device_context_draw_bitmap(struct d2d_device_context *context, ID2D1Bitmap *bitmap, + const D2D1_RECT_F *dst_rect, float opacity, D2D1_INTERPOLATION_MODE interpolation_mode, + const D2D1_RECT_F *src_rect, const D2D1_MATRIX_4X4_F *perspective_transform) { - struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface); - D2D1_BITMAP_BRUSH_PROPERTIES bitmap_brush_desc; + D2D1_BITMAP_BRUSH_PROPERTIES1 bitmap_brush_desc; D2D1_BRUSH_PROPERTIES brush_desc; - ID2D1BitmapBrush *brush; + struct d2d_brush *brush; D2D1_RECT_F s, d; HRESULT hr;
- 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 (perspective_transform) + FIXME("Perspective transform is ignored.\n");
if (src_rect) { @@ -1062,14 +1054,33 @@ static void STDMETHODCALLTYPE d2d_device_context_DrawBitmap(ID2D1DeviceContext * brush_desc.transform._22 = fabsf((d.bottom - d.top) / (s.bottom - s.top)); brush_desc.transform._32 = min(d.top, d.bottom) - min(s.top, s.bottom) * brush_desc.transform._22;
- if (FAILED(hr = d2d_device_context_CreateBitmapBrush(iface, bitmap, &bitmap_brush_desc, &brush_desc, &brush))) + if (FAILED(hr = d2d_bitmap_brush_create(context->factory, bitmap, &bitmap_brush_desc, &brush_desc, &brush))) { ERR("Failed to create bitmap brush, hr %#x.\n", hr); return; }
- d2d_device_context_FillRectangle(iface, &d, (ID2D1Brush *)brush); - ID2D1BitmapBrush_Release(brush); + d2d_device_context_FillRectangle(&context->ID2D1DeviceContext_iface, &d, &brush->ID2D1Brush_iface); + ID2D1Brush_Release(&brush->ID2D1Brush_iface); +} + +static void STDMETHODCALLTYPE d2d_device_context_DrawBitmap(ID2D1DeviceContext *iface, + 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); + + 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; + } + + d2d_device_context_draw_bitmap(context, bitmap, dst_rect, opacity, interpolation_mode, src_rect, NULL); }
static void STDMETHODCALLTYPE d2d_device_context_DrawText(ID2D1DeviceContext *iface, @@ -2154,10 +2165,15 @@ static void STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_DrawBitmap(I ID2D1Bitmap *bitmap, const D2D1_RECT_F *dst_rect, float opacity, D2D1_INTERPOLATION_MODE interpolation_mode, const D2D1_RECT_F *src_rect, const D2D1_MATRIX_4X4_F *perspective_transform) { - FIXME("iface %p, bitmap %p, dst_rect %s, opacity %.8e, interpolation_mode %#x, " - "src_rect %s, perspective_transform %p stub!\n", + struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface); + + TRACE("iface %p, bitmap %p, dst_rect %s, opacity %.8e, interpolation_mode %#x, " + "src_rect %s, perspective_transform %p.\n", iface, bitmap, debug_d2d_rect_f(dst_rect), opacity, interpolation_mode, debug_d2d_rect_f(src_rect), perspective_transform); + + d2d_device_context_draw_bitmap(context, bitmap, dst_rect, opacity, interpolation_mode, src_rect, + perspective_transform); }
static void STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_PushLayer(ID2D1DeviceContext *iface,
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com