Commit bc47dc3f authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d2d1: Implement d2d_layer_GetSize().

parent 6d638b9e
......@@ -242,9 +242,10 @@ struct d2d_layer
LONG refcount;
ID2D1Factory *factory;
D2D1_SIZE_F size;
};
HRESULT d2d_layer_create(ID2D1Factory *factory, struct d2d_layer **layer) DECLSPEC_HIDDEN;
HRESULT d2d_layer_create(ID2D1Factory *factory, const D2D1_SIZE_F *size, struct d2d_layer **layer) DECLSPEC_HIDDEN;
struct d2d_mesh
{
......
......@@ -84,10 +84,11 @@ static void STDMETHODCALLTYPE d2d_layer_GetFactory(ID2D1Layer *iface, ID2D1Facto
static D2D1_SIZE_F * STDMETHODCALLTYPE d2d_layer_GetSize(ID2D1Layer *iface, D2D1_SIZE_F *size)
{
FIXME("iface %p, size %p stub!\n", iface, size);
struct d2d_layer *layer = impl_from_ID2D1Layer(iface);
TRACE("iface %p, size %p.\n", iface, size);
size->width = 0;
size->height = 0;
*size = layer->size;
return size;
}
......@@ -100,7 +101,7 @@ static const struct ID2D1LayerVtbl d2d_layer_vtbl =
d2d_layer_GetSize,
};
HRESULT d2d_layer_create(ID2D1Factory *factory, struct d2d_layer **layer)
HRESULT d2d_layer_create(ID2D1Factory *factory, const D2D1_SIZE_F *size, struct d2d_layer **layer)
{
if (!(*layer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(**layer))))
return E_OUTOFMEMORY;
......@@ -108,6 +109,8 @@ HRESULT d2d_layer_create(ID2D1Factory *factory, struct d2d_layer **layer)
(*layer)->ID2D1Layer_iface.lpVtbl = &d2d_layer_vtbl;
(*layer)->refcount = 1;
ID2D1Factory_AddRef((*layer)->factory = factory);
if (size)
(*layer)->size = *size;
TRACE("Created layer %p.\n", *layer);
......
......@@ -464,7 +464,7 @@ static HRESULT STDMETHODCALLTYPE d2d_d3d_render_target_CreateLayer(ID2D1RenderTa
TRACE("iface %p, size %p, layer %p.\n", iface, size, layer);
if (SUCCEEDED(hr = d2d_layer_create(render_target->factory, &object)))
if (SUCCEEDED(hr = d2d_layer_create(render_target->factory, size, &object)))
*layer = &object->ID2D1Layer_iface;
return hr;
......
......@@ -4536,6 +4536,7 @@ static void test_layer(void)
ID3D10Device1 *device;
IDXGISurface *surface;
ID2D1Layer *layer;
D2D1_SIZE_F size;
ULONG refcount;
HWND window;
HRESULT hr;
......@@ -4561,6 +4562,17 @@ static void test_layer(void)
ID2D1Layer_GetFactory(layer, &layer_factory);
ok(layer_factory == factory, "Got unexpected layer factory %p, expected %p.\n", layer_factory, factory);
ID2D1Factory_Release(layer_factory);
size = ID2D1Layer_GetSize(layer);
ok(size.width == 0.0f, "Got unexpected width %.8e.\n", size.width);
ok(size.height == 0.0f, "Got unexpected height %.8e.\n", size.height);
ID2D1Layer_Release(layer);
set_size_f(&size, 800.0f, 600.0f);
hr = ID2D1RenderTarget_CreateLayer(rt, &size, &layer);
ok(SUCCEEDED(hr), "Failed to create layer, hr %#x.\n", hr);
size = ID2D1Layer_GetSize(layer);
ok(size.width == 800.0f, "Got unexpected width %.8e.\n", size.width);
ok(size.height == 600.0f, "Got unexpected height %.8e.\n", size.height);
ID2D1Layer_Release(layer);
ID2D1RenderTarget_Release(rt);
......
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