From: Henri Verbeet Subject: [PATCH 1/5] d2d1: Implement d2d_d3d_render_target_CreateMesh(). Message-Id: <1410857056-25723-1-git-send-email-hverbeet@codeweavers.com> Date: Tue, 16 Sep 2014 10:44:12 +0200 --- dlls/d2d1/Makefile.in | 1 + dlls/d2d1/d2d1_private.h | 8 ++++ dlls/d2d1/mesh.c | 100 +++++++++++++++++++++++++++++++++++++++++++++ dlls/d2d1/render_target.c | 14 ++++++- 4 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 dlls/d2d1/mesh.c diff --git a/dlls/d2d1/Makefile.in b/dlls/d2d1/Makefile.in index 60072ca..6c27e22 100644 --- a/dlls/d2d1/Makefile.in +++ b/dlls/d2d1/Makefile.in @@ -5,6 +5,7 @@ IMPORTS = d3d10_1 dxguid uuid C_SRCS = \ brush.c \ factory.c \ + mesh.c \ render_target.c \ stroke.c \ wic_render_target.c diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 4ee4ab0..0b8cf2b 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -107,4 +107,12 @@ struct d2d_stroke_style void d2d_stroke_style_init(struct d2d_stroke_style *style, ID2D1Factory *factory, const D2D1_STROKE_STYLE_PROPERTIES *desc, const float *dashes, UINT32 dash_count) DECLSPEC_HIDDEN; +struct d2d_mesh +{ + ID2D1Mesh ID2D1Mesh_iface; + LONG refcount; +}; + +void d2d_mesh_init(struct d2d_mesh *mesh) DECLSPEC_HIDDEN; + #endif /* __WINE_D2D1_PRIVATE_H */ diff --git a/dlls/d2d1/mesh.c b/dlls/d2d1/mesh.c new file mode 100644 index 0000000..b566382 --- /dev/null +++ b/dlls/d2d1/mesh.c @@ -0,0 +1,100 @@ +/* + * Copyright 2014 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_mesh *impl_from_ID2D1Mesh(ID2D1Mesh *iface) +{ + return CONTAINING_RECORD(iface, struct d2d_mesh, ID2D1Mesh_iface); +} + +static HRESULT STDMETHODCALLTYPE d2d_mesh_QueryInterface(ID2D1Mesh *iface, REFIID iid, void **out) +{ + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_ID2D1Mesh) + || IsEqualGUID(iid, &IID_ID2D1Resource) + || IsEqualGUID(iid, &IID_IUnknown)) + { + ID2D1Mesh_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_mesh_AddRef(ID2D1Mesh *iface) +{ + struct d2d_mesh *mesh = impl_from_ID2D1Mesh(iface); + ULONG refcount = InterlockedIncrement(&mesh->refcount); + + TRACE("%p increasing refcount to %u.\n", iface, refcount); + + return refcount; +} + +static ULONG STDMETHODCALLTYPE d2d_mesh_Release(ID2D1Mesh *iface) +{ + struct d2d_mesh *mesh = impl_from_ID2D1Mesh(iface); + ULONG refcount = InterlockedDecrement(&mesh->refcount); + + TRACE("%p decreasing refcount to %u.\n", iface, refcount); + + if (!refcount) + HeapFree(GetProcessHeap(), 0, mesh); + + return refcount; +} + +static void STDMETHODCALLTYPE d2d_mesh_GetFactory(ID2D1Mesh *iface, ID2D1Factory **factory) +{ + FIXME("iface %p, factory %p stub!\n", iface, factory); + + *factory = NULL; +} + +static HRESULT STDMETHODCALLTYPE d2d_mesh_Open(ID2D1Mesh *iface, ID2D1TessellationSink **sink) +{ + FIXME("iface %p, sink %p stub!\n", iface, sink); + + return E_NOTIMPL; +} + +static const struct ID2D1MeshVtbl d2d_mesh_vtbl = +{ + d2d_mesh_QueryInterface, + d2d_mesh_AddRef, + d2d_mesh_Release, + d2d_mesh_GetFactory, + d2d_mesh_Open, +}; + +void d2d_mesh_init(struct d2d_mesh *mesh) +{ + mesh->ID2D1Mesh_iface.lpVtbl = &d2d_mesh_vtbl; + mesh->refcount = 1; +} diff --git a/dlls/d2d1/render_target.c b/dlls/d2d1/render_target.c index 4d69697..8a55890 100644 --- a/dlls/d2d1/render_target.c +++ b/dlls/d2d1/render_target.c @@ -304,9 +304,19 @@ static HRESULT STDMETHODCALLTYPE d2d_d3d_render_target_CreateLayer(ID2D1RenderTa static HRESULT STDMETHODCALLTYPE d2d_d3d_render_target_CreateMesh(ID2D1RenderTarget *iface, ID2D1Mesh **mesh) { - FIXME("iface %p, mesh %p stub!\n", iface, mesh); + struct d2d_mesh *object; - return E_NOTIMPL; + TRACE("iface %p, mesh %p.\n", iface, mesh); + + if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + return E_OUTOFMEMORY; + + d2d_mesh_init(object); + + TRACE("Created mesh %p.\n", object); + *mesh = &object->ID2D1Mesh_iface; + + return S_OK; } static void STDMETHODCALLTYPE d2d_d3d_render_target_DrawLine(ID2D1RenderTarget *iface, -- 1.7.10.4