d2d1: Implement GetImageLocalBounds() for bitmap.
Signed-off-by: Ziqing Hui <zhui@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
1f0b080f15
commit
c037144db7
|
@ -1978,7 +1978,41 @@ static BOOL STDMETHODCALLTYPE d2d_device_context_IsBufferPrecisionSupported(ID2D
|
||||||
static void STDMETHODCALLTYPE d2d_device_context_GetImageLocalBounds(ID2D1DeviceContext *iface,
|
static void STDMETHODCALLTYPE d2d_device_context_GetImageLocalBounds(ID2D1DeviceContext *iface,
|
||||||
ID2D1Image *image, D2D1_RECT_F *local_bounds)
|
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,
|
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);
|
set_rect(&bounds, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
size = ID2D1Bitmap_GetSize(bitmap);
|
size = ID2D1Bitmap_GetSize(bitmap);
|
||||||
ID2D1DeviceContext_GetImageLocalBounds(context, (ID2D1Image *)bitmap, &bounds);
|
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",
|
"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);
|
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_GetDpi(context, &dpi_x, &dpi_y);
|
||||||
ID2D1DeviceContext_SetDpi(context, dpi_x * 2.0f, dpi_y * 2.0f);
|
ID2D1DeviceContext_SetDpi(context, dpi_x * 2.0f, dpi_y * 2.0f);
|
||||||
ID2D1DeviceContext_GetImageLocalBounds(context, (ID2D1Image *)bitmap, &bounds);
|
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",
|
"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);
|
bounds.left, bounds.top, bounds.right, bounds.bottom, 0.0f, 0.0f, size.width, size.height);
|
||||||
ID2D1DeviceContext_SetDpi(context, dpi_x, dpi_y);
|
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);
|
ok(unit_mode == D2D1_UNIT_MODE_DIPS, "Got unexpected unit mode %#x.\n", unit_mode);
|
||||||
ID2D1DeviceContext_SetUnitMode(context, D2D1_UNIT_MODE_PIXELS);
|
ID2D1DeviceContext_SetUnitMode(context, D2D1_UNIT_MODE_PIXELS);
|
||||||
ID2D1DeviceContext_GetImageLocalBounds(context, (ID2D1Image *)bitmap, &bounds);
|
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",
|
"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,
|
bounds.left, bounds.top, bounds.right, bounds.bottom, 0.0f, 0.0f,
|
||||||
(float)test->pixel_size.width, (float)test->pixel_size.height);
|
(float)test->pixel_size.width, (float)test->pixel_size.height);
|
||||||
|
|
Loading…
Reference in New Issue