Commit c037144d authored by Ziqing Hui's avatar Ziqing Hui Committed by Alexandre Julliard

d2d1: Implement GetImageLocalBounds() for bitmap.

parent 1f0b080f
......@@ -1978,7 +1978,41 @@ static BOOL STDMETHODCALLTYPE d2d_device_context_IsBufferPrecisionSupported(ID2D
static void STDMETHODCALLTYPE d2d_device_context_GetImageLocalBounds(ID2D1DeviceContext *iface,
ID2D1Image *image, D2D1_RECT_F *local_bounds)
{
FIXME("iface %p, image %p, local_bounds %p stub!\n", iface, image, local_bounds);
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
D2D_SIZE_U pixel_size;
ID2D1Bitmap *bitmap;
D2D_SIZE_F size;
TRACE("iface %p, image %p, local_bounds %p.\n", iface, image, local_bounds);
if (SUCCEEDED(ID2D1Image_QueryInterface(image, &IID_ID2D1Bitmap, (void **)&bitmap)))
{
local_bounds->left = 0.0f;
local_bounds->top = 0.0f;
switch (context->drawing_state.unitMode)
{
case D2D1_UNIT_MODE_DIPS:
size = ID2D1Bitmap_GetSize(bitmap);
local_bounds->right = size.width;
local_bounds->bottom = size.height;
break;
case D2D1_UNIT_MODE_PIXELS:
pixel_size = ID2D1Bitmap_GetPixelSize(bitmap);
local_bounds->right = pixel_size.width;
local_bounds->bottom = pixel_size.height;
break;
default:
WARN("Unknown unit mode %#x.\n", context->drawing_state.unitMode);
break;
}
ID2D1Bitmap_Release(bitmap);
}
else
{
FIXME("Unable to get local bounds of image %p.\n", image);
}
}
static HRESULT STDMETHODCALLTYPE d2d_device_context_GetImageWorldBounds(ID2D1DeviceContext *iface,
......
......@@ -10824,7 +10824,7 @@ static void test_image_bounds(BOOL d3d11)
set_rect(&bounds, 0.0f, 0.0f, 0.0f, 0.0f);
size = ID2D1Bitmap_GetSize(bitmap);
ID2D1DeviceContext_GetImageLocalBounds(context, (ID2D1Image *)bitmap, &bounds);
todo_wine ok(compare_rect(&bounds, 0.0f, 0.0f, size.width, size.height, 0),
ok(compare_rect(&bounds, 0.0f, 0.0f, size.width, size.height, 0),
"Got unexpected bounds {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
bounds.left, bounds.top, bounds.right, bounds.bottom, 0.0f, 0.0f, size.width, size.height);
......@@ -10832,7 +10832,7 @@ static void test_image_bounds(BOOL d3d11)
ID2D1DeviceContext_GetDpi(context, &dpi_x, &dpi_y);
ID2D1DeviceContext_SetDpi(context, dpi_x * 2.0f, dpi_y * 2.0f);
ID2D1DeviceContext_GetImageLocalBounds(context, (ID2D1Image *)bitmap, &bounds);
todo_wine ok(compare_rect(&bounds, 0.0f, 0.0f, size.width, size.height, 0),
ok(compare_rect(&bounds, 0.0f, 0.0f, size.width, size.height, 0),
"Got unexpected bounds {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
bounds.left, bounds.top, bounds.right, bounds.bottom, 0.0f, 0.0f, size.width, size.height);
ID2D1DeviceContext_SetDpi(context, dpi_x, dpi_y);
......@@ -10842,7 +10842,8 @@ static void test_image_bounds(BOOL d3d11)
ok(unit_mode == D2D1_UNIT_MODE_DIPS, "Got unexpected unit mode %#x.\n", unit_mode);
ID2D1DeviceContext_SetUnitMode(context, D2D1_UNIT_MODE_PIXELS);
ID2D1DeviceContext_GetImageLocalBounds(context, (ID2D1Image *)bitmap, &bounds);
todo_wine ok(compare_rect(&bounds, 0.0f, 0.0f, test->pixel_size.width, test->pixel_size.height, 0),
todo_wine_if(!compare_float(test->dpi_x, 96.0f, 0) || !compare_float(test->dpi_y, 96.0f, 0))
ok(compare_rect(&bounds, 0.0f, 0.0f, test->pixel_size.width, test->pixel_size.height, 0),
"Got unexpected bounds {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
bounds.left, bounds.top, bounds.right, bounds.bottom, 0.0f, 0.0f,
(float)test->pixel_size.width, (float)test->pixel_size.height);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment