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

d2d1: Implement d2d_factory_CreateTransformedGeometry().

parent 69906b59
......@@ -249,6 +249,8 @@ struct d2d_geometry
ID2D1Factory *factory;
D2D_MATRIX_3X2_F transform;
D2D1_POINT_2F *vertices;
size_t vertex_count;
......@@ -277,12 +279,18 @@ struct d2d_geometry
{
D2D1_RECT_F rect;
} rectangle;
struct
{
ID2D1Geometry *src_geometry;
} transformed;
} u;
};
void d2d_path_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *factory) DECLSPEC_HIDDEN;
HRESULT d2d_rectangle_geometry_init(struct d2d_geometry *geometry,
ID2D1Factory *factory, const D2D1_RECT_F *rect) DECLSPEC_HIDDEN;
void d2d_transformed_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *factory,
ID2D1Geometry *src_geometry, const D2D_MATRIX_3X2_F *transform) DECLSPEC_HIDDEN;
struct d2d_geometry *unsafe_impl_from_ID2D1Geometry(ID2D1Geometry *iface) DECLSPEC_HIDDEN;
static inline void d2d_matrix_multiply(D2D_MATRIX_3X2_F *a, const D2D_MATRIX_3X2_F *b)
......
......@@ -150,10 +150,20 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateTransformedGeometry(ID2D1Fact
ID2D1Geometry *src_geometry, const D2D1_MATRIX_3X2_F *transform,
ID2D1TransformedGeometry **transformed_geometry)
{
FIXME("iface %p, src_geometry %p, transform %p, transformed_geometry %p stub!\n",
struct d2d_geometry *object;
TRACE("iface %p, src_geometry %p, transform %p, transformed_geometry %p.\n",
iface, src_geometry, transform, transformed_geometry);
return E_NOTIMPL;
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
d2d_transformed_geometry_init(object, iface, src_geometry, transform);
TRACE("Created transformed geometry %p.\n", object);
*transformed_geometry = (ID2D1TransformedGeometry *)&object->ID2D1Geometry_iface;
return S_OK;
}
static HRESULT STDMETHODCALLTYPE d2d_factory_CreatePathGeometry(ID2D1Factory *iface, ID2D1PathGeometry **geometry)
......
......@@ -133,6 +133,7 @@ static void d2d_draw(struct d2d_d3d_render_target *render_target, enum d2d_shape
{
struct d2d_shape_resources *shape_resources = &render_target->shape_resources[shape_type];
ID3D10Device *device = render_target->device;
D3D10_RECT scissor_rect;
unsigned int offset;
D3D10_VIEWPORT vp;
HRESULT hr;
......@@ -164,16 +165,22 @@ static void d2d_draw(struct d2d_d3d_render_target *render_target, enum d2d_shape
if (render_target->clip_stack.count)
{
const D2D1_RECT_F *clip_rect;
D3D10_RECT scissor_rect;
clip_rect = &render_target->clip_stack.stack[render_target->clip_stack.count - 1];
scissor_rect.left = clip_rect->left + 0.5f;
scissor_rect.top = clip_rect->top + 0.5f;
scissor_rect.right = clip_rect->right + 0.5f;
scissor_rect.bottom = clip_rect->bottom + 0.5f;
ID3D10Device_RSSetScissorRects(device, 1, &scissor_rect);
ID3D10Device_RSSetState(device, render_target->rs);
}
else
{
scissor_rect.left = 0.0f;
scissor_rect.top = 0.0f;
scissor_rect.right = render_target->pixel_size.width;
scissor_rect.bottom = render_target->pixel_size.height;
}
ID3D10Device_RSSetScissorRects(device, 1, &scissor_rect);
ID3D10Device_RSSetState(device, render_target->rs);
ID3D10Device_OMSetRenderTargets(device, 1, &render_target->view, NULL);
if (brush)
d2d_brush_bind_resources(brush, render_target, shape_type);
......@@ -664,6 +671,7 @@ static void STDMETHODCALLTYPE d2d_d3d_render_target_FillGeometry(ID2D1RenderTarg
ID3D10Buffer *ib, *vb, *vs_cb, *ps_cb;
D3D10_SUBRESOURCE_DATA buffer_data;
D3D10_BUFFER_DESC buffer_desc;
D2D1_MATRIX_3X2_F w, g;
float tmp_x, tmp_y;
HRESULT hr;
struct
......@@ -681,13 +689,24 @@ static void STDMETHODCALLTYPE d2d_d3d_render_target_FillGeometry(ID2D1RenderTarg
tmp_x = (2.0f * render_target->dpi_x) / (96.0f * render_target->pixel_size.width);
tmp_y = -(2.0f * render_target->dpi_y) / (96.0f * render_target->pixel_size.height);
transform._11 = render_target->drawing_state.transform._11 * tmp_x;
transform._21 = render_target->drawing_state.transform._21 * tmp_x;
transform._31 = render_target->drawing_state.transform._31 * tmp_x - 1.0f;
w = render_target->drawing_state.transform;
w._11 *= tmp_x;
w._21 *= tmp_x;
w._31 = w._31 * tmp_x - 1.0f;
w._12 *= tmp_y;
w._22 *= tmp_y;
w._32 = w._32 * tmp_y + 1.0f;
g = geometry_impl->transform;
d2d_matrix_multiply(&g, &w);
transform._11 = g._11;
transform._21 = g._21;
transform._31 = g._31;
transform.pad0 = 0.0f;
transform._12 = render_target->drawing_state.transform._12 * tmp_y;
transform._22 = render_target->drawing_state.transform._22 * tmp_y;
transform._32 = render_target->drawing_state.transform._32 * tmp_y + 1.0f;
transform._12 = g._12;
transform._22 = g._22;
transform._32 = g._32;
transform.pad1 = 0.0f;
buffer_desc.ByteWidth = sizeof(transform);
......@@ -1801,7 +1820,7 @@ HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_target,
}
rs_desc.FillMode = D3D10_FILL_SOLID;
rs_desc.CullMode = D3D10_CULL_BACK;
rs_desc.CullMode = D3D10_CULL_NONE;
rs_desc.FrontCounterClockwise = FALSE;
rs_desc.DepthBias = 0;
rs_desc.DepthBiasClamp = 0.0f;
......
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