From 2b1d3bfb472b2bef864ada5b415270dbfc0ad8bf Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Mon, 15 Jun 2015 14:07:35 +0200 Subject: [PATCH] d2d1: Implement d2d_factory_CreatePathGeometry(). --- dlls/d2d1/Makefile.in | 1 + dlls/d2d1/d2d1_private.h | 8 ++ dlls/d2d1/factory.c | 14 ++- dlls/d2d1/geometry.c | 255 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 276 insertions(+), 2 deletions(-) create mode 100644 dlls/d2d1/geometry.c diff --git a/dlls/d2d1/Makefile.in b/dlls/d2d1/Makefile.in index 2828bac22a7..c5f5523157d 100644 --- a/dlls/d2d1/Makefile.in +++ b/dlls/d2d1/Makefile.in @@ -6,6 +6,7 @@ C_SRCS = \ bitmap.c \ brush.c \ factory.c \ + geometry.c \ mesh.c \ render_target.c \ state_block.c \ diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 447a1361e42..791df3c83d7 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -189,4 +189,12 @@ void d2d_state_block_init(struct d2d_state_block *state_block, const D2D1_DRAWIN IDWriteRenderingParams *text_rendering_params) DECLSPEC_HIDDEN; struct d2d_state_block *unsafe_impl_from_ID2D1DrawingStateBlock(ID2D1DrawingStateBlock *iface) DECLSPEC_HIDDEN; +struct d2d_geometry +{ + ID2D1Geometry ID2D1Geometry_iface; + LONG refcount; +}; + +void d2d_path_geometry_init(struct d2d_geometry *geometry) DECLSPEC_HIDDEN; + #endif /* __WINE_D2D1_PRIVATE_H */ diff --git a/dlls/d2d1/factory.c b/dlls/d2d1/factory.c index d276b301a77..7886d7395b2 100644 --- a/dlls/d2d1/factory.c +++ b/dlls/d2d1/factory.c @@ -136,9 +136,19 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateTransformedGeometry(ID2D1Fact static HRESULT STDMETHODCALLTYPE d2d_factory_CreatePathGeometry(ID2D1Factory *iface, ID2D1PathGeometry **geometry) { - FIXME("iface %p, geometry %p stub!\n", iface, geometry); + struct d2d_geometry *object; - return E_NOTIMPL; + TRACE("iface %p, geometry %p.\n", iface, geometry); + + if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + return E_OUTOFMEMORY; + + d2d_path_geometry_init(object); + + TRACE("Created path geometry %p.\n", object); + *geometry = (ID2D1PathGeometry *)&object->ID2D1Geometry_iface; + + return S_OK; } static HRESULT STDMETHODCALLTYPE d2d_factory_CreateStrokeStyle(ID2D1Factory *iface, diff --git a/dlls/d2d1/geometry.c b/dlls/d2d1/geometry.c new file mode 100644 index 00000000000..a6658cb6d08 --- /dev/null +++ b/dlls/d2d1/geometry.c @@ -0,0 +1,255 @@ +/* + * Copyright 2015 Henri Verbeet for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "config.h" +#include "wine/port.h" + +#include "d2d1_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d2d); + +static inline struct d2d_geometry *impl_from_ID2D1PathGeometry(ID2D1PathGeometry *iface) +{ + return CONTAINING_RECORD(iface, struct d2d_geometry, ID2D1Geometry_iface); +} + +static HRESULT STDMETHODCALLTYPE d2d_path_geometry_QueryInterface(ID2D1PathGeometry *iface, REFIID iid, void **out) +{ + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_ID2D1PathGeometry) + || IsEqualGUID(iid, &IID_ID2D1Geometry) + || IsEqualGUID(iid, &IID_ID2D1Resource) + || IsEqualGUID(iid, &IID_IUnknown)) + { + ID2D1PathGeometry_AddRef(iface); + *out = iface; + return S_OK; + } + + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE d2d_path_geometry_AddRef(ID2D1PathGeometry *iface) +{ + struct d2d_geometry *geometry = impl_from_ID2D1PathGeometry(iface); + ULONG refcount = InterlockedIncrement(&geometry->refcount); + + TRACE("%p increasing refcount to %u.\n", iface, refcount); + + return refcount; +} + +static ULONG STDMETHODCALLTYPE d2d_path_geometry_Release(ID2D1PathGeometry *iface) +{ + struct d2d_geometry *geometry = impl_from_ID2D1PathGeometry(iface); + ULONG refcount = InterlockedDecrement(&geometry->refcount); + + TRACE("%p decreasing refcount to %u.\n", iface, refcount); + + if (!refcount) + HeapFree(GetProcessHeap(), 0, geometry); + + return refcount; +} + +static void STDMETHODCALLTYPE d2d_path_geometry_GetFactory(ID2D1PathGeometry *iface, ID2D1Factory **factory) +{ + FIXME("iface %p, factory %p stub!\n", iface, factory); + + *factory = NULL; +} + +static HRESULT STDMETHODCALLTYPE d2d_path_geometry_GetBounds(ID2D1PathGeometry *iface, + const D2D1_MATRIX_3X2_F *transform, D2D1_RECT_F *bounds) +{ + FIXME("iface %p, transform %p, bounds %p stub!\n", iface, transform, bounds); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d2d_path_geometry_GetWidenedBounds(ID2D1PathGeometry *iface, float stroke_width, + ID2D1StrokeStyle *stroke_style, const D2D1_MATRIX_3X2_F *transform, float tolerance, D2D1_RECT_F *bounds) +{ + FIXME("iface %p, stroke_width %.8e, stroke_style %p, transform %p, tolerance %.8e, bounds %p stub!\n", + iface, stroke_width, stroke_style, transform, tolerance, bounds); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d2d_path_geometry_StrokeContainsPoint(ID2D1PathGeometry *iface, + D2D1_POINT_2F point, float stroke_width, ID2D1StrokeStyle *stroke_style, const D2D1_MATRIX_3X2_F *transform, + float tolerance, BOOL *contains) +{ + FIXME("iface %p, point {%.8e, %.8e}, stroke_width %.8e, stroke_style %p, " + "transform %p, tolerance %.8e, contains %p stub!\n", + iface, point.x, point.y, stroke_width, stroke_style, transform, tolerance, contains); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d2d_path_geometry_FillContainsPoint(ID2D1PathGeometry *iface, + D2D1_POINT_2F point, const D2D1_MATRIX_3X2_F *transform, float tolerance, BOOL *contains) +{ + FIXME("iface %p, point {%.8e, %.8e}, transform %p, tolerance %.8e, contains %p stub!\n", + iface, point.x, point.y, transform, tolerance, contains); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d2d_path_geometry_CompareWithGeometry(ID2D1PathGeometry *iface, + ID2D1Geometry *geometry, const D2D1_MATRIX_3X2_F *transform, float tolerance, D2D1_GEOMETRY_RELATION *relation) +{ + FIXME("iface %p, geometry %p, transform %p, tolerance %.8e, relation %p stub!\n", + iface, geometry, transform, tolerance, relation); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d2d_path_geometry_Simplify(ID2D1PathGeometry *iface, + D2D1_GEOMETRY_SIMPLIFICATION_OPTION option, const D2D1_MATRIX_3X2_F *transform, float tolerance, + ID2D1SimplifiedGeometrySink *sink) +{ + FIXME("iface %p, option %#x, transform %p, tolerance %.8e, sink %p stub!\n", + iface, option, transform, tolerance, sink); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d2d_path_geometry_Tessellate(ID2D1PathGeometry *iface, + const D2D1_MATRIX_3X2_F *transform, float tolerance, ID2D1TessellationSink *sink) +{ + FIXME("iface %p, transform %p, tolerance %.8e, sink %p stub!\n", iface, transform, tolerance, sink); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d2d_path_geometry_CombineWithGeometry(ID2D1PathGeometry *iface, + ID2D1Geometry *geometry, D2D1_COMBINE_MODE combine_mode, const D2D1_MATRIX_3X2_F *transform, + float tolerance, ID2D1SimplifiedGeometrySink *sink) +{ + FIXME("iface %p, geometry %p, combine_mode %#x, transform %p, tolerance %.8e, sink %p stub!\n", + iface, geometry, combine_mode, transform, tolerance, sink); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d2d_path_geometry_Outline(ID2D1PathGeometry *iface, + const D2D1_MATRIX_3X2_F *transform, float tolerance, ID2D1SimplifiedGeometrySink *sink) +{ + FIXME("iface %p, transform %p, tolerance %.8e, sink %p stub!\n", iface, transform, tolerance, sink); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d2d_path_geometry_ComputeArea(ID2D1PathGeometry *iface, + const D2D1_MATRIX_3X2_F *transform, float tolerance, float *area) +{ + FIXME("iface %p, transform %p, tolerance %.8e, area %p stub!\n", iface, transform, tolerance, area); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d2d_path_geometry_ComputeLength(ID2D1PathGeometry *iface, + const D2D1_MATRIX_3X2_F *transform, float tolerance, float *length) +{ + FIXME("iface %p, transform %p, tolerance %.8e, length %p stub!\n", iface, transform, tolerance, length); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d2d_path_geometry_ComputePointAtLength(ID2D1PathGeometry *iface, float length, + const D2D1_MATRIX_3X2_F *transform, float tolerance, D2D1_POINT_2F *point, D2D1_POINT_2F *tangent) +{ + FIXME("iface %p, length %.8e, transform %p, tolerance %.8e, point %p, tangent %p stub!\n", + iface, length, transform, tolerance, point, tangent); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d2d_path_geometry_Widen(ID2D1PathGeometry *iface, float stroke_width, + ID2D1StrokeStyle *stroke_style, const D2D1_MATRIX_3X2_F *transform, float tolerance, + ID2D1SimplifiedGeometrySink *sink) +{ + FIXME("iface %p, stroke_width %.8e, stroke_style %p, transform %p, tolerance %.8e, sink %p stub!\n", + iface, stroke_width, stroke_style, transform, tolerance, sink); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d2d_path_geometry_Open(ID2D1PathGeometry *iface, ID2D1GeometrySink **sink) +{ + FIXME("iface %p, sink %p stub!\n", iface, sink); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d2d_path_geometry_Stream(ID2D1PathGeometry *iface, ID2D1GeometrySink *sink) +{ + FIXME("iface %p, sink %p stub!\n", iface, sink); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d2d_path_geometry_GetSegmentCount(ID2D1PathGeometry *iface, UINT32 *count) +{ + FIXME("iface %p, count %p stub!\n", iface, count); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d2d_path_geometry_GetFigureCount(ID2D1PathGeometry *iface, UINT32 *count) +{ + FIXME("iface %p, count %p stub!\n", iface, count); + + return E_NOTIMPL; +} + +static const struct ID2D1PathGeometryVtbl d2d_path_geometry_vtbl = +{ + d2d_path_geometry_QueryInterface, + d2d_path_geometry_AddRef, + d2d_path_geometry_Release, + d2d_path_geometry_GetFactory, + d2d_path_geometry_GetBounds, + d2d_path_geometry_GetWidenedBounds, + d2d_path_geometry_StrokeContainsPoint, + d2d_path_geometry_FillContainsPoint, + d2d_path_geometry_CompareWithGeometry, + d2d_path_geometry_Simplify, + d2d_path_geometry_Tessellate, + d2d_path_geometry_CombineWithGeometry, + d2d_path_geometry_Outline, + d2d_path_geometry_ComputeArea, + d2d_path_geometry_ComputeLength, + d2d_path_geometry_ComputePointAtLength, + d2d_path_geometry_Widen, + d2d_path_geometry_Open, + d2d_path_geometry_Stream, + d2d_path_geometry_GetSegmentCount, + d2d_path_geometry_GetFigureCount, +}; + +void d2d_path_geometry_init(struct d2d_geometry *geometry) +{ + geometry->ID2D1Geometry_iface.lpVtbl = (ID2D1GeometryVtbl *)&d2d_path_geometry_vtbl; + geometry->refcount = 1; +}