2014-06-16 13:13:20 +02:00
|
|
|
|
/*
|
|
|
|
|
* 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 "d2d1_private.h"
|
|
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d2d);
|
|
|
|
|
|
2014-06-16 13:13:21 +02:00
|
|
|
|
static inline struct d2d_gradient *impl_from_ID2D1GradientStopCollection(ID2D1GradientStopCollection *iface)
|
|
|
|
|
{
|
|
|
|
|
return CONTAINING_RECORD(iface, struct d2d_gradient, ID2D1GradientStopCollection_iface);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_gradient_QueryInterface(ID2D1GradientStopCollection *iface,
|
|
|
|
|
REFIID iid, void **out)
|
|
|
|
|
{
|
|
|
|
|
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
|
|
|
|
|
|
|
|
|
|
if (IsEqualGUID(iid, &IID_ID2D1GradientStopCollection)
|
|
|
|
|
|| IsEqualGUID(iid, &IID_ID2D1Resource)
|
|
|
|
|
|| IsEqualGUID(iid, &IID_IUnknown))
|
|
|
|
|
{
|
|
|
|
|
ID2D1GradientStopCollection_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_gradient_AddRef(ID2D1GradientStopCollection *iface)
|
|
|
|
|
{
|
|
|
|
|
struct d2d_gradient *gradient = impl_from_ID2D1GradientStopCollection(iface);
|
|
|
|
|
ULONG refcount = InterlockedIncrement(&gradient->refcount);
|
|
|
|
|
|
|
|
|
|
TRACE("%p increasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE d2d_gradient_Release(ID2D1GradientStopCollection *iface)
|
|
|
|
|
{
|
|
|
|
|
struct d2d_gradient *gradient = impl_from_ID2D1GradientStopCollection(iface);
|
|
|
|
|
ULONG refcount = InterlockedDecrement(&gradient->refcount);
|
|
|
|
|
|
|
|
|
|
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
|
|
if (!refcount)
|
2014-11-03 08:59:38 +01:00
|
|
|
|
{
|
2018-01-30 13:24:39 +01:00
|
|
|
|
heap_free(gradient->stops);
|
2021-06-28 09:17:37 +02:00
|
|
|
|
ID3D11ShaderResourceView_Release(gradient->view);
|
2015-08-02 18:56:09 +02:00
|
|
|
|
ID2D1Factory_Release(gradient->factory);
|
2018-01-30 13:24:39 +01:00
|
|
|
|
heap_free(gradient);
|
2014-11-03 08:59:38 +01:00
|
|
|
|
}
|
2014-06-16 13:13:21 +02:00
|
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_gradient_GetFactory(ID2D1GradientStopCollection *iface, ID2D1Factory **factory)
|
|
|
|
|
{
|
2015-08-02 18:56:09 +02:00
|
|
|
|
struct d2d_gradient *gradient = impl_from_ID2D1GradientStopCollection(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p, factory %p.\n", iface, factory);
|
2014-06-16 13:13:21 +02:00
|
|
|
|
|
2015-08-02 18:56:09 +02:00
|
|
|
|
ID2D1Factory_AddRef(*factory = gradient->factory);
|
2014-06-16 13:13:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static UINT32 STDMETHODCALLTYPE d2d_gradient_GetGradientStopCount(ID2D1GradientStopCollection *iface)
|
|
|
|
|
{
|
2014-11-03 08:59:37 +01:00
|
|
|
|
struct d2d_gradient *gradient = impl_from_ID2D1GradientStopCollection(iface);
|
2014-06-16 13:13:21 +02:00
|
|
|
|
|
2014-11-03 08:59:37 +01:00
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
|
|
return gradient->stop_count;
|
2014-06-16 13:13:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_gradient_GetGradientStops(ID2D1GradientStopCollection *iface,
|
|
|
|
|
D2D1_GRADIENT_STOP *stops, UINT32 stop_count)
|
|
|
|
|
{
|
2014-11-03 08:59:38 +01:00
|
|
|
|
struct d2d_gradient *gradient = impl_from_ID2D1GradientStopCollection(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p, stops %p, stop_count %u.\n", iface, stops, stop_count);
|
|
|
|
|
|
|
|
|
|
memcpy(stops, gradient->stops, min(gradient->stop_count, stop_count) * sizeof(*stops));
|
2014-06-16 13:13:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static D2D1_GAMMA STDMETHODCALLTYPE d2d_gradient_GetColorInterpolationGamma(ID2D1GradientStopCollection *iface)
|
|
|
|
|
{
|
|
|
|
|
FIXME("iface %p stub!\n", iface);
|
|
|
|
|
|
|
|
|
|
return D2D1_GAMMA_1_0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static D2D1_EXTEND_MODE STDMETHODCALLTYPE d2d_gradient_GetExtendMode(ID2D1GradientStopCollection *iface)
|
|
|
|
|
{
|
|
|
|
|
FIXME("iface %p stub!\n", iface);
|
|
|
|
|
|
|
|
|
|
return D2D1_EXTEND_MODE_CLAMP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct ID2D1GradientStopCollectionVtbl d2d_gradient_vtbl =
|
|
|
|
|
{
|
|
|
|
|
d2d_gradient_QueryInterface,
|
|
|
|
|
d2d_gradient_AddRef,
|
|
|
|
|
d2d_gradient_Release,
|
|
|
|
|
d2d_gradient_GetFactory,
|
|
|
|
|
d2d_gradient_GetGradientStopCount,
|
|
|
|
|
d2d_gradient_GetGradientStops,
|
|
|
|
|
d2d_gradient_GetColorInterpolationGamma,
|
|
|
|
|
d2d_gradient_GetExtendMode,
|
|
|
|
|
};
|
|
|
|
|
|
2021-06-24 09:35:34 +02:00
|
|
|
|
HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D11Device1 *device, const D2D1_GRADIENT_STOP *stops,
|
2021-06-24 09:35:33 +02:00
|
|
|
|
UINT32 stop_count, D2D1_GAMMA gamma, D2D1_EXTEND_MODE extend_mode, struct d2d_gradient **out)
|
2014-06-16 13:13:21 +02:00
|
|
|
|
{
|
2021-06-24 09:35:34 +02:00
|
|
|
|
D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc;
|
|
|
|
|
D3D11_SUBRESOURCE_DATA buffer_data;
|
2021-06-28 09:17:37 +02:00
|
|
|
|
ID3D11ShaderResourceView *view;
|
2021-06-24 09:35:33 +02:00
|
|
|
|
struct d2d_gradient *gradient;
|
2021-06-24 09:35:34 +02:00
|
|
|
|
D3D11_BUFFER_DESC buffer_desc;
|
2017-09-26 12:22:38 +02:00
|
|
|
|
struct d2d_vec4 *data;
|
2021-06-24 09:35:34 +02:00
|
|
|
|
ID3D11Buffer *buffer;
|
2017-09-26 12:22:38 +02:00
|
|
|
|
unsigned int i;
|
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
2021-06-24 09:35:33 +02:00
|
|
|
|
*out = NULL;
|
2018-02-01 00:37:35 +01:00
|
|
|
|
if (!(data = heap_calloc(stop_count, 2 * sizeof(*data))))
|
2017-09-26 12:22:38 +02:00
|
|
|
|
{
|
|
|
|
|
ERR("Failed to allocate data.\n");
|
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < stop_count; ++i)
|
|
|
|
|
{
|
|
|
|
|
data[i * 2].x = stops[i].position;
|
|
|
|
|
data[i * 2 + 1].x = stops[i].color.r;
|
|
|
|
|
data[i * 2 + 1].y = stops[i].color.g;
|
|
|
|
|
data[i * 2 + 1].z = stops[i].color.b;
|
|
|
|
|
data[i * 2 + 1].w = stops[i].color.a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buffer_desc.ByteWidth = 2 * stop_count * sizeof(*data);
|
2021-06-24 09:35:34 +02:00
|
|
|
|
buffer_desc.Usage = D3D11_USAGE_DEFAULT;
|
|
|
|
|
buffer_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
2017-09-26 12:22:38 +02:00
|
|
|
|
buffer_desc.CPUAccessFlags = 0;
|
|
|
|
|
buffer_desc.MiscFlags = 0;
|
|
|
|
|
|
|
|
|
|
buffer_data.pSysMem = data;
|
|
|
|
|
buffer_data.SysMemPitch = 0;
|
|
|
|
|
buffer_data.SysMemSlicePitch = 0;
|
|
|
|
|
|
2021-06-24 09:35:34 +02:00
|
|
|
|
hr = ID3D11Device1_CreateBuffer(device, &buffer_desc, &buffer_data, &buffer);
|
2018-01-30 13:24:39 +01:00
|
|
|
|
heap_free(data);
|
2017-09-26 12:22:38 +02:00
|
|
|
|
if (FAILED(hr))
|
|
|
|
|
{
|
|
|
|
|
ERR("Failed to create buffer, hr %#x.\n", hr);
|
|
|
|
|
return hr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
srv_desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
2021-06-24 09:35:34 +02:00
|
|
|
|
srv_desc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
|
2017-09-26 12:22:38 +02:00
|
|
|
|
srv_desc.Buffer.ElementOffset = 0;
|
|
|
|
|
srv_desc.Buffer.ElementWidth = 2 * stop_count;
|
|
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
|
hr = ID3D11Device1_CreateShaderResourceView(device, (ID3D11Resource *)buffer, &srv_desc, &view);
|
2021-06-24 09:35:34 +02:00
|
|
|
|
ID3D11Buffer_Release(buffer);
|
2017-09-26 12:22:38 +02:00
|
|
|
|
if (FAILED(hr))
|
|
|
|
|
{
|
|
|
|
|
ERR("Failed to create view, hr %#x.\n", hr);
|
|
|
|
|
return hr;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-24 09:35:33 +02:00
|
|
|
|
if (!(gradient = heap_alloc_zero(sizeof(*gradient))))
|
2017-09-26 12:22:38 +02:00
|
|
|
|
{
|
2021-06-28 09:17:37 +02:00
|
|
|
|
ID3D11ShaderResourceView_Release(view);
|
2016-03-31 13:49:31 +02:00
|
|
|
|
return E_OUTOFMEMORY;
|
2017-09-26 12:22:38 +02:00
|
|
|
|
}
|
2016-03-31 13:49:31 +02:00
|
|
|
|
|
2017-09-26 12:22:38 +02:00
|
|
|
|
if (gamma != D2D1_GAMMA_2_2)
|
|
|
|
|
FIXME("Ignoring gamma %#x.\n", gamma);
|
|
|
|
|
if (extend_mode != D2D1_EXTEND_MODE_CLAMP)
|
|
|
|
|
FIXME("Ignoring extend mode %#x.\n", extend_mode);
|
2014-06-16 13:13:21 +02:00
|
|
|
|
|
2021-06-24 09:35:33 +02:00
|
|
|
|
gradient->ID2D1GradientStopCollection_iface.lpVtbl = &d2d_gradient_vtbl;
|
|
|
|
|
gradient->refcount = 1;
|
|
|
|
|
ID2D1Factory_AddRef(gradient->factory = factory);
|
|
|
|
|
gradient->view = view;
|
2014-11-03 08:59:37 +01:00
|
|
|
|
|
2021-06-24 09:35:33 +02:00
|
|
|
|
gradient->stop_count = stop_count;
|
|
|
|
|
if (!(gradient->stops = heap_calloc(stop_count, sizeof(*stops))))
|
2016-03-31 13:49:31 +02:00
|
|
|
|
{
|
2021-06-28 09:17:37 +02:00
|
|
|
|
ID3D11ShaderResourceView_Release(view);
|
2021-06-24 09:35:33 +02:00
|
|
|
|
heap_free(gradient);
|
2014-11-03 08:59:38 +01:00
|
|
|
|
return E_OUTOFMEMORY;
|
2016-03-31 13:49:31 +02:00
|
|
|
|
}
|
2021-06-24 09:35:33 +02:00
|
|
|
|
memcpy(gradient->stops, stops, stop_count * sizeof(*stops));
|
2014-11-03 08:59:38 +01:00
|
|
|
|
|
2021-06-24 09:35:33 +02:00
|
|
|
|
TRACE("Created gradient %p.\n", gradient);
|
|
|
|
|
*out = gradient;
|
2014-11-03 08:59:38 +01:00
|
|
|
|
return S_OK;
|
2014-06-16 13:13:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-26 12:22:39 +02:00
|
|
|
|
static struct d2d_gradient *unsafe_impl_from_ID2D1GradientStopCollection(ID2D1GradientStopCollection *iface)
|
|
|
|
|
{
|
|
|
|
|
if (!iface)
|
|
|
|
|
return NULL;
|
|
|
|
|
assert(iface->lpVtbl == &d2d_gradient_vtbl);
|
|
|
|
|
return CONTAINING_RECORD(iface, struct d2d_gradient, ID2D1GradientStopCollection_iface);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-28 09:17:36 +02:00
|
|
|
|
static void d2d_gradient_bind(struct d2d_gradient *gradient, ID3D11Device1 *device, unsigned int brush_idx)
|
2017-09-28 13:14:18 +02:00
|
|
|
|
{
|
2021-06-28 09:17:36 +02:00
|
|
|
|
ID3D11DeviceContext *context;
|
|
|
|
|
ID3D11Device1_GetImmediateContext(device, &context);
|
2021-06-28 09:17:37 +02:00
|
|
|
|
ID3D11DeviceContext_PSSetShaderResources(context, 2 + brush_idx, 1, &gradient->view);
|
2021-06-28 09:17:36 +02:00
|
|
|
|
ID3D11DeviceContext_Release(context);
|
2017-09-28 13:14:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-02 18:56:06 +02:00
|
|
|
|
static void d2d_brush_destroy(struct d2d_brush *brush)
|
|
|
|
|
{
|
|
|
|
|
ID2D1Factory_Release(brush->factory);
|
2018-01-30 13:24:39 +01:00
|
|
|
|
heap_free(brush);
|
2015-08-02 18:56:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void d2d_brush_init(struct d2d_brush *brush, ID2D1Factory *factory,
|
2014-11-06 08:20:14 +01:00
|
|
|
|
enum d2d_brush_type type, const D2D1_BRUSH_PROPERTIES *desc, const struct ID2D1BrushVtbl *vtbl)
|
2014-06-16 13:13:22 +02:00
|
|
|
|
{
|
2015-01-29 10:27:20 +01:00
|
|
|
|
static const D2D1_MATRIX_3X2_F identity =
|
2020-05-15 15:22:41 +02:00
|
|
|
|
{{{
|
2015-01-29 10:27:20 +01:00
|
|
|
|
1.0f, 0.0f,
|
|
|
|
|
0.0f, 1.0f,
|
|
|
|
|
0.0f, 0.0f,
|
2020-05-15 15:22:41 +02:00
|
|
|
|
}}};
|
2015-01-29 10:27:20 +01:00
|
|
|
|
|
2014-06-16 13:13:22 +02:00
|
|
|
|
brush->ID2D1Brush_iface.lpVtbl = vtbl;
|
|
|
|
|
brush->refcount = 1;
|
2015-08-02 18:56:06 +02:00
|
|
|
|
ID2D1Factory_AddRef(brush->factory = factory);
|
2014-11-06 08:20:17 +01:00
|
|
|
|
brush->opacity = desc ? desc->opacity : 1.0f;
|
2015-01-29 10:27:20 +01:00
|
|
|
|
brush->transform = desc ? desc->transform : identity;
|
2014-11-06 08:20:14 +01:00
|
|
|
|
brush->type = type;
|
2014-06-16 13:13:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-16 13:13:20 +02:00
|
|
|
|
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)
|
2015-08-02 18:56:06 +02:00
|
|
|
|
d2d_brush_destroy(brush);
|
2014-06-16 13:13:20 +02:00
|
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_solid_color_brush_GetFactory(ID2D1SolidColorBrush *iface, ID2D1Factory **factory)
|
|
|
|
|
{
|
2015-08-02 18:56:08 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1SolidColorBrush(iface);
|
2014-06-16 13:13:20 +02:00
|
|
|
|
|
2015-08-02 18:56:08 +02:00
|
|
|
|
TRACE("iface %p, factory %p.\n", iface, factory);
|
|
|
|
|
|
|
|
|
|
ID2D1Factory_AddRef(*factory = brush->factory);
|
2014-06-16 13:13:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_solid_color_brush_SetOpacity(ID2D1SolidColorBrush *iface, float opacity)
|
|
|
|
|
{
|
2014-11-06 08:20:17 +01:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1SolidColorBrush(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p, opacity %.8e.\n", iface, opacity);
|
|
|
|
|
|
|
|
|
|
brush->opacity = opacity;
|
2014-06-16 13:13:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_solid_color_brush_SetTransform(ID2D1SolidColorBrush *iface,
|
|
|
|
|
const D2D1_MATRIX_3X2_F *transform)
|
|
|
|
|
{
|
2015-01-29 10:27:25 +01:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1SolidColorBrush(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p, transform %p.\n", iface, transform);
|
|
|
|
|
|
|
|
|
|
brush->transform = *transform;
|
2014-06-16 13:13:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static float STDMETHODCALLTYPE d2d_solid_color_brush_GetOpacity(ID2D1SolidColorBrush *iface)
|
|
|
|
|
{
|
2014-11-17 11:29:22 +01:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1SolidColorBrush(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
2014-06-16 13:13:20 +02:00
|
|
|
|
|
2014-11-17 11:29:22 +01:00
|
|
|
|
return brush->opacity;
|
2014-06-16 13:13:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_solid_color_brush_GetTransform(ID2D1SolidColorBrush *iface,
|
|
|
|
|
D2D1_MATRIX_3X2_F *transform)
|
|
|
|
|
{
|
2015-01-29 10:27:22 +01:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1SolidColorBrush(iface);
|
2014-06-16 13:13:20 +02:00
|
|
|
|
|
2015-01-29 10:27:22 +01:00
|
|
|
|
TRACE("iface %p, transform %p.\n", iface, transform);
|
2014-06-16 13:13:20 +02:00
|
|
|
|
|
2015-01-29 10:27:22 +01:00
|
|
|
|
*transform = brush->transform;
|
2014-06-16 13:13:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_solid_color_brush_SetColor(ID2D1SolidColorBrush *iface, const D2D1_COLOR_F *color)
|
|
|
|
|
{
|
2014-11-06 08:20:15 +01:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1SolidColorBrush(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p, color %p.\n", iface, color);
|
|
|
|
|
|
|
|
|
|
brush->u.solid.color = *color;
|
2014-06-16 13:13:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-05 17:33:03 +02:00
|
|
|
|
static D2D1_COLOR_F * STDMETHODCALLTYPE d2d_solid_color_brush_GetColor(ID2D1SolidColorBrush *iface, D2D1_COLOR_F *color)
|
2014-06-16 13:13:20 +02:00
|
|
|
|
{
|
2014-11-06 08:20:16 +01:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1SolidColorBrush(iface);
|
2014-06-16 13:13:20 +02:00
|
|
|
|
|
2014-11-06 08:20:16 +01:00
|
|
|
|
TRACE("iface %p, color %p.\n", iface, color);
|
2014-06-16 13:13:20 +02:00
|
|
|
|
|
2014-11-06 08:20:16 +01:00
|
|
|
|
*color = brush->u.solid.color;
|
2014-09-05 17:33:03 +02:00
|
|
|
|
return color;
|
2014-06-16 13:13:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
};
|
|
|
|
|
|
2016-03-31 13:49:31 +02:00
|
|
|
|
HRESULT d2d_solid_color_brush_create(ID2D1Factory *factory, const D2D1_COLOR_F *color,
|
|
|
|
|
const D2D1_BRUSH_PROPERTIES *desc, struct d2d_brush **brush)
|
2014-06-16 13:13:20 +02:00
|
|
|
|
{
|
2018-01-30 13:24:39 +01:00
|
|
|
|
if (!(*brush = heap_alloc_zero(sizeof(**brush))))
|
2016-03-31 13:49:31 +02:00
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
|
|
d2d_brush_init(*brush, factory, D2D_BRUSH_TYPE_SOLID, desc,
|
2014-11-06 08:20:14 +01:00
|
|
|
|
(ID2D1BrushVtbl *)&d2d_solid_color_brush_vtbl);
|
2016-03-31 13:49:31 +02:00
|
|
|
|
(*brush)->u.solid.color = *color;
|
|
|
|
|
|
|
|
|
|
TRACE("Created brush %p.\n", *brush);
|
|
|
|
|
return S_OK;
|
2014-06-16 13:13:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline struct d2d_brush *impl_from_ID2D1LinearGradientBrush(ID2D1LinearGradientBrush *iface)
|
|
|
|
|
{
|
|
|
|
|
return CONTAINING_RECORD(iface, struct d2d_brush, ID2D1Brush_iface);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_linear_gradient_brush_QueryInterface(ID2D1LinearGradientBrush *iface,
|
|
|
|
|
REFIID iid, void **out)
|
|
|
|
|
{
|
|
|
|
|
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
|
|
|
|
|
|
|
|
|
|
if (IsEqualGUID(iid, &IID_ID2D1LinearGradientBrush)
|
|
|
|
|
|| IsEqualGUID(iid, &IID_ID2D1Brush)
|
|
|
|
|
|| IsEqualGUID(iid, &IID_ID2D1Resource)
|
|
|
|
|
|| IsEqualGUID(iid, &IID_IUnknown))
|
|
|
|
|
{
|
|
|
|
|
ID2D1LinearGradientBrush_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_linear_gradient_brush_AddRef(ID2D1LinearGradientBrush *iface)
|
|
|
|
|
{
|
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1LinearGradientBrush(iface);
|
|
|
|
|
ULONG refcount = InterlockedIncrement(&brush->refcount);
|
|
|
|
|
|
|
|
|
|
TRACE("%p increasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE d2d_linear_gradient_brush_Release(ID2D1LinearGradientBrush *iface)
|
|
|
|
|
{
|
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1LinearGradientBrush(iface);
|
|
|
|
|
ULONG refcount = InterlockedDecrement(&brush->refcount);
|
|
|
|
|
|
|
|
|
|
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
|
|
if (!refcount)
|
2016-10-28 08:51:06 +02:00
|
|
|
|
{
|
2017-09-26 12:22:39 +02:00
|
|
|
|
ID2D1GradientStopCollection_Release(&brush->u.linear.gradient->ID2D1GradientStopCollection_iface);
|
2015-08-02 18:56:06 +02:00
|
|
|
|
d2d_brush_destroy(brush);
|
2016-10-28 08:51:06 +02:00
|
|
|
|
}
|
2014-06-16 13:13:22 +02:00
|
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_linear_gradient_brush_GetFactory(ID2D1LinearGradientBrush *iface,
|
|
|
|
|
ID2D1Factory **factory)
|
|
|
|
|
{
|
2015-08-02 18:56:07 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1LinearGradientBrush(iface);
|
2014-06-16 13:13:22 +02:00
|
|
|
|
|
2015-08-02 18:56:07 +02:00
|
|
|
|
TRACE("iface %p, factory %p.\n", iface, factory);
|
|
|
|
|
|
|
|
|
|
ID2D1Factory_AddRef(*factory = brush->factory);
|
2014-06-16 13:13:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_linear_gradient_brush_SetOpacity(ID2D1LinearGradientBrush *iface, float opacity)
|
|
|
|
|
{
|
2017-09-26 12:22:36 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1LinearGradientBrush(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p, opacity %.8e.\n", iface, opacity);
|
|
|
|
|
|
|
|
|
|
brush->opacity = opacity;
|
2014-06-16 13:13:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_linear_gradient_brush_SetTransform(ID2D1LinearGradientBrush *iface,
|
|
|
|
|
const D2D1_MATRIX_3X2_F *transform)
|
|
|
|
|
{
|
2015-01-29 10:27:24 +01:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1LinearGradientBrush(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p, transform %p.\n", iface, transform);
|
|
|
|
|
|
|
|
|
|
brush->transform = *transform;
|
2014-06-16 13:13:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static float STDMETHODCALLTYPE d2d_linear_gradient_brush_GetOpacity(ID2D1LinearGradientBrush *iface)
|
|
|
|
|
{
|
2017-09-26 12:22:37 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1LinearGradientBrush(iface);
|
2014-06-16 13:13:22 +02:00
|
|
|
|
|
2017-09-26 12:22:37 +02:00
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
|
|
return brush->opacity;
|
2014-06-16 13:13:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_linear_gradient_brush_GetTransform(ID2D1LinearGradientBrush *iface,
|
|
|
|
|
D2D1_MATRIX_3X2_F *transform)
|
|
|
|
|
{
|
2015-01-29 10:27:21 +01:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1LinearGradientBrush(iface);
|
2014-06-16 13:13:22 +02:00
|
|
|
|
|
2015-01-29 10:27:21 +01:00
|
|
|
|
TRACE("iface %p, transform %p.\n", iface, transform);
|
2014-06-16 13:13:22 +02:00
|
|
|
|
|
2015-01-29 10:27:21 +01:00
|
|
|
|
*transform = brush->transform;
|
2014-06-16 13:13:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_linear_gradient_brush_SetStartPoint(ID2D1LinearGradientBrush *iface,
|
|
|
|
|
D2D1_POINT_2F start_point)
|
|
|
|
|
{
|
2016-10-28 08:51:05 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1LinearGradientBrush(iface);
|
|
|
|
|
|
2018-09-25 00:25:17 +02:00
|
|
|
|
TRACE("iface %p, start_point %s.\n", iface, debug_d2d_point_2f(&start_point));
|
2016-10-28 08:51:05 +02:00
|
|
|
|
|
2017-09-26 12:22:39 +02:00
|
|
|
|
brush->u.linear.start = start_point;
|
2014-06-16 13:13:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_linear_gradient_brush_SetEndPoint(ID2D1LinearGradientBrush *iface,
|
|
|
|
|
D2D1_POINT_2F end_point)
|
|
|
|
|
{
|
2016-10-28 08:51:05 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1LinearGradientBrush(iface);
|
|
|
|
|
|
2018-09-25 00:25:17 +02:00
|
|
|
|
TRACE("iface %p, end_point %s.\n", iface, debug_d2d_point_2f(&end_point));
|
2016-10-28 08:51:05 +02:00
|
|
|
|
|
2017-09-26 12:22:39 +02:00
|
|
|
|
brush->u.linear.end = end_point;
|
2014-06-16 13:13:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-05 17:33:03 +02:00
|
|
|
|
static D2D1_POINT_2F * STDMETHODCALLTYPE d2d_linear_gradient_brush_GetStartPoint(ID2D1LinearGradientBrush *iface,
|
|
|
|
|
D2D1_POINT_2F *point)
|
2014-06-16 13:13:22 +02:00
|
|
|
|
{
|
2016-10-28 08:51:05 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1LinearGradientBrush(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p, point %p.\n", iface, point);
|
2014-06-16 13:13:22 +02:00
|
|
|
|
|
2017-09-26 12:22:39 +02:00
|
|
|
|
*point = brush->u.linear.start;
|
2014-06-16 13:13:22 +02:00
|
|
|
|
return point;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-05 17:33:03 +02:00
|
|
|
|
static D2D1_POINT_2F * STDMETHODCALLTYPE d2d_linear_gradient_brush_GetEndPoint(ID2D1LinearGradientBrush *iface,
|
|
|
|
|
D2D1_POINT_2F *point)
|
2014-06-16 13:13:22 +02:00
|
|
|
|
{
|
2016-10-28 08:51:05 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1LinearGradientBrush(iface);
|
2014-06-16 13:13:22 +02:00
|
|
|
|
|
2016-10-28 08:51:05 +02:00
|
|
|
|
TRACE("iface %p, point %p.\n", iface, point);
|
|
|
|
|
|
2017-09-26 12:22:39 +02:00
|
|
|
|
*point = brush->u.linear.end;
|
2014-06-16 13:13:22 +02:00
|
|
|
|
return point;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_linear_gradient_brush_GetGradientStopCollection(ID2D1LinearGradientBrush *iface,
|
|
|
|
|
ID2D1GradientStopCollection **gradient)
|
|
|
|
|
{
|
2016-10-28 08:51:06 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1LinearGradientBrush(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p, gradient %p.\n", iface, gradient);
|
2014-06-16 13:13:22 +02:00
|
|
|
|
|
2017-09-26 12:22:39 +02:00
|
|
|
|
ID2D1GradientStopCollection_AddRef(*gradient = &brush->u.linear.gradient->ID2D1GradientStopCollection_iface);
|
2014-06-16 13:13:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct ID2D1LinearGradientBrushVtbl d2d_linear_gradient_brush_vtbl =
|
|
|
|
|
{
|
|
|
|
|
d2d_linear_gradient_brush_QueryInterface,
|
|
|
|
|
d2d_linear_gradient_brush_AddRef,
|
|
|
|
|
d2d_linear_gradient_brush_Release,
|
|
|
|
|
d2d_linear_gradient_brush_GetFactory,
|
|
|
|
|
d2d_linear_gradient_brush_SetOpacity,
|
|
|
|
|
d2d_linear_gradient_brush_SetTransform,
|
|
|
|
|
d2d_linear_gradient_brush_GetOpacity,
|
|
|
|
|
d2d_linear_gradient_brush_GetTransform,
|
|
|
|
|
d2d_linear_gradient_brush_SetStartPoint,
|
|
|
|
|
d2d_linear_gradient_brush_SetEndPoint,
|
|
|
|
|
d2d_linear_gradient_brush_GetStartPoint,
|
|
|
|
|
d2d_linear_gradient_brush_GetEndPoint,
|
|
|
|
|
d2d_linear_gradient_brush_GetGradientStopCollection,
|
|
|
|
|
};
|
|
|
|
|
|
2018-01-30 13:24:39 +01:00
|
|
|
|
HRESULT d2d_linear_gradient_brush_create(ID2D1Factory *factory,
|
|
|
|
|
const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES *gradient_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
|
|
|
|
|
ID2D1GradientStopCollection *gradient, struct d2d_brush **brush)
|
2014-06-16 13:13:22 +02:00
|
|
|
|
{
|
2018-01-30 13:24:39 +01:00
|
|
|
|
if (!(*brush = heap_alloc_zero(sizeof(**brush))))
|
2016-03-31 13:49:31 +02:00
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
|
|
d2d_brush_init(*brush, factory, D2D_BRUSH_TYPE_LINEAR, brush_desc,
|
2014-11-06 08:20:14 +01:00
|
|
|
|
(ID2D1BrushVtbl *)&d2d_linear_gradient_brush_vtbl);
|
2017-09-26 12:22:39 +02:00
|
|
|
|
(*brush)->u.linear.gradient = unsafe_impl_from_ID2D1GradientStopCollection(gradient);
|
|
|
|
|
ID2D1GradientStopCollection_AddRef(&(*brush)->u.linear.gradient->ID2D1GradientStopCollection_iface);
|
|
|
|
|
(*brush)->u.linear.start = gradient_brush_desc->startPoint;
|
|
|
|
|
(*brush)->u.linear.end = gradient_brush_desc->endPoint;
|
2016-03-31 13:49:31 +02:00
|
|
|
|
|
|
|
|
|
TRACE("Created brush %p.\n", *brush);
|
|
|
|
|
return S_OK;
|
2014-11-06 08:20:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-26 12:22:40 +02:00
|
|
|
|
static inline struct d2d_brush *impl_from_ID2D1RadialGradientBrush(ID2D1RadialGradientBrush *iface)
|
|
|
|
|
{
|
|
|
|
|
return CONTAINING_RECORD(iface, struct d2d_brush, ID2D1Brush_iface);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_radial_gradient_brush_QueryInterface(ID2D1RadialGradientBrush *iface,
|
|
|
|
|
REFIID iid, void **out)
|
|
|
|
|
{
|
|
|
|
|
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
|
|
|
|
|
|
|
|
|
|
if (IsEqualGUID(iid, &IID_ID2D1RadialGradientBrush)
|
|
|
|
|
|| IsEqualGUID(iid, &IID_ID2D1Brush)
|
|
|
|
|
|| IsEqualGUID(iid, &IID_ID2D1Resource)
|
|
|
|
|
|| IsEqualGUID(iid, &IID_IUnknown))
|
|
|
|
|
{
|
|
|
|
|
ID2D1RadialGradientBrush_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_radial_gradient_brush_AddRef(ID2D1RadialGradientBrush *iface)
|
|
|
|
|
{
|
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1RadialGradientBrush(iface);
|
|
|
|
|
ULONG refcount = InterlockedIncrement(&brush->refcount);
|
|
|
|
|
|
|
|
|
|
TRACE("%p increasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE d2d_radial_gradient_brush_Release(ID2D1RadialGradientBrush *iface)
|
|
|
|
|
{
|
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1RadialGradientBrush(iface);
|
|
|
|
|
ULONG refcount = InterlockedDecrement(&brush->refcount);
|
|
|
|
|
|
|
|
|
|
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
|
|
if (!refcount)
|
2017-09-27 09:47:56 +02:00
|
|
|
|
{
|
|
|
|
|
ID2D1GradientStopCollection_Release(&brush->u.radial.gradient->ID2D1GradientStopCollection_iface);
|
2017-09-26 12:22:40 +02:00
|
|
|
|
d2d_brush_destroy(brush);
|
2017-09-27 09:47:56 +02:00
|
|
|
|
}
|
2017-09-26 12:22:40 +02:00
|
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_radial_gradient_brush_GetFactory(ID2D1RadialGradientBrush *iface,
|
|
|
|
|
ID2D1Factory **factory)
|
|
|
|
|
{
|
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1RadialGradientBrush(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p, factory %p.\n", iface, factory);
|
|
|
|
|
|
|
|
|
|
ID2D1Factory_AddRef(*factory = brush->factory);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_radial_gradient_brush_SetOpacity(ID2D1RadialGradientBrush *iface, float opacity)
|
|
|
|
|
{
|
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1RadialGradientBrush(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p, opacity %.8e.\n", iface, opacity);
|
|
|
|
|
|
|
|
|
|
brush->opacity = opacity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_radial_gradient_brush_SetTransform(ID2D1RadialGradientBrush *iface,
|
|
|
|
|
const D2D1_MATRIX_3X2_F *transform)
|
|
|
|
|
{
|
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1RadialGradientBrush(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p, transform %p.\n", iface, transform);
|
|
|
|
|
|
|
|
|
|
brush->transform = *transform;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static float STDMETHODCALLTYPE d2d_radial_gradient_brush_GetOpacity(ID2D1RadialGradientBrush *iface)
|
|
|
|
|
{
|
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1RadialGradientBrush(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
|
|
return brush->opacity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_radial_gradient_brush_GetTransform(ID2D1RadialGradientBrush *iface,
|
|
|
|
|
D2D1_MATRIX_3X2_F *transform)
|
|
|
|
|
{
|
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1RadialGradientBrush(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p, transform %p.\n", iface, transform);
|
|
|
|
|
|
|
|
|
|
*transform = brush->transform;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_radial_gradient_brush_SetCenter(ID2D1RadialGradientBrush *iface,
|
|
|
|
|
D2D1_POINT_2F centre)
|
|
|
|
|
{
|
2017-09-27 09:47:53 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1RadialGradientBrush(iface);
|
|
|
|
|
|
2018-09-25 00:25:17 +02:00
|
|
|
|
TRACE("iface %p, centre %s.\n", iface, debug_d2d_point_2f(¢re));
|
2017-09-27 09:47:53 +02:00
|
|
|
|
|
|
|
|
|
brush->u.radial.centre = centre;
|
2017-09-26 12:22:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_radial_gradient_brush_SetGradientOriginOffset(ID2D1RadialGradientBrush *iface,
|
|
|
|
|
D2D1_POINT_2F offset)
|
|
|
|
|
{
|
2017-09-27 09:47:55 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1RadialGradientBrush(iface);
|
|
|
|
|
|
2018-09-25 00:25:17 +02:00
|
|
|
|
TRACE("iface %p, offset %s.\n", iface, debug_d2d_point_2f(&offset));
|
2017-09-27 09:47:55 +02:00
|
|
|
|
|
|
|
|
|
brush->u.radial.offset = offset;
|
2017-09-26 12:22:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_radial_gradient_brush_SetRadiusX(ID2D1RadialGradientBrush *iface, float radius)
|
|
|
|
|
{
|
2017-09-28 13:14:16 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1RadialGradientBrush(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p, radius %.8e.\n", iface, radius);
|
|
|
|
|
|
|
|
|
|
brush->u.radial.radius.x = radius;
|
2017-09-26 12:22:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_radial_gradient_brush_SetRadiusY(ID2D1RadialGradientBrush *iface, float radius)
|
|
|
|
|
{
|
2017-09-28 13:14:17 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1RadialGradientBrush(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p, radius %.8e.\n", iface, radius);
|
|
|
|
|
|
|
|
|
|
brush->u.radial.radius.y = radius;
|
2017-09-26 12:22:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static D2D1_POINT_2F * STDMETHODCALLTYPE d2d_radial_gradient_brush_GetCenter(ID2D1RadialGradientBrush *iface,
|
|
|
|
|
D2D1_POINT_2F *centre)
|
|
|
|
|
{
|
2017-09-27 09:47:52 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1RadialGradientBrush(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p, centre %p.\n", iface, centre);
|
2017-09-26 12:22:40 +02:00
|
|
|
|
|
2017-09-27 09:47:52 +02:00
|
|
|
|
*centre = brush->u.radial.centre;
|
2017-09-26 12:22:40 +02:00
|
|
|
|
return centre;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static D2D1_POINT_2F * STDMETHODCALLTYPE d2d_radial_gradient_brush_GetGradientOriginOffset(
|
|
|
|
|
ID2D1RadialGradientBrush *iface, D2D1_POINT_2F *offset)
|
|
|
|
|
{
|
2017-09-27 09:47:54 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1RadialGradientBrush(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p, offset %p.\n", iface, offset);
|
2017-09-26 12:22:40 +02:00
|
|
|
|
|
2017-09-27 09:47:54 +02:00
|
|
|
|
*offset = brush->u.radial.offset;
|
2017-09-26 12:22:40 +02:00
|
|
|
|
return offset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static float STDMETHODCALLTYPE d2d_radial_gradient_brush_GetRadiusX(ID2D1RadialGradientBrush *iface)
|
|
|
|
|
{
|
2017-09-28 13:14:14 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1RadialGradientBrush(iface);
|
2017-09-26 12:22:40 +02:00
|
|
|
|
|
2017-09-28 13:14:14 +02:00
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
|
|
return brush->u.radial.radius.x;
|
2017-09-26 12:22:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static float STDMETHODCALLTYPE d2d_radial_gradient_brush_GetRadiusY(ID2D1RadialGradientBrush *iface)
|
|
|
|
|
{
|
2017-09-28 13:14:15 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1RadialGradientBrush(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
2017-09-26 12:22:40 +02:00
|
|
|
|
|
2017-09-28 13:14:15 +02:00
|
|
|
|
return brush->u.radial.radius.y;
|
2017-09-26 12:22:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_radial_gradient_brush_GetGradientStopCollection(ID2D1RadialGradientBrush *iface,
|
|
|
|
|
ID2D1GradientStopCollection **gradient)
|
|
|
|
|
{
|
2017-09-27 09:47:56 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1RadialGradientBrush(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p, gradient %p.\n", iface, gradient);
|
2017-09-26 12:22:40 +02:00
|
|
|
|
|
2017-09-27 09:47:56 +02:00
|
|
|
|
ID2D1GradientStopCollection_AddRef(*gradient = &brush->u.radial.gradient->ID2D1GradientStopCollection_iface);
|
2017-09-26 12:22:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct ID2D1RadialGradientBrushVtbl d2d_radial_gradient_brush_vtbl =
|
|
|
|
|
{
|
|
|
|
|
d2d_radial_gradient_brush_QueryInterface,
|
|
|
|
|
d2d_radial_gradient_brush_AddRef,
|
|
|
|
|
d2d_radial_gradient_brush_Release,
|
|
|
|
|
d2d_radial_gradient_brush_GetFactory,
|
|
|
|
|
d2d_radial_gradient_brush_SetOpacity,
|
|
|
|
|
d2d_radial_gradient_brush_SetTransform,
|
|
|
|
|
d2d_radial_gradient_brush_GetOpacity,
|
|
|
|
|
d2d_radial_gradient_brush_GetTransform,
|
|
|
|
|
d2d_radial_gradient_brush_SetCenter,
|
|
|
|
|
d2d_radial_gradient_brush_SetGradientOriginOffset,
|
|
|
|
|
d2d_radial_gradient_brush_SetRadiusX,
|
|
|
|
|
d2d_radial_gradient_brush_SetRadiusY,
|
|
|
|
|
d2d_radial_gradient_brush_GetCenter,
|
|
|
|
|
d2d_radial_gradient_brush_GetGradientOriginOffset,
|
|
|
|
|
d2d_radial_gradient_brush_GetRadiusX,
|
|
|
|
|
d2d_radial_gradient_brush_GetRadiusY,
|
|
|
|
|
d2d_radial_gradient_brush_GetGradientStopCollection,
|
|
|
|
|
};
|
|
|
|
|
|
2017-09-27 09:47:52 +02:00
|
|
|
|
HRESULT d2d_radial_gradient_brush_create(ID2D1Factory *factory,
|
|
|
|
|
const D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES *gradient_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
|
2017-09-26 12:22:40 +02:00
|
|
|
|
ID2D1GradientStopCollection *gradient, struct d2d_brush **brush)
|
|
|
|
|
{
|
|
|
|
|
struct d2d_brush *b;
|
|
|
|
|
|
2018-01-30 13:24:39 +01:00
|
|
|
|
if (!(b = heap_alloc_zero(sizeof(*b))))
|
2017-09-26 12:22:40 +02:00
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
|
|
d2d_brush_init(b, factory, D2D_BRUSH_TYPE_RADIAL, brush_desc, (ID2D1BrushVtbl *)&d2d_radial_gradient_brush_vtbl);
|
2017-09-27 09:47:56 +02:00
|
|
|
|
b->u.radial.gradient = unsafe_impl_from_ID2D1GradientStopCollection(gradient);
|
|
|
|
|
ID2D1GradientStopCollection_AddRef(&b->u.radial.gradient->ID2D1GradientStopCollection_iface);
|
2017-09-27 09:47:52 +02:00
|
|
|
|
b->u.radial.centre = gradient_desc->center;
|
2017-09-27 09:47:54 +02:00
|
|
|
|
b->u.radial.offset = gradient_desc->gradientOriginOffset;
|
2017-09-28 13:14:14 +02:00
|
|
|
|
b->u.radial.radius.x = gradient_desc->radiusX;
|
|
|
|
|
b->u.radial.radius.y = gradient_desc->radiusY;
|
2017-09-26 12:22:40 +02:00
|
|
|
|
|
|
|
|
|
TRACE("Created brush %p.\n", b);
|
|
|
|
|
*brush = b;
|
|
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
static inline struct d2d_brush *impl_from_ID2D1BitmapBrush1(ID2D1BitmapBrush1 *iface)
|
2014-12-01 08:45:45 +01:00
|
|
|
|
{
|
|
|
|
|
return CONTAINING_RECORD(iface, struct d2d_brush, ID2D1Brush_iface);
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_bitmap_brush_QueryInterface(ID2D1BitmapBrush1 *iface,
|
2014-12-01 08:45:45 +01:00
|
|
|
|
REFIID iid, void **out)
|
|
|
|
|
{
|
|
|
|
|
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
if (IsEqualGUID(iid, &IID_ID2D1BitmapBrush1)
|
|
|
|
|
|| IsEqualGUID(iid, &IID_ID2D1BitmapBrush)
|
2014-12-01 08:45:45 +01:00
|
|
|
|
|| IsEqualGUID(iid, &IID_ID2D1Brush)
|
|
|
|
|
|| IsEqualGUID(iid, &IID_ID2D1Resource)
|
|
|
|
|
|| IsEqualGUID(iid, &IID_IUnknown))
|
|
|
|
|
{
|
2018-09-18 12:17:47 +02:00
|
|
|
|
ID2D1BitmapBrush1_AddRef(iface);
|
2014-12-01 08:45:45 +01:00
|
|
|
|
*out = iface;
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
|
|
|
|
|
|
|
|
|
|
*out = NULL;
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
static ULONG STDMETHODCALLTYPE d2d_bitmap_brush_AddRef(ID2D1BitmapBrush1 *iface)
|
2014-12-01 08:45:45 +01:00
|
|
|
|
{
|
2018-09-18 12:17:47 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
|
2014-12-01 08:45:45 +01:00
|
|
|
|
ULONG refcount = InterlockedIncrement(&brush->refcount);
|
|
|
|
|
|
|
|
|
|
TRACE("%p increasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
static ULONG STDMETHODCALLTYPE d2d_bitmap_brush_Release(ID2D1BitmapBrush1 *iface)
|
2014-12-01 08:45:45 +01:00
|
|
|
|
{
|
2018-09-18 12:17:47 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
|
2014-12-01 08:45:45 +01:00
|
|
|
|
ULONG refcount = InterlockedDecrement(&brush->refcount);
|
|
|
|
|
|
|
|
|
|
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
|
|
if (!refcount)
|
2015-02-06 09:57:01 +01:00
|
|
|
|
{
|
2015-07-29 11:36:20 +02:00
|
|
|
|
if (brush->u.bitmap.bitmap)
|
2018-05-23 13:44:12 +02:00
|
|
|
|
ID2D1Bitmap1_Release(&brush->u.bitmap.bitmap->ID2D1Bitmap1_iface);
|
2015-08-02 18:56:06 +02:00
|
|
|
|
d2d_brush_destroy(brush);
|
2015-02-06 09:57:01 +01:00
|
|
|
|
}
|
2014-12-01 08:45:45 +01:00
|
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
static void STDMETHODCALLTYPE d2d_bitmap_brush_GetFactory(ID2D1BitmapBrush1 *iface,
|
2014-12-01 08:45:45 +01:00
|
|
|
|
ID2D1Factory **factory)
|
|
|
|
|
{
|
2018-09-18 12:17:47 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
|
2014-12-01 08:45:45 +01:00
|
|
|
|
|
2015-08-02 18:56:06 +02:00
|
|
|
|
TRACE("iface %p, factory %p.\n", iface, factory);
|
|
|
|
|
|
|
|
|
|
ID2D1Factory_AddRef(*factory = brush->factory);
|
2014-12-01 08:45:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
static void STDMETHODCALLTYPE d2d_bitmap_brush_SetOpacity(ID2D1BitmapBrush1 *iface, float opacity)
|
2014-12-01 08:45:45 +01:00
|
|
|
|
{
|
2018-09-18 12:17:47 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
|
2014-12-01 08:45:45 +01:00
|
|
|
|
|
|
|
|
|
TRACE("iface %p, opacity %.8e.\n", iface, opacity);
|
|
|
|
|
|
|
|
|
|
brush->opacity = opacity;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
static void STDMETHODCALLTYPE d2d_bitmap_brush_SetTransform(ID2D1BitmapBrush1 *iface,
|
2014-12-01 08:45:45 +01:00
|
|
|
|
const D2D1_MATRIX_3X2_F *transform)
|
|
|
|
|
{
|
2018-09-18 12:17:47 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
|
2015-01-29 10:27:23 +01:00
|
|
|
|
|
|
|
|
|
TRACE("iface %p, transform %p.\n", iface, transform);
|
|
|
|
|
|
|
|
|
|
brush->transform = *transform;
|
2014-12-01 08:45:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
static float STDMETHODCALLTYPE d2d_bitmap_brush_GetOpacity(ID2D1BitmapBrush1 *iface)
|
2014-12-01 08:45:45 +01:00
|
|
|
|
{
|
2018-09-18 12:17:47 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
|
2014-12-01 08:45:45 +01:00
|
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
|
|
return brush->opacity;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
static void STDMETHODCALLTYPE d2d_bitmap_brush_GetTransform(ID2D1BitmapBrush1 *iface,
|
2014-12-01 08:45:45 +01:00
|
|
|
|
D2D1_MATRIX_3X2_F *transform)
|
|
|
|
|
{
|
2018-09-18 12:17:47 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
|
2014-12-01 08:45:45 +01:00
|
|
|
|
|
2015-01-29 10:27:20 +01:00
|
|
|
|
TRACE("iface %p, transform %p.\n", iface, transform);
|
2014-12-01 08:45:45 +01:00
|
|
|
|
|
2015-01-29 10:27:20 +01:00
|
|
|
|
*transform = brush->transform;
|
2014-12-01 08:45:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
static void STDMETHODCALLTYPE d2d_bitmap_brush_SetExtendModeX(ID2D1BitmapBrush1 *iface, D2D1_EXTEND_MODE mode)
|
2014-12-01 08:45:45 +01:00
|
|
|
|
{
|
2018-09-18 12:17:47 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
|
2015-04-27 16:39:32 +02:00
|
|
|
|
|
|
|
|
|
TRACE("iface %p, mode %#x.\n", iface, mode);
|
|
|
|
|
|
|
|
|
|
brush->u.bitmap.extend_mode_x = mode;
|
2014-12-01 08:45:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
static void STDMETHODCALLTYPE d2d_bitmap_brush_SetExtendModeY(ID2D1BitmapBrush1 *iface, D2D1_EXTEND_MODE mode)
|
2014-12-01 08:45:45 +01:00
|
|
|
|
{
|
2018-09-18 12:17:47 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
|
2015-04-27 16:39:34 +02:00
|
|
|
|
|
|
|
|
|
TRACE("iface %p, mode %#x.\n", iface, mode);
|
|
|
|
|
|
|
|
|
|
brush->u.bitmap.extend_mode_y = mode;
|
2014-12-01 08:45:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
static void STDMETHODCALLTYPE d2d_bitmap_brush_SetInterpolationMode(ID2D1BitmapBrush1 *iface,
|
2014-12-01 08:45:45 +01:00
|
|
|
|
D2D1_BITMAP_INTERPOLATION_MODE mode)
|
|
|
|
|
{
|
2018-09-18 12:17:47 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
|
2015-04-24 19:31:35 +02:00
|
|
|
|
|
|
|
|
|
TRACE("iface %p, mode %#x.\n", iface, mode);
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
switch (mode)
|
|
|
|
|
{
|
|
|
|
|
case D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR:
|
|
|
|
|
case D2D1_BITMAP_INTERPOLATION_MODE_LINEAR:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
WARN("Unknown interpolation mode %#x.\n", mode);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-07 00:51:59 +02:00
|
|
|
|
brush->u.bitmap.interpolation_mode = d2d1_1_interp_mode_from_d2d1(mode);
|
2014-12-01 08:45:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
static void STDMETHODCALLTYPE d2d_bitmap_brush_SetBitmap(ID2D1BitmapBrush1 *iface, ID2D1Bitmap *bitmap)
|
2014-12-01 08:45:45 +01:00
|
|
|
|
{
|
2018-09-18 12:17:47 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
|
2015-07-29 11:36:20 +02:00
|
|
|
|
|
|
|
|
|
TRACE("iface %p, bitmap %p.\n", iface, bitmap);
|
|
|
|
|
|
|
|
|
|
if (bitmap)
|
|
|
|
|
ID2D1Bitmap_AddRef(bitmap);
|
|
|
|
|
if (brush->u.bitmap.bitmap)
|
2018-05-23 13:44:12 +02:00
|
|
|
|
ID2D1Bitmap1_Release(&brush->u.bitmap.bitmap->ID2D1Bitmap1_iface);
|
2015-07-29 11:36:20 +02:00
|
|
|
|
brush->u.bitmap.bitmap = unsafe_impl_from_ID2D1Bitmap(bitmap);
|
2014-12-01 08:45:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
static D2D1_EXTEND_MODE STDMETHODCALLTYPE d2d_bitmap_brush_GetExtendModeX(ID2D1BitmapBrush1 *iface)
|
2014-12-01 08:45:45 +01:00
|
|
|
|
{
|
2018-09-18 12:17:47 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
|
2014-12-01 08:45:45 +01:00
|
|
|
|
|
2015-04-27 16:39:33 +02:00
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
|
|
return brush->u.bitmap.extend_mode_x;
|
2014-12-01 08:45:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
static D2D1_EXTEND_MODE STDMETHODCALLTYPE d2d_bitmap_brush_GetExtendModeY(ID2D1BitmapBrush1 *iface)
|
2014-12-01 08:45:45 +01:00
|
|
|
|
{
|
2018-09-18 12:17:47 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
|
2014-12-01 08:45:45 +01:00
|
|
|
|
|
2015-04-27 16:39:35 +02:00
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
|
|
return brush->u.bitmap.extend_mode_y;
|
2014-12-01 08:45:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
static D2D1_BITMAP_INTERPOLATION_MODE STDMETHODCALLTYPE d2d_bitmap_brush_GetInterpolationMode(ID2D1BitmapBrush1 *iface)
|
2014-12-01 08:45:45 +01:00
|
|
|
|
{
|
2018-09-18 12:17:47 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
|
2015-04-24 19:31:36 +02:00
|
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
2014-12-01 08:45:45 +01:00
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
switch (brush->u.bitmap.interpolation_mode)
|
|
|
|
|
{
|
|
|
|
|
case D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR:
|
2020-04-07 00:51:58 +02:00
|
|
|
|
return D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR;
|
2018-09-18 12:17:47 +02:00
|
|
|
|
case D2D1_INTERPOLATION_MODE_LINEAR:
|
|
|
|
|
default:
|
|
|
|
|
return D2D1_BITMAP_INTERPOLATION_MODE_LINEAR;
|
|
|
|
|
}
|
2014-12-01 08:45:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
static void STDMETHODCALLTYPE d2d_bitmap_brush_GetBitmap(ID2D1BitmapBrush1 *iface, ID2D1Bitmap **bitmap)
|
2014-12-01 08:45:45 +01:00
|
|
|
|
{
|
2018-09-18 12:17:47 +02:00
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
|
2015-04-23 20:23:26 +02:00
|
|
|
|
|
|
|
|
|
TRACE("iface %p, bitmap %p.\n", iface, bitmap);
|
|
|
|
|
|
2018-05-23 13:44:12 +02:00
|
|
|
|
if ((*bitmap = (ID2D1Bitmap *)&brush->u.bitmap.bitmap->ID2D1Bitmap1_iface))
|
2015-04-23 20:23:26 +02:00
|
|
|
|
ID2D1Bitmap_AddRef(*bitmap);
|
2014-12-01 08:45:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
static void STDMETHODCALLTYPE d2d_bitmap_brush_SetInterpolationMode1(ID2D1BitmapBrush1 *iface,
|
|
|
|
|
D2D1_INTERPOLATION_MODE mode)
|
|
|
|
|
{
|
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p, mode %#x.\n", iface, mode);
|
|
|
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
|
{
|
|
|
|
|
case D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR:
|
|
|
|
|
case D2D1_INTERPOLATION_MODE_LINEAR:
|
|
|
|
|
break;
|
|
|
|
|
case D2D1_INTERPOLATION_MODE_CUBIC:
|
|
|
|
|
case D2D1_INTERPOLATION_MODE_MULTI_SAMPLE_LINEAR:
|
|
|
|
|
case D2D1_INTERPOLATION_MODE_ANISOTROPIC:
|
|
|
|
|
case D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC:
|
|
|
|
|
FIXME("Unhandled interpolation mode %#x.\n", mode);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
WARN("Unknown interpolation mode %#x.\n", mode);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
brush->u.bitmap.interpolation_mode = mode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static D2D1_INTERPOLATION_MODE STDMETHODCALLTYPE d2d_bitmap_brush_GetInterpolationMode1(ID2D1BitmapBrush1 *iface)
|
|
|
|
|
{
|
|
|
|
|
struct d2d_brush *brush = impl_from_ID2D1BitmapBrush1(iface);
|
|
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
|
|
return brush->u.bitmap.interpolation_mode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct ID2D1BitmapBrush1Vtbl d2d_bitmap_brush_vtbl =
|
2014-12-01 08:45:45 +01:00
|
|
|
|
{
|
|
|
|
|
d2d_bitmap_brush_QueryInterface,
|
|
|
|
|
d2d_bitmap_brush_AddRef,
|
|
|
|
|
d2d_bitmap_brush_Release,
|
|
|
|
|
d2d_bitmap_brush_GetFactory,
|
|
|
|
|
d2d_bitmap_brush_SetOpacity,
|
|
|
|
|
d2d_bitmap_brush_SetTransform,
|
|
|
|
|
d2d_bitmap_brush_GetOpacity,
|
|
|
|
|
d2d_bitmap_brush_GetTransform,
|
|
|
|
|
d2d_bitmap_brush_SetExtendModeX,
|
|
|
|
|
d2d_bitmap_brush_SetExtendModeY,
|
|
|
|
|
d2d_bitmap_brush_SetInterpolationMode,
|
|
|
|
|
d2d_bitmap_brush_SetBitmap,
|
|
|
|
|
d2d_bitmap_brush_GetExtendModeX,
|
|
|
|
|
d2d_bitmap_brush_GetExtendModeY,
|
|
|
|
|
d2d_bitmap_brush_GetInterpolationMode,
|
|
|
|
|
d2d_bitmap_brush_GetBitmap,
|
2018-09-18 12:17:47 +02:00
|
|
|
|
d2d_bitmap_brush_SetInterpolationMode1,
|
|
|
|
|
d2d_bitmap_brush_GetInterpolationMode1,
|
2014-12-01 08:45:45 +01:00
|
|
|
|
};
|
|
|
|
|
|
2018-09-18 12:17:48 +02:00
|
|
|
|
HRESULT d2d_bitmap_brush_create(ID2D1Factory *factory, ID2D1Bitmap *bitmap,
|
|
|
|
|
const D2D1_BITMAP_BRUSH_PROPERTIES1 *bitmap_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
|
|
|
|
|
struct d2d_brush **brush)
|
2014-12-01 08:45:45 +01:00
|
|
|
|
{
|
2018-01-30 13:24:39 +01:00
|
|
|
|
if (!(*brush = heap_alloc_zero(sizeof(**brush))))
|
2016-03-31 13:49:31 +02:00
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
|
|
d2d_brush_init(*brush, factory, D2D_BRUSH_TYPE_BITMAP,
|
2015-02-06 09:57:01 +01:00
|
|
|
|
brush_desc, (ID2D1BrushVtbl *)&d2d_bitmap_brush_vtbl);
|
2016-03-31 13:49:31 +02:00
|
|
|
|
if (((*brush)->u.bitmap.bitmap = unsafe_impl_from_ID2D1Bitmap(bitmap)))
|
2018-05-23 13:44:12 +02:00
|
|
|
|
ID2D1Bitmap1_AddRef(&(*brush)->u.bitmap.bitmap->ID2D1Bitmap1_iface);
|
2015-04-24 19:31:35 +02:00
|
|
|
|
if (bitmap_brush_desc)
|
2015-04-27 16:39:32 +02:00
|
|
|
|
{
|
2016-03-31 13:49:31 +02:00
|
|
|
|
(*brush)->u.bitmap.extend_mode_x = bitmap_brush_desc->extendModeX;
|
|
|
|
|
(*brush)->u.bitmap.extend_mode_y = bitmap_brush_desc->extendModeY;
|
|
|
|
|
(*brush)->u.bitmap.interpolation_mode = bitmap_brush_desc->interpolationMode;
|
2015-04-27 16:39:32 +02:00
|
|
|
|
}
|
2015-04-24 19:31:35 +02:00
|
|
|
|
else
|
2015-04-27 16:39:32 +02:00
|
|
|
|
{
|
2016-03-31 13:49:31 +02:00
|
|
|
|
(*brush)->u.bitmap.extend_mode_x = D2D1_EXTEND_MODE_CLAMP;
|
|
|
|
|
(*brush)->u.bitmap.extend_mode_y = D2D1_EXTEND_MODE_CLAMP;
|
2018-10-04 13:37:32 +02:00
|
|
|
|
(*brush)->u.bitmap.interpolation_mode = D2D1_INTERPOLATION_MODE_LINEAR;
|
2015-04-27 16:39:32 +02:00
|
|
|
|
}
|
2016-03-31 13:49:31 +02:00
|
|
|
|
|
|
|
|
|
TRACE("Created brush %p.\n", *brush);
|
|
|
|
|
return S_OK;
|
2014-12-01 08:45:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-11-06 08:20:14 +01:00
|
|
|
|
struct d2d_brush *unsafe_impl_from_ID2D1Brush(ID2D1Brush *iface)
|
|
|
|
|
{
|
|
|
|
|
if (!iface)
|
|
|
|
|
return NULL;
|
|
|
|
|
assert(iface->lpVtbl == (const ID2D1BrushVtbl *)&d2d_solid_color_brush_vtbl
|
2014-12-01 08:45:45 +01:00
|
|
|
|
|| iface->lpVtbl == (const ID2D1BrushVtbl *)&d2d_linear_gradient_brush_vtbl
|
2017-09-26 12:22:40 +02:00
|
|
|
|
|| iface->lpVtbl == (const ID2D1BrushVtbl *)&d2d_radial_gradient_brush_vtbl
|
2014-12-01 08:45:45 +01:00
|
|
|
|
|| iface->lpVtbl == (const ID2D1BrushVtbl *)&d2d_bitmap_brush_vtbl);
|
2014-11-06 08:20:14 +01:00
|
|
|
|
return CONTAINING_RECORD(iface, struct d2d_brush, ID2D1Brush_iface);
|
2014-06-16 13:13:20 +02:00
|
|
|
|
}
|
2015-02-06 09:57:01 +01:00
|
|
|
|
|
2021-06-28 09:17:35 +02:00
|
|
|
|
static D3D11_TEXTURE_ADDRESS_MODE texture_address_mode_from_extend_mode(D2D1_EXTEND_MODE mode)
|
2015-04-27 16:39:32 +02:00
|
|
|
|
{
|
|
|
|
|
switch (mode)
|
|
|
|
|
{
|
|
|
|
|
case D2D1_EXTEND_MODE_CLAMP:
|
2021-06-28 09:17:35 +02:00
|
|
|
|
return D3D11_TEXTURE_ADDRESS_CLAMP;
|
2015-04-27 16:39:32 +02:00
|
|
|
|
case D2D1_EXTEND_MODE_WRAP:
|
2021-06-28 09:17:35 +02:00
|
|
|
|
return D3D11_TEXTURE_ADDRESS_WRAP;
|
2015-04-27 16:39:32 +02:00
|
|
|
|
case D2D1_EXTEND_MODE_MIRROR:
|
2021-06-28 09:17:35 +02:00
|
|
|
|
return D3D11_TEXTURE_ADDRESS_MIRROR;
|
2015-04-27 16:39:32 +02:00
|
|
|
|
default:
|
|
|
|
|
FIXME("Unhandled extend mode %#x.\n", mode);
|
2021-06-28 09:17:35 +02:00
|
|
|
|
return D3D11_TEXTURE_ADDRESS_CLAMP;
|
2015-04-27 16:39:32 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-10 14:13:23 +02:00
|
|
|
|
BOOL d2d_brush_fill_cb(const struct d2d_brush *brush, struct d2d_brush_cb *cb)
|
2015-07-14 15:57:41 +02:00
|
|
|
|
{
|
2017-09-28 13:14:18 +02:00
|
|
|
|
float theta, sin_theta, cos_theta;
|
|
|
|
|
float dpi_scale, d, s1, s2, t, u;
|
2017-09-23 13:36:59 +02:00
|
|
|
|
struct d2d_bitmap *bitmap;
|
2017-09-28 13:14:18 +02:00
|
|
|
|
D2D1_POINT_2F v_p, v_q;
|
2017-09-23 13:36:59 +02:00
|
|
|
|
D2D1_COLOR_F *colour;
|
2017-09-23 13:37:01 +02:00
|
|
|
|
D2D_MATRIX_3X2_F b;
|
2015-07-14 15:57:41 +02:00
|
|
|
|
|
2017-09-23 13:36:59 +02:00
|
|
|
|
if (!brush)
|
2015-07-14 15:57:41 +02:00
|
|
|
|
{
|
2017-09-23 13:36:59 +02:00
|
|
|
|
cb->type = D2D_BRUSH_TYPE_COUNT;
|
2015-11-18 16:10:21 +01:00
|
|
|
|
return TRUE;
|
2015-07-14 15:57:41 +02:00
|
|
|
|
}
|
2015-11-18 16:10:21 +01:00
|
|
|
|
|
2017-09-23 13:36:59 +02:00
|
|
|
|
cb->type = brush->type;
|
|
|
|
|
cb->opacity = brush->opacity;
|
|
|
|
|
|
|
|
|
|
switch (brush->type)
|
2015-07-14 15:57:41 +02:00
|
|
|
|
{
|
2017-09-23 13:36:59 +02:00
|
|
|
|
case D2D_BRUSH_TYPE_SOLID:
|
|
|
|
|
colour = &cb->u.solid.colour;
|
|
|
|
|
|
|
|
|
|
*colour = brush->u.solid.color;
|
|
|
|
|
colour->r *= colour->a;
|
|
|
|
|
colour->g *= colour->a;
|
|
|
|
|
colour->b *= colour->a;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2017-09-26 12:22:39 +02:00
|
|
|
|
case D2D_BRUSH_TYPE_LINEAR:
|
|
|
|
|
b = brush->transform;
|
|
|
|
|
d2d_point_transform(&cb->u.linear.start, &b, brush->u.linear.start.x, brush->u.linear.start.y);
|
|
|
|
|
d2d_point_transform(&cb->u.linear.end, &b, brush->u.linear.end.x, brush->u.linear.end.y);
|
|
|
|
|
cb->u.linear.stop_count = brush->u.linear.gradient->stop_count;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2017-09-28 13:14:18 +02:00
|
|
|
|
case D2D_BRUSH_TYPE_RADIAL:
|
|
|
|
|
b = brush->transform;
|
|
|
|
|
d2d_point_transform(&cb->u.radial.centre, &b, brush->u.radial.centre.x, brush->u.radial.centre.y);
|
|
|
|
|
b._31 = b._32 = 0.0f;
|
|
|
|
|
d2d_point_transform(&cb->u.radial.offset, &b, brush->u.radial.offset.x, brush->u.radial.offset.y);
|
|
|
|
|
|
|
|
|
|
/* After a transformation, the axes of the ellipse are no longer
|
|
|
|
|
* necessarily orthogonal, but they are conjugate diameters.
|
|
|
|
|
*
|
|
|
|
|
* A = ⎡a.x b.x⎤
|
|
|
|
|
* ⎣a.y b.y⎦
|
|
|
|
|
*
|
|
|
|
|
* = ⎡cos(θ) -sin(θ)⎤⎡σ₁ 0 ⎤⎡cos(φ) -sin(φ)⎤
|
|
|
|
|
* ⎣sin(θ) cos(θ)⎦⎣0 σ₂⎦⎣sin(φ) cos(φ)⎦
|
|
|
|
|
*
|
|
|
|
|
* a' = [σ₁· cos(θ) σ₁·sin(θ)]
|
|
|
|
|
* b' = [σ₂·-sin(θ) σ₂·cos(θ)] */
|
|
|
|
|
|
|
|
|
|
d2d_point_set(&v_p, brush->u.radial.radius.x * b._11, brush->u.radial.radius.y * b._21);
|
|
|
|
|
d2d_point_set(&v_q, brush->u.radial.radius.x * b._12, brush->u.radial.radius.y * b._22);
|
|
|
|
|
|
|
|
|
|
t = 0.5f * d2d_point_dot(&v_p, &v_p);
|
|
|
|
|
u = 0.5f * d2d_point_dot(&v_q, &v_q);
|
|
|
|
|
s1 = t + u;
|
|
|
|
|
|
|
|
|
|
t = t - u;
|
|
|
|
|
u = d2d_point_dot(&v_p, &v_q);
|
|
|
|
|
s2 = sqrtf(t * t + u * u);
|
|
|
|
|
|
|
|
|
|
theta = 0.5f * atan2(u, t);
|
|
|
|
|
sin_theta = sinf(theta);
|
|
|
|
|
cos_theta = cosf(theta);
|
|
|
|
|
|
|
|
|
|
t = sqrtf(s1 + s2);
|
|
|
|
|
d2d_point_set(&cb->u.radial.ra, t * cos_theta, t * sin_theta);
|
|
|
|
|
t = sqrtf(s1 - s2);
|
|
|
|
|
d2d_point_set(&cb->u.radial.rb, t * -sin_theta, t * cos_theta);
|
|
|
|
|
|
|
|
|
|
cb->u.radial.stop_count = brush->u.linear.gradient->stop_count;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2017-09-23 13:36:59 +02:00
|
|
|
|
case D2D_BRUSH_TYPE_BITMAP:
|
|
|
|
|
bitmap = brush->u.bitmap.bitmap;
|
|
|
|
|
|
|
|
|
|
/* Scale for bitmap size and dpi. */
|
|
|
|
|
b = brush->transform;
|
|
|
|
|
dpi_scale = bitmap->pixel_size.width * (96.0f / bitmap->dpi_x);
|
|
|
|
|
b._11 *= dpi_scale;
|
|
|
|
|
b._21 *= dpi_scale;
|
|
|
|
|
dpi_scale = bitmap->pixel_size.height * (96.0f / bitmap->dpi_y);
|
|
|
|
|
b._12 *= dpi_scale;
|
|
|
|
|
b._22 *= dpi_scale;
|
|
|
|
|
|
|
|
|
|
/* Invert the matrix. (Because the matrix is applied to the
|
|
|
|
|
* sampling coordinates. I.e., to scale the bitmap by 2 we need to
|
|
|
|
|
* divide the coordinates by 2.) */
|
|
|
|
|
d = b._11 * b._22 - b._21 * b._12;
|
|
|
|
|
if (d != 0.0f)
|
|
|
|
|
{
|
|
|
|
|
cb->u.bitmap._11 = b._22 / d;
|
|
|
|
|
cb->u.bitmap._21 = -b._21 / d;
|
|
|
|
|
cb->u.bitmap._31 = (b._21 * b._32 - b._31 * b._22) / d;
|
|
|
|
|
cb->u.bitmap._12 = -b._12 / d;
|
|
|
|
|
cb->u.bitmap._22 = b._11 / d;
|
|
|
|
|
cb->u.bitmap._32 = -(b._11 * b._32 - b._31 * b._12) / d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cb->u.bitmap.ignore_alpha = bitmap->format.alphaMode == D2D1_ALPHA_MODE_IGNORE;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2015-07-14 15:57:41 +02:00
|
|
|
|
|
2017-09-23 13:36:59 +02:00
|
|
|
|
default:
|
|
|
|
|
FIXME("Unhandled brush type %#x.\n", brush->type);
|
|
|
|
|
return FALSE;
|
2015-07-14 15:57:41 +02:00
|
|
|
|
}
|
2015-11-18 16:10:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-10 14:13:21 +02:00
|
|
|
|
static void d2d_brush_bind_bitmap(struct d2d_brush *brush, struct d2d_device_context *context,
|
|
|
|
|
unsigned int brush_idx)
|
2015-11-18 16:10:21 +01:00
|
|
|
|
{
|
2021-06-28 09:17:35 +02:00
|
|
|
|
ID3D11SamplerState **sampler_state;
|
2021-06-28 09:17:36 +02:00
|
|
|
|
ID3D11DeviceContext *d3d_context;
|
2015-11-18 16:10:21 +01:00
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
|
ID3D11Device1_GetImmediateContext(context->d3d_device, &d3d_context);
|
|
|
|
|
ID3D11DeviceContext_PSSetShaderResources(d3d_context, brush_idx, 1, &brush->u.bitmap.bitmap->srv);
|
2021-06-10 14:13:21 +02:00
|
|
|
|
|
|
|
|
|
sampler_state = &context->sampler_states
|
|
|
|
|
[brush->u.bitmap.interpolation_mode % D2D_SAMPLER_INTERPOLATION_MODE_COUNT]
|
|
|
|
|
[brush->u.bitmap.extend_mode_x % D2D_SAMPLER_EXTEND_MODE_COUNT]
|
|
|
|
|
[brush->u.bitmap.extend_mode_y % D2D_SAMPLER_EXTEND_MODE_COUNT];
|
|
|
|
|
|
|
|
|
|
if (!*sampler_state)
|
2015-11-18 16:10:21 +01:00
|
|
|
|
{
|
2021-06-28 09:17:35 +02:00
|
|
|
|
D3D11_SAMPLER_DESC sampler_desc;
|
2015-11-18 16:10:21 +01:00
|
|
|
|
|
2018-09-18 12:17:47 +02:00
|
|
|
|
if (brush->u.bitmap.interpolation_mode == D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR)
|
2021-06-28 09:17:35 +02:00
|
|
|
|
sampler_desc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
|
2015-11-18 16:10:21 +01:00
|
|
|
|
else
|
2021-06-28 09:17:35 +02:00
|
|
|
|
sampler_desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
2015-11-18 16:10:21 +01:00
|
|
|
|
sampler_desc.AddressU = texture_address_mode_from_extend_mode(brush->u.bitmap.extend_mode_x);
|
|
|
|
|
sampler_desc.AddressV = texture_address_mode_from_extend_mode(brush->u.bitmap.extend_mode_y);
|
2021-06-28 09:17:35 +02:00
|
|
|
|
sampler_desc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
2015-11-18 16:10:21 +01:00
|
|
|
|
sampler_desc.MipLODBias = 0.0f;
|
|
|
|
|
sampler_desc.MaxAnisotropy = 0;
|
2021-06-28 09:17:35 +02:00
|
|
|
|
sampler_desc.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
2015-11-18 16:10:21 +01:00
|
|
|
|
sampler_desc.BorderColor[0] = 0.0f;
|
|
|
|
|
sampler_desc.BorderColor[1] = 0.0f;
|
|
|
|
|
sampler_desc.BorderColor[2] = 0.0f;
|
|
|
|
|
sampler_desc.BorderColor[3] = 0.0f;
|
|
|
|
|
sampler_desc.MinLOD = 0.0f;
|
|
|
|
|
sampler_desc.MaxLOD = 0.0f;
|
|
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
|
if (FAILED(hr = ID3D11Device1_CreateSamplerState(context->d3d_device, &sampler_desc, sampler_state)))
|
2015-11-18 16:10:21 +01:00
|
|
|
|
ERR("Failed to create sampler state, hr %#x.\n", hr);
|
|
|
|
|
}
|
2021-06-28 09:17:35 +02:00
|
|
|
|
|
2021-06-28 09:17:36 +02:00
|
|
|
|
ID3D11DeviceContext_PSSetSamplers(d3d_context, brush_idx, 1, sampler_state);
|
|
|
|
|
ID3D11DeviceContext_Release(d3d_context);
|
2015-11-18 16:10:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-10 14:13:21 +02:00
|
|
|
|
void d2d_brush_bind_resources(struct d2d_brush *brush, struct d2d_device_context *context, unsigned int brush_idx)
|
2015-02-06 09:57:01 +01:00
|
|
|
|
{
|
2017-09-26 12:22:39 +02:00
|
|
|
|
switch (brush->type)
|
|
|
|
|
{
|
|
|
|
|
case D2D_BRUSH_TYPE_SOLID:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case D2D_BRUSH_TYPE_LINEAR:
|
2021-06-28 09:17:37 +02:00
|
|
|
|
d2d_gradient_bind(brush->u.linear.gradient, context->d3d_device, brush_idx);
|
2017-09-28 13:14:18 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case D2D_BRUSH_TYPE_RADIAL:
|
2021-06-28 09:17:37 +02:00
|
|
|
|
d2d_gradient_bind(brush->u.radial.gradient, context->d3d_device, brush_idx);
|
2017-09-26 12:22:39 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case D2D_BRUSH_TYPE_BITMAP:
|
2021-06-10 14:13:21 +02:00
|
|
|
|
d2d_brush_bind_bitmap(brush, context, brush_idx);
|
2017-09-26 12:22:39 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
FIXME("Unhandled brush type %#x.\n", brush->type);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2015-02-06 09:57:01 +01:00
|
|
|
|
}
|