Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/d2d1/device.c | 18 ++++++------------ dlls/d2d1/tests/d2d1.c | 30 ++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 3c8431ce8f4..b609a2c1e24 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -1072,25 +1072,19 @@ static void d2d_device_context_draw_bitmap(struct d2d_device_context *context, I D2D1_BITMAP_BRUSH_PROPERTIES1 bitmap_brush_desc; D2D1_BRUSH_PROPERTIES brush_desc; struct d2d_brush *brush; + D2D1_SIZE_F size; D2D1_RECT_F s, d; HRESULT hr;
if (perspective_transform) FIXME("Perspective transform is ignored.\n");
- if (src_rect) + size = ID2D1Bitmap_GetSize(bitmap); + d2d_rect_set(&s, 0.0f, 0.0f, size.width, size.height); + if (src_rect && src_rect->left <= src_rect->right + && src_rect->top <= src_rect->bottom) { - s = *src_rect; - } - else - { - D2D1_SIZE_F size; - - size = ID2D1Bitmap_GetSize(bitmap); - s.left = 0.0f; - s.top = 0.0f; - s.right = size.width; - s.bottom = size.height; + d2d_rect_intersect(&s, src_rect); }
if (dst_rect) diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index d571cfe8d15..6e3bc4a51d2 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -1676,6 +1676,7 @@ static void test_bitmap_brush(void) IDXGISwapChain *swapchain; ID2D1BitmapBrush1 *brush1; ID2D1BitmapBrush *brush; + D2D1_SIZE_F image_size; ID2D1RenderTarget *rt; ID3D10Device1 *device; IDXGISurface *surface; @@ -1740,6 +1741,7 @@ static void test_bitmap_brush(void) bitmap_desc.dpiY = 96.0f; hr = ID2D1RenderTarget_CreateBitmap(rt, size, bitmap_data, 4 * sizeof(*bitmap_data), &bitmap_desc, &bitmap); ok(SUCCEEDED(hr), "Failed to create bitmap, hr %#x.\n", hr); + image_size = ID2D1Bitmap_GetSize(bitmap);
hr = ID2D1Bitmap_QueryInterface(bitmap, &IID_ID2D1Image, (void **)&image); ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Vista */, "Failed to get ID2D1Image, hr %#x.\n", hr); @@ -1810,12 +1812,24 @@ static void test_bitmap_brush(void) D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, NULL); set_rect(&dst_rect, 0.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_NEAREST_NEIGHBOR, &src_rect); + set_rect(&dst_rect, 4.0f, 12.0f, 12.0f, 20.0f); + set_rect(&src_rect, 0.0f, 0.0f, image_size.width * 2, image_size.height * 2); + ID2D1RenderTarget_DrawBitmap(rt, bitmap, &dst_rect, 1.0f, + D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, &src_rect); + set_rect(&dst_rect, 4.0f, 8.0f, 12.0f, 12.0f); + set_rect(&src_rect, image_size.width / 2, image_size.height / 2, image_size.width, image_size.height); + ID2D1RenderTarget_DrawBitmap(rt, bitmap, &dst_rect, 1.0f, + D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, &src_rect); + set_rect(&dst_rect, 0.0f, 4.0f, 4.0f, 8.0f); + set_rect(&src_rect, image_size.width, 0.0f, 0.0f, image_size.height); ID2D1RenderTarget_DrawBitmap(rt, bitmap, &dst_rect, 1.0f, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, &src_rect);
hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL); ok(SUCCEEDED(hr), "Failed to end draw, hr %#x.\n", hr); - match = compare_surface(surface, "9437f4447d98feaad41a1c4202ee90aadc718ee6"); + match = compare_surface(surface, "f5d039c280fa33ba05496c9883192a34108efbbe"); ok(match, "Surface does not match.\n");
/* Invalid interpolation mode. */ @@ -1828,7 +1842,19 @@ static void test_bitmap_brush(void)
hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL); ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); - match = compare_surface(surface, "9437f4447d98feaad41a1c4202ee90aadc718ee6"); + match = compare_surface(surface, "f5d039c280fa33ba05496c9883192a34108efbbe"); + ok(match, "Surface does not match.\n"); + + ID2D1RenderTarget_BeginDraw(rt); + ID2D1RenderTarget_Clear(rt, &color); + + set_rect(&src_rect, image_size.width, 0.0f, 0.0f, image_size.height); + ID2D1RenderTarget_DrawBitmap(rt, bitmap, NULL, 1.0f, + D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, &src_rect); + + hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL); + ok(SUCCEEDED(hr), "Failed to end draw, hr %#x.\n", hr); + match = compare_surface(surface, "59043096393570ad800dbcbfdd644394b79493bd"); ok(match, "Surface does not match.\n");
ID2D1RenderTarget_BeginDraw(rt);
Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/d2d1/device.c | 3 +++ dlls/d2d1/tests/d2d1.c | 5 +++++ 2 files changed, 8 insertions(+)
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index b609a2c1e24..e8bc7207a67 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -1087,6 +1087,9 @@ static void d2d_device_context_draw_bitmap(struct d2d_device_context *context, I d2d_rect_intersect(&s, src_rect); }
+ if (s.left == s.right || s.top == s.bottom) + return; + if (dst_rect) { d = *dst_rect; diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 6e3bc4a51d2..19bb94530c2 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -1835,6 +1835,11 @@ static void test_bitmap_brush(void) /* Invalid interpolation mode. */ ID2D1RenderTarget_BeginDraw(rt);
+ set_rect(&dst_rect, 4.0f, 8.0f, 8.0f, 12.0f); + set_rect(&src_rect, 0.0f, 1.0f, image_size.width, 1.0f); + ID2D1RenderTarget_DrawBitmap(rt, bitmap, &dst_rect, 1.0f, + D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, &src_rect); + 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,
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=84067
Your paranoid android.
=== w2008s64 (32 bit report) ===
d2d1: d2d1: Timeout
=== wvistau64 (64 bit report) ===
d2d1: d2d1: Timeout
=== w2008s64 (64 bit report) ===
d2d1: d2d1: Timeout
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/d2d1/device.c | 34 +++++++++++++++--- dlls/d2d1/tests/d2d1.c | 79 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 108 insertions(+), 5 deletions(-)
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index e8bc7207a67..5f04c3aa833 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -1067,7 +1067,8 @@ static void STDMETHODCALLTYPE d2d_device_context_FillOpacityMask(ID2D1DeviceCont
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) + const D2D1_RECT_F *src_rect, const D2D1_POINT_2F *offset, + const D2D1_MATRIX_4X4_F *perspective_transform) { D2D1_BITMAP_BRUSH_PROPERTIES1 bitmap_brush_desc; D2D1_BRUSH_PROPERTIES brush_desc; @@ -1102,6 +1103,14 @@ static void d2d_device_context_draw_bitmap(struct d2d_device_context *context, I d.bottom = s.bottom - s.top; }
+ if (offset) + { + d.left += offset->x; + d.top += offset->y; + d.right += offset->x; + d.bottom += offset->y; + } + bitmap_brush_desc.extendModeX = D2D1_EXTEND_MODE_CLAMP; bitmap_brush_desc.extendModeY = D2D1_EXTEND_MODE_CLAMP; bitmap_brush_desc.interpolationMode = interpolation_mode; @@ -1141,7 +1150,7 @@ static void STDMETHODCALLTYPE d2d_device_context_DrawBitmap(ID2D1DeviceContext * }
d2d_device_context_draw_bitmap(context, bitmap, dst_rect, opacity, d2d1_1_interp_mode_from_d2d1(interpolation_mode), - src_rect, NULL); + src_rect, NULL, NULL); }
static void STDMETHODCALLTYPE d2d_device_context_DrawText(ID2D1DeviceContext *iface, @@ -2211,9 +2220,26 @@ static void STDMETHODCALLTYPE d2d_device_context_DrawImage(ID2D1DeviceContext *i const D2D1_POINT_2F *target_offset, const D2D1_RECT_F *image_rect, D2D1_INTERPOLATION_MODE interpolation_mode, D2D1_COMPOSITE_MODE composite_mode) { - FIXME("iface %p, image %p, target_offset %s, image_rect %s, interpolation_mode %#x, composite_mode %#x stub!\n", + struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface); + ID2D1Bitmap *bitmap; + + TRACE("iface %p, image %p, target_offset %s, image_rect %s, interpolation_mode %#x, composite_mode %#x.\n", iface, image, debug_d2d_point_2f(target_offset), debug_d2d_rect_f(image_rect), interpolation_mode, composite_mode); + + if (composite_mode != D2D1_COMPOSITE_MODE_SOURCE_OVER) + FIXME("Unhandled composite mode %#x.\n", composite_mode); + + if (SUCCEEDED(ID2D1Image_QueryInterface(image, &IID_ID2D1Bitmap, (void **)&bitmap))) + { + d2d_device_context_draw_bitmap(context, bitmap, NULL, 1.0f, d2d1_1_interp_mode_from_d2d1(interpolation_mode), + image_rect, target_offset, NULL); + + ID2D1Bitmap_Release(bitmap); + return; + } + + FIXME("Unhandled image %p.\n", image); }
static void STDMETHODCALLTYPE d2d_device_context_DrawGdiMetafile(ID2D1DeviceContext *iface, @@ -2235,7 +2261,7 @@ static void STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_DrawBitmap(I debug_d2d_rect_f(src_rect), perspective_transform);
d2d_device_context_draw_bitmap(context, bitmap, dst_rect, opacity, interpolation_mode, src_rect, - perspective_transform); + NULL, perspective_transform); }
static void STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_PushLayer(ID2D1DeviceContext *iface, diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 19bb94530c2..8627f5ebef6 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -1746,7 +1746,84 @@ static void test_bitmap_brush(void) hr = ID2D1Bitmap_QueryInterface(bitmap, &IID_ID2D1Image, (void **)&image); ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Vista */, "Failed to get ID2D1Image, hr %#x.\n", hr); if (hr == S_OK) - ID2D1Image_Release(image); + { + ID2D1DeviceContext *context; + D2D1_POINT_2F offset; + D2D1_RECT_F src_rect; + + hr = ID2D1RenderTarget_QueryInterface(rt, &IID_ID2D1DeviceContext, (void **)&context); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + ID2D1RenderTarget_BeginDraw(rt); + set_color(&color, 0.0f, 0.0f, 1.0f, 1.0f); + ID2D1RenderTarget_Clear(rt, &color); + + ID2D1RenderTarget_GetTransform(rt, &tmp_matrix); + set_matrix_identity(&matrix); + translate_matrix(&matrix, 20.0f, 12.0f); + scale_matrix(&matrix, 2.0f, 6.0f); + ID2D1RenderTarget_SetTransform(rt, &matrix); + + /* Crash on Windows 7+ */ + if (0) + { + ID2D1DeviceContext_DrawImage(context, NULL, NULL, NULL, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, + D2D1_COMPOSITE_MODE_SOURCE_OVER); + } + + ID2D1DeviceContext_DrawImage(context, image, NULL, NULL, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, + D2D1_COMPOSITE_MODE_SOURCE_OVER); + + set_rect(&src_rect, 0.0f, 0.0f, image_size.width, image_size.height); + + ID2D1DeviceContext_DrawImage(context, image, NULL, &src_rect, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, + D2D1_COMPOSITE_MODE_SOURCE_OVER); + + offset.x = -1; + offset.y = -1; + ID2D1DeviceContext_DrawImage(context, image, &offset, NULL, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, + D2D1_COMPOSITE_MODE_SOURCE_OVER); + + offset.x = image_size.width * 2; + offset.y = image_size.height; + ID2D1DeviceContext_DrawImage(context, image, &offset, NULL, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, + D2D1_COMPOSITE_MODE_SOURCE_OVER); + + offset.x = image_size.width * 3; + set_rect(&src_rect, image_size.width / 2, image_size.height / 2, image_size.width, image_size.height); + ID2D1DeviceContext_DrawImage(context, image, &offset, &src_rect, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, + D2D1_COMPOSITE_MODE_SOURCE_OVER); + + offset.x = image_size.width * 4; + set_rect(&src_rect, 0.0f, 0.0f, image_size.width * 2, image_size.height * 2); + ID2D1DeviceContext_DrawImage(context, image, &offset, &src_rect, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, + D2D1_COMPOSITE_MODE_SOURCE_OVER); + + offset.x = image_size.width * 5; + set_rect(&src_rect, image_size.width, image_size.height, 0.0f, 0.0f); + ID2D1DeviceContext_DrawImage(context, image, &offset, &src_rect, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, + D2D1_COMPOSITE_MODE_SOURCE_OVER); + + hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL); + ok(SUCCEEDED(hr), "Failed to end draw, hr %#x.\n", hr); + match = compare_surface(surface, "95675fbc4a16404c9568d41b14e8f6be64240998"); + ok(match, "Surface does not match.\n"); + + ID2D1RenderTarget_BeginDraw(rt); + + offset.x = image_size.width * 6; + set_rect(&src_rect, 1.0f, 0.0f, 1.0f, image_size.height); + ID2D1DeviceContext_DrawImage(context, image, &offset, &src_rect, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, + D2D1_COMPOSITE_MODE_SOURCE_OVER); + + hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL); + ok(SUCCEEDED(hr), "Failed to end draw, hr %#x.\n", hr); + match = compare_surface(surface, "95675fbc4a16404c9568d41b14e8f6be64240998"); + ok(match, "Surface does not match.\n"); + + ID2D1RenderTarget_SetTransform(rt, &tmp_matrix); + ID2D1DeviceContext_Release(context); + }
/* Creating a brush with a NULL bitmap crashes on Vista, but works fine on * Windows 7+. */
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=84068
Your paranoid android.
=== w2008s64 (32 bit report) ===
d2d1: d2d1: Timeout
=== wvistau64 (64 bit report) ===
d2d1: d2d1: Timeout
=== w2008s64 (64 bit report) ===
d2d1: d2d1: Timeout
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=84066
Your paranoid android.
=== w2008s64 (32 bit report) ===
d2d1: d2d1: Timeout
=== wvistau64 (64 bit report) ===
d2d1: d2d1: Timeout
=== w2008s64 (64 bit report) ===
d2d1: d2d1: Timeout