Module: wine Branch: master Commit: cfde833140bab044b68652efddbaf24a16736803 URL: http://source.winehq.org/git/wine.git/?a=commit;h=cfde833140bab044b68652efdd...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Mon Jun 16 13:13:20 2014 +0200
d2d1: Implement d2d_d3d_render_target_CreateSolidColorBrush().
---
dlls/d2d1/Makefile.in | 1 + dlls/d2d1/brush.c | 150 +++++++++++++++++++++++++++++++++++++++++++++ dlls/d2d1/d2d1_private.h | 9 +++ dlls/d2d1/render_target.c | 14 ++++- 4 files changed, 172 insertions(+), 2 deletions(-)
diff --git a/dlls/d2d1/Makefile.in b/dlls/d2d1/Makefile.in index 4e106ad..ed451ef 100644 --- a/dlls/d2d1/Makefile.in +++ b/dlls/d2d1/Makefile.in @@ -3,6 +3,7 @@ IMPORTLIB = d2d1 IMPORTS = uuid
C_SRCS = \ + brush.c \ factory.c \ render_target.c
diff --git a/dlls/d2d1/brush.c b/dlls/d2d1/brush.c new file mode 100644 index 0000000..21fac12 --- /dev/null +++ b/dlls/d2d1/brush.c @@ -0,0 +1,150 @@ +/* + * 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_brush *impl_from_ID2D1SolidColorBrush(ID2D1SolidColorBrush *iface) +{ + return CONTAINING_RECORD(iface, struct d2d_brush, ID2D1Brush_iface); +} + +static HRESULT STDMETHODCALLTYPE d2d_solid_color_brush_QueryInterface(ID2D1SolidColorBrush *iface, + REFIID iid, void **out) +{ + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_ID2D1SolidColorBrush) + || IsEqualGUID(iid, &IID_ID2D1Brush) + || IsEqualGUID(iid, &IID_ID2D1Resource) + || IsEqualGUID(iid, &IID_IUnknown)) + { + ID2D1SolidColorBrush_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_solid_color_brush_AddRef(ID2D1SolidColorBrush *iface) +{ + struct d2d_brush *brush = impl_from_ID2D1SolidColorBrush(iface); + ULONG refcount = InterlockedIncrement(&brush->refcount); + + TRACE("%p increasing refcount to %u.\n", iface, refcount); + + return refcount; +} + +static ULONG STDMETHODCALLTYPE d2d_solid_color_brush_Release(ID2D1SolidColorBrush *iface) +{ + struct d2d_brush *brush = impl_from_ID2D1SolidColorBrush(iface); + ULONG refcount = InterlockedDecrement(&brush->refcount); + + TRACE("%p decreasing refcount to %u.\n", iface, refcount); + + if (!refcount) + HeapFree(GetProcessHeap(), 0, brush); + + return refcount; +} + +static void STDMETHODCALLTYPE d2d_solid_color_brush_GetFactory(ID2D1SolidColorBrush *iface, ID2D1Factory **factory) +{ + FIXME("iface %p, factory %p stub!\n", iface, factory); + + *factory = NULL; +} + +static void STDMETHODCALLTYPE d2d_solid_color_brush_SetOpacity(ID2D1SolidColorBrush *iface, float opacity) +{ + FIXME("iface %p, opacity %.8e stub!\n", iface, opacity); +} + +static void STDMETHODCALLTYPE d2d_solid_color_brush_SetTransform(ID2D1SolidColorBrush *iface, + const D2D1_MATRIX_3X2_F *transform) +{ + FIXME("iface %p, transform %p stub!\n", iface, transform); +} + +static float STDMETHODCALLTYPE d2d_solid_color_brush_GetOpacity(ID2D1SolidColorBrush *iface) +{ + FIXME("iface %p stub!\n", iface); + + return 0.0f; +} + +static void STDMETHODCALLTYPE d2d_solid_color_brush_GetTransform(ID2D1SolidColorBrush *iface, + D2D1_MATRIX_3X2_F *transform) +{ + static const D2D1_MATRIX_3X2_F identity = + { + 1.0f, 0.0f, + 0.0f, 1.0f, + 0.0f, 0.0f, + }; + + FIXME("iface %p, transform %p stub!\n", iface, transform); + + *transform = identity; +} + +static void STDMETHODCALLTYPE d2d_solid_color_brush_SetColor(ID2D1SolidColorBrush *iface, const D2D1_COLOR_F *color) +{ + FIXME("iface %p, color %p stub!\n", iface, color); +} + +static D2D1_COLOR_F STDMETHODCALLTYPE d2d_solid_color_brush_GetColor(ID2D1SolidColorBrush *iface) +{ + static const D2D1_COLOR_F black = {0.0f, 0.0f, 0.0f, 1.0f}; + + FIXME("iface %p stub!\n", iface); + + return black; +} + +static const struct ID2D1SolidColorBrushVtbl d2d_solid_color_brush_vtbl = +{ + d2d_solid_color_brush_QueryInterface, + d2d_solid_color_brush_AddRef, + d2d_solid_color_brush_Release, + d2d_solid_color_brush_GetFactory, + d2d_solid_color_brush_SetOpacity, + d2d_solid_color_brush_SetTransform, + d2d_solid_color_brush_GetOpacity, + d2d_solid_color_brush_GetTransform, + d2d_solid_color_brush_SetColor, + d2d_solid_color_brush_GetColor, +}; + +void d2d_solid_color_brush_init(struct d2d_brush *brush, ID2D1RenderTarget *render_target, + const D2D1_COLOR_F *color, const D2D1_BRUSH_PROPERTIES *desc) +{ + FIXME("Ignoring brush properties.\n"); + + brush->ID2D1Brush_iface.lpVtbl = (ID2D1BrushVtbl *)&d2d_solid_color_brush_vtbl; + brush->refcount = 1; +} diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 5609db6..9e91728 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -33,4 +33,13 @@ struct d2d_d3d_render_target void d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_target, ID2D1Factory *factory, IDXGISurface *surface, const D2D1_RENDER_TARGET_PROPERTIES *desc) DECLSPEC_HIDDEN;
+struct d2d_brush +{ + ID2D1Brush ID2D1Brush_iface; + LONG refcount; +}; + +void d2d_solid_color_brush_init(struct d2d_brush *brush, ID2D1RenderTarget *render_target, + const D2D1_COLOR_F *color, const D2D1_BRUSH_PROPERTIES *desc) DECLSPEC_HIDDEN; + #endif /* __WINE_D2D1_PRIVATE_H */ diff --git a/dlls/d2d1/render_target.c b/dlls/d2d1/render_target.c index be9c1b6..e8c56a0 100644 --- a/dlls/d2d1/render_target.c +++ b/dlls/d2d1/render_target.c @@ -117,9 +117,19 @@ static HRESULT STDMETHODCALLTYPE d2d_d3d_render_target_CreateBitmapBrush(ID2D1Re static HRESULT STDMETHODCALLTYPE d2d_d3d_render_target_CreateSolidColorBrush(ID2D1RenderTarget *iface, const D2D1_COLOR_F *color, const D2D1_BRUSH_PROPERTIES *desc, ID2D1SolidColorBrush **brush) { - FIXME("iface %p, color %p, desc %p, brush %p stub!\n", iface, color, desc, brush); + struct d2d_brush *object;
- return E_NOTIMPL; + TRACE("iface %p, color %p, desc %p, brush %p.\n", iface, color, desc, brush); + + if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + return E_OUTOFMEMORY; + + d2d_solid_color_brush_init(object, iface, color, desc); + + TRACE("Created brush %p.\n", object); + *brush = (ID2D1SolidColorBrush *)&object->ID2D1Brush_iface; + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d2d_d3d_render_target_CreateGradientStopCollection(ID2D1RenderTarget *iface,