2014-05-20 07:38:44 +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-09-05 15:50:59 +02:00
|
|
|
#define INITIAL_CLIP_STACK_SIZE 4
|
|
|
|
|
2017-04-04 12:13:20 +02:00
|
|
|
static const D2D1_MATRIX_3X2_F identity =
|
2020-05-15 15:22:41 +02:00
|
|
|
{{{
|
2017-04-04 12:13:20 +02:00
|
|
|
1.0f, 0.0f,
|
|
|
|
0.0f, 1.0f,
|
|
|
|
0.0f, 0.0f,
|
2020-05-15 15:22:41 +02:00
|
|
|
}}};
|
2017-04-04 12:13:20 +02:00
|
|
|
|
2014-10-06 08:24:17 +02:00
|
|
|
struct d2d_draw_text_layout_ctx
|
|
|
|
{
|
|
|
|
ID2D1Brush *brush;
|
|
|
|
D2D1_DRAW_TEXT_OPTIONS options;
|
|
|
|
};
|
|
|
|
|
2018-05-19 18:20:17 +02:00
|
|
|
static inline struct d2d_device *impl_from_ID2D1Device(ID2D1Device *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct d2d_device, ID2D1Device_iface);
|
|
|
|
}
|
|
|
|
|
2018-09-29 01:02:06 +02:00
|
|
|
static struct d2d_device *unsafe_impl_from_ID2D1Device(ID2D1Device *iface);
|
|
|
|
|
2016-01-26 13:36:18 +01:00
|
|
|
static ID2D1Brush *d2d_draw_get_text_brush(struct d2d_draw_text_layout_ctx *context, IUnknown *effect)
|
|
|
|
{
|
|
|
|
ID2D1Brush *brush = NULL;
|
|
|
|
|
|
|
|
if (effect && SUCCEEDED(IUnknown_QueryInterface(effect, &IID_ID2D1Brush, (void**)&brush)))
|
|
|
|
return brush;
|
|
|
|
|
|
|
|
ID2D1Brush_AddRef(context->brush);
|
|
|
|
return context->brush;
|
|
|
|
}
|
|
|
|
|
2014-09-05 15:50:59 +02:00
|
|
|
static void d2d_rect_intersect(D2D1_RECT_F *dst, const D2D1_RECT_F *src)
|
|
|
|
{
|
|
|
|
if (src->left > dst->left)
|
|
|
|
dst->left = src->left;
|
|
|
|
if (src->top > dst->top)
|
|
|
|
dst->top = src->top;
|
|
|
|
if (src->right < dst->right)
|
|
|
|
dst->right = src->right;
|
|
|
|
if (src->bottom < dst->bottom)
|
|
|
|
dst->bottom = src->bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void d2d_rect_set(D2D1_RECT_F *dst, float left, float top, float right, float bottom)
|
|
|
|
{
|
|
|
|
dst->left = left;
|
|
|
|
dst->top = top;
|
|
|
|
dst->right = right;
|
|
|
|
dst->bottom = bottom;
|
|
|
|
}
|
|
|
|
|
2015-11-18 22:23:23 +01:00
|
|
|
static void d2d_size_set(D2D1_SIZE_U *dst, float width, float height)
|
|
|
|
{
|
|
|
|
dst->width = width;
|
|
|
|
dst->height = height;
|
|
|
|
}
|
|
|
|
|
2014-09-15 11:03:33 +02:00
|
|
|
static BOOL d2d_clip_stack_init(struct d2d_clip_stack *stack)
|
2014-09-05 15:50:59 +02:00
|
|
|
{
|
2018-01-30 13:24:39 +01:00
|
|
|
if (!(stack->stack = heap_alloc(INITIAL_CLIP_STACK_SIZE * sizeof(*stack->stack))))
|
2014-09-05 15:50:59 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2014-09-15 11:03:33 +02:00
|
|
|
stack->size = INITIAL_CLIP_STACK_SIZE;
|
|
|
|
stack->count = 0;
|
2014-09-05 15:50:59 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void d2d_clip_stack_cleanup(struct d2d_clip_stack *stack)
|
|
|
|
{
|
2018-01-30 13:24:39 +01:00
|
|
|
heap_free(stack->stack);
|
2014-09-05 15:50:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL d2d_clip_stack_push(struct d2d_clip_stack *stack, const D2D1_RECT_F *rect)
|
|
|
|
{
|
2014-09-15 11:03:33 +02:00
|
|
|
D2D1_RECT_F r;
|
|
|
|
|
2018-01-31 16:19:41 +01:00
|
|
|
if (!d2d_array_reserve((void **)&stack->stack, &stack->size, stack->count + 1, sizeof(*stack->stack)))
|
|
|
|
return FALSE;
|
2014-09-05 15:50:59 +02:00
|
|
|
|
2014-09-15 11:03:33 +02:00
|
|
|
r = *rect;
|
|
|
|
if (stack->count)
|
|
|
|
d2d_rect_intersect(&r, &stack->stack[stack->count - 1]);
|
|
|
|
stack->stack[stack->count++] = r;
|
2014-09-05 15:50:59 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-09-15 11:03:33 +02:00
|
|
|
static void d2d_clip_stack_pop(struct d2d_clip_stack *stack)
|
2014-09-05 15:50:59 +02:00
|
|
|
{
|
2014-09-15 11:03:33 +02:00
|
|
|
if (!stack->count)
|
2014-09-05 15:50:59 +02:00
|
|
|
return;
|
2014-09-15 11:03:33 +02:00
|
|
|
--stack->count;
|
2014-09-05 15:50:59 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void d2d_device_context_draw(struct d2d_device_context *render_target, enum d2d_shape_type shape_type,
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11Buffer *ib, unsigned int index_count, ID3D11Buffer *vb, unsigned int vb_stride,
|
2021-06-11 10:35:49 +02:00
|
|
|
struct d2d_brush *brush, struct d2d_brush *opacity_brush)
|
2014-11-06 08:20:14 +01:00
|
|
|
{
|
2015-07-20 11:07:28 +02:00
|
|
|
struct d2d_shape_resources *shape_resources = &render_target->shape_resources[shape_type];
|
2021-06-28 09:17:36 +02:00
|
|
|
ID3DDeviceContextState *prev_state;
|
2021-06-28 09:17:37 +02:00
|
|
|
ID3D11Device1 *device = render_target->d3d_device;
|
2021-06-28 09:17:36 +02:00
|
|
|
ID3D11DeviceContext1 *context;
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11Buffer *vs_cb = render_target->vs_cb, *ps_cb = render_target->ps_cb;
|
2021-06-28 09:17:36 +02:00
|
|
|
D3D11_RECT scissor_rect;
|
2014-11-06 08:20:14 +01:00
|
|
|
unsigned int offset;
|
2021-06-28 09:17:36 +02:00
|
|
|
D3D11_VIEWPORT vp;
|
2014-11-06 08:20:14 +01:00
|
|
|
|
|
|
|
vp.TopLeftX = 0;
|
|
|
|
vp.TopLeftY = 0;
|
|
|
|
vp.Width = render_target->pixel_size.width;
|
|
|
|
vp.Height = render_target->pixel_size.height;
|
|
|
|
vp.MinDepth = 0.0f;
|
|
|
|
vp.MaxDepth = 1.0f;
|
|
|
|
|
2021-06-28 09:17:36 +02:00
|
|
|
ID3D11Device1_GetImmediateContext1(device, &context);
|
|
|
|
ID3D11DeviceContext1_SwapDeviceContextState(context, render_target->d3d_state, &prev_state);
|
2014-11-06 08:20:14 +01:00
|
|
|
|
2021-06-28 09:17:36 +02:00
|
|
|
ID3D11DeviceContext1_IASetInputLayout(context, shape_resources->il);
|
|
|
|
ID3D11DeviceContext1_IASetPrimitiveTopology(context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
|
|
|
ID3D11DeviceContext1_IASetIndexBuffer(context, ib, DXGI_FORMAT_R16_UINT, 0);
|
2014-11-06 08:20:14 +01:00
|
|
|
offset = 0;
|
2021-06-28 09:17:36 +02:00
|
|
|
ID3D11DeviceContext1_IASetVertexBuffers(context, 0, 1, &vb, &vb_stride, &offset);
|
|
|
|
ID3D11DeviceContext1_VSSetConstantBuffers(context, 0, 1, &vs_cb);
|
|
|
|
ID3D11DeviceContext1_VSSetShader(context, shape_resources->vs, NULL, 0);
|
|
|
|
ID3D11DeviceContext1_PSSetConstantBuffers(context, 0, 1, &ps_cb);
|
|
|
|
ID3D11DeviceContext1_PSSetShader(context, render_target->ps, NULL, 0);
|
|
|
|
ID3D11DeviceContext1_RSSetViewports(context, 1, &vp);
|
2014-11-06 08:20:14 +01:00
|
|
|
if (render_target->clip_stack.count)
|
|
|
|
{
|
|
|
|
const D2D1_RECT_F *clip_rect;
|
|
|
|
|
|
|
|
clip_rect = &render_target->clip_stack.stack[render_target->clip_stack.count - 1];
|
2017-08-29 14:13:38 +02:00
|
|
|
scissor_rect.left = ceilf(clip_rect->left - 0.5f);
|
|
|
|
scissor_rect.top = ceilf(clip_rect->top - 0.5f);
|
|
|
|
scissor_rect.right = ceilf(clip_rect->right - 0.5f);
|
|
|
|
scissor_rect.bottom = ceilf(clip_rect->bottom - 0.5f);
|
2014-11-06 08:20:14 +01:00
|
|
|
}
|
2015-08-20 11:42:04 +02:00
|
|
|
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;
|
|
|
|
}
|
2021-06-28 09:17:36 +02:00
|
|
|
ID3D11DeviceContext1_RSSetScissorRects(context, 1, &scissor_rect);
|
|
|
|
ID3D11DeviceContext1_RSSetState(context, render_target->rs);
|
2021-06-28 09:17:37 +02:00
|
|
|
ID3D11DeviceContext1_OMSetRenderTargets(context, 1, &render_target->target->rtv, NULL);
|
2015-02-06 09:57:01 +01:00
|
|
|
if (brush)
|
2017-09-23 13:36:59 +02:00
|
|
|
{
|
2021-06-28 09:17:36 +02:00
|
|
|
ID3D11DeviceContext1_OMSetBlendState(context, render_target->bs, NULL, D3D11_DEFAULT_SAMPLE_MASK);
|
2021-06-10 14:13:21 +02:00
|
|
|
d2d_brush_bind_resources(brush, render_target, 0);
|
2017-09-23 13:36:59 +02:00
|
|
|
}
|
2021-11-02 14:46:57 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ID3D11DeviceContext1_OMSetBlendState(context, NULL, NULL, D3D11_DEFAULT_SAMPLE_MASK);
|
|
|
|
}
|
2017-09-23 13:36:59 +02:00
|
|
|
if (opacity_brush)
|
2021-06-10 14:13:21 +02:00
|
|
|
d2d_brush_bind_resources(opacity_brush, render_target, 1);
|
2014-11-06 08:20:14 +01:00
|
|
|
|
2015-07-20 11:07:28 +02:00
|
|
|
if (ib)
|
2021-06-28 09:17:36 +02:00
|
|
|
ID3D11DeviceContext1_DrawIndexed(context, index_count, 0, 0);
|
2015-07-20 11:07:28 +02:00
|
|
|
else
|
2021-06-28 09:17:36 +02:00
|
|
|
ID3D11DeviceContext1_Draw(context, index_count, 0);
|
2021-06-25 09:34:01 +02:00
|
|
|
|
2021-06-28 09:17:36 +02:00
|
|
|
ID3D11DeviceContext1_SwapDeviceContextState(context, prev_state, NULL);
|
|
|
|
ID3D11DeviceContext1_Release(context);
|
|
|
|
ID3DDeviceContextState_Release(prev_state);
|
2014-11-06 08:20:14 +01:00
|
|
|
}
|
|
|
|
|
2018-10-05 09:23:22 +02:00
|
|
|
static void d2d_device_context_set_error(struct d2d_device_context *context, HRESULT code)
|
|
|
|
{
|
|
|
|
context->error.code = code;
|
|
|
|
context->error.tag1 = context->drawing_state.tag1;
|
|
|
|
context->error.tag2 = context->drawing_state.tag2;
|
|
|
|
}
|
|
|
|
|
2018-09-12 17:59:51 +02:00
|
|
|
static inline struct d2d_device_context *impl_from_IUnknown(IUnknown *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct d2d_device_context, IUnknown_iface);
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static inline struct d2d_device_context *impl_from_ID2D1DeviceContext(ID2D1DeviceContext *iface)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct d2d_device_context, ID2D1DeviceContext_iface);
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-09-12 17:59:51 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_inner_QueryInterface(IUnknown *iface, REFIID iid, void **out)
|
2018-08-17 16:54:11 +02:00
|
|
|
{
|
2018-09-12 17:59:51 +02:00
|
|
|
struct d2d_device_context *context = impl_from_IUnknown(iface);
|
2017-02-14 16:19:00 +01:00
|
|
|
|
2014-05-20 07:38:44 +02:00
|
|
|
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
if (IsEqualGUID(iid, &IID_ID2D1DeviceContext)
|
|
|
|
|| IsEqualGUID(iid, &IID_ID2D1RenderTarget)
|
2014-05-20 07:38:44 +02:00
|
|
|
|| IsEqualGUID(iid, &IID_ID2D1Resource)
|
|
|
|
|| IsEqualGUID(iid, &IID_IUnknown))
|
|
|
|
{
|
2018-09-12 17:59:51 +02:00
|
|
|
ID2D1DeviceContext_AddRef(&context->ID2D1DeviceContext_iface);
|
|
|
|
*out = &context->ID2D1DeviceContext_iface;
|
2014-05-20 07:38:44 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2017-02-14 16:19:00 +01:00
|
|
|
else if (IsEqualGUID(iid, &IID_ID2D1GdiInteropRenderTarget))
|
|
|
|
{
|
2018-09-12 17:59:51 +02:00
|
|
|
ID2D1GdiInteropRenderTarget_AddRef(&context->ID2D1GdiInteropRenderTarget_iface);
|
|
|
|
*out = &context->ID2D1GdiInteropRenderTarget_iface;
|
2017-02-14 16:19:00 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
2014-05-20 07:38:44 +02:00
|
|
|
|
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
|
|
|
|
|
|
|
|
*out = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2018-09-12 17:59:51 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE d2d_device_context_inner_AddRef(IUnknown *iface)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-09-12 17:59:51 +02:00
|
|
|
struct d2d_device_context *context = impl_from_IUnknown(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&context->refcount);
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2022-02-01 19:23:14 +01:00
|
|
|
TRACE("%p increasing refcount to %lu.\n", iface, refcount);
|
2014-05-20 07:38:44 +02:00
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2018-09-12 17:59:51 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE d2d_device_context_inner_Release(IUnknown *iface)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-09-12 17:59:51 +02:00
|
|
|
struct d2d_device_context *context = impl_from_IUnknown(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&context->refcount);
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2022-02-01 19:23:14 +01:00
|
|
|
TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
|
2014-05-20 07:38:44 +02:00
|
|
|
|
|
|
|
if (!refcount)
|
2014-09-05 15:50:58 +02:00
|
|
|
{
|
2021-06-10 14:13:21 +02:00
|
|
|
unsigned int i, j, k;
|
2015-07-20 11:07:28 +02:00
|
|
|
|
2018-09-12 17:59:51 +02:00
|
|
|
d2d_clip_stack_cleanup(&context->clip_stack);
|
|
|
|
IDWriteRenderingParams_Release(context->default_text_rendering_params);
|
|
|
|
if (context->text_rendering_params)
|
|
|
|
IDWriteRenderingParams_Release(context->text_rendering_params);
|
2018-09-29 01:02:06 +02:00
|
|
|
if (context->bs)
|
2021-06-28 09:17:34 +02:00
|
|
|
ID3D11BlendState_Release(context->bs);
|
2021-06-28 09:17:33 +02:00
|
|
|
ID3D11RasterizerState_Release(context->rs);
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11Buffer_Release(context->vb);
|
|
|
|
ID3D11Buffer_Release(context->ib);
|
|
|
|
ID3D11Buffer_Release(context->ps_cb);
|
2021-06-25 09:34:04 +02:00
|
|
|
ID3D11PixelShader_Release(context->ps);
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11Buffer_Release(context->vs_cb);
|
2015-07-20 11:07:28 +02:00
|
|
|
for (i = 0; i < D2D_SHAPE_TYPE_COUNT; ++i)
|
|
|
|
{
|
2021-06-25 09:34:03 +02:00
|
|
|
ID3D11VertexShader_Release(context->shape_resources[i].vs);
|
2021-06-25 09:34:02 +02:00
|
|
|
ID3D11InputLayout_Release(context->shape_resources[i].il);
|
2015-07-20 11:07:28 +02:00
|
|
|
}
|
2021-06-10 14:13:21 +02:00
|
|
|
for (i = 0; i < D2D_SAMPLER_INTERPOLATION_MODE_COUNT; ++i)
|
|
|
|
{
|
|
|
|
for (j = 0; j < D2D_SAMPLER_EXTEND_MODE_COUNT; ++j)
|
|
|
|
{
|
|
|
|
for (k = 0; k < D2D_SAMPLER_EXTEND_MODE_COUNT; ++k)
|
|
|
|
{
|
|
|
|
if (context->sampler_states[i][j][k])
|
2021-06-28 09:17:35 +02:00
|
|
|
ID3D11SamplerState_Release(context->sampler_states[i][j][k]);
|
2021-06-10 14:13:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-06-28 09:17:36 +02:00
|
|
|
if (context->d3d_state)
|
|
|
|
ID3DDeviceContextState_Release(context->d3d_state);
|
2018-09-29 01:02:06 +02:00
|
|
|
if (context->target)
|
|
|
|
ID2D1Bitmap1_Release(&context->target->ID2D1Bitmap1_iface);
|
2021-06-28 09:17:37 +02:00
|
|
|
ID3D11Device1_Release(context->d3d_device);
|
2018-09-12 17:59:51 +02:00
|
|
|
ID2D1Factory_Release(context->factory);
|
2018-09-24 06:58:31 +02:00
|
|
|
ID2D1Device_Release(context->device);
|
2018-09-12 17:59:51 +02:00
|
|
|
heap_free(context);
|
2014-09-05 15:50:58 +02:00
|
|
|
}
|
2014-05-20 07:38:44 +02:00
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2018-09-12 17:59:51 +02:00
|
|
|
static const struct IUnknownVtbl d2d_device_context_inner_unknown_vtbl =
|
|
|
|
{
|
|
|
|
d2d_device_context_inner_QueryInterface,
|
|
|
|
d2d_device_context_inner_AddRef,
|
|
|
|
d2d_device_context_inner_Release,
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_QueryInterface(ID2D1DeviceContext *iface, REFIID iid, void **out)
|
|
|
|
{
|
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
|
|
|
|
|
|
|
|
return IUnknown_QueryInterface(context->outer_unknown, iid, out);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE d2d_device_context_AddRef(ID2D1DeviceContext *iface)
|
|
|
|
{
|
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return IUnknown_AddRef(context->outer_unknown);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE d2d_device_context_Release(ID2D1DeviceContext *iface)
|
|
|
|
{
|
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return IUnknown_Release(context->outer_unknown);
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_GetFactory(ID2D1DeviceContext *iface, ID2D1Factory **factory)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2015-03-26 09:41:16 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, factory %p.\n", iface, factory);
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2015-03-26 09:41:16 +01:00
|
|
|
*factory = render_target->factory;
|
|
|
|
ID2D1Factory_AddRef(*factory);
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateBitmap(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
D2D1_SIZE_U size, const void *src_data, UINT32 pitch, const D2D1_BITMAP_PROPERTIES *desc, ID2D1Bitmap **bitmap)
|
|
|
|
{
|
2018-09-13 18:16:47 +02:00
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
|
|
|
D2D1_BITMAP_PROPERTIES1 bitmap_desc;
|
2014-09-16 10:44:13 +02:00
|
|
|
struct d2d_bitmap *object;
|
2015-02-06 09:57:01 +01:00
|
|
|
HRESULT hr;
|
2014-09-16 10:44:13 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, size {%u, %u}, src_data %p, pitch %u, desc %p, bitmap %p.\n",
|
2014-05-20 07:38:44 +02:00
|
|
|
iface, size.width, size.height, src_data, pitch, desc, bitmap);
|
|
|
|
|
2018-09-13 18:16:47 +02:00
|
|
|
if (desc)
|
|
|
|
{
|
|
|
|
memcpy(&bitmap_desc, desc, sizeof(*desc));
|
|
|
|
bitmap_desc.bitmapOptions = 0;
|
|
|
|
bitmap_desc.colorContext = NULL;
|
|
|
|
}
|
|
|
|
|
2018-09-16 17:51:19 +02:00
|
|
|
if (SUCCEEDED(hr = d2d_bitmap_create(context, size, src_data, pitch, desc ? &bitmap_desc : NULL, &object)))
|
2018-05-23 13:44:12 +02:00
|
|
|
*bitmap = (ID2D1Bitmap *)&object->ID2D1Bitmap1_iface;
|
2014-09-16 10:44:13 +02:00
|
|
|
|
2016-03-29 20:30:38 +02:00
|
|
|
return hr;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateBitmapFromWicBitmap(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
IWICBitmapSource *bitmap_source, const D2D1_BITMAP_PROPERTIES *desc, ID2D1Bitmap **bitmap)
|
|
|
|
{
|
2018-09-13 18:16:47 +02:00
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
|
|
|
D2D1_BITMAP_PROPERTIES1 bitmap_desc;
|
2016-03-29 20:30:38 +02:00
|
|
|
struct d2d_bitmap *object;
|
2014-09-16 10:44:14 +02:00
|
|
|
HRESULT hr;
|
2015-07-23 19:32:05 +02:00
|
|
|
|
2014-09-16 10:44:14 +02:00
|
|
|
TRACE("iface %p, bitmap_source %p, desc %p, bitmap %p.\n",
|
2014-05-20 07:38:44 +02:00
|
|
|
iface, bitmap_source, desc, bitmap);
|
|
|
|
|
2018-09-13 18:16:47 +02:00
|
|
|
if (desc)
|
|
|
|
{
|
|
|
|
memcpy(&bitmap_desc, desc, sizeof(*desc));
|
|
|
|
bitmap_desc.bitmapOptions = 0;
|
|
|
|
bitmap_desc.colorContext = NULL;
|
|
|
|
}
|
|
|
|
|
2018-09-16 17:51:19 +02:00
|
|
|
if (SUCCEEDED(hr = d2d_bitmap_create_from_wic_bitmap(context, bitmap_source, desc ? &bitmap_desc : NULL, &object)))
|
2018-05-23 13:44:12 +02:00
|
|
|
*bitmap = (ID2D1Bitmap *)&object->ID2D1Bitmap1_iface;
|
2014-09-16 10:44:14 +02:00
|
|
|
|
|
|
|
return hr;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateSharedBitmap(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
REFIID iid, void *data, const D2D1_BITMAP_PROPERTIES *desc, ID2D1Bitmap **bitmap)
|
|
|
|
{
|
2018-09-13 18:16:47 +02:00
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
|
|
|
D2D1_BITMAP_PROPERTIES1 bitmap_desc;
|
2015-08-04 08:53:27 +02:00
|
|
|
struct d2d_bitmap *object;
|
|
|
|
HRESULT hr;
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2015-08-04 08:53:27 +02:00
|
|
|
TRACE("iface %p, iid %s, data %p, desc %p, bitmap %p.\n",
|
|
|
|
iface, debugstr_guid(iid), data, desc, bitmap);
|
|
|
|
|
2018-09-13 18:16:47 +02:00
|
|
|
if (desc)
|
|
|
|
{
|
|
|
|
memcpy(&bitmap_desc, desc, sizeof(*desc));
|
|
|
|
bitmap_desc.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW;
|
|
|
|
bitmap_desc.colorContext = NULL;
|
|
|
|
}
|
|
|
|
|
2018-09-16 17:51:19 +02:00
|
|
|
if (SUCCEEDED(hr = d2d_bitmap_create_shared(context, iid, data, desc ? &bitmap_desc : NULL, &object)))
|
2018-05-23 13:44:12 +02:00
|
|
|
*bitmap = (ID2D1Bitmap *)&object->ID2D1Bitmap1_iface;
|
2015-08-04 08:53:27 +02:00
|
|
|
|
2016-03-29 20:30:38 +02:00
|
|
|
return hr;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateBitmapBrush(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
ID2D1Bitmap *bitmap, const D2D1_BITMAP_BRUSH_PROPERTIES *bitmap_brush_desc,
|
|
|
|
const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1BitmapBrush **brush)
|
|
|
|
{
|
2018-09-18 12:17:48 +02:00
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
2014-12-01 08:45:45 +01:00
|
|
|
struct d2d_brush *object;
|
2016-03-31 13:49:31 +02:00
|
|
|
HRESULT hr;
|
2014-12-01 08:45:45 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, bitmap %p, bitmap_brush_desc %p, brush_desc %p, brush %p.\n",
|
2014-05-20 07:38:44 +02:00
|
|
|
iface, bitmap, bitmap_brush_desc, brush_desc, brush);
|
|
|
|
|
2018-09-18 12:17:48 +02:00
|
|
|
if (SUCCEEDED(hr = d2d_bitmap_brush_create(context->factory, bitmap, (const D2D1_BITMAP_BRUSH_PROPERTIES1 *)bitmap_brush_desc,
|
|
|
|
brush_desc, &object)))
|
2016-03-31 13:49:31 +02:00
|
|
|
*brush = (ID2D1BitmapBrush *)&object->ID2D1Brush_iface;
|
2014-12-01 08:45:45 +01:00
|
|
|
|
2016-03-31 13:49:31 +02:00
|
|
|
return hr;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateSolidColorBrush(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
const D2D1_COLOR_F *color, const D2D1_BRUSH_PROPERTIES *desc, ID2D1SolidColorBrush **brush)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2014-06-16 13:13:20 +02:00
|
|
|
struct d2d_brush *object;
|
2016-03-31 13:49:31 +02:00
|
|
|
HRESULT hr;
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2014-06-16 13:13:20 +02:00
|
|
|
TRACE("iface %p, color %p, desc %p, brush %p.\n", iface, color, desc, brush);
|
|
|
|
|
2016-03-31 13:49:31 +02:00
|
|
|
if (SUCCEEDED(hr = d2d_solid_color_brush_create(render_target->factory, color, desc, &object)))
|
|
|
|
*brush = (ID2D1SolidColorBrush *)&object->ID2D1Brush_iface;
|
2014-06-16 13:13:20 +02:00
|
|
|
|
2016-03-31 13:49:31 +02:00
|
|
|
return hr;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateGradientStopCollection(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
const D2D1_GRADIENT_STOP *stops, UINT32 stop_count, D2D1_GAMMA gamma, D2D1_EXTEND_MODE extend_mode,
|
|
|
|
ID2D1GradientStopCollection **gradient)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2014-06-16 13:13:21 +02:00
|
|
|
struct d2d_gradient *object;
|
2014-11-03 08:59:38 +01:00
|
|
|
HRESULT hr;
|
2014-06-16 13:13:21 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, stops %p, stop_count %u, gamma %#x, extend_mode %#x, gradient %p.\n",
|
2014-05-20 07:38:44 +02:00
|
|
|
iface, stops, stop_count, gamma, extend_mode, gradient);
|
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
if (SUCCEEDED(hr = d2d_gradient_create(render_target->factory, render_target->d3d_device,
|
2017-09-26 12:22:38 +02:00
|
|
|
stops, stop_count, gamma, extend_mode, &object)))
|
2016-03-31 13:49:31 +02:00
|
|
|
*gradient = &object->ID2D1GradientStopCollection_iface;
|
2014-06-16 13:13:21 +02:00
|
|
|
|
2016-03-31 13:49:31 +02:00
|
|
|
return hr;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateLinearGradientBrush(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES *gradient_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
|
|
|
|
ID2D1GradientStopCollection *gradient, ID2D1LinearGradientBrush **brush)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2014-06-16 13:13:22 +02:00
|
|
|
struct d2d_brush *object;
|
2016-03-31 13:49:31 +02:00
|
|
|
HRESULT hr;
|
2014-06-16 13:13:22 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, gradient_brush_desc %p, brush_desc %p, gradient %p, brush %p.\n",
|
2014-05-20 07:38:44 +02:00
|
|
|
iface, gradient_brush_desc, brush_desc, gradient, brush);
|
|
|
|
|
2016-03-31 13:49:31 +02:00
|
|
|
if (SUCCEEDED(hr = d2d_linear_gradient_brush_create(render_target->factory, gradient_brush_desc, brush_desc,
|
|
|
|
gradient, &object)))
|
|
|
|
*brush = (ID2D1LinearGradientBrush *)&object->ID2D1Brush_iface;
|
2014-06-16 13:13:22 +02:00
|
|
|
|
2016-03-31 13:49:31 +02:00
|
|
|
return hr;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateRadialGradientBrush(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
const D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES *gradient_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
|
|
|
|
ID2D1GradientStopCollection *gradient, ID2D1RadialGradientBrush **brush)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2017-09-26 12:22:40 +02:00
|
|
|
struct d2d_brush *object;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, gradient_brush_desc %p, brush_desc %p, gradient %p, brush %p.\n",
|
2014-05-20 07:38:44 +02:00
|
|
|
iface, gradient_brush_desc, brush_desc, gradient, brush);
|
|
|
|
|
2017-09-26 12:22:40 +02:00
|
|
|
if (SUCCEEDED(hr = d2d_radial_gradient_brush_create(render_target->factory,
|
2017-09-27 09:47:52 +02:00
|
|
|
gradient_brush_desc, brush_desc, gradient, &object)))
|
2017-09-26 12:22:40 +02:00
|
|
|
*brush = (ID2D1RadialGradientBrush *)&object->ID2D1Brush_iface;
|
|
|
|
|
|
|
|
return hr;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateCompatibleRenderTarget(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
const D2D1_SIZE_F *size, const D2D1_SIZE_U *pixel_size, const D2D1_PIXEL_FORMAT *format,
|
2016-10-19 19:00:21 +02:00
|
|
|
D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS options, ID2D1BitmapRenderTarget **rt)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2016-10-19 19:00:21 +02:00
|
|
|
struct d2d_bitmap_render_target *object;
|
|
|
|
HRESULT hr;
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2016-10-19 19:00:21 +02:00
|
|
|
TRACE("iface %p, size %p, pixel_size %p, format %p, options %#x, render_target %p.\n",
|
|
|
|
iface, size, pixel_size, format, options, rt);
|
|
|
|
|
2018-01-30 13:24:39 +01:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2016-10-19 19:00:21 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (FAILED(hr = d2d_bitmap_render_target_init(object, render_target, size, pixel_size,
|
|
|
|
format, options)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to initialise render target, hr %#lx.\n", hr);
|
2018-01-30 13:24:39 +01:00
|
|
|
heap_free(object);
|
2016-10-19 19:00:21 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Created render target %p.\n", object);
|
|
|
|
*rt = &object->ID2D1BitmapRenderTarget_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateLayer(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
const D2D1_SIZE_F *size, ID2D1Layer **layer)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2017-06-02 17:56:31 +02:00
|
|
|
struct d2d_layer *object;
|
|
|
|
HRESULT hr;
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2017-06-02 17:56:31 +02:00
|
|
|
TRACE("iface %p, size %p, layer %p.\n", iface, size, layer);
|
|
|
|
|
2017-06-02 17:56:32 +02:00
|
|
|
if (SUCCEEDED(hr = d2d_layer_create(render_target->factory, size, &object)))
|
2017-06-02 17:56:31 +02:00
|
|
|
*layer = &object->ID2D1Layer_iface;
|
|
|
|
|
|
|
|
return hr;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateMesh(ID2D1DeviceContext *iface, ID2D1Mesh **mesh)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2014-09-16 10:44:12 +02:00
|
|
|
struct d2d_mesh *object;
|
2016-03-31 13:49:32 +02:00
|
|
|
HRESULT hr;
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2014-09-16 10:44:12 +02:00
|
|
|
TRACE("iface %p, mesh %p.\n", iface, mesh);
|
|
|
|
|
2016-03-31 13:49:32 +02:00
|
|
|
if (SUCCEEDED(hr = d2d_mesh_create(render_target->factory, &object)))
|
|
|
|
*mesh = &object->ID2D1Mesh_iface;
|
2014-09-16 10:44:12 +02:00
|
|
|
|
2016-03-31 13:49:32 +02:00
|
|
|
return hr;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_DrawLine(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
D2D1_POINT_2F p0, D2D1_POINT_2F p1, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2016-11-21 13:10:33 +01:00
|
|
|
ID2D1PathGeometry *geometry;
|
|
|
|
ID2D1GeometrySink *sink;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2018-09-25 00:25:17 +02:00
|
|
|
TRACE("iface %p, p0 %s, p1 %s, brush %p, stroke_width %.8e, stroke_style %p.\n",
|
|
|
|
iface, debug_d2d_point_2f(&p0), debug_d2d_point_2f(&p1), brush, stroke_width, stroke_style);
|
2016-11-21 13:10:33 +01:00
|
|
|
|
|
|
|
if (FAILED(hr = ID2D1Factory_CreatePathGeometry(render_target->factory, &geometry)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to create path geometry, hr %#lx.\n", hr);
|
2016-11-21 13:10:33 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(hr = ID2D1PathGeometry_Open(geometry, &sink)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to open geometry sink, hr %#lx.\n", hr);
|
2016-11-21 13:10:33 +01:00
|
|
|
ID2D1PathGeometry_Release(geometry);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-23 08:10:28 +01:00
|
|
|
ID2D1GeometrySink_BeginFigure(sink, p0, D2D1_FIGURE_BEGIN_HOLLOW);
|
2016-11-21 13:10:33 +01:00
|
|
|
ID2D1GeometrySink_AddLine(sink, p1);
|
2017-02-23 08:10:28 +01:00
|
|
|
ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_OPEN);
|
2016-11-21 13:10:33 +01:00
|
|
|
if (FAILED(hr = ID2D1GeometrySink_Close(sink)))
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to close geometry sink, hr %#lx.\n", hr);
|
2016-11-21 13:10:33 +01:00
|
|
|
ID2D1GeometrySink_Release(sink);
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
ID2D1DeviceContext_DrawGeometry(iface, (ID2D1Geometry *)geometry, brush, stroke_width, stroke_style);
|
2016-11-21 13:10:33 +01:00
|
|
|
ID2D1PathGeometry_Release(geometry);
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_DrawRectangle(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
const D2D1_RECT_F *rect, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2016-10-10 16:29:56 +02:00
|
|
|
ID2D1RectangleGeometry *geometry;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2017-07-10 18:02:18 +02:00
|
|
|
TRACE("iface %p, rect %s, brush %p, stroke_width %.8e, stroke_style %p.\n",
|
|
|
|
iface, debug_d2d_rect_f(rect), brush, stroke_width, stroke_style);
|
2016-10-10 16:29:56 +02:00
|
|
|
|
|
|
|
if (FAILED(hr = ID2D1Factory_CreateRectangleGeometry(render_target->factory, rect, &geometry)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create geometry, hr %#lx.\n", hr);
|
2016-10-10 16:29:56 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
ID2D1DeviceContext_DrawGeometry(iface, (ID2D1Geometry *)geometry, brush, stroke_width, stroke_style);
|
2016-10-10 16:29:56 +02:00
|
|
|
ID2D1RectangleGeometry_Release(geometry);
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_FillRectangle(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
const D2D1_RECT_F *rect, ID2D1Brush *brush)
|
2015-07-14 15:57:42 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2015-07-14 15:57:42 +02:00
|
|
|
ID2D1RectangleGeometry *geometry;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2017-07-10 18:02:18 +02:00
|
|
|
TRACE("iface %p, rect %s, brush %p.\n", iface, debug_d2d_rect_f(rect), brush);
|
2015-07-21 08:39:05 +02:00
|
|
|
|
2015-07-14 15:57:42 +02:00
|
|
|
if (FAILED(hr = ID2D1Factory_CreateRectangleGeometry(render_target->factory, rect, &geometry)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create geometry, hr %#lx.\n", hr);
|
2015-07-14 15:57:42 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
ID2D1DeviceContext_FillGeometry(iface, (ID2D1Geometry *)geometry, brush, NULL);
|
2015-07-14 15:57:42 +02:00
|
|
|
ID2D1RectangleGeometry_Release(geometry);
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_DrawRoundedRectangle(ID2D1DeviceContext *iface,
|
2015-07-14 15:57:42 +02:00
|
|
|
const D2D1_ROUNDED_RECT *rect, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2016-10-10 16:29:56 +02:00
|
|
|
ID2D1RoundedRectangleGeometry *geometry;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, rect %p, brush %p, stroke_width %.8e, stroke_style %p.\n",
|
2015-07-14 15:57:42 +02:00
|
|
|
iface, rect, brush, stroke_width, stroke_style);
|
2016-10-10 16:29:56 +02:00
|
|
|
|
|
|
|
if (FAILED(hr = ID2D1Factory_CreateRoundedRectangleGeometry(render_target->factory, rect, &geometry)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create geometry, hr %#lx.\n", hr);
|
2016-10-10 16:29:56 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
ID2D1DeviceContext_DrawGeometry(iface, (ID2D1Geometry *)geometry, brush, stroke_width, stroke_style);
|
2016-10-10 16:29:56 +02:00
|
|
|
ID2D1RoundedRectangleGeometry_Release(geometry);
|
2015-07-14 15:57:42 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_FillRoundedRectangle(ID2D1DeviceContext *iface,
|
2015-07-14 15:57:42 +02:00
|
|
|
const D2D1_ROUNDED_RECT *rect, ID2D1Brush *brush)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2015-07-21 08:39:06 +02:00
|
|
|
ID2D1RoundedRectangleGeometry *geometry;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, rect %p, brush %p.\n", iface, rect, brush);
|
|
|
|
|
|
|
|
if (FAILED(hr = ID2D1Factory_CreateRoundedRectangleGeometry(render_target->factory, rect, &geometry)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create geometry, hr %#lx.\n", hr);
|
2015-07-21 08:39:06 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
ID2D1DeviceContext_FillGeometry(iface, (ID2D1Geometry *)geometry, brush, NULL);
|
2015-07-21 08:39:06 +02:00
|
|
|
ID2D1RoundedRectangleGeometry_Release(geometry);
|
2015-07-14 15:57:42 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_DrawEllipse(ID2D1DeviceContext *iface,
|
2015-07-14 15:57:42 +02:00
|
|
|
const D2D1_ELLIPSE *ellipse, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2016-10-10 16:29:56 +02:00
|
|
|
ID2D1EllipseGeometry *geometry;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, ellipse %p, brush %p, stroke_width %.8e, stroke_style %p.\n",
|
2015-07-14 15:57:42 +02:00
|
|
|
iface, ellipse, brush, stroke_width, stroke_style);
|
2016-10-10 16:29:56 +02:00
|
|
|
|
|
|
|
if (FAILED(hr = ID2D1Factory_CreateEllipseGeometry(render_target->factory, ellipse, &geometry)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create geometry, hr %#lx.\n", hr);
|
2016-10-10 16:29:56 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
ID2D1DeviceContext_DrawGeometry(iface, (ID2D1Geometry *)geometry, brush, stroke_width, stroke_style);
|
2016-10-10 16:29:56 +02:00
|
|
|
ID2D1EllipseGeometry_Release(geometry);
|
2015-07-14 15:57:42 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_FillEllipse(ID2D1DeviceContext *iface,
|
2015-07-14 15:57:42 +02:00
|
|
|
const D2D1_ELLIPSE *ellipse, ID2D1Brush *brush)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2015-07-21 08:39:07 +02:00
|
|
|
ID2D1EllipseGeometry *geometry;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, ellipse %p, brush %p.\n", iface, ellipse, brush);
|
|
|
|
|
|
|
|
if (FAILED(hr = ID2D1Factory_CreateEllipseGeometry(render_target->factory, ellipse, &geometry)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create geometry, hr %#lx.\n", hr);
|
2015-07-21 08:39:07 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
ID2D1DeviceContext_FillGeometry(iface, (ID2D1Geometry *)geometry, brush, NULL);
|
2015-07-21 08:39:07 +02:00
|
|
|
ID2D1EllipseGeometry_Release(geometry);
|
2015-07-14 15:57:42 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 14:13:23 +02:00
|
|
|
static HRESULT d2d_device_context_update_ps_cb(struct d2d_device_context *context,
|
|
|
|
struct d2d_brush *brush, struct d2d_brush *opacity_brush, BOOL outline, BOOL is_arc)
|
|
|
|
{
|
2021-06-25 09:34:01 +02:00
|
|
|
D3D11_MAPPED_SUBRESOURCE map_desc;
|
|
|
|
ID3D11DeviceContext *d3d_context;
|
2021-06-10 14:13:23 +02:00
|
|
|
struct d2d_ps_cb *cb_data;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
ID3D11Device1_GetImmediateContext(context->d3d_device, &d3d_context);
|
2021-06-25 09:34:01 +02:00
|
|
|
|
|
|
|
if (FAILED(hr = ID3D11DeviceContext_Map(d3d_context, (ID3D11Resource *)context->ps_cb,
|
|
|
|
0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc)))
|
2021-06-10 14:13:23 +02:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to map constant buffer, hr %#lx.\n", hr);
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11DeviceContext_Release(d3d_context);
|
2021-06-10 14:13:23 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2021-06-25 09:34:01 +02:00
|
|
|
cb_data = map_desc.pData;
|
2021-06-10 14:13:23 +02:00
|
|
|
cb_data->outline = outline;
|
|
|
|
cb_data->is_arc = is_arc;
|
|
|
|
cb_data->pad[0] = 0;
|
|
|
|
cb_data->pad[1] = 0;
|
|
|
|
if (!d2d_brush_fill_cb(brush, &cb_data->colour_brush))
|
|
|
|
WARN("Failed to initialize colour brush buffer.\n");
|
|
|
|
if (!d2d_brush_fill_cb(opacity_brush, &cb_data->opacity_brush))
|
|
|
|
WARN("Failed to initialize opacity brush buffer.\n");
|
|
|
|
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11DeviceContext_Unmap(d3d_context, (ID3D11Resource *)context->ps_cb, 0);
|
|
|
|
ID3D11DeviceContext_Release(d3d_context);
|
2021-06-10 14:13:23 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2021-06-11 10:35:49 +02:00
|
|
|
static HRESULT d2d_device_context_update_vs_cb(struct d2d_device_context *context,
|
|
|
|
const D2D_MATRIX_3X2_F *geometry_transform, float stroke_width)
|
2017-02-03 13:37:09 +01:00
|
|
|
{
|
2021-06-25 09:34:01 +02:00
|
|
|
D3D11_MAPPED_SUBRESOURCE map_desc;
|
|
|
|
ID3D11DeviceContext *d3d_context;
|
2017-02-03 13:37:09 +01:00
|
|
|
const D2D1_MATRIX_3X2_F *w;
|
2021-06-11 10:35:49 +02:00
|
|
|
struct d2d_vs_cb *cb_data;
|
2017-02-03 13:37:09 +01:00
|
|
|
float tmp_x, tmp_y;
|
|
|
|
HRESULT hr;
|
2021-06-11 10:35:49 +02:00
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
ID3D11Device1_GetImmediateContext(context->d3d_device, &d3d_context);
|
2021-06-25 09:34:01 +02:00
|
|
|
|
|
|
|
if (FAILED(hr = ID3D11DeviceContext_Map(d3d_context, (ID3D11Resource *)context->vs_cb,
|
|
|
|
0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc)))
|
2017-02-03 13:37:09 +01:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to map constant buffer, hr %#lx.\n", hr);
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11DeviceContext_Release(d3d_context);
|
2021-06-11 10:35:49 +02:00
|
|
|
return hr;
|
|
|
|
}
|
2017-02-03 13:37:09 +01:00
|
|
|
|
2021-06-25 09:34:01 +02:00
|
|
|
cb_data = map_desc.pData;
|
2021-06-11 10:35:49 +02:00
|
|
|
cb_data->transform_geometry._11 = geometry_transform->_11;
|
|
|
|
cb_data->transform_geometry._21 = geometry_transform->_21;
|
|
|
|
cb_data->transform_geometry._31 = geometry_transform->_31;
|
|
|
|
cb_data->transform_geometry.pad0 = 0.0f;
|
|
|
|
cb_data->transform_geometry._12 = geometry_transform->_12;
|
|
|
|
cb_data->transform_geometry._22 = geometry_transform->_22;
|
|
|
|
cb_data->transform_geometry._32 = geometry_transform->_32;
|
|
|
|
cb_data->transform_geometry.stroke_width = stroke_width;
|
|
|
|
|
|
|
|
w = &context->drawing_state.transform;
|
|
|
|
|
|
|
|
tmp_x = context->desc.dpiX / 96.0f;
|
|
|
|
cb_data->transform_rtx.x = w->_11 * tmp_x;
|
|
|
|
cb_data->transform_rtx.y = w->_21 * tmp_x;
|
|
|
|
cb_data->transform_rtx.z = w->_31 * tmp_x;
|
|
|
|
cb_data->transform_rtx.w = 2.0f / context->pixel_size.width;
|
|
|
|
|
|
|
|
tmp_y = context->desc.dpiY / 96.0f;
|
|
|
|
cb_data->transform_rty.x = w->_12 * tmp_y;
|
|
|
|
cb_data->transform_rty.y = w->_22 * tmp_y;
|
|
|
|
cb_data->transform_rty.z = w->_32 * tmp_y;
|
|
|
|
cb_data->transform_rty.w = -2.0f / context->pixel_size.height;
|
|
|
|
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11DeviceContext_Unmap(d3d_context, (ID3D11Resource *)context->vs_cb, 0);
|
|
|
|
ID3D11DeviceContext_Release(d3d_context);
|
2021-06-11 10:35:49 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void d2d_device_context_draw_geometry(struct d2d_device_context *render_target,
|
|
|
|
const struct d2d_geometry *geometry, struct d2d_brush *brush, float stroke_width)
|
|
|
|
{
|
2021-06-25 09:34:01 +02:00
|
|
|
D3D11_SUBRESOURCE_DATA buffer_data;
|
|
|
|
D3D11_BUFFER_DESC buffer_desc;
|
|
|
|
ID3D11Buffer *ib, *vb;
|
2021-06-11 10:35:49 +02:00
|
|
|
HRESULT hr;
|
2017-02-03 13:37:09 +01:00
|
|
|
|
2021-06-11 10:35:49 +02:00
|
|
|
if (FAILED(hr = d2d_device_context_update_vs_cb(render_target, &geometry->transform, stroke_width)))
|
2017-02-03 13:37:09 +01:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to update vs constant buffer, hr %#lx.\n", hr);
|
2017-02-03 13:37:09 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-10 14:13:23 +02:00
|
|
|
if (FAILED(hr = d2d_device_context_update_ps_cb(render_target, brush, NULL, TRUE, FALSE)))
|
2020-03-03 18:59:47 +01:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to update ps constant buffer, hr %#lx.\n", hr);
|
2020-03-03 18:59:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-25 09:34:01 +02:00
|
|
|
buffer_desc.Usage = D3D11_USAGE_DEFAULT;
|
2021-06-11 10:35:49 +02:00
|
|
|
buffer_desc.CPUAccessFlags = 0;
|
|
|
|
buffer_desc.MiscFlags = 0;
|
|
|
|
|
|
|
|
buffer_data.SysMemPitch = 0;
|
|
|
|
buffer_data.SysMemSlicePitch = 0;
|
|
|
|
|
2017-02-03 13:37:09 +01:00
|
|
|
if (geometry->outline.face_count)
|
|
|
|
{
|
|
|
|
buffer_desc.ByteWidth = geometry->outline.face_count * sizeof(*geometry->outline.faces);
|
2021-06-25 09:34:01 +02:00
|
|
|
buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
2017-02-03 13:37:09 +01:00
|
|
|
buffer_data.pSysMem = geometry->outline.faces;
|
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &ib)))
|
2017-02-03 13:37:09 +01:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to create index buffer, hr %#lx.\n", hr);
|
2021-06-11 10:35:49 +02:00
|
|
|
return;
|
2017-02-03 13:37:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
buffer_desc.ByteWidth = geometry->outline.vertex_count * sizeof(*geometry->outline.vertices);
|
2021-06-25 09:34:01 +02:00
|
|
|
buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
2017-02-03 13:37:09 +01:00
|
|
|
buffer_data.pSysMem = geometry->outline.vertices;
|
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb)))
|
2017-02-03 13:37:09 +01:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create vertex buffer, hr %#lx.\n", hr);
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11Buffer_Release(ib);
|
2021-06-11 10:35:49 +02:00
|
|
|
return;
|
2017-02-03 13:37:09 +01:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
d2d_device_context_draw(render_target, D2D_SHAPE_TYPE_OUTLINE, ib, 3 * geometry->outline.face_count, vb,
|
2021-06-11 10:35:49 +02:00
|
|
|
sizeof(*geometry->outline.vertices), brush, NULL);
|
2017-02-03 13:37:09 +01:00
|
|
|
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11Buffer_Release(vb);
|
|
|
|
ID3D11Buffer_Release(ib);
|
2017-02-03 13:37:09 +01:00
|
|
|
}
|
|
|
|
|
2017-05-21 17:53:43 +02:00
|
|
|
if (geometry->outline.bezier_face_count)
|
|
|
|
{
|
|
|
|
buffer_desc.ByteWidth = geometry->outline.bezier_face_count * sizeof(*geometry->outline.bezier_faces);
|
2021-06-25 09:34:01 +02:00
|
|
|
buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
2017-05-21 17:53:43 +02:00
|
|
|
buffer_data.pSysMem = geometry->outline.bezier_faces;
|
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &ib)))
|
2017-05-21 17:53:43 +02:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to create curves index buffer, hr %#lx.\n", hr);
|
2021-06-11 10:35:49 +02:00
|
|
|
return;
|
2017-05-21 17:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
buffer_desc.ByteWidth = geometry->outline.bezier_count * sizeof(*geometry->outline.beziers);
|
2021-06-25 09:34:01 +02:00
|
|
|
buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
2017-05-21 17:53:43 +02:00
|
|
|
buffer_data.pSysMem = geometry->outline.beziers;
|
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb)))
|
2017-05-21 17:53:43 +02:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create curves vertex buffer, hr %#lx.\n", hr);
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11Buffer_Release(ib);
|
2021-06-11 10:35:49 +02:00
|
|
|
return;
|
2017-05-21 17:53:43 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
d2d_device_context_draw(render_target, D2D_SHAPE_TYPE_BEZIER_OUTLINE, ib,
|
|
|
|
3 * geometry->outline.bezier_face_count, vb,
|
2021-06-11 10:35:49 +02:00
|
|
|
sizeof(*geometry->outline.beziers), brush, NULL);
|
2020-03-03 18:59:47 +01:00
|
|
|
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11Buffer_Release(vb);
|
|
|
|
ID3D11Buffer_Release(ib);
|
2020-03-03 18:59:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (geometry->outline.arc_face_count)
|
|
|
|
{
|
|
|
|
buffer_desc.ByteWidth = geometry->outline.arc_face_count * sizeof(*geometry->outline.arc_faces);
|
2021-06-25 09:34:01 +02:00
|
|
|
buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
2020-03-03 18:59:47 +01:00
|
|
|
buffer_data.pSysMem = geometry->outline.arc_faces;
|
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &ib)))
|
2020-03-03 18:59:47 +01:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to create arcs index buffer, hr %#lx.\n", hr);
|
2021-06-11 10:35:49 +02:00
|
|
|
return;
|
2020-03-03 18:59:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
buffer_desc.ByteWidth = geometry->outline.arc_count * sizeof(*geometry->outline.arcs);
|
2021-06-25 09:34:01 +02:00
|
|
|
buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
2020-03-03 18:59:47 +01:00
|
|
|
buffer_data.pSysMem = geometry->outline.arcs;
|
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb)))
|
2020-03-03 18:59:47 +01:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create arcs vertex buffer, hr %#lx.\n", hr);
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11Buffer_Release(ib);
|
2021-06-11 10:35:49 +02:00
|
|
|
return;
|
2020-03-03 18:59:47 +01:00
|
|
|
}
|
|
|
|
|
2021-06-10 14:13:23 +02:00
|
|
|
if (SUCCEEDED(d2d_device_context_update_ps_cb(render_target, brush, NULL, TRUE, TRUE)))
|
|
|
|
d2d_device_context_draw(render_target, D2D_SHAPE_TYPE_ARC_OUTLINE, ib,
|
|
|
|
3 * geometry->outline.arc_face_count, vb,
|
2021-06-11 10:35:49 +02:00
|
|
|
sizeof(*geometry->outline.arcs), brush, NULL);
|
2017-05-21 17:53:43 +02:00
|
|
|
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11Buffer_Release(vb);
|
|
|
|
ID3D11Buffer_Release(ib);
|
2017-05-21 17:53:43 +02:00
|
|
|
}
|
2017-02-03 13:37:09 +01:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_DrawGeometry(ID2D1DeviceContext *iface,
|
2015-07-14 15:57:42 +02:00
|
|
|
ID2D1Geometry *geometry, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
|
|
|
|
{
|
2017-02-03 13:37:09 +01:00
|
|
|
const struct d2d_geometry *geometry_impl = unsafe_impl_from_ID2D1Geometry(geometry);
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2017-02-03 13:37:09 +01:00
|
|
|
struct d2d_brush *brush_impl = unsafe_impl_from_ID2D1Brush(brush);
|
|
|
|
|
|
|
|
TRACE("iface %p, geometry %p, brush %p, stroke_width %.8e, stroke_style %p.\n",
|
2015-07-14 15:57:42 +02:00
|
|
|
iface, geometry, brush, stroke_width, stroke_style);
|
2017-02-03 13:37:09 +01:00
|
|
|
|
|
|
|
if (stroke_style)
|
2017-08-07 09:31:53 +02:00
|
|
|
FIXME("Ignoring stroke style %p.\n", stroke_style);
|
2017-02-03 13:37:09 +01:00
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
d2d_device_context_draw_geometry(render_target, geometry_impl, brush_impl, stroke_width);
|
2015-07-14 15:57:42 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void d2d_device_context_fill_geometry(struct d2d_device_context *render_target,
|
2015-11-18 22:23:23 +01:00
|
|
|
const struct d2d_geometry *geometry, struct d2d_brush *brush, struct d2d_brush *opacity_brush)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2021-06-25 09:34:01 +02:00
|
|
|
D3D11_SUBRESOURCE_DATA buffer_data;
|
|
|
|
D3D11_BUFFER_DESC buffer_desc;
|
|
|
|
ID3D11Buffer *ib, *vb;
|
2014-11-06 08:20:14 +01:00
|
|
|
HRESULT hr;
|
2021-06-11 10:35:49 +02:00
|
|
|
|
2021-06-25 09:34:01 +02:00
|
|
|
buffer_desc.Usage = D3D11_USAGE_DEFAULT;
|
2015-07-20 11:07:28 +02:00
|
|
|
buffer_desc.CPUAccessFlags = 0;
|
|
|
|
buffer_desc.MiscFlags = 0;
|
|
|
|
|
|
|
|
buffer_data.SysMemPitch = 0;
|
|
|
|
buffer_data.SysMemSlicePitch = 0;
|
2014-11-06 08:20:14 +01:00
|
|
|
|
2021-06-11 10:35:49 +02:00
|
|
|
if (FAILED(hr = d2d_device_context_update_vs_cb(render_target, &geometry->transform, 0.0f)))
|
2014-11-06 08:20:14 +01:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to update vs constant buffer, hr %#lx.\n", hr);
|
2014-11-06 08:20:14 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-10 14:13:23 +02:00
|
|
|
if (FAILED(hr = d2d_device_context_update_ps_cb(render_target, brush, opacity_brush, FALSE, FALSE)))
|
2014-11-06 08:20:14 +01:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to update ps constant buffer, hr %#lx.\n", hr);
|
2014-11-06 08:20:14 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-12-08 14:31:58 +01:00
|
|
|
if (geometry->fill.face_count)
|
2015-07-20 11:07:28 +02:00
|
|
|
{
|
2016-12-08 14:31:58 +01:00
|
|
|
buffer_desc.ByteWidth = geometry->fill.face_count * sizeof(*geometry->fill.faces);
|
2021-06-25 09:34:01 +02:00
|
|
|
buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
2016-12-08 14:31:58 +01:00
|
|
|
buffer_data.pSysMem = geometry->fill.faces;
|
2015-07-20 11:07:28 +02:00
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &ib)))
|
2015-08-17 12:55:17 +02:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to create index buffer, hr %#lx.\n", hr);
|
2021-06-11 10:35:49 +02:00
|
|
|
return;
|
2015-08-17 12:55:17 +02:00
|
|
|
}
|
2015-07-20 11:07:28 +02:00
|
|
|
|
2016-12-08 14:31:58 +01:00
|
|
|
buffer_desc.ByteWidth = geometry->fill.vertex_count * sizeof(*geometry->fill.vertices);
|
2021-06-25 09:34:01 +02:00
|
|
|
buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
2016-12-08 14:31:58 +01:00
|
|
|
buffer_data.pSysMem = geometry->fill.vertices;
|
2015-08-17 12:55:17 +02:00
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb)))
|
2015-08-17 12:55:17 +02:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create vertex buffer, hr %#lx.\n", hr);
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11Buffer_Release(ib);
|
2021-06-11 10:35:49 +02:00
|
|
|
return;
|
2015-08-17 12:55:17 +02:00
|
|
|
}
|
2015-07-20 11:07:28 +02:00
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
d2d_device_context_draw(render_target, D2D_SHAPE_TYPE_TRIANGLE, ib, 3 * geometry->fill.face_count, vb,
|
2021-06-11 10:35:49 +02:00
|
|
|
sizeof(*geometry->fill.vertices), brush, opacity_brush);
|
2014-11-06 08:20:14 +01:00
|
|
|
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11Buffer_Release(vb);
|
|
|
|
ID3D11Buffer_Release(ib);
|
2015-08-17 12:55:17 +02:00
|
|
|
}
|
2015-07-20 11:07:28 +02:00
|
|
|
|
2016-12-08 14:31:59 +01:00
|
|
|
if (geometry->fill.bezier_vertex_count)
|
2015-07-20 11:07:28 +02:00
|
|
|
{
|
2016-12-08 14:31:59 +01:00
|
|
|
buffer_desc.ByteWidth = geometry->fill.bezier_vertex_count * sizeof(*geometry->fill.bezier_vertices);
|
2021-06-25 09:34:01 +02:00
|
|
|
buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
2016-12-08 14:31:59 +01:00
|
|
|
buffer_data.pSysMem = geometry->fill.bezier_vertices;
|
2015-07-20 11:07:28 +02:00
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb)))
|
2015-07-20 11:07:28 +02:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create curves vertex buffer, hr %#lx.\n", hr);
|
2021-06-11 10:35:49 +02:00
|
|
|
return;
|
2015-07-20 11:07:28 +02:00
|
|
|
}
|
|
|
|
|
2020-03-03 18:59:46 +01:00
|
|
|
d2d_device_context_draw(render_target, D2D_SHAPE_TYPE_CURVE, NULL, geometry->fill.bezier_vertex_count, vb,
|
2021-06-11 10:35:49 +02:00
|
|
|
sizeof(*geometry->fill.bezier_vertices), brush, opacity_brush);
|
2020-03-03 18:59:46 +01:00
|
|
|
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11Buffer_Release(vb);
|
2020-03-03 18:59:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (geometry->fill.arc_vertex_count)
|
|
|
|
{
|
|
|
|
buffer_desc.ByteWidth = geometry->fill.arc_vertex_count * sizeof(*geometry->fill.arc_vertices);
|
2021-06-25 09:34:01 +02:00
|
|
|
buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
2020-03-03 18:59:46 +01:00
|
|
|
buffer_data.pSysMem = geometry->fill.arc_vertices;
|
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb)))
|
2020-03-03 18:59:46 +01:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create arc vertex buffer, hr %#lx.\n", hr);
|
2021-06-11 10:35:49 +02:00
|
|
|
return;
|
2020-03-03 18:59:46 +01:00
|
|
|
}
|
|
|
|
|
2021-06-10 14:13:23 +02:00
|
|
|
if (SUCCEEDED(d2d_device_context_update_ps_cb(render_target, brush, opacity_brush, FALSE, TRUE)))
|
|
|
|
d2d_device_context_draw(render_target, D2D_SHAPE_TYPE_CURVE, NULL, geometry->fill.arc_vertex_count, vb,
|
2021-06-11 10:35:49 +02:00
|
|
|
sizeof(*geometry->fill.arc_vertices), brush, opacity_brush);
|
2015-07-20 11:07:28 +02:00
|
|
|
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11Buffer_Release(vb);
|
2015-07-20 11:07:28 +02:00
|
|
|
}
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_FillGeometry(ID2D1DeviceContext *iface,
|
2015-11-18 22:23:23 +01:00
|
|
|
ID2D1Geometry *geometry, ID2D1Brush *brush, ID2D1Brush *opacity_brush)
|
|
|
|
{
|
|
|
|
const struct d2d_geometry *geometry_impl = unsafe_impl_from_ID2D1Geometry(geometry);
|
|
|
|
struct d2d_brush *opacity_brush_impl = unsafe_impl_from_ID2D1Brush(opacity_brush);
|
2018-10-05 09:23:22 +02:00
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
2015-11-18 22:23:23 +01:00
|
|
|
struct d2d_brush *brush_impl = unsafe_impl_from_ID2D1Brush(brush);
|
|
|
|
|
|
|
|
TRACE("iface %p, geometry %p, brush %p, opacity_brush %p.\n", iface, geometry, brush, opacity_brush);
|
|
|
|
|
2018-10-05 09:23:22 +02:00
|
|
|
if (FAILED(context->error.code))
|
2015-11-18 22:23:23 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (opacity_brush && brush_impl->type != D2D_BRUSH_TYPE_BITMAP)
|
|
|
|
{
|
2018-10-05 09:23:22 +02:00
|
|
|
d2d_device_context_set_error(context, D2DERR_INCOMPATIBLE_BRUSH_TYPES);
|
2015-11-18 22:23:23 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-05 09:23:22 +02:00
|
|
|
d2d_device_context_fill_geometry(context, geometry_impl, brush_impl, opacity_brush_impl);
|
2015-11-18 22:23:23 +01:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_FillMesh(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
ID2D1Mesh *mesh, ID2D1Brush *brush)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, mesh %p, brush %p stub!\n", iface, mesh, brush);
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_FillOpacityMask(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
ID2D1Bitmap *mask, ID2D1Brush *brush, D2D1_OPACITY_MASK_CONTENT content,
|
|
|
|
const D2D1_RECT_F *dst_rect, const D2D1_RECT_F *src_rect)
|
|
|
|
{
|
2017-07-10 18:02:18 +02:00
|
|
|
FIXME("iface %p, mask %p, brush %p, content %#x, dst_rect %s, src_rect %s stub!\n",
|
|
|
|
iface, mask, brush, content, debug_d2d_rect_f(dst_rect), debug_d2d_rect_f(src_rect));
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-10-04 13:37:34 +02:00
|
|
|
static void d2d_device_context_draw_bitmap(struct d2d_device_context *context, ID2D1Bitmap *bitmap,
|
|
|
|
const D2D1_RECT_F *dst_rect, float opacity, D2D1_INTERPOLATION_MODE interpolation_mode,
|
2021-01-15 15:55:39 +01:00
|
|
|
const D2D1_RECT_F *src_rect, const D2D1_POINT_2F *offset,
|
|
|
|
const D2D1_MATRIX_4X4_F *perspective_transform)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-10-04 13:37:34 +02:00
|
|
|
D2D1_BITMAP_BRUSH_PROPERTIES1 bitmap_brush_desc;
|
2015-02-06 09:57:02 +01:00
|
|
|
D2D1_BRUSH_PROPERTIES brush_desc;
|
2018-10-04 13:37:34 +02:00
|
|
|
struct d2d_brush *brush;
|
2021-01-15 15:55:37 +01:00
|
|
|
D2D1_SIZE_F size;
|
2015-02-06 09:57:02 +01:00
|
|
|
D2D1_RECT_F s, d;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2018-10-04 13:37:34 +02:00
|
|
|
if (perspective_transform)
|
|
|
|
FIXME("Perspective transform is ignored.\n");
|
2018-10-04 13:37:33 +02:00
|
|
|
|
2021-01-15 15:55:37 +01:00
|
|
|
size = ID2D1Bitmap_GetSize(bitmap);
|
|
|
|
d2d_rect_set(&s, 0.0f, 0.0f, size.width, size.height);
|
|
|
|
if (src_rect && src_rect->left <= src_rect->right
|
|
|
|
&& src_rect->top <= src_rect->bottom)
|
2015-02-06 09:57:02 +01:00
|
|
|
{
|
2021-01-15 15:55:37 +01:00
|
|
|
d2d_rect_intersect(&s, src_rect);
|
2015-02-06 09:57:02 +01:00
|
|
|
}
|
|
|
|
|
2021-01-15 15:55:38 +01:00
|
|
|
if (s.left == s.right || s.top == s.bottom)
|
|
|
|
return;
|
|
|
|
|
2015-02-06 09:57:02 +01:00
|
|
|
if (dst_rect)
|
|
|
|
{
|
|
|
|
d = *dst_rect;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
d.left = 0.0f;
|
|
|
|
d.top = 0.0f;
|
|
|
|
d.right = s.right - s.left;
|
|
|
|
d.bottom = s.bottom - s.top;
|
|
|
|
}
|
|
|
|
|
2021-01-15 15:55:39 +01:00
|
|
|
if (offset)
|
|
|
|
{
|
|
|
|
d.left += offset->x;
|
|
|
|
d.top += offset->y;
|
|
|
|
d.right += offset->x;
|
|
|
|
d.bottom += offset->y;
|
|
|
|
}
|
|
|
|
|
2015-02-06 09:57:02 +01:00
|
|
|
bitmap_brush_desc.extendModeX = D2D1_EXTEND_MODE_CLAMP;
|
|
|
|
bitmap_brush_desc.extendModeY = D2D1_EXTEND_MODE_CLAMP;
|
|
|
|
bitmap_brush_desc.interpolationMode = interpolation_mode;
|
|
|
|
|
|
|
|
brush_desc.opacity = opacity;
|
2015-04-23 20:23:24 +02:00
|
|
|
brush_desc.transform._11 = fabsf((d.right - d.left) / (s.right - s.left));
|
2015-02-06 09:57:02 +01:00
|
|
|
brush_desc.transform._21 = 0.0f;
|
2015-04-23 20:23:25 +02:00
|
|
|
brush_desc.transform._31 = min(d.left, d.right) - min(s.left, s.right) * brush_desc.transform._11;
|
2015-02-06 09:57:02 +01:00
|
|
|
brush_desc.transform._12 = 0.0f;
|
2015-04-23 20:23:24 +02:00
|
|
|
brush_desc.transform._22 = fabsf((d.bottom - d.top) / (s.bottom - s.top));
|
2015-04-23 20:23:25 +02:00
|
|
|
brush_desc.transform._32 = min(d.top, d.bottom) - min(s.top, s.bottom) * brush_desc.transform._22;
|
2015-02-06 09:57:02 +01:00
|
|
|
|
2018-10-04 13:37:34 +02:00
|
|
|
if (FAILED(hr = d2d_bitmap_brush_create(context->factory, bitmap, &bitmap_brush_desc, &brush_desc, &brush)))
|
2015-02-06 09:57:02 +01:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create bitmap brush, hr %#lx.\n", hr);
|
2015-02-06 09:57:02 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-04 13:37:34 +02:00
|
|
|
d2d_device_context_FillRectangle(&context->ID2D1DeviceContext_iface, &d, &brush->ID2D1Brush_iface);
|
|
|
|
ID2D1Brush_Release(&brush->ID2D1Brush_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_DrawBitmap(ID2D1DeviceContext *iface,
|
|
|
|
ID2D1Bitmap *bitmap, const D2D1_RECT_F *dst_rect, float opacity,
|
|
|
|
D2D1_BITMAP_INTERPOLATION_MODE interpolation_mode, const D2D1_RECT_F *src_rect)
|
|
|
|
{
|
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, bitmap %p, dst_rect %s, opacity %.8e, interpolation_mode %#x, src_rect %s.\n",
|
|
|
|
iface, bitmap, debug_d2d_rect_f(dst_rect), opacity, interpolation_mode, debug_d2d_rect_f(src_rect));
|
|
|
|
|
|
|
|
if (interpolation_mode != D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR
|
|
|
|
&& interpolation_mode != D2D1_BITMAP_INTERPOLATION_MODE_LINEAR)
|
|
|
|
{
|
2018-10-05 09:23:22 +02:00
|
|
|
d2d_device_context_set_error(context, E_INVALIDARG);
|
2018-10-04 13:37:34 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-04-07 00:51:59 +02:00
|
|
|
d2d_device_context_draw_bitmap(context, bitmap, dst_rect, opacity, d2d1_1_interp_mode_from_d2d1(interpolation_mode),
|
2021-01-15 15:55:39 +01:00
|
|
|
src_rect, NULL, NULL);
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_DrawText(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
const WCHAR *string, UINT32 string_len, IDWriteTextFormat *text_format, const D2D1_RECT_F *layout_rect,
|
|
|
|
ID2D1Brush *brush, D2D1_DRAW_TEXT_OPTIONS options, DWRITE_MEASURING_MODE measuring_mode)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2015-07-10 15:03:46 +02:00
|
|
|
IDWriteTextLayout *text_layout;
|
|
|
|
IDWriteFactory *dwrite_factory;
|
|
|
|
D2D1_POINT_2F origin;
|
2021-01-19 13:48:16 +01:00
|
|
|
float width, height;
|
2015-07-10 15:03:46 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2017-07-10 18:02:18 +02:00
|
|
|
TRACE("iface %p, string %s, string_len %u, text_format %p, layout_rect %s, "
|
2015-07-10 15:03:46 +02:00
|
|
|
"brush %p, options %#x, measuring_mode %#x.\n",
|
2017-07-10 18:02:18 +02:00
|
|
|
iface, debugstr_wn(string, string_len), string_len, text_format, debug_d2d_rect_f(layout_rect),
|
2014-05-20 07:38:44 +02:00
|
|
|
brush, options, measuring_mode);
|
2015-07-10 15:03:46 +02:00
|
|
|
|
|
|
|
if (FAILED(hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED,
|
|
|
|
&IID_IDWriteFactory, (IUnknown **)&dwrite_factory)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create dwrite factory, hr %#lx.\n", hr);
|
2015-07-10 15:03:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-01-19 13:48:16 +01:00
|
|
|
width = max(0.0f, layout_rect->right - layout_rect->left);
|
|
|
|
height = max(0.0f, layout_rect->bottom - layout_rect->top);
|
2016-01-20 19:31:56 +01:00
|
|
|
if (measuring_mode == DWRITE_MEASURING_MODE_NATURAL)
|
|
|
|
hr = IDWriteFactory_CreateTextLayout(dwrite_factory, string, string_len, text_format,
|
2021-01-19 13:48:16 +01:00
|
|
|
width, height, &text_layout);
|
2016-01-20 19:31:56 +01:00
|
|
|
else
|
|
|
|
hr = IDWriteFactory_CreateGdiCompatibleTextLayout(dwrite_factory, string, string_len, text_format,
|
2021-01-19 13:48:16 +01:00
|
|
|
width, height, render_target->desc.dpiX / 96.0f, (DWRITE_MATRIX *)&render_target->drawing_state.transform,
|
|
|
|
measuring_mode == DWRITE_MEASURING_MODE_GDI_NATURAL, &text_layout);
|
2015-07-10 15:03:46 +02:00
|
|
|
IDWriteFactory_Release(dwrite_factory);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create text layout, hr %#lx.\n", hr);
|
2015-07-10 15:03:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-01-19 13:48:15 +01:00
|
|
|
d2d_point_set(&origin, min(layout_rect->left, layout_rect->right), min(layout_rect->top, layout_rect->bottom));
|
2018-08-17 16:54:11 +02:00
|
|
|
ID2D1DeviceContext_DrawTextLayout(iface, origin, text_layout, brush, options);
|
2015-07-10 15:03:46 +02:00
|
|
|
IDWriteTextLayout_Release(text_layout);
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_DrawTextLayout(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
D2D1_POINT_2F origin, IDWriteTextLayout *layout, ID2D1Brush *brush, D2D1_DRAW_TEXT_OPTIONS options)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2014-10-06 08:24:17 +02:00
|
|
|
struct d2d_draw_text_layout_ctx ctx;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2018-09-25 00:25:17 +02:00
|
|
|
TRACE("iface %p, origin %s, layout %p, brush %p, options %#x.\n",
|
|
|
|
iface, debug_d2d_point_2f(&origin), layout, brush, options);
|
2014-10-06 08:24:17 +02:00
|
|
|
|
|
|
|
ctx.brush = brush;
|
|
|
|
ctx.options = options;
|
|
|
|
|
|
|
|
if (FAILED(hr = IDWriteTextLayout_Draw(layout,
|
|
|
|
&ctx, &render_target->IDWriteTextRenderer_iface, origin.x, origin.y)))
|
2022-02-01 19:23:14 +01:00
|
|
|
FIXME("Failed to draw text layout, hr %#lx.\n", hr);
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static D2D1_ANTIALIAS_MODE d2d_device_context_set_aa_mode_from_text_aa_mode(struct d2d_device_context *rt)
|
2017-07-18 08:46:17 +02:00
|
|
|
{
|
|
|
|
D2D1_ANTIALIAS_MODE prev_antialias_mode = rt->drawing_state.antialiasMode;
|
|
|
|
rt->drawing_state.antialiasMode = rt->drawing_state.textAntialiasMode == D2D1_TEXT_ANTIALIAS_MODE_ALIASED ?
|
|
|
|
D2D1_ANTIALIAS_MODE_ALIASED : D2D1_ANTIALIAS_MODE_PER_PRIMITIVE;
|
|
|
|
return prev_antialias_mode;
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void d2d_device_context_draw_glyph_run_outline(struct d2d_device_context *render_target,
|
2015-11-18 22:23:23 +01:00
|
|
|
D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run, ID2D1Brush *brush)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2015-07-09 14:22:10 +02:00
|
|
|
D2D1_MATRIX_3X2_F *transform, prev_transform;
|
2017-07-18 08:46:17 +02:00
|
|
|
D2D1_ANTIALIAS_MODE prev_antialias_mode;
|
2015-07-09 14:22:10 +02:00
|
|
|
ID2D1PathGeometry *geometry;
|
|
|
|
ID2D1GeometrySink *sink;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (FAILED(hr = ID2D1Factory_CreatePathGeometry(render_target->factory, &geometry)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create geometry, hr %#lx.\n", hr);
|
2015-07-09 14:22:10 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(hr = ID2D1PathGeometry_Open(geometry, &sink)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to open geometry sink, hr %#lx.\n", hr);
|
2015-07-09 14:22:10 +02:00
|
|
|
ID2D1PathGeometry_Release(geometry);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(hr = IDWriteFontFace_GetGlyphRunOutline(glyph_run->fontFace, glyph_run->fontEmSize,
|
|
|
|
glyph_run->glyphIndices, glyph_run->glyphAdvances, glyph_run->glyphOffsets, glyph_run->glyphCount,
|
|
|
|
glyph_run->isSideways, glyph_run->bidiLevel & 1, (IDWriteGeometrySink *)sink)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to get glyph run outline, hr %#lx.\n", hr);
|
2015-07-09 14:22:10 +02:00
|
|
|
ID2D1GeometrySink_Release(sink);
|
|
|
|
ID2D1PathGeometry_Release(geometry);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(hr = ID2D1GeometrySink_Close(sink)))
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to close geometry sink, hr %#lx.\n", hr);
|
2015-07-09 14:22:10 +02:00
|
|
|
ID2D1GeometrySink_Release(sink);
|
|
|
|
|
|
|
|
transform = &render_target->drawing_state.transform;
|
|
|
|
prev_transform = *transform;
|
|
|
|
transform->_31 += baseline_origin.x * transform->_11 + baseline_origin.y * transform->_21;
|
|
|
|
transform->_32 += baseline_origin.x * transform->_12 + baseline_origin.y * transform->_22;
|
2018-08-17 16:54:11 +02:00
|
|
|
prev_antialias_mode = d2d_device_context_set_aa_mode_from_text_aa_mode(render_target);
|
|
|
|
d2d_device_context_fill_geometry(render_target, unsafe_impl_from_ID2D1Geometry((ID2D1Geometry *)geometry),
|
2015-11-18 22:23:23 +01:00
|
|
|
unsafe_impl_from_ID2D1Brush(brush), NULL);
|
2017-07-18 08:46:17 +02:00
|
|
|
render_target->drawing_state.antialiasMode = prev_antialias_mode;
|
2015-07-09 14:22:10 +02:00
|
|
|
*transform = prev_transform;
|
|
|
|
|
|
|
|
ID2D1PathGeometry_Release(geometry);
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void d2d_device_context_draw_glyph_run_bitmap(struct d2d_device_context *render_target,
|
2015-11-18 22:23:23 +01:00
|
|
|
D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run, ID2D1Brush *brush,
|
2018-08-16 13:55:28 +02:00
|
|
|
DWRITE_RENDERING_MODE rendering_mode, DWRITE_MEASURING_MODE measuring_mode,
|
2017-07-18 08:46:15 +02:00
|
|
|
DWRITE_TEXT_ANTIALIAS_MODE antialias_mode)
|
2015-11-18 22:23:23 +01:00
|
|
|
{
|
|
|
|
ID2D1RectangleGeometry *geometry = NULL;
|
|
|
|
ID2D1BitmapBrush *opacity_brush = NULL;
|
|
|
|
D2D1_BITMAP_PROPERTIES bitmap_desc;
|
|
|
|
ID2D1Bitmap *opacity_bitmap = NULL;
|
|
|
|
IDWriteGlyphRunAnalysis *analysis;
|
|
|
|
DWRITE_TEXTURE_TYPE texture_type;
|
|
|
|
D2D1_BRUSH_PROPERTIES brush_desc;
|
2017-07-18 08:46:15 +02:00
|
|
|
IDWriteFactory2 *dwrite_factory;
|
2018-08-16 13:55:28 +02:00
|
|
|
D2D1_MATRIX_3X2_F *transform, m;
|
2015-11-18 22:23:23 +01:00
|
|
|
void *opacity_values = NULL;
|
|
|
|
size_t opacity_values_size;
|
|
|
|
D2D1_SIZE_U bitmap_size;
|
2018-08-16 13:55:28 +02:00
|
|
|
float scale_x, scale_y;
|
2015-11-18 22:23:23 +01:00
|
|
|
D2D1_RECT_F run_rect;
|
|
|
|
RECT bounds;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (FAILED(hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED,
|
2017-07-18 08:46:15 +02:00
|
|
|
&IID_IDWriteFactory2, (IUnknown **)&dwrite_factory)))
|
2015-11-18 22:23:23 +01:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create dwrite factory, hr %#lx.\n", hr);
|
2015-11-18 22:23:23 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-16 13:55:28 +02:00
|
|
|
transform = &render_target->drawing_state.transform;
|
|
|
|
|
|
|
|
scale_x = render_target->desc.dpiX / 96.0f;
|
|
|
|
m._11 = transform->_11 * scale_x;
|
|
|
|
m._21 = transform->_21 * scale_x;
|
|
|
|
m._31 = transform->_31 * scale_x;
|
|
|
|
|
|
|
|
scale_y = render_target->desc.dpiY / 96.0f;
|
|
|
|
m._12 = transform->_12 * scale_y;
|
|
|
|
m._22 = transform->_22 * scale_y;
|
|
|
|
m._32 = transform->_32 * scale_y;
|
|
|
|
|
|
|
|
hr = IDWriteFactory2_CreateGlyphRunAnalysis(dwrite_factory, glyph_run, (DWRITE_MATRIX *)&m,
|
|
|
|
rendering_mode, measuring_mode, DWRITE_GRID_FIT_MODE_DEFAULT, antialias_mode,
|
|
|
|
baseline_origin.x, baseline_origin.y, &analysis);
|
2017-07-18 08:46:15 +02:00
|
|
|
IDWriteFactory2_Release(dwrite_factory);
|
2015-11-18 22:23:23 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create glyph run analysis, hr %#lx.\n", hr);
|
2015-11-18 22:23:23 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-05 12:35:30 +02:00
|
|
|
if (rendering_mode == DWRITE_RENDERING_MODE_ALIASED || antialias_mode == DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE)
|
2015-11-18 22:23:23 +01:00
|
|
|
texture_type = DWRITE_TEXTURE_ALIASED_1x1;
|
|
|
|
else
|
|
|
|
texture_type = DWRITE_TEXTURE_CLEARTYPE_3x1;
|
|
|
|
|
|
|
|
if (FAILED(hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, texture_type, &bounds)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to get alpha texture bounds, hr %#lx.\n", hr);
|
2015-11-18 22:23:23 +01:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
d2d_size_set(&bitmap_size, bounds.right - bounds.left, bounds.bottom - bounds.top);
|
|
|
|
if (!bitmap_size.width || !bitmap_size.height)
|
|
|
|
{
|
|
|
|
/* Empty run, nothing to do. */
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (texture_type == DWRITE_TEXTURE_CLEARTYPE_3x1)
|
|
|
|
bitmap_size.width *= 3;
|
2018-02-01 00:37:35 +01:00
|
|
|
if (!(opacity_values = heap_calloc(bitmap_size.height, bitmap_size.width)))
|
2015-11-18 22:23:23 +01:00
|
|
|
{
|
|
|
|
ERR("Failed to allocate opacity values.\n");
|
|
|
|
goto done;
|
|
|
|
}
|
2018-01-31 16:19:40 +01:00
|
|
|
opacity_values_size = bitmap_size.height * bitmap_size.width;
|
2015-11-18 22:23:23 +01:00
|
|
|
|
|
|
|
if (FAILED(hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis,
|
|
|
|
texture_type, &bounds, opacity_values, opacity_values_size)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create alpha texture, hr %#lx.\n", hr);
|
2015-11-18 22:23:23 +01:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
bitmap_desc.pixelFormat.format = DXGI_FORMAT_A8_UNORM;
|
|
|
|
bitmap_desc.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED;
|
2016-10-19 19:00:21 +02:00
|
|
|
bitmap_desc.dpiX = render_target->desc.dpiX;
|
2015-11-18 22:23:23 +01:00
|
|
|
if (texture_type == DWRITE_TEXTURE_CLEARTYPE_3x1)
|
|
|
|
bitmap_desc.dpiX *= 3.0f;
|
2016-10-19 19:00:21 +02:00
|
|
|
bitmap_desc.dpiY = render_target->desc.dpiY;
|
2018-08-17 16:54:11 +02:00
|
|
|
if (FAILED(hr = d2d_device_context_CreateBitmap(&render_target->ID2D1DeviceContext_iface,
|
2015-11-18 22:23:23 +01:00
|
|
|
bitmap_size, opacity_values, bitmap_size.width, &bitmap_desc, &opacity_bitmap)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create opacity bitmap, hr %#lx.\n", hr);
|
2015-11-18 22:23:23 +01:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2018-08-16 13:55:28 +02:00
|
|
|
d2d_rect_set(&run_rect, bounds.left / scale_x, bounds.top / scale_y,
|
|
|
|
bounds.right / scale_x, bounds.bottom / scale_y);
|
|
|
|
|
2015-11-18 22:23:23 +01:00
|
|
|
brush_desc.opacity = 1.0f;
|
|
|
|
brush_desc.transform._11 = 1.0f;
|
|
|
|
brush_desc.transform._12 = 0.0f;
|
|
|
|
brush_desc.transform._21 = 0.0f;
|
|
|
|
brush_desc.transform._22 = 1.0f;
|
2018-08-16 13:55:28 +02:00
|
|
|
brush_desc.transform._31 = run_rect.left;
|
|
|
|
brush_desc.transform._32 = run_rect.top;
|
2018-08-17 16:54:11 +02:00
|
|
|
if (FAILED(hr = d2d_device_context_CreateBitmapBrush(&render_target->ID2D1DeviceContext_iface,
|
2015-11-18 22:23:23 +01:00
|
|
|
opacity_bitmap, NULL, &brush_desc, &opacity_brush)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create opacity bitmap brush, hr %#lx.\n", hr);
|
2015-11-18 22:23:23 +01:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(hr = ID2D1Factory_CreateRectangleGeometry(render_target->factory, &run_rect, &geometry)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create geometry, hr %#lx.\n", hr);
|
2015-11-18 22:23:23 +01:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2018-08-16 13:55:28 +02:00
|
|
|
m = *transform;
|
2017-04-04 12:13:20 +02:00
|
|
|
*transform = identity;
|
2018-08-17 16:54:11 +02:00
|
|
|
d2d_device_context_fill_geometry(render_target, unsafe_impl_from_ID2D1Geometry((ID2D1Geometry *)geometry),
|
2015-11-18 22:23:23 +01:00
|
|
|
unsafe_impl_from_ID2D1Brush(brush), unsafe_impl_from_ID2D1Brush((ID2D1Brush *)opacity_brush));
|
2018-08-16 13:55:28 +02:00
|
|
|
*transform = m;
|
2015-11-18 22:23:23 +01:00
|
|
|
|
|
|
|
done:
|
|
|
|
if (geometry)
|
|
|
|
ID2D1RectangleGeometry_Release(geometry);
|
|
|
|
if (opacity_brush)
|
|
|
|
ID2D1BitmapBrush_Release(opacity_brush);
|
|
|
|
if (opacity_bitmap)
|
|
|
|
ID2D1Bitmap_Release(opacity_bitmap);
|
2018-01-30 13:24:39 +01:00
|
|
|
heap_free(opacity_values);
|
2015-11-18 22:23:23 +01:00
|
|
|
IDWriteGlyphRunAnalysis_Release(analysis);
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_DrawGlyphRun(ID2D1DeviceContext *iface,
|
2015-11-18 22:23:23 +01:00
|
|
|
D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run, ID2D1Brush *brush,
|
|
|
|
DWRITE_MEASURING_MODE measuring_mode)
|
|
|
|
{
|
2018-09-25 00:25:17 +02:00
|
|
|
TRACE("iface %p, baseline_origin %s, glyph_run %p, brush %p, measuring_mode %#x.\n",
|
|
|
|
iface, debug_d2d_point_2f(&baseline_origin), glyph_run, brush, measuring_mode);
|
2015-11-18 22:23:23 +01:00
|
|
|
|
2018-10-23 10:48:42 +02:00
|
|
|
ID2D1DeviceContext_DrawGlyphRun(iface, baseline_origin, glyph_run, NULL, brush, measuring_mode);
|
2015-11-18 22:23:23 +01:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_SetTransform(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
const D2D1_MATRIX_3X2_F *transform)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2014-07-22 08:44:22 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, transform %p.\n", iface, transform);
|
|
|
|
|
2015-03-27 09:07:06 +01:00
|
|
|
render_target->drawing_state.transform = *transform;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_GetTransform(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
D2D1_MATRIX_3X2_F *transform)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2014-07-22 08:44:21 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, transform %p.\n", iface, transform);
|
|
|
|
|
2015-03-27 09:07:06 +01:00
|
|
|
*transform = render_target->drawing_state.transform;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_SetAntialiasMode(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
D2D1_ANTIALIAS_MODE antialias_mode)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2015-03-26 09:41:19 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, antialias_mode %#x stub!\n", iface, antialias_mode);
|
|
|
|
|
2015-03-27 09:07:06 +01:00
|
|
|
render_target->drawing_state.antialiasMode = antialias_mode;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static D2D1_ANTIALIAS_MODE STDMETHODCALLTYPE d2d_device_context_GetAntialiasMode(ID2D1DeviceContext *iface)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2015-03-26 09:41:20 +01:00
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2015-03-27 09:07:06 +01:00
|
|
|
return render_target->drawing_state.antialiasMode;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_SetTextAntialiasMode(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
D2D1_TEXT_ANTIALIAS_MODE antialias_mode)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2015-03-27 09:07:02 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, antialias_mode %#x.\n", iface, antialias_mode);
|
|
|
|
|
2015-03-27 09:07:06 +01:00
|
|
|
render_target->drawing_state.textAntialiasMode = antialias_mode;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static D2D1_TEXT_ANTIALIAS_MODE STDMETHODCALLTYPE d2d_device_context_GetTextAntialiasMode(ID2D1DeviceContext *iface)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2015-03-27 09:07:03 +01:00
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2015-03-27 09:07:06 +01:00
|
|
|
return render_target->drawing_state.textAntialiasMode;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_SetTextRenderingParams(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
IDWriteRenderingParams *text_rendering_params)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2015-03-26 09:41:17 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, text_rendering_params %p.\n", iface, text_rendering_params);
|
|
|
|
|
|
|
|
if (text_rendering_params)
|
|
|
|
IDWriteRenderingParams_AddRef(text_rendering_params);
|
|
|
|
if (render_target->text_rendering_params)
|
|
|
|
IDWriteRenderingParams_Release(render_target->text_rendering_params);
|
|
|
|
render_target->text_rendering_params = text_rendering_params;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_GetTextRenderingParams(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
IDWriteRenderingParams **text_rendering_params)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2015-03-26 09:41:18 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, text_rendering_params %p.\n", iface, text_rendering_params);
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2015-03-26 09:41:18 +01:00
|
|
|
if ((*text_rendering_params = render_target->text_rendering_params))
|
|
|
|
IDWriteRenderingParams_AddRef(*text_rendering_params);
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_SetTags(ID2D1DeviceContext *iface, D2D1_TAG tag1, D2D1_TAG tag2)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2015-03-27 09:07:04 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, tag1 %s, tag2 %s.\n", iface, wine_dbgstr_longlong(tag1), wine_dbgstr_longlong(tag2));
|
|
|
|
|
2015-03-27 09:07:06 +01:00
|
|
|
render_target->drawing_state.tag1 = tag1;
|
|
|
|
render_target->drawing_state.tag2 = tag2;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_GetTags(ID2D1DeviceContext *iface, D2D1_TAG *tag1, D2D1_TAG *tag2)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2015-03-27 09:07:05 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, tag1 %p, tag2 %p.\n", iface, tag1, tag2);
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2015-03-27 09:07:06 +01:00
|
|
|
*tag1 = render_target->drawing_state.tag1;
|
|
|
|
*tag2 = render_target->drawing_state.tag2;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_PushLayer(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
const D2D1_LAYER_PARAMETERS *layer_parameters, ID2D1Layer *layer)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, layer_parameters %p, layer %p stub!\n", iface, layer_parameters, layer);
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_PopLayer(ID2D1DeviceContext *iface)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
|
|
|
FIXME("iface %p stub!\n", iface);
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_Flush(ID2D1DeviceContext *iface, D2D1_TAG *tag1, D2D1_TAG *tag2)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-09-12 17:59:51 +02:00
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
|
|
|
|
2014-05-20 07:38:44 +02:00
|
|
|
FIXME("iface %p, tag1 %p, tag2 %p stub!\n", iface, tag1, tag2);
|
|
|
|
|
2018-09-24 06:58:29 +02:00
|
|
|
if (context->ops && context->ops->device_context_present)
|
2018-09-12 17:59:51 +02:00
|
|
|
context->ops->device_context_present(context->outer_unknown);
|
|
|
|
|
2014-05-20 07:38:44 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_SaveDrawingState(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
ID2D1DrawingStateBlock *state_block)
|
|
|
|
{
|
2015-03-30 09:17:01 +02:00
|
|
|
struct d2d_state_block *state_block_impl = unsafe_impl_from_ID2D1DrawingStateBlock(state_block);
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2015-03-30 09:17:01 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, state_block %p.\n", iface, state_block);
|
|
|
|
|
|
|
|
state_block_impl->drawing_state = render_target->drawing_state;
|
|
|
|
if (render_target->text_rendering_params)
|
|
|
|
IDWriteRenderingParams_AddRef(render_target->text_rendering_params);
|
|
|
|
if (state_block_impl->text_rendering_params)
|
|
|
|
IDWriteRenderingParams_Release(state_block_impl->text_rendering_params);
|
|
|
|
state_block_impl->text_rendering_params = render_target->text_rendering_params;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_RestoreDrawingState(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
ID2D1DrawingStateBlock *state_block)
|
|
|
|
{
|
2015-03-30 09:17:02 +02:00
|
|
|
struct d2d_state_block *state_block_impl = unsafe_impl_from_ID2D1DrawingStateBlock(state_block);
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2015-03-30 09:17:02 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, state_block %p.\n", iface, state_block);
|
|
|
|
|
|
|
|
render_target->drawing_state = state_block_impl->drawing_state;
|
|
|
|
if (state_block_impl->text_rendering_params)
|
|
|
|
IDWriteRenderingParams_AddRef(state_block_impl->text_rendering_params);
|
|
|
|
if (render_target->text_rendering_params)
|
|
|
|
IDWriteRenderingParams_Release(render_target->text_rendering_params);
|
|
|
|
render_target->text_rendering_params = state_block_impl->text_rendering_params;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_PushAxisAlignedClip(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
const D2D1_RECT_F *clip_rect, D2D1_ANTIALIAS_MODE antialias_mode)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2014-09-05 15:50:59 +02:00
|
|
|
D2D1_RECT_F transformed_rect;
|
|
|
|
float x_scale, y_scale;
|
|
|
|
D2D1_POINT_2F point;
|
|
|
|
|
2017-07-10 18:02:18 +02:00
|
|
|
TRACE("iface %p, clip_rect %s, antialias_mode %#x.\n", iface, debug_d2d_rect_f(clip_rect), antialias_mode);
|
2014-09-05 15:50:59 +02:00
|
|
|
|
|
|
|
if (antialias_mode != D2D1_ANTIALIAS_MODE_ALIASED)
|
|
|
|
FIXME("Ignoring antialias_mode %#x.\n", antialias_mode);
|
|
|
|
|
2016-10-19 19:00:21 +02:00
|
|
|
x_scale = render_target->desc.dpiX / 96.0f;
|
|
|
|
y_scale = render_target->desc.dpiY / 96.0f;
|
2015-03-27 09:07:06 +01:00
|
|
|
d2d_point_transform(&point, &render_target->drawing_state.transform,
|
|
|
|
clip_rect->left * x_scale, clip_rect->top * y_scale);
|
2014-09-05 15:50:59 +02:00
|
|
|
d2d_rect_set(&transformed_rect, point.x, point.y, point.x, point.y);
|
2015-03-27 09:07:06 +01:00
|
|
|
d2d_point_transform(&point, &render_target->drawing_state.transform,
|
|
|
|
clip_rect->left * x_scale, clip_rect->bottom * y_scale);
|
2014-09-05 15:50:59 +02:00
|
|
|
d2d_rect_expand(&transformed_rect, &point);
|
2015-03-27 09:07:06 +01:00
|
|
|
d2d_point_transform(&point, &render_target->drawing_state.transform,
|
|
|
|
clip_rect->right * x_scale, clip_rect->top * y_scale);
|
2014-09-05 15:50:59 +02:00
|
|
|
d2d_rect_expand(&transformed_rect, &point);
|
2015-03-27 09:07:06 +01:00
|
|
|
d2d_point_transform(&point, &render_target->drawing_state.transform,
|
|
|
|
clip_rect->right * x_scale, clip_rect->bottom * y_scale);
|
2014-09-05 15:50:59 +02:00
|
|
|
d2d_rect_expand(&transformed_rect, &point);
|
|
|
|
|
|
|
|
if (!d2d_clip_stack_push(&render_target->clip_stack, &transformed_rect))
|
|
|
|
WARN("Failed to push clip rect.\n");
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_PopAxisAlignedClip(ID2D1DeviceContext *iface)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2014-09-05 15:50:59 +02:00
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2014-09-15 11:03:33 +02:00
|
|
|
d2d_clip_stack_pop(&render_target->clip_stack);
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_Clear(ID2D1DeviceContext *iface, const D2D1_COLOR_F *colour)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2021-06-25 09:34:01 +02:00
|
|
|
D3D11_MAPPED_SUBRESOURCE map_desc;
|
|
|
|
ID3D11DeviceContext *d3d_context;
|
2021-06-11 10:35:49 +02:00
|
|
|
struct d2d_ps_cb *ps_cb_data;
|
|
|
|
struct d2d_vs_cb *vs_cb_data;
|
2017-09-23 13:36:59 +02:00
|
|
|
D2D1_COLOR_F *c;
|
2014-09-05 15:50:58 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2017-09-23 13:36:59 +02:00
|
|
|
TRACE("iface %p, colour %p.\n", iface, colour);
|
2014-09-05 15:50:58 +02:00
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
ID3D11Device1_GetImmediateContext(render_target->d3d_device, &d3d_context);
|
2021-06-25 09:34:01 +02:00
|
|
|
|
|
|
|
if (FAILED(hr = ID3D11DeviceContext_Map(d3d_context, (ID3D11Resource *)render_target->vs_cb,
|
|
|
|
0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc)))
|
2014-09-05 15:50:58 +02:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to map vs constant buffer, hr %#lx.\n", hr);
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11DeviceContext_Release(d3d_context);
|
2014-09-05 15:50:58 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-25 09:34:01 +02:00
|
|
|
vs_cb_data = map_desc.pData;
|
2021-06-11 10:35:49 +02:00
|
|
|
vs_cb_data->transform_geometry._11 = 1.0f;
|
|
|
|
vs_cb_data->transform_geometry._21 = 0.0f;
|
|
|
|
vs_cb_data->transform_geometry._31 = 0.0f;
|
|
|
|
vs_cb_data->transform_geometry.pad0 = 0.0f;
|
|
|
|
vs_cb_data->transform_geometry._12 = 0.0f;
|
|
|
|
vs_cb_data->transform_geometry._22 = 1.0f;
|
|
|
|
vs_cb_data->transform_geometry._32 = 0.0f;
|
|
|
|
vs_cb_data->transform_geometry.stroke_width = 0.0f;
|
|
|
|
vs_cb_data->transform_rtx.x = 1.0f;
|
|
|
|
vs_cb_data->transform_rtx.y = 0.0f;
|
|
|
|
vs_cb_data->transform_rtx.z = 1.0f;
|
|
|
|
vs_cb_data->transform_rtx.w = 1.0f;
|
|
|
|
vs_cb_data->transform_rty.x = 0.0f;
|
|
|
|
vs_cb_data->transform_rty.y = 1.0f;
|
|
|
|
vs_cb_data->transform_rty.z = 1.0f;
|
|
|
|
vs_cb_data->transform_rty.w = -1.0f;
|
|
|
|
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11DeviceContext_Unmap(d3d_context, (ID3D11Resource *)render_target->vs_cb, 0);
|
2021-06-11 10:35:49 +02:00
|
|
|
|
2021-06-25 09:34:01 +02:00
|
|
|
if (FAILED(hr = ID3D11DeviceContext_Map(d3d_context, (ID3D11Resource *)render_target->ps_cb,
|
|
|
|
0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc)))
|
2021-06-11 10:35:49 +02:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to map ps constant buffer, hr %#lx.\n", hr);
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11DeviceContext_Release(d3d_context);
|
2021-06-10 14:13:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-25 09:34:01 +02:00
|
|
|
ps_cb_data = map_desc.pData;
|
2021-06-11 10:35:49 +02:00
|
|
|
memset(ps_cb_data, 0, sizeof(*ps_cb_data));
|
|
|
|
ps_cb_data->colour_brush.type = D2D_BRUSH_TYPE_SOLID;
|
|
|
|
ps_cb_data->colour_brush.opacity = 1.0f;
|
|
|
|
ps_cb_data->opacity_brush.type = D2D_BRUSH_TYPE_COUNT;
|
|
|
|
c = &ps_cb_data->colour_brush.u.solid.colour;
|
2017-09-23 13:36:59 +02:00
|
|
|
if (colour)
|
|
|
|
*c = *colour;
|
2016-10-19 19:00:21 +02:00
|
|
|
if (render_target->desc.pixelFormat.alphaMode == D2D1_ALPHA_MODE_IGNORE)
|
2017-09-23 13:36:59 +02:00
|
|
|
c->a = 1.0f;
|
|
|
|
c->r *= c->a;
|
|
|
|
c->g *= c->a;
|
|
|
|
c->b *= c->a;
|
|
|
|
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11DeviceContext_Unmap(d3d_context, (ID3D11Resource *)render_target->ps_cb, 0);
|
|
|
|
ID3D11DeviceContext_Release(d3d_context);
|
2014-09-05 15:50:58 +02:00
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
d2d_device_context_draw(render_target, D2D_SHAPE_TYPE_TRIANGLE, render_target->ib, 6,
|
2021-06-11 10:35:49 +02:00
|
|
|
render_target->vb, render_target->vb_stride, NULL, NULL);
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_BeginDraw(ID2D1DeviceContext *iface)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2015-11-18 16:10:20 +01:00
|
|
|
|
2014-09-03 07:48:21 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
2015-11-18 16:10:20 +01:00
|
|
|
|
|
|
|
memset(&render_target->error, 0, sizeof(render_target->error));
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_EndDraw(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
D2D1_TAG *tag1, D2D1_TAG *tag2)
|
|
|
|
{
|
2018-09-12 17:59:51 +02:00
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
|
|
|
HRESULT hr;
|
2015-11-18 16:10:20 +01:00
|
|
|
|
2014-09-03 07:48:22 +02:00
|
|
|
TRACE("iface %p, tag1 %p, tag2 %p.\n", iface, tag1, tag2);
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2014-09-03 07:48:22 +02:00
|
|
|
if (tag1)
|
2018-09-12 17:59:51 +02:00
|
|
|
*tag1 = context->error.tag1;
|
2014-09-03 07:48:22 +02:00
|
|
|
if (tag2)
|
2018-09-12 17:59:51 +02:00
|
|
|
*tag2 = context->error.tag2;
|
|
|
|
|
2018-09-24 06:58:29 +02:00
|
|
|
if (context->ops && context->ops->device_context_present)
|
2018-09-12 17:59:51 +02:00
|
|
|
{
|
|
|
|
if (FAILED(hr = context->ops->device_context_present(context->outer_unknown)))
|
|
|
|
context->error.code = hr;
|
|
|
|
}
|
2014-09-03 07:48:22 +02:00
|
|
|
|
2018-09-12 17:59:51 +02:00
|
|
|
return context->error.code;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static D2D1_PIXEL_FORMAT * STDMETHODCALLTYPE d2d_device_context_GetPixelFormat(ID2D1DeviceContext *iface,
|
2014-09-05 17:33:03 +02:00
|
|
|
D2D1_PIXEL_FORMAT *format)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2015-07-21 08:39:09 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, format %p.\n", iface, format);
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2016-10-19 19:00:21 +02:00
|
|
|
*format = render_target->desc.pixelFormat;
|
2014-05-20 07:38:44 +02:00
|
|
|
return format;
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_SetDpi(ID2D1DeviceContext *iface, float dpi_x, float dpi_y)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2014-09-04 08:14:30 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, dpi_x %.8e, dpi_y %.8e.\n", iface, dpi_x, dpi_y);
|
|
|
|
|
|
|
|
if (dpi_x == 0.0f && dpi_y == 0.0f)
|
|
|
|
{
|
|
|
|
dpi_x = 96.0f;
|
|
|
|
dpi_y = 96.0f;
|
|
|
|
}
|
2016-01-20 19:31:58 +01:00
|
|
|
else if (dpi_x <= 0.0f || dpi_y <= 0.0f)
|
2016-01-19 22:43:33 +01:00
|
|
|
return;
|
2014-09-04 08:14:30 +02:00
|
|
|
|
2016-10-19 19:00:21 +02:00
|
|
|
render_target->desc.dpiX = dpi_x;
|
|
|
|
render_target->desc.dpiY = dpi_y;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_GetDpi(ID2D1DeviceContext *iface, float *dpi_x, float *dpi_y)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2014-09-04 08:14:29 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, dpi_x %p, dpi_y %p.\n", iface, dpi_x, dpi_y);
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2016-10-19 19:00:21 +02:00
|
|
|
*dpi_x = render_target->desc.dpiX;
|
|
|
|
*dpi_y = render_target->desc.dpiY;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static D2D1_SIZE_F * STDMETHODCALLTYPE d2d_device_context_GetSize(ID2D1DeviceContext *iface, D2D1_SIZE_F *size)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2014-09-05 17:33:04 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, size %p.\n", iface, size);
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2016-10-19 19:00:21 +02:00
|
|
|
size->width = render_target->pixel_size.width / (render_target->desc.dpiX / 96.0f);
|
|
|
|
size->height = render_target->pixel_size.height / (render_target->desc.dpiY / 96.0f);
|
2014-05-20 07:38:44 +02:00
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static D2D1_SIZE_U * STDMETHODCALLTYPE d2d_device_context_GetPixelSize(ID2D1DeviceContext *iface,
|
2014-09-05 17:33:03 +02:00
|
|
|
D2D1_SIZE_U *pixel_size)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2014-09-05 17:33:03 +02:00
|
|
|
TRACE("iface %p, pixel_size %p.\n", iface, pixel_size);
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2014-09-05 17:33:03 +02:00
|
|
|
*pixel_size = render_target->pixel_size;
|
|
|
|
return pixel_size;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static UINT32 STDMETHODCALLTYPE d2d_device_context_GetMaximumBitmapSize(ID2D1DeviceContext *iface)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2018-11-12 14:15:38 +01:00
|
|
|
TRACE("iface %p.\n", iface);
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
return D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static BOOL STDMETHODCALLTYPE d2d_device_context_IsSupported(ID2D1DeviceContext *iface,
|
2014-05-20 07:38:44 +02:00
|
|
|
const D2D1_RENDER_TARGET_PROPERTIES *desc)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, desc %p stub!\n", iface, desc);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_CreateBitmap(ID2D1DeviceContext *iface,
|
|
|
|
D2D1_SIZE_U size, const void *src_data, UINT32 pitch,
|
|
|
|
const D2D1_BITMAP_PROPERTIES1 *desc, ID2D1Bitmap1 **bitmap)
|
|
|
|
{
|
2018-09-29 01:02:03 +02:00
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
|
|
|
struct d2d_bitmap *object;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, size {%u, %u}, src_data %p, pitch %u, desc %p, bitmap %p.\n",
|
2018-08-17 16:54:11 +02:00
|
|
|
iface, size.width, size.height, src_data, pitch, desc, bitmap);
|
|
|
|
|
2018-09-29 01:02:03 +02:00
|
|
|
if (SUCCEEDED(hr = d2d_bitmap_create(context, size, src_data, pitch, desc, &object)))
|
|
|
|
*bitmap = &object->ID2D1Bitmap1_iface;
|
|
|
|
|
|
|
|
return hr;
|
2018-08-17 16:54:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_CreateBitmapFromWicBitmap(
|
|
|
|
ID2D1DeviceContext *iface, IWICBitmapSource *bitmap_source,
|
|
|
|
const D2D1_BITMAP_PROPERTIES1 *desc, ID2D1Bitmap1 **bitmap)
|
|
|
|
{
|
2018-10-03 07:53:57 +02:00
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
|
|
|
struct d2d_bitmap *object;
|
|
|
|
HRESULT hr;
|
2018-08-17 16:54:11 +02:00
|
|
|
|
2018-10-03 07:53:57 +02:00
|
|
|
TRACE("iface %p, bitmap_source %p, desc %p, bitmap %p.\n", iface, bitmap_source, desc, bitmap);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr = d2d_bitmap_create_from_wic_bitmap(context, bitmap_source, desc, &object)))
|
|
|
|
*bitmap = &object->ID2D1Bitmap1_iface;
|
|
|
|
|
|
|
|
return hr;
|
2018-08-17 16:54:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateColorContext(ID2D1DeviceContext *iface,
|
|
|
|
D2D1_COLOR_SPACE space, const BYTE *profile, UINT32 profile_size, ID2D1ColorContext **color_context)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, space %#x, profile %p, profile_size %u, color_context %p stub!\n",
|
|
|
|
iface, space, profile, profile_size, color_context);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateColorContextFromFilename(ID2D1DeviceContext *iface,
|
|
|
|
const WCHAR *filename, ID2D1ColorContext **color_context)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, filename %s, color_context %p stub!\n", iface, debugstr_w(filename), color_context);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateColorContextFromWicColorContext(ID2D1DeviceContext *iface,
|
|
|
|
IWICColorContext *wic_color_context, ID2D1ColorContext **color_context)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, wic_color_context %p, color_context %p stub!\n", iface, wic_color_context, color_context);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateBitmapFromDxgiSurface(ID2D1DeviceContext *iface,
|
|
|
|
IDXGISurface *surface, const D2D1_BITMAP_PROPERTIES1 *desc, ID2D1Bitmap1 **bitmap)
|
|
|
|
{
|
2018-09-19 13:55:08 +02:00
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
|
|
|
D2D1_BITMAP_PROPERTIES1 bitmap_desc;
|
|
|
|
struct d2d_bitmap *object;
|
|
|
|
HRESULT hr;
|
2018-08-17 16:54:11 +02:00
|
|
|
|
2018-09-19 13:55:08 +02:00
|
|
|
TRACE("iface %p, surface %p, desc %p, bitmap %p.\n", iface, surface, desc, bitmap);
|
|
|
|
|
|
|
|
if (!desc)
|
|
|
|
{
|
|
|
|
DXGI_SURFACE_DESC surface_desc;
|
|
|
|
|
|
|
|
if (FAILED(hr = IDXGISurface_GetDesc(surface, &surface_desc)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to get surface desc, hr %#lx.\n", hr);
|
2018-09-19 13:55:08 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&bitmap_desc, 0, sizeof(bitmap_desc));
|
|
|
|
bitmap_desc.pixelFormat.format = surface_desc.Format;
|
2018-09-29 01:02:05 +02:00
|
|
|
bitmap_desc.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED;
|
2018-09-19 13:55:08 +02:00
|
|
|
bitmap_desc.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW;
|
|
|
|
desc = &bitmap_desc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr = d2d_bitmap_create_shared(context, &IID_IDXGISurface, surface, desc, &object)))
|
|
|
|
*bitmap = &object->ID2D1Bitmap1_iface;
|
|
|
|
|
|
|
|
return hr;
|
2018-08-17 16:54:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateEffect(ID2D1DeviceContext *iface,
|
|
|
|
REFCLSID effect_id, ID2D1Effect **effect)
|
|
|
|
{
|
2021-07-20 16:16:08 +02:00
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
2018-09-26 02:34:47 +02:00
|
|
|
struct d2d_effect *object;
|
2021-08-08 06:40:32 +02:00
|
|
|
HRESULT hr;
|
2018-09-26 02:34:47 +02:00
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
FIXME("iface %p, effect_id %s, effect %p stub!\n", iface, debugstr_guid(effect_id), effect);
|
|
|
|
|
2018-09-26 02:34:47 +02:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2021-08-08 06:40:33 +02:00
|
|
|
if (FAILED(hr = d2d_effect_init(object, context->factory, effect_id)))
|
2021-08-08 06:40:32 +02:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to initialise effect, hr %#lx.\n", hr);
|
2021-08-08 06:40:32 +02:00
|
|
|
heap_free(object);
|
|
|
|
return hr;
|
|
|
|
}
|
2018-09-26 02:34:47 +02:00
|
|
|
|
|
|
|
TRACE("Created effect %p.\n", object);
|
|
|
|
*effect = &object->ID2D1Effect_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
2018-08-17 16:54:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_CreateGradientStopCollection(
|
|
|
|
ID2D1DeviceContext *iface, const D2D1_GRADIENT_STOP *stops, UINT32 stop_count,
|
|
|
|
D2D1_COLOR_SPACE preinterpolation_space, D2D1_COLOR_SPACE postinterpolation_space,
|
|
|
|
D2D1_BUFFER_PRECISION buffer_precision, D2D1_EXTEND_MODE extend_mode,
|
|
|
|
D2D1_COLOR_INTERPOLATION_MODE color_interpolation_mode, ID2D1GradientStopCollection1 **gradient)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, stops %p, stop_count %u, preinterpolation_space %#x, postinterpolation_space %#x, "
|
|
|
|
"buffer_precision %#x, extend_mode %#x, color_interpolation_mode %#x, gradient %p stub!\n",
|
|
|
|
iface, stops, stop_count, preinterpolation_space, postinterpolation_space,
|
|
|
|
buffer_precision, extend_mode, color_interpolation_mode, gradient);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateImageBrush(ID2D1DeviceContext *iface,
|
|
|
|
ID2D1Image *image, const D2D1_IMAGE_BRUSH_PROPERTIES *image_brush_desc,
|
|
|
|
const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1ImageBrush **brush)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, image %p, image_brush_desc %p, brush_desc %p, brush %p stub!\n",
|
|
|
|
iface, image, image_brush_desc, brush_desc, brush);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_CreateBitmapBrush(ID2D1DeviceContext *iface,
|
|
|
|
ID2D1Bitmap *bitmap, const D2D1_BITMAP_BRUSH_PROPERTIES1 *bitmap_brush_desc,
|
2018-09-18 12:17:48 +02:00
|
|
|
const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1BitmapBrush1 **brush)
|
2018-08-17 16:54:11 +02:00
|
|
|
{
|
2018-09-18 12:17:48 +02:00
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
|
|
|
struct d2d_brush *object;
|
|
|
|
HRESULT hr;
|
2018-08-17 16:54:11 +02:00
|
|
|
|
2018-09-18 12:17:48 +02:00
|
|
|
TRACE("iface %p, bitmap %p, bitmap_brush_desc %p, brush_desc %p, brush %p.\n", iface, bitmap, bitmap_brush_desc,
|
|
|
|
brush_desc, brush);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr = d2d_bitmap_brush_create(context->factory, bitmap, bitmap_brush_desc, brush_desc, &object)))
|
|
|
|
*brush = (ID2D1BitmapBrush1 *)&object->ID2D1Brush_iface;
|
|
|
|
|
|
|
|
return hr;
|
2018-08-17 16:54:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateCommandList(ID2D1DeviceContext *iface,
|
|
|
|
ID2D1CommandList **command_list)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, command_list %p stub!\n", iface, command_list);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL STDMETHODCALLTYPE d2d_device_context_IsDxgiFormatSupported(ID2D1DeviceContext *iface, DXGI_FORMAT format)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, format %#x stub!\n", iface, format);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL STDMETHODCALLTYPE d2d_device_context_IsBufferPrecisionSupported(ID2D1DeviceContext *iface,
|
|
|
|
D2D1_BUFFER_PRECISION buffer_precision)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, buffer_precision %#x stub!\n", iface, buffer_precision);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_GetImageLocalBounds(ID2D1DeviceContext *iface,
|
|
|
|
ID2D1Image *image, D2D1_RECT_F *local_bounds)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, image %p, local_bounds %p stub!\n", iface, image, local_bounds);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_GetImageWorldBounds(ID2D1DeviceContext *iface,
|
|
|
|
ID2D1Image *image, D2D1_RECT_F *world_bounds)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, image %p, world_bounds %p stub!\n", iface, image, world_bounds);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_GetGlyphRunWorldBounds(ID2D1DeviceContext *iface,
|
|
|
|
D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run,
|
|
|
|
DWRITE_MEASURING_MODE measuring_mode, D2D1_RECT_F *bounds)
|
|
|
|
{
|
2018-09-25 00:25:17 +02:00
|
|
|
FIXME("iface %p, baseline_origin %s, glyph_run %p, measuring_mode %#x, bounds %p stub!\n",
|
|
|
|
iface, debug_d2d_point_2f(&baseline_origin), glyph_run, measuring_mode, bounds);
|
2018-08-17 16:54:11 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_GetDevice(ID2D1DeviceContext *iface, ID2D1Device **device)
|
|
|
|
{
|
2018-09-24 06:58:31 +02:00
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, device %p.\n", iface, device);
|
|
|
|
|
|
|
|
*device = context->device;
|
|
|
|
ID2D1Device_AddRef(*device);
|
2018-08-17 16:54:11 +02:00
|
|
|
}
|
|
|
|
|
2018-09-29 01:02:06 +02:00
|
|
|
static void d2d_device_context_reset_target(struct d2d_device_context *context)
|
|
|
|
{
|
|
|
|
if (!context->target)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ID2D1Bitmap1_Release(&context->target->ID2D1Bitmap1_iface);
|
|
|
|
context->target = NULL;
|
|
|
|
|
2019-10-24 16:10:47 +02:00
|
|
|
/* Note that DPI settings are kept. */
|
2018-09-29 01:02:06 +02:00
|
|
|
memset(&context->desc.pixelFormat, 0, sizeof(context->desc.pixelFormat));
|
|
|
|
memset(&context->pixel_size, 0, sizeof(context->pixel_size));
|
|
|
|
|
2021-06-28 09:17:34 +02:00
|
|
|
ID3D11BlendState_Release(context->bs);
|
2018-09-29 01:02:06 +02:00
|
|
|
context->bs = NULL;
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_SetTarget(ID2D1DeviceContext *iface, ID2D1Image *target)
|
|
|
|
{
|
2018-09-29 01:02:06 +02:00
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
|
|
|
struct d2d_bitmap *bitmap_impl;
|
2021-06-28 09:17:34 +02:00
|
|
|
D3D11_BLEND_DESC blend_desc;
|
2018-09-29 01:02:06 +02:00
|
|
|
ID2D1Bitmap *bitmap;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, target %p.\n", iface, target);
|
|
|
|
|
|
|
|
if (!target)
|
|
|
|
{
|
|
|
|
d2d_device_context_reset_target(context);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(ID2D1Image_QueryInterface(target, &IID_ID2D1Bitmap, (void **)&bitmap)))
|
|
|
|
{
|
|
|
|
FIXME("Only bitmap targets are supported.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bitmap_impl = unsafe_impl_from_ID2D1Bitmap(bitmap);
|
|
|
|
|
|
|
|
if (!(bitmap_impl->options & D2D1_BITMAP_OPTIONS_TARGET))
|
|
|
|
{
|
2022-03-11 07:31:41 +01:00
|
|
|
ID2D1Bitmap_Release(bitmap);
|
2018-10-05 09:23:22 +02:00
|
|
|
d2d_device_context_set_error(context, D2DERR_INVALID_TARGET);
|
2018-09-29 01:02:06 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
d2d_device_context_reset_target(context);
|
|
|
|
|
|
|
|
/* Set sizes and pixel format. */
|
|
|
|
context->pixel_size = bitmap_impl->pixel_size;
|
|
|
|
context->desc.pixelFormat = bitmap_impl->format;
|
|
|
|
context->target = bitmap_impl;
|
|
|
|
|
|
|
|
memset(&blend_desc, 0, sizeof(blend_desc));
|
2021-06-28 09:17:34 +02:00
|
|
|
blend_desc.IndependentBlendEnable = FALSE;
|
|
|
|
blend_desc.RenderTarget[0].BlendEnable = TRUE;
|
|
|
|
blend_desc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
|
|
|
|
blend_desc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
|
|
|
|
blend_desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
|
2022-03-11 07:31:55 +01:00
|
|
|
blend_desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
|
|
|
|
blend_desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
|
2021-06-28 09:17:34 +02:00
|
|
|
blend_desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
|
|
|
blend_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreateBlendState(context->d3d_device, &blend_desc, &context->bs)))
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to create blend state, hr %#lx.\n", hr);
|
2018-08-17 16:54:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_GetTarget(ID2D1DeviceContext *iface, ID2D1Image **target)
|
|
|
|
{
|
2018-09-29 01:02:06 +02:00
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, target %p.\n", iface, target);
|
|
|
|
|
|
|
|
*target = context->target ? (ID2D1Image *)&context->target->ID2D1Bitmap1_iface : NULL;
|
|
|
|
if (*target)
|
|
|
|
ID2D1Image_AddRef(*target);
|
2018-08-17 16:54:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_SetRenderingControls(ID2D1DeviceContext *iface,
|
|
|
|
const D2D1_RENDERING_CONTROLS *rendering_controls)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, rendering_controls %p stub!\n", iface, rendering_controls);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_GetRenderingControls(ID2D1DeviceContext *iface,
|
|
|
|
D2D1_RENDERING_CONTROLS *rendering_controls)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, rendering_controls %p stub!\n", iface, rendering_controls);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_SetPrimitiveBlend(ID2D1DeviceContext *iface,
|
|
|
|
D2D1_PRIMITIVE_BLEND primitive_blend)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, primitive_blend %#x stub!\n", iface, primitive_blend);
|
|
|
|
}
|
|
|
|
|
|
|
|
static D2D1_PRIMITIVE_BLEND STDMETHODCALLTYPE d2d_device_context_GetPrimitiveBlend(ID2D1DeviceContext *iface)
|
|
|
|
{
|
|
|
|
FIXME("iface %p stub!\n", iface);
|
|
|
|
|
|
|
|
return D2D1_PRIMITIVE_BLEND_SOURCE_OVER;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_SetUnitMode(ID2D1DeviceContext *iface, D2D1_UNIT_MODE unit_mode)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, unit_mode %#x stub!\n", iface, unit_mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
static D2D1_UNIT_MODE STDMETHODCALLTYPE d2d_device_context_GetUnitMode(ID2D1DeviceContext *iface)
|
|
|
|
{
|
|
|
|
FIXME("iface %p stub!\n", iface);
|
|
|
|
|
|
|
|
return D2D1_UNIT_MODE_DIPS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_DrawGlyphRun(ID2D1DeviceContext *iface,
|
|
|
|
D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run,
|
|
|
|
const DWRITE_GLYPH_RUN_DESCRIPTION *glyph_run_desc, ID2D1Brush *brush, DWRITE_MEASURING_MODE measuring_mode)
|
|
|
|
{
|
2018-10-23 10:48:42 +02:00
|
|
|
DWRITE_TEXT_ANTIALIAS_MODE antialias_mode = DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE;
|
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
|
|
|
IDWriteRenderingParams *rendering_params;
|
|
|
|
DWRITE_RENDERING_MODE rendering_mode;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, baseline_origin %s, glyph_run %p, glyph_run_desc %p, brush %p, measuring_mode %#x.\n",
|
2018-09-25 00:25:17 +02:00
|
|
|
iface, debug_d2d_point_2f(&baseline_origin), glyph_run, glyph_run_desc, brush, measuring_mode);
|
2018-10-23 10:48:42 +02:00
|
|
|
|
|
|
|
if (FAILED(context->error.code))
|
|
|
|
return;
|
|
|
|
|
|
|
|
rendering_params = context->text_rendering_params ? context->text_rendering_params
|
|
|
|
: context->default_text_rendering_params;
|
|
|
|
|
|
|
|
rendering_mode = IDWriteRenderingParams_GetRenderingMode(rendering_params);
|
|
|
|
|
|
|
|
switch (context->drawing_state.textAntialiasMode)
|
|
|
|
{
|
|
|
|
case D2D1_TEXT_ANTIALIAS_MODE_ALIASED:
|
|
|
|
if (rendering_mode == DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL
|
|
|
|
|| rendering_mode == DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC
|
|
|
|
|| rendering_mode == DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL
|
|
|
|
|| rendering_mode == DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC)
|
|
|
|
d2d_device_context_set_error(context, E_INVALIDARG);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE:
|
|
|
|
if (rendering_mode == DWRITE_RENDERING_MODE_ALIASED
|
|
|
|
|| rendering_mode == DWRITE_RENDERING_MODE_OUTLINE)
|
|
|
|
d2d_device_context_set_error(context, E_INVALIDARG);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE:
|
|
|
|
if (rendering_mode == DWRITE_RENDERING_MODE_ALIASED)
|
|
|
|
d2d_device_context_set_error(context, E_INVALIDARG);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(context->error.code))
|
|
|
|
return;
|
|
|
|
|
|
|
|
rendering_mode = DWRITE_RENDERING_MODE_DEFAULT;
|
|
|
|
switch (context->drawing_state.textAntialiasMode)
|
|
|
|
{
|
|
|
|
case D2D1_TEXT_ANTIALIAS_MODE_DEFAULT:
|
|
|
|
if (IDWriteRenderingParams_GetClearTypeLevel(rendering_params) > 0.0f)
|
|
|
|
antialias_mode = DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE:
|
|
|
|
antialias_mode = DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case D2D1_TEXT_ANTIALIAS_MODE_ALIASED:
|
|
|
|
rendering_mode = DWRITE_RENDERING_MODE_ALIASED;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rendering_mode == DWRITE_RENDERING_MODE_DEFAULT)
|
|
|
|
{
|
|
|
|
if (FAILED(hr = IDWriteFontFace_GetRecommendedRenderingMode(glyph_run->fontFace, glyph_run->fontEmSize,
|
|
|
|
max(context->desc.dpiX, context->desc.dpiY) / 96.0f,
|
|
|
|
measuring_mode, rendering_params, &rendering_mode)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to get recommended rendering mode, hr %#lx.\n", hr);
|
2018-10-23 10:48:42 +02:00
|
|
|
rendering_mode = DWRITE_RENDERING_MODE_OUTLINE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rendering_mode == DWRITE_RENDERING_MODE_OUTLINE)
|
|
|
|
d2d_device_context_draw_glyph_run_outline(context, baseline_origin, glyph_run, brush);
|
|
|
|
else
|
|
|
|
d2d_device_context_draw_glyph_run_bitmap(context, baseline_origin, glyph_run, brush,
|
|
|
|
rendering_mode, measuring_mode, antialias_mode);
|
2018-08-17 16:54:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_DrawImage(ID2D1DeviceContext *iface, ID2D1Image *image,
|
|
|
|
const D2D1_POINT_2F *target_offset, const D2D1_RECT_F *image_rect, D2D1_INTERPOLATION_MODE interpolation_mode,
|
|
|
|
D2D1_COMPOSITE_MODE composite_mode)
|
|
|
|
{
|
2021-01-15 15:55:39 +01:00
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
|
|
|
ID2D1Bitmap *bitmap;
|
|
|
|
|
|
|
|
TRACE("iface %p, image %p, target_offset %s, image_rect %s, interpolation_mode %#x, composite_mode %#x.\n",
|
2018-09-25 00:25:17 +02:00
|
|
|
iface, image, debug_d2d_point_2f(target_offset), debug_d2d_rect_f(image_rect),
|
|
|
|
interpolation_mode, composite_mode);
|
2021-01-15 15:55:39 +01:00
|
|
|
|
|
|
|
if (composite_mode != D2D1_COMPOSITE_MODE_SOURCE_OVER)
|
|
|
|
FIXME("Unhandled composite mode %#x.\n", composite_mode);
|
|
|
|
|
|
|
|
if (SUCCEEDED(ID2D1Image_QueryInterface(image, &IID_ID2D1Bitmap, (void **)&bitmap)))
|
|
|
|
{
|
|
|
|
d2d_device_context_draw_bitmap(context, bitmap, NULL, 1.0f, d2d1_1_interp_mode_from_d2d1(interpolation_mode),
|
|
|
|
image_rect, target_offset, NULL);
|
|
|
|
|
|
|
|
ID2D1Bitmap_Release(bitmap);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("Unhandled image %p.\n", image);
|
2018-08-17 16:54:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_DrawGdiMetafile(ID2D1DeviceContext *iface,
|
|
|
|
ID2D1GdiMetafile *metafile, const D2D1_POINT_2F *target_offset)
|
|
|
|
{
|
2018-09-25 00:25:17 +02:00
|
|
|
FIXME("iface %p, metafile %p, target_offset %s stub!\n",
|
|
|
|
iface, metafile, debug_d2d_point_2f(target_offset));
|
2018-08-17 16:54:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_DrawBitmap(ID2D1DeviceContext *iface,
|
|
|
|
ID2D1Bitmap *bitmap, const D2D1_RECT_F *dst_rect, float opacity, D2D1_INTERPOLATION_MODE interpolation_mode,
|
|
|
|
const D2D1_RECT_F *src_rect, const D2D1_MATRIX_4X4_F *perspective_transform)
|
|
|
|
{
|
2018-10-04 13:37:34 +02:00
|
|
|
struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, bitmap %p, dst_rect %s, opacity %.8e, interpolation_mode %#x, "
|
|
|
|
"src_rect %s, perspective_transform %p.\n",
|
2018-08-17 16:54:11 +02:00
|
|
|
iface, bitmap, debug_d2d_rect_f(dst_rect), opacity, interpolation_mode,
|
|
|
|
debug_d2d_rect_f(src_rect), perspective_transform);
|
2018-10-04 13:37:34 +02:00
|
|
|
|
|
|
|
d2d_device_context_draw_bitmap(context, bitmap, dst_rect, opacity, interpolation_mode, src_rect,
|
2021-01-15 15:55:39 +01:00
|
|
|
NULL, perspective_transform);
|
2018-08-17 16:54:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_PushLayer(ID2D1DeviceContext *iface,
|
|
|
|
const D2D1_LAYER_PARAMETERS1 *layer_parameters, ID2D1Layer *layer)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, layer_parameters %p, layer %p stub!\n", iface, layer_parameters, layer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_InvalidateEffectInputRectangle(ID2D1DeviceContext *iface,
|
|
|
|
ID2D1Effect *effect, UINT32 input, const D2D1_RECT_F *input_rect)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, effect %p, input %u, input_rect %s stub!\n",
|
|
|
|
iface, effect, input, debug_d2d_rect_f(input_rect));
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_GetEffectInvalidRectangleCount(ID2D1DeviceContext *iface,
|
|
|
|
ID2D1Effect *effect, UINT32 *rect_count)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, effect %p, rect_count %p stub!\n", iface, effect, rect_count);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_GetEffectInvalidRectangles(ID2D1DeviceContext *iface,
|
|
|
|
ID2D1Effect *effect, D2D1_RECT_F *rectangles, UINT32 rect_count)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, effect %p, rectangles %p, rect_count %u stub!\n", iface, effect, rectangles, rect_count);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_device_context_GetEffectRequiredInputRectangles(ID2D1DeviceContext *iface,
|
|
|
|
ID2D1Effect *effect, const D2D1_RECT_F *image_rect, const D2D1_EFFECT_INPUT_DESCRIPTION *desc,
|
|
|
|
D2D1_RECT_F *input_rect, UINT32 input_count)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, effect %p, image_rect %s, desc %p, input_rect %p, input_count %u stub!\n",
|
|
|
|
iface, effect, debug_d2d_rect_f(image_rect), desc, input_rect, input_count);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_FillOpacityMask(ID2D1DeviceContext *iface,
|
|
|
|
ID2D1Bitmap *mask, ID2D1Brush *brush, const D2D1_RECT_F *dst_rect, const D2D1_RECT_F *src_rect)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, mask %p, brush %p, dst_rect %s, src_rect %s stub!\n",
|
|
|
|
iface, mask, brush, debug_d2d_rect_f(dst_rect), debug_d2d_rect_f(src_rect));
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ID2D1DeviceContextVtbl d2d_device_context_vtbl =
|
|
|
|
{
|
|
|
|
d2d_device_context_QueryInterface,
|
|
|
|
d2d_device_context_AddRef,
|
|
|
|
d2d_device_context_Release,
|
|
|
|
d2d_device_context_GetFactory,
|
|
|
|
d2d_device_context_CreateBitmap,
|
|
|
|
d2d_device_context_CreateBitmapFromWicBitmap,
|
|
|
|
d2d_device_context_CreateSharedBitmap,
|
|
|
|
d2d_device_context_CreateBitmapBrush,
|
|
|
|
d2d_device_context_CreateSolidColorBrush,
|
|
|
|
d2d_device_context_CreateGradientStopCollection,
|
|
|
|
d2d_device_context_CreateLinearGradientBrush,
|
|
|
|
d2d_device_context_CreateRadialGradientBrush,
|
|
|
|
d2d_device_context_CreateCompatibleRenderTarget,
|
|
|
|
d2d_device_context_CreateLayer,
|
|
|
|
d2d_device_context_CreateMesh,
|
|
|
|
d2d_device_context_DrawLine,
|
|
|
|
d2d_device_context_DrawRectangle,
|
|
|
|
d2d_device_context_FillRectangle,
|
|
|
|
d2d_device_context_DrawRoundedRectangle,
|
|
|
|
d2d_device_context_FillRoundedRectangle,
|
|
|
|
d2d_device_context_DrawEllipse,
|
|
|
|
d2d_device_context_FillEllipse,
|
|
|
|
d2d_device_context_DrawGeometry,
|
|
|
|
d2d_device_context_FillGeometry,
|
|
|
|
d2d_device_context_FillMesh,
|
|
|
|
d2d_device_context_FillOpacityMask,
|
|
|
|
d2d_device_context_DrawBitmap,
|
|
|
|
d2d_device_context_DrawText,
|
|
|
|
d2d_device_context_DrawTextLayout,
|
|
|
|
d2d_device_context_DrawGlyphRun,
|
|
|
|
d2d_device_context_SetTransform,
|
|
|
|
d2d_device_context_GetTransform,
|
|
|
|
d2d_device_context_SetAntialiasMode,
|
|
|
|
d2d_device_context_GetAntialiasMode,
|
|
|
|
d2d_device_context_SetTextAntialiasMode,
|
|
|
|
d2d_device_context_GetTextAntialiasMode,
|
|
|
|
d2d_device_context_SetTextRenderingParams,
|
|
|
|
d2d_device_context_GetTextRenderingParams,
|
|
|
|
d2d_device_context_SetTags,
|
|
|
|
d2d_device_context_GetTags,
|
|
|
|
d2d_device_context_PushLayer,
|
|
|
|
d2d_device_context_PopLayer,
|
|
|
|
d2d_device_context_Flush,
|
|
|
|
d2d_device_context_SaveDrawingState,
|
|
|
|
d2d_device_context_RestoreDrawingState,
|
|
|
|
d2d_device_context_PushAxisAlignedClip,
|
|
|
|
d2d_device_context_PopAxisAlignedClip,
|
|
|
|
d2d_device_context_Clear,
|
|
|
|
d2d_device_context_BeginDraw,
|
|
|
|
d2d_device_context_EndDraw,
|
|
|
|
d2d_device_context_GetPixelFormat,
|
|
|
|
d2d_device_context_SetDpi,
|
|
|
|
d2d_device_context_GetDpi,
|
|
|
|
d2d_device_context_GetSize,
|
|
|
|
d2d_device_context_GetPixelSize,
|
|
|
|
d2d_device_context_GetMaximumBitmapSize,
|
|
|
|
d2d_device_context_IsSupported,
|
|
|
|
d2d_device_context_ID2D1DeviceContext_CreateBitmap,
|
|
|
|
d2d_device_context_ID2D1DeviceContext_CreateBitmapFromWicBitmap,
|
|
|
|
d2d_device_context_CreateColorContext,
|
|
|
|
d2d_device_context_CreateColorContextFromFilename,
|
|
|
|
d2d_device_context_CreateColorContextFromWicColorContext,
|
|
|
|
d2d_device_context_CreateBitmapFromDxgiSurface,
|
|
|
|
d2d_device_context_CreateEffect,
|
|
|
|
d2d_device_context_ID2D1DeviceContext_CreateGradientStopCollection,
|
|
|
|
d2d_device_context_CreateImageBrush,
|
|
|
|
d2d_device_context_ID2D1DeviceContext_CreateBitmapBrush,
|
|
|
|
d2d_device_context_CreateCommandList,
|
|
|
|
d2d_device_context_IsDxgiFormatSupported,
|
|
|
|
d2d_device_context_IsBufferPrecisionSupported,
|
|
|
|
d2d_device_context_GetImageLocalBounds,
|
|
|
|
d2d_device_context_GetImageWorldBounds,
|
|
|
|
d2d_device_context_GetGlyphRunWorldBounds,
|
|
|
|
d2d_device_context_GetDevice,
|
|
|
|
d2d_device_context_SetTarget,
|
|
|
|
d2d_device_context_GetTarget,
|
|
|
|
d2d_device_context_SetRenderingControls,
|
|
|
|
d2d_device_context_GetRenderingControls,
|
|
|
|
d2d_device_context_SetPrimitiveBlend,
|
|
|
|
d2d_device_context_GetPrimitiveBlend,
|
|
|
|
d2d_device_context_SetUnitMode,
|
|
|
|
d2d_device_context_GetUnitMode,
|
|
|
|
d2d_device_context_ID2D1DeviceContext_DrawGlyphRun,
|
|
|
|
d2d_device_context_DrawImage,
|
|
|
|
d2d_device_context_DrawGdiMetafile,
|
|
|
|
d2d_device_context_ID2D1DeviceContext_DrawBitmap,
|
|
|
|
d2d_device_context_ID2D1DeviceContext_PushLayer,
|
|
|
|
d2d_device_context_InvalidateEffectInputRectangle,
|
|
|
|
d2d_device_context_GetEffectInvalidRectangleCount,
|
|
|
|
d2d_device_context_GetEffectInvalidRectangles,
|
|
|
|
d2d_device_context_GetEffectRequiredInputRectangles,
|
|
|
|
d2d_device_context_ID2D1DeviceContext_FillOpacityMask,
|
2014-05-20 07:38:44 +02:00
|
|
|
};
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static inline struct d2d_device_context *impl_from_IDWriteTextRenderer(IDWriteTextRenderer *iface)
|
2014-10-06 08:24:17 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct d2d_device_context, IDWriteTextRenderer_iface);
|
2014-10-06 08:24:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-07 18:34:27 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_text_renderer_QueryInterface(IDWriteTextRenderer *iface, REFIID iid, void **out)
|
2014-10-06 08:24:17 +02:00
|
|
|
{
|
|
|
|
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
|
|
|
|
|
|
|
|
if (IsEqualGUID(iid, &IID_IDWriteTextRenderer)
|
|
|
|
|| IsEqualGUID(iid, &IID_IDWritePixelSnapping)
|
|
|
|
|| IsEqualGUID(iid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
IDWriteTextRenderer_AddRef(iface);
|
|
|
|
*out = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
|
|
|
|
|
|
|
|
*out = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2014-10-07 18:34:27 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE d2d_text_renderer_AddRef(IDWriteTextRenderer *iface)
|
2014-10-06 08:24:17 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_IDWriteTextRenderer(iface);
|
2014-10-06 08:24:17 +02:00
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
return d2d_device_context_AddRef(&render_target->ID2D1DeviceContext_iface);
|
2014-10-06 08:24:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-07 18:34:27 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE d2d_text_renderer_Release(IDWriteTextRenderer *iface)
|
2014-10-06 08:24:17 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_IDWriteTextRenderer(iface);
|
2014-10-06 08:24:17 +02:00
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
return d2d_device_context_Release(&render_target->ID2D1DeviceContext_iface);
|
2014-10-06 08:24:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-07 18:34:27 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_text_renderer_IsPixelSnappingDisabled(IDWriteTextRenderer *iface,
|
2014-10-06 08:24:17 +02:00
|
|
|
void *ctx, BOOL *disabled)
|
|
|
|
{
|
2015-07-09 14:22:11 +02:00
|
|
|
struct d2d_draw_text_layout_ctx *context = ctx;
|
2014-10-06 08:24:17 +02:00
|
|
|
|
2015-07-09 14:22:11 +02:00
|
|
|
TRACE("iface %p, ctx %p, disabled %p.\n", iface, ctx, disabled);
|
|
|
|
|
|
|
|
*disabled = context->options & D2D1_DRAW_TEXT_OPTIONS_NO_SNAP;
|
|
|
|
|
|
|
|
return S_OK;
|
2014-10-06 08:24:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-07 18:34:27 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_text_renderer_GetCurrentTransform(IDWriteTextRenderer *iface,
|
2014-10-06 08:24:17 +02:00
|
|
|
void *ctx, DWRITE_MATRIX *transform)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_IDWriteTextRenderer(iface);
|
2014-10-06 08:24:17 +02:00
|
|
|
|
2015-07-09 14:22:12 +02:00
|
|
|
TRACE("iface %p, ctx %p, transform %p.\n", iface, ctx, transform);
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
d2d_device_context_GetTransform(&render_target->ID2D1DeviceContext_iface, (D2D1_MATRIX_3X2_F *)transform);
|
2015-07-09 14:22:12 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2014-10-06 08:24:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-07 18:34:27 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_text_renderer_GetPixelsPerDip(IDWriteTextRenderer *iface, void *ctx, float *ppd)
|
2014-10-06 08:24:17 +02:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_IDWriteTextRenderer(iface);
|
2014-10-06 08:24:17 +02:00
|
|
|
|
2015-07-09 14:22:13 +02:00
|
|
|
TRACE("iface %p, ctx %p, ppd %p.\n", iface, ctx, ppd);
|
|
|
|
|
2016-10-19 19:00:21 +02:00
|
|
|
*ppd = render_target->desc.dpiY / 96.0f;
|
2015-07-09 14:22:13 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2014-10-06 08:24:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-07 18:34:27 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_text_renderer_DrawGlyphRun(IDWriteTextRenderer *iface, void *ctx,
|
2014-10-06 08:24:17 +02:00
|
|
|
float baseline_origin_x, float baseline_origin_y, DWRITE_MEASURING_MODE measuring_mode,
|
|
|
|
const DWRITE_GLYPH_RUN *glyph_run, const DWRITE_GLYPH_RUN_DESCRIPTION *desc, IUnknown *effect)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_IDWriteTextRenderer(iface);
|
2015-06-15 22:30:09 +02:00
|
|
|
D2D1_POINT_2F baseline_origin = {baseline_origin_x, baseline_origin_y};
|
|
|
|
struct d2d_draw_text_layout_ctx *context = ctx;
|
2016-11-07 21:19:14 +01:00
|
|
|
BOOL color_font = FALSE;
|
2016-01-26 13:36:18 +01:00
|
|
|
ID2D1Brush *brush;
|
2015-06-15 22:30:09 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, ctx %p, baseline_origin_x %.8e, baseline_origin_y %.8e, "
|
|
|
|
"measuring_mode %#x, glyph_run %p, desc %p, effect %p.\n",
|
2014-10-06 08:24:17 +02:00
|
|
|
iface, ctx, baseline_origin_x, baseline_origin_y,
|
|
|
|
measuring_mode, glyph_run, desc, effect);
|
|
|
|
|
2015-06-15 22:30:09 +02:00
|
|
|
if (desc)
|
2015-08-17 12:55:16 +02:00
|
|
|
WARN("Ignoring glyph run description %p.\n", desc);
|
2016-11-07 21:19:14 +01:00
|
|
|
if (context->options & ~(D2D1_DRAW_TEXT_OPTIONS_NO_SNAP | D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT))
|
2015-06-15 22:30:09 +02:00
|
|
|
FIXME("Ignoring options %#x.\n", context->options);
|
|
|
|
|
2016-01-26 13:36:18 +01:00
|
|
|
brush = d2d_draw_get_text_brush(context, effect);
|
|
|
|
|
2015-06-15 22:30:09 +02:00
|
|
|
TRACE("%s\n", debugstr_wn(desc->string, desc->stringLength));
|
2016-11-07 21:19:14 +01:00
|
|
|
|
|
|
|
if (context->options & D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT)
|
|
|
|
{
|
|
|
|
IDWriteFontFace2 *fontface;
|
|
|
|
|
|
|
|
if (SUCCEEDED(IDWriteFontFace_QueryInterface(glyph_run->fontFace,
|
|
|
|
&IID_IDWriteFontFace2, (void **)&fontface)))
|
|
|
|
{
|
|
|
|
color_font = IDWriteFontFace2_IsColorFont(fontface);
|
|
|
|
IDWriteFontFace2_Release(fontface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (color_font)
|
|
|
|
{
|
|
|
|
IDWriteColorGlyphRunEnumerator *layers;
|
|
|
|
IDWriteFactory2 *dwrite_factory;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (FAILED(hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, &IID_IDWriteFactory2,
|
|
|
|
(IUnknown **)&dwrite_factory)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create dwrite factory, hr %#lx.\n", hr);
|
2016-11-07 21:19:14 +01:00
|
|
|
ID2D1Brush_Release(brush);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDWriteFactory2_TranslateColorGlyphRun(dwrite_factory, baseline_origin_x, baseline_origin_y,
|
|
|
|
glyph_run, desc, measuring_mode, (DWRITE_MATRIX *)&render_target->drawing_state.transform, 0, &layers);
|
|
|
|
IDWriteFactory2_Release(dwrite_factory);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create colour glyph run enumerator, hr %#lx.\n", hr);
|
2016-11-07 21:19:14 +01:00
|
|
|
ID2D1Brush_Release(brush);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
const DWRITE_COLOR_GLYPH_RUN *color_run;
|
|
|
|
ID2D1Brush *color_brush;
|
|
|
|
D2D1_POINT_2F origin;
|
|
|
|
BOOL has_run = FALSE;
|
|
|
|
|
|
|
|
if (FAILED(hr = IDWriteColorGlyphRunEnumerator_MoveNext(layers, &has_run)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to switch colour glyph layer, hr %#lx.\n", hr);
|
2016-11-07 21:19:14 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!has_run)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (FAILED(hr = IDWriteColorGlyphRunEnumerator_GetCurrentRun(layers, &color_run)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to get current colour run, hr %#lx.\n", hr);
|
2016-11-07 21:19:14 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (color_run->paletteIndex == 0xffff)
|
|
|
|
color_brush = brush;
|
|
|
|
else
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
if (FAILED(hr = d2d_device_context_CreateSolidColorBrush(&render_target->ID2D1DeviceContext_iface,
|
2016-11-07 21:19:14 +01:00
|
|
|
&color_run->runColor, NULL, (ID2D1SolidColorBrush **)&color_brush)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create solid colour brush, hr %#lx.\n", hr);
|
2016-11-07 21:19:14 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
origin.x = color_run->baselineOriginX;
|
|
|
|
origin.y = color_run->baselineOriginY;
|
2018-08-17 16:54:11 +02:00
|
|
|
d2d_device_context_DrawGlyphRun(&render_target->ID2D1DeviceContext_iface,
|
2016-11-07 21:19:14 +01:00
|
|
|
origin, &color_run->glyphRun, color_brush, measuring_mode);
|
|
|
|
|
|
|
|
if (color_brush != brush)
|
|
|
|
ID2D1Brush_Release(color_brush);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteColorGlyphRunEnumerator_Release(layers);
|
|
|
|
}
|
|
|
|
else
|
2018-08-17 16:54:11 +02:00
|
|
|
d2d_device_context_DrawGlyphRun(&render_target->ID2D1DeviceContext_iface,
|
2016-11-07 21:19:14 +01:00
|
|
|
baseline_origin, glyph_run, brush, measuring_mode);
|
2016-01-26 13:36:18 +01:00
|
|
|
|
|
|
|
ID2D1Brush_Release(brush);
|
2015-06-15 22:30:09 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2014-10-06 08:24:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-07 18:34:27 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_text_renderer_DrawUnderline(IDWriteTextRenderer *iface, void *ctx,
|
2014-10-06 08:24:17 +02:00
|
|
|
float baseline_origin_x, float baseline_origin_y, const DWRITE_UNDERLINE *underline, IUnknown *effect)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_IDWriteTextRenderer(iface);
|
2016-01-21 20:29:51 +01:00
|
|
|
const D2D1_MATRIX_3X2_F *m = &render_target->drawing_state.transform;
|
|
|
|
struct d2d_draw_text_layout_ctx *context = ctx;
|
2017-07-18 08:46:17 +02:00
|
|
|
D2D1_ANTIALIAS_MODE prev_antialias_mode;
|
2017-02-24 12:11:33 +01:00
|
|
|
D2D1_POINT_2F start, end;
|
2016-01-27 21:34:00 +01:00
|
|
|
ID2D1Brush *brush;
|
2017-02-24 12:11:33 +01:00
|
|
|
float thickness;
|
2016-01-21 20:29:51 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, ctx %p, baseline_origin_x %.8e, baseline_origin_y %.8e, underline %p, effect %p\n",
|
2014-10-06 08:24:17 +02:00
|
|
|
iface, ctx, baseline_origin_x, baseline_origin_y, underline, effect);
|
|
|
|
|
2016-01-21 20:29:51 +01:00
|
|
|
/* minimal thickness in DIPs that will result in at least 1 pixel thick line */
|
2017-02-24 12:11:33 +01:00
|
|
|
thickness = max(96.0f / (render_target->desc.dpiY * sqrtf(m->_21 * m->_21 + m->_22 * m->_22)),
|
|
|
|
underline->thickness);
|
2016-01-21 20:29:51 +01:00
|
|
|
|
2016-01-27 21:34:00 +01:00
|
|
|
brush = d2d_draw_get_text_brush(context, effect);
|
|
|
|
|
2017-02-24 12:11:33 +01:00
|
|
|
start.x = baseline_origin_x;
|
|
|
|
start.y = baseline_origin_y + underline->offset + thickness / 2.0f;
|
|
|
|
end.x = start.x + underline->width;
|
|
|
|
end.y = start.y;
|
2018-08-17 16:54:11 +02:00
|
|
|
prev_antialias_mode = d2d_device_context_set_aa_mode_from_text_aa_mode(render_target);
|
|
|
|
d2d_device_context_DrawLine(&render_target->ID2D1DeviceContext_iface, start, end, brush, thickness, NULL);
|
2017-07-18 08:46:17 +02:00
|
|
|
render_target->drawing_state.antialiasMode = prev_antialias_mode;
|
2016-01-27 21:34:00 +01:00
|
|
|
|
|
|
|
ID2D1Brush_Release(brush);
|
|
|
|
|
2016-01-21 20:29:51 +01:00
|
|
|
return S_OK;
|
2014-10-06 08:24:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-07 18:34:27 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_text_renderer_DrawStrikethrough(IDWriteTextRenderer *iface, void *ctx,
|
2014-10-06 08:24:17 +02:00
|
|
|
float baseline_origin_x, float baseline_origin_y, const DWRITE_STRIKETHROUGH *strikethrough, IUnknown *effect)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_IDWriteTextRenderer(iface);
|
2017-02-26 12:47:14 +01:00
|
|
|
const D2D1_MATRIX_3X2_F *m = &render_target->drawing_state.transform;
|
|
|
|
struct d2d_draw_text_layout_ctx *context = ctx;
|
2017-07-18 08:46:17 +02:00
|
|
|
D2D1_ANTIALIAS_MODE prev_antialias_mode;
|
2017-02-26 12:47:14 +01:00
|
|
|
D2D1_POINT_2F start, end;
|
|
|
|
ID2D1Brush *brush;
|
|
|
|
float thickness;
|
|
|
|
|
|
|
|
TRACE("iface %p, ctx %p, baseline_origin_x %.8e, baseline_origin_y %.8e, strikethrough %p, effect %p.\n",
|
2014-10-06 08:24:17 +02:00
|
|
|
iface, ctx, baseline_origin_x, baseline_origin_y, strikethrough, effect);
|
|
|
|
|
2017-02-26 12:47:14 +01:00
|
|
|
/* minimal thickness in DIPs that will result in at least 1 pixel thick line */
|
|
|
|
thickness = max(96.0f / (render_target->desc.dpiY * sqrtf(m->_21 * m->_21 + m->_22 * m->_22)),
|
|
|
|
strikethrough->thickness);
|
|
|
|
|
|
|
|
brush = d2d_draw_get_text_brush(context, effect);
|
|
|
|
|
|
|
|
start.x = baseline_origin_x;
|
|
|
|
start.y = baseline_origin_y + strikethrough->offset + thickness / 2.0f;
|
|
|
|
end.x = start.x + strikethrough->width;
|
|
|
|
end.y = start.y;
|
2018-08-17 16:54:11 +02:00
|
|
|
prev_antialias_mode = d2d_device_context_set_aa_mode_from_text_aa_mode(render_target);
|
|
|
|
d2d_device_context_DrawLine(&render_target->ID2D1DeviceContext_iface, start, end, brush, thickness, NULL);
|
2017-07-18 08:46:17 +02:00
|
|
|
render_target->drawing_state.antialiasMode = prev_antialias_mode;
|
2017-02-26 12:47:14 +01:00
|
|
|
|
|
|
|
ID2D1Brush_Release(brush);
|
|
|
|
|
|
|
|
return S_OK;
|
2014-10-06 08:24:17 +02:00
|
|
|
}
|
|
|
|
|
2014-10-07 18:34:27 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_text_renderer_DrawInlineObject(IDWriteTextRenderer *iface, void *ctx,
|
2014-10-06 08:24:17 +02:00
|
|
|
float origin_x, float origin_y, IDWriteInlineObject *object, BOOL is_sideways, BOOL is_rtl, IUnknown *effect)
|
|
|
|
{
|
2017-08-24 16:33:07 +02:00
|
|
|
struct d2d_draw_text_layout_ctx *context = ctx;
|
|
|
|
ID2D1Brush *brush;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2015-08-18 11:24:13 +02:00
|
|
|
TRACE("iface %p, ctx %p, origin_x %.8e, origin_y %.8e, object %p, is_sideways %#x, is_rtl %#x, effect %p.\n",
|
2014-10-06 08:24:17 +02:00
|
|
|
iface, ctx, origin_x, origin_y, object, is_sideways, is_rtl, effect);
|
|
|
|
|
2017-08-24 16:33:07 +02:00
|
|
|
/* Inline objects may not pass effects all the way down, when using layout object internally for example.
|
|
|
|
This is how default trimming sign object in DirectWrite works - it does not use effect passed to Draw(),
|
|
|
|
and resulting DrawGlyphRun() is always called with NULL effect, however original effect is used and correct
|
|
|
|
brush is selected at Direct2D level. */
|
|
|
|
brush = context->brush;
|
|
|
|
context->brush = d2d_draw_get_text_brush(context, effect);
|
|
|
|
|
|
|
|
hr = IDWriteInlineObject_Draw(object, ctx, iface, origin_x, origin_y, is_sideways, is_rtl, effect);
|
|
|
|
|
|
|
|
ID2D1Brush_Release(context->brush);
|
|
|
|
context->brush = brush;
|
|
|
|
|
|
|
|
return hr;
|
2014-10-06 08:24:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IDWriteTextRendererVtbl d2d_text_renderer_vtbl =
|
|
|
|
{
|
|
|
|
d2d_text_renderer_QueryInterface,
|
|
|
|
d2d_text_renderer_AddRef,
|
|
|
|
d2d_text_renderer_Release,
|
|
|
|
d2d_text_renderer_IsPixelSnappingDisabled,
|
|
|
|
d2d_text_renderer_GetCurrentTransform,
|
|
|
|
d2d_text_renderer_GetPixelsPerDip,
|
|
|
|
d2d_text_renderer_DrawGlyphRun,
|
|
|
|
d2d_text_renderer_DrawUnderline,
|
|
|
|
d2d_text_renderer_DrawStrikethrough,
|
|
|
|
d2d_text_renderer_DrawInlineObject,
|
|
|
|
};
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static inline struct d2d_device_context *impl_from_ID2D1GdiInteropRenderTarget(ID2D1GdiInteropRenderTarget *iface)
|
2017-02-14 16:19:00 +01:00
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct d2d_device_context, ID2D1GdiInteropRenderTarget_iface);
|
2017-02-14 16:19:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_gdi_interop_render_target_QueryInterface(ID2D1GdiInteropRenderTarget *iface,
|
|
|
|
REFIID iid, void **out)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1GdiInteropRenderTarget(iface);
|
2017-02-14 16:19:00 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
|
|
|
|
|
|
|
|
return IUnknown_QueryInterface(render_target->outer_unknown, iid, out);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE d2d_gdi_interop_render_target_AddRef(ID2D1GdiInteropRenderTarget *iface)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1GdiInteropRenderTarget(iface);
|
2017-02-14 16:19:00 +01:00
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return IUnknown_AddRef(render_target->outer_unknown);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE d2d_gdi_interop_render_target_Release(ID2D1GdiInteropRenderTarget *iface)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1GdiInteropRenderTarget(iface);
|
2017-02-14 16:19:00 +01:00
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return IUnknown_Release(render_target->outer_unknown);
|
|
|
|
}
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
static HRESULT d2d_device_context_get_surface(struct d2d_device_context *render_target, IDXGISurface1 **surface)
|
2017-02-14 16:19:00 +01:00
|
|
|
{
|
2021-06-21 09:57:47 +02:00
|
|
|
ID3D11Resource *resource;
|
2017-02-14 16:19:00 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
ID3D11RenderTargetView_GetResource(render_target->target->rtv, &resource);
|
2021-06-21 09:57:47 +02:00
|
|
|
hr = ID3D11Resource_QueryInterface(resource, &IID_IDXGISurface1, (void **)surface);
|
|
|
|
ID3D11Resource_Release(resource);
|
2017-02-14 16:19:00 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
*surface = NULL;
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to get DXGI surface, %#lx.\n", hr);
|
2017-02-14 16:19:00 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_gdi_interop_render_target_GetDC(ID2D1GdiInteropRenderTarget *iface,
|
|
|
|
D2D1_DC_INITIALIZE_MODE mode, HDC *dc)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1GdiInteropRenderTarget(iface);
|
2017-02-14 16:19:00 +01:00
|
|
|
IDXGISurface1 *surface;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, mode %d, dc %p.\n", iface, mode, dc);
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
if (FAILED(hr = d2d_device_context_get_surface(render_target, &surface)))
|
2017-02-14 16:19:00 +01:00
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = IDXGISurface1_GetDC(surface, mode != D2D1_DC_INITIALIZE_MODE_COPY, dc);
|
|
|
|
IDXGISurface1_Release(surface);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d2d_gdi_interop_render_target_ReleaseDC(ID2D1GdiInteropRenderTarget *iface,
|
|
|
|
const RECT *update)
|
|
|
|
{
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *render_target = impl_from_ID2D1GdiInteropRenderTarget(iface);
|
2017-02-14 16:19:00 +01:00
|
|
|
IDXGISurface1 *surface;
|
|
|
|
RECT update_rect;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, update rect %s.\n", iface, wine_dbgstr_rect(update));
|
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
if (FAILED(hr = d2d_device_context_get_surface(render_target, &surface)))
|
2017-02-14 16:19:00 +01:00
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (update)
|
|
|
|
update_rect = *update;
|
|
|
|
hr = IDXGISurface1_ReleaseDC(surface, update ? &update_rect : NULL);
|
|
|
|
IDXGISurface1_Release(surface);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ID2D1GdiInteropRenderTargetVtbl d2d_gdi_interop_render_target_vtbl =
|
|
|
|
{
|
|
|
|
d2d_gdi_interop_render_target_QueryInterface,
|
|
|
|
d2d_gdi_interop_render_target_AddRef,
|
|
|
|
d2d_gdi_interop_render_target_Release,
|
|
|
|
d2d_gdi_interop_render_target_GetDC,
|
|
|
|
d2d_gdi_interop_render_target_ReleaseDC,
|
|
|
|
};
|
|
|
|
|
2018-09-24 06:58:31 +02:00
|
|
|
static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, ID2D1Device *device,
|
2018-09-29 01:02:06 +02:00
|
|
|
IUnknown *outer_unknown, const struct d2d_device_context_ops *ops)
|
2014-05-20 07:38:44 +02:00
|
|
|
{
|
2021-06-25 09:34:01 +02:00
|
|
|
D3D11_SUBRESOURCE_DATA buffer_data;
|
2018-09-29 01:02:06 +02:00
|
|
|
struct d2d_device *device_impl;
|
2015-11-18 22:23:23 +01:00
|
|
|
IDWriteFactory *dwrite_factory;
|
2021-06-28 09:17:33 +02:00
|
|
|
D3D11_RASTERIZER_DESC rs_desc;
|
2021-06-25 09:34:01 +02:00
|
|
|
D3D11_BUFFER_DESC buffer_desc;
|
2017-09-23 13:36:59 +02:00
|
|
|
unsigned int i;
|
2014-09-03 07:48:23 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2021-06-25 09:34:02 +02:00
|
|
|
static const D3D11_INPUT_ELEMENT_DESC il_desc_outline[] =
|
2017-02-03 13:37:09 +01:00
|
|
|
{
|
2021-06-25 09:34:02 +02:00
|
|
|
{"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
|
|
|
{"PREV", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
|
|
|
{"NEXT", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
2017-02-03 13:37:09 +01:00
|
|
|
};
|
2021-06-25 09:34:02 +02:00
|
|
|
static const D3D11_INPUT_ELEMENT_DESC il_desc_curve_outline[] =
|
2017-05-21 17:53:43 +02:00
|
|
|
{
|
2021-06-25 09:34:02 +02:00
|
|
|
{"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
|
|
|
{"P", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
|
|
|
{"P", 1, DXGI_FORMAT_R32G32_FLOAT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
|
|
|
{"P", 2, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
|
|
|
{"PREV", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
|
|
|
{"NEXT", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 40, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
2017-05-21 17:53:43 +02:00
|
|
|
};
|
2021-06-25 09:34:02 +02:00
|
|
|
static const D3D11_INPUT_ELEMENT_DESC il_desc_triangle[] =
|
2017-09-23 13:36:59 +02:00
|
|
|
{
|
2021-06-25 09:34:02 +02:00
|
|
|
{"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
2017-09-23 13:36:59 +02:00
|
|
|
};
|
2021-06-25 09:34:02 +02:00
|
|
|
static const D3D11_INPUT_ELEMENT_DESC il_desc_curve[] =
|
2015-07-20 11:07:28 +02:00
|
|
|
{
|
2021-06-25 09:34:02 +02:00
|
|
|
{"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
|
|
|
{"TEXCOORD", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
2015-07-20 11:07:28 +02:00
|
|
|
};
|
2017-02-03 13:37:09 +01:00
|
|
|
static const DWORD vs_code_outline[] =
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
float3x2 transform_geometry;
|
|
|
|
float stroke_width;
|
|
|
|
float4 transform_rtx;
|
|
|
|
float4 transform_rty;
|
|
|
|
|
2017-09-23 13:37:00 +02:00
|
|
|
struct output
|
|
|
|
{
|
2017-09-23 13:37:01 +02:00
|
|
|
float2 p : WORLD_POSITION;
|
2017-09-23 13:37:00 +02:00
|
|
|
float4 b : BEZIER;
|
|
|
|
nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM;
|
2017-09-23 13:37:01 +02:00
|
|
|
float4 position : SV_POSITION;
|
2017-09-23 13:37:00 +02:00
|
|
|
};
|
|
|
|
|
2017-02-03 13:37:10 +01:00
|
|
|
/* The lines PₚᵣₑᵥP₀ and P₀Pₙₑₓₜ, both offset by ±½w, intersect each other at:
|
|
|
|
*
|
|
|
|
* Pᵢ = P₀ ± w · ½q⃑ᵢ.
|
|
|
|
*
|
|
|
|
* Where:
|
|
|
|
*
|
|
|
|
* q⃑ᵢ = q̂ₚᵣₑᵥ⊥ + tan(½θ) · -q̂ₚᵣₑᵥ
|
|
|
|
* θ = ∠PₚᵣₑᵥP₀Pₙₑₓₜ
|
|
|
|
* q⃑ₚᵣₑᵥ = P₀ - Pₚᵣₑᵥ */
|
2017-09-23 13:37:00 +02:00
|
|
|
void main(float2 position : POSITION, float2 prev : PREV, float2 next : NEXT, out struct output o)
|
2017-02-03 13:37:09 +01:00
|
|
|
{
|
2017-02-03 13:37:10 +01:00
|
|
|
float2 q_prev, q_next, v_p, q_i;
|
2017-09-23 13:37:00 +02:00
|
|
|
float2x2 geom;
|
2017-02-03 13:37:10 +01:00
|
|
|
float l;
|
|
|
|
|
2017-09-23 13:37:00 +02:00
|
|
|
o.stroke_transform = float2x2(transform_rtx.xy, transform_rty.xy) * stroke_width * 0.5f;
|
2017-02-03 13:37:10 +01:00
|
|
|
|
2017-09-23 13:37:00 +02:00
|
|
|
geom = float2x2(transform_geometry._11_21, transform_geometry._12_22);
|
|
|
|
q_prev = normalize(mul(geom, prev));
|
|
|
|
q_next = normalize(mul(geom, next));
|
2017-02-03 13:37:10 +01:00
|
|
|
|
|
|
|
/* tan(½θ) = sin(θ) / (1 + cos(θ))
|
|
|
|
* = (q̂ₚᵣₑᵥ⊥ · q̂ₙₑₓₜ) / (1 + (q̂ₚᵣₑᵥ · q̂ₙₑₓₜ)) */
|
|
|
|
v_p = float2(-q_prev.y, q_prev.x);
|
|
|
|
l = -dot(v_p, q_next) / (1.0f + dot(q_prev, q_next));
|
|
|
|
q_i = l * q_prev + v_p;
|
2017-02-03 13:37:09 +01:00
|
|
|
|
2017-09-23 13:37:00 +02:00
|
|
|
o.b = float4(0.0, 0.0, 0.0, 0.0);
|
|
|
|
|
2017-09-23 13:37:01 +02:00
|
|
|
o.p = mul(float3(position, 1.0f), transform_geometry) + stroke_width * 0.5f * q_i;
|
|
|
|
position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f))
|
2017-09-23 13:37:00 +02:00
|
|
|
* float2(transform_rtx.w, transform_rty.w);
|
|
|
|
o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f);
|
2017-02-03 13:37:09 +01:00
|
|
|
}
|
|
|
|
#endif
|
2017-09-23 13:37:01 +02:00
|
|
|
0x43425844, 0xfb16cd75, 0xf5ec3e80, 0xceacf250, 0x91d29d18, 0x00000001, 0x00000608, 0x00000003,
|
|
|
|
0x0000002c, 0x00000098, 0x00000154, 0x4e475349, 0x00000064, 0x00000003, 0x00000008, 0x00000050,
|
2017-02-03 13:37:10 +01:00
|
|
|
0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000303, 0x00000059, 0x00000000, 0x00000000,
|
|
|
|
0x00000003, 0x00000001, 0x00000303, 0x0000005e, 0x00000000, 0x00000000, 0x00000003, 0x00000002,
|
2017-09-23 13:37:01 +02:00
|
|
|
0x00000303, 0x49534f50, 0x4e4f4954, 0x45525000, 0x454e0056, 0xab005458, 0x4e47534f, 0x000000b4,
|
|
|
|
0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000c03,
|
|
|
|
0x0000008f, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000096, 0x00000000,
|
|
|
|
0x00000000, 0x00000003, 0x00000002, 0x00000c03, 0x00000096, 0x00000001, 0x00000000, 0x00000003,
|
|
|
|
0x00000003, 0x00000c03, 0x000000a7, 0x00000000, 0x00000001, 0x00000003, 0x00000004, 0x0000000f,
|
|
|
|
0x4c524f57, 0x4f505f44, 0x49544953, 0x42004e4f, 0x45495a45, 0x54530052, 0x454b4f52, 0x4152545f,
|
|
|
|
0x4f46534e, 0x53004d52, 0x4f505f56, 0x49544953, 0xab004e4f, 0x52444853, 0x000004ac, 0x00010040,
|
|
|
|
0x0000012b, 0x04000059, 0x00208e46, 0x00000000, 0x00000004, 0x0300005f, 0x00101032, 0x00000000,
|
|
|
|
0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x00101032, 0x00000002, 0x03000065, 0x00102032,
|
|
|
|
0x00000000, 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x00102032, 0x00000002, 0x03000065,
|
|
|
|
0x00102032, 0x00000003, 0x04000067, 0x001020f2, 0x00000004, 0x00000001, 0x02000068, 0x00000003,
|
|
|
|
0x0800000f, 0x00100012, 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000002,
|
|
|
|
0x0800000f, 0x00100022, 0x00000000, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000002,
|
|
|
|
0x0700000f, 0x00100042, 0x00000000, 0x00100046, 0x00000000, 0x00100046, 0x00000000, 0x05000044,
|
|
|
|
0x00100042, 0x00000000, 0x0010002a, 0x00000000, 0x07000038, 0x00100032, 0x00000000, 0x00100aa6,
|
|
|
|
0x00000000, 0x00100046, 0x00000000, 0x0800000f, 0x00100012, 0x00000001, 0x00208046, 0x00000000,
|
|
|
|
0x00000000, 0x00101046, 0x00000001, 0x0800000f, 0x00100022, 0x00000001, 0x00208046, 0x00000000,
|
|
|
|
0x00000001, 0x00101046, 0x00000001, 0x0700000f, 0x00100042, 0x00000000, 0x00100046, 0x00000001,
|
|
|
|
0x00100046, 0x00000001, 0x05000044, 0x00100042, 0x00000000, 0x0010002a, 0x00000000, 0x07000038,
|
|
|
|
0x00100032, 0x00000001, 0x00100aa6, 0x00000000, 0x00100046, 0x00000001, 0x06000036, 0x001000c2,
|
|
|
|
0x00000001, 0x80100556, 0x00000041, 0x00000001, 0x0700000f, 0x00100042, 0x00000000, 0x00100a26,
|
|
|
|
0x00000001, 0x00100046, 0x00000000, 0x0700000f, 0x00100012, 0x00000000, 0x00100046, 0x00000001,
|
|
|
|
0x00100046, 0x00000000, 0x07000000, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x00004001,
|
|
|
|
0x3f800000, 0x0800000e, 0x00100012, 0x00000000, 0x8010002a, 0x00000041, 0x00000000, 0x0010000a,
|
|
|
|
0x00000000, 0x09000032, 0x00100032, 0x00000000, 0x00100006, 0x00000000, 0x00100046, 0x00000001,
|
|
|
|
0x00100f36, 0x00000001, 0x08000038, 0x00100042, 0x00000000, 0x0020803a, 0x00000000, 0x00000001,
|
|
|
|
0x00004001, 0x3f000000, 0x05000036, 0x00100032, 0x00000001, 0x00101046, 0x00000000, 0x05000036,
|
|
|
|
0x00100042, 0x00000001, 0x00004001, 0x3f800000, 0x08000010, 0x00100012, 0x00000002, 0x00100246,
|
|
|
|
0x00000001, 0x00208246, 0x00000000, 0x00000000, 0x08000010, 0x00100022, 0x00000002, 0x00100246,
|
|
|
|
0x00000001, 0x00208246, 0x00000000, 0x00000001, 0x09000032, 0x00100032, 0x00000000, 0x00100aa6,
|
|
|
|
0x00000000, 0x00100046, 0x00000000, 0x00100046, 0x00000002, 0x05000036, 0x00102032, 0x00000000,
|
|
|
|
0x00100046, 0x00000000, 0x08000036, 0x001020f2, 0x00000001, 0x00004002, 0x00000000, 0x00000000,
|
|
|
|
0x00000000, 0x00000000, 0x06000036, 0x00100032, 0x00000001, 0x00208046, 0x00000000, 0x00000002,
|
|
|
|
0x06000036, 0x001000c2, 0x00000001, 0x00208406, 0x00000000, 0x00000003, 0x08000038, 0x001000f2,
|
|
|
|
0x00000001, 0x00100e46, 0x00000001, 0x00208ff6, 0x00000000, 0x00000001, 0x0a000038, 0x001000f2,
|
|
|
|
0x00000001, 0x00100e46, 0x00000001, 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000,
|
|
|
|
0x05000036, 0x00102032, 0x00000002, 0x00100086, 0x00000001, 0x05000036, 0x00102032, 0x00000003,
|
|
|
|
0x001005d6, 0x00000001, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x3f800000, 0x08000010,
|
|
|
|
0x00100082, 0x00000000, 0x00208246, 0x00000000, 0x00000002, 0x00100246, 0x00000000, 0x08000010,
|
|
|
|
0x00100012, 0x00000000, 0x00208246, 0x00000000, 0x00000003, 0x00100246, 0x00000000, 0x08000038,
|
|
|
|
0x00100022, 0x00000000, 0x0010000a, 0x00000000, 0x0020803a, 0x00000000, 0x00000003, 0x08000038,
|
|
|
|
0x00100012, 0x00000000, 0x0010003a, 0x00000000, 0x0020803a, 0x00000000, 0x00000002, 0x0a000000,
|
|
|
|
0x00102032, 0x00000004, 0x00100046, 0x00000000, 0x00004002, 0xbf800000, 0x3f800000, 0x00000000,
|
|
|
|
0x00000000, 0x08000036, 0x001020c2, 0x00000004, 0x00004002, 0x00000000, 0x00000000, 0x00000000,
|
|
|
|
0x3f800000, 0x0100003e,
|
2014-09-05 15:50:58 +02:00
|
|
|
};
|
2017-05-21 17:53:43 +02:00
|
|
|
/* ⎡p0.x p0.y 1⎤
|
|
|
|
* A = ⎢p1.x p1.y 1⎥
|
|
|
|
* ⎣p2.x p2.y 1⎦
|
|
|
|
*
|
|
|
|
* ⎡0 0⎤
|
|
|
|
* B = ⎢½ 0⎥
|
|
|
|
* ⎣1 1⎦
|
|
|
|
*
|
|
|
|
* A' = ⎡p1.x-p0.x p1.y-p0.y⎤
|
|
|
|
* ⎣p2.x-p0.x p2.y-p0.y⎦
|
|
|
|
*
|
|
|
|
* B' = ⎡½ 0⎤
|
|
|
|
* ⎣1 1⎦
|
|
|
|
*
|
|
|
|
* A'T = B'
|
|
|
|
* T = A'⁻¹B'
|
|
|
|
*/
|
|
|
|
static const DWORD vs_code_bezier_outline[] =
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
float3x2 transform_geometry;
|
|
|
|
float stroke_width;
|
|
|
|
float4 transform_rtx;
|
|
|
|
float4 transform_rty;
|
|
|
|
|
2017-09-23 13:37:00 +02:00
|
|
|
struct output
|
|
|
|
{
|
2017-09-23 13:37:01 +02:00
|
|
|
float2 p : WORLD_POSITION;
|
2017-09-23 13:37:00 +02:00
|
|
|
float4 b : BEZIER;
|
|
|
|
nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM;
|
2017-09-23 13:37:01 +02:00
|
|
|
float4 position : SV_POSITION;
|
2017-09-23 13:37:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
void main(float2 position : POSITION, float2 p0 : P0, float2 p1 : P1, float2 p2 : P2,
|
|
|
|
float2 prev : PREV, float2 next : NEXT, out struct output o)
|
2017-05-21 17:53:43 +02:00
|
|
|
{
|
|
|
|
float2 q_prev, q_next, v_p, q_i, p;
|
|
|
|
float2x2 geom, rt;
|
|
|
|
float l;
|
|
|
|
|
|
|
|
geom = float2x2(transform_geometry._11_21, transform_geometry._12_22);
|
|
|
|
rt = float2x2(transform_rtx.xy, transform_rty.xy);
|
2017-09-23 13:37:00 +02:00
|
|
|
o.stroke_transform = rt * stroke_width * 0.5f;
|
2017-05-21 17:53:43 +02:00
|
|
|
|
|
|
|
p = mul(geom, position);
|
|
|
|
p0 = mul(geom, p0);
|
|
|
|
p1 = mul(geom, p1);
|
|
|
|
p2 = mul(geom, p2);
|
|
|
|
|
|
|
|
p -= p0;
|
|
|
|
p1 -= p0;
|
|
|
|
p2 -= p0;
|
|
|
|
|
|
|
|
q_prev = normalize(mul(geom, prev));
|
|
|
|
q_next = normalize(mul(geom, next));
|
|
|
|
|
|
|
|
v_p = float2(-q_prev.y, q_prev.x);
|
|
|
|
l = -dot(v_p, q_next) / (1.0f + dot(q_prev, q_next));
|
|
|
|
q_i = l * q_prev + v_p;
|
2020-02-11 16:50:03 +01:00
|
|
|
p += 0.5f * stroke_width * q_i;
|
2017-05-21 17:53:43 +02:00
|
|
|
|
2017-05-31 11:07:06 +02:00
|
|
|
v_p = mul(rt, p2);
|
|
|
|
v_p = normalize(float2(-v_p.y, v_p.x));
|
|
|
|
if (abs(dot(mul(rt, p1), v_p)) < 1.0f)
|
2017-05-21 17:53:43 +02:00
|
|
|
{
|
2017-09-23 13:37:00 +02:00
|
|
|
o.b.xzw = float3(0.0f, 0.0f, 0.0f);
|
|
|
|
o.b.y = dot(mul(rt, p), v_p);
|
2017-05-21 17:53:43 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-23 13:37:00 +02:00
|
|
|
o.b.zw = sign(dot(mul(rt, p1), v_p)) * v_p;
|
2017-05-21 17:53:43 +02:00
|
|
|
v_p = -float2(-p.y, p.x) / dot(float2(-p1.y, p1.x), p2);
|
2017-09-23 13:37:00 +02:00
|
|
|
o.b.x = dot(v_p, p1 - 0.5f * p2);
|
|
|
|
o.b.y = dot(v_p, p1);
|
2017-05-21 17:53:43 +02:00
|
|
|
}
|
|
|
|
|
2020-02-11 16:50:03 +01:00
|
|
|
o.p = mul(float3(position, 1.0f), transform_geometry) + 0.5f * stroke_width * q_i;
|
2017-09-23 13:37:01 +02:00
|
|
|
position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f))
|
2017-09-23 13:37:00 +02:00
|
|
|
* float2(transform_rtx.w, transform_rty.w);
|
|
|
|
o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f);
|
2017-05-21 17:53:43 +02:00
|
|
|
}
|
|
|
|
#endif
|
2020-02-11 16:50:03 +01:00
|
|
|
0x43425844, 0x356a0c5f, 0x8e4ba153, 0xe52cf793, 0xa6b774ea, 0x00000001, 0x00000afc, 0x00000003,
|
2017-09-23 13:37:01 +02:00
|
|
|
0x0000002c, 0x000000e4, 0x000001a0, 0x4e475349, 0x000000b0, 0x00000006, 0x00000008, 0x00000098,
|
2017-05-21 17:53:43 +02:00
|
|
|
0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000303, 0x000000a1, 0x00000000, 0x00000000,
|
|
|
|
0x00000003, 0x00000001, 0x00000303, 0x000000a1, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
|
|
|
|
0x00000303, 0x000000a1, 0x00000002, 0x00000000, 0x00000003, 0x00000003, 0x00000303, 0x000000a3,
|
|
|
|
0x00000000, 0x00000000, 0x00000003, 0x00000004, 0x00000303, 0x000000a8, 0x00000000, 0x00000000,
|
|
|
|
0x00000003, 0x00000005, 0x00000303, 0x49534f50, 0x4e4f4954, 0x50005000, 0x00564552, 0x5458454e,
|
2017-09-23 13:37:01 +02:00
|
|
|
0xababab00, 0x4e47534f, 0x000000b4, 0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000000,
|
|
|
|
0x00000003, 0x00000000, 0x00000c03, 0x0000008f, 0x00000000, 0x00000000, 0x00000003, 0x00000001,
|
|
|
|
0x0000000f, 0x00000096, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000c03, 0x00000096,
|
|
|
|
0x00000001, 0x00000000, 0x00000003, 0x00000003, 0x00000c03, 0x000000a7, 0x00000000, 0x00000001,
|
|
|
|
0x00000003, 0x00000004, 0x0000000f, 0x4c524f57, 0x4f505f44, 0x49544953, 0x42004e4f, 0x45495a45,
|
|
|
|
0x54530052, 0x454b4f52, 0x4152545f, 0x4f46534e, 0x53004d52, 0x4f505f56, 0x49544953, 0xab004e4f,
|
2020-02-11 16:50:03 +01:00
|
|
|
0x52444853, 0x00000954, 0x00010040, 0x00000255, 0x04000059, 0x00208e46, 0x00000000, 0x00000004,
|
2017-09-23 13:37:01 +02:00
|
|
|
0x0300005f, 0x00101032, 0x00000000, 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x00101032,
|
|
|
|
0x00000002, 0x0300005f, 0x00101032, 0x00000003, 0x0300005f, 0x00101032, 0x00000004, 0x0300005f,
|
|
|
|
0x00101032, 0x00000005, 0x03000065, 0x00102032, 0x00000000, 0x03000065, 0x001020f2, 0x00000001,
|
|
|
|
0x03000065, 0x00102032, 0x00000002, 0x03000065, 0x00102032, 0x00000003, 0x04000067, 0x001020f2,
|
|
|
|
0x00000004, 0x00000001, 0x02000068, 0x00000006, 0x0800000f, 0x00100012, 0x00000000, 0x00208046,
|
|
|
|
0x00000000, 0x00000000, 0x00101046, 0x00000005, 0x0800000f, 0x00100022, 0x00000000, 0x00208046,
|
|
|
|
0x00000000, 0x00000001, 0x00101046, 0x00000005, 0x0700000f, 0x00100042, 0x00000000, 0x00100046,
|
|
|
|
0x00000000, 0x00100046, 0x00000000, 0x05000044, 0x00100042, 0x00000000, 0x0010002a, 0x00000000,
|
|
|
|
0x07000038, 0x00100032, 0x00000000, 0x00100aa6, 0x00000000, 0x00100046, 0x00000000, 0x0800000f,
|
|
|
|
0x00100012, 0x00000001, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000004, 0x0800000f,
|
|
|
|
0x00100022, 0x00000001, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000004, 0x0700000f,
|
|
|
|
0x00100042, 0x00000000, 0x00100046, 0x00000001, 0x00100046, 0x00000001, 0x05000044, 0x00100042,
|
|
|
|
0x00000000, 0x0010002a, 0x00000000, 0x07000038, 0x00100032, 0x00000001, 0x00100aa6, 0x00000000,
|
|
|
|
0x00100046, 0x00000001, 0x06000036, 0x001000c2, 0x00000001, 0x80100556, 0x00000041, 0x00000001,
|
|
|
|
0x0700000f, 0x00100042, 0x00000000, 0x00100a26, 0x00000001, 0x00100046, 0x00000000, 0x0700000f,
|
|
|
|
0x00100012, 0x00000000, 0x00100046, 0x00000001, 0x00100046, 0x00000000, 0x07000000, 0x00100012,
|
|
|
|
0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x3f800000, 0x0800000e, 0x00100012, 0x00000000,
|
|
|
|
0x8010002a, 0x00000041, 0x00000000, 0x0010000a, 0x00000000, 0x09000032, 0x00100032, 0x00000000,
|
|
|
|
0x00100006, 0x00000000, 0x00100046, 0x00000001, 0x00100f36, 0x00000001, 0x05000036, 0x00100032,
|
|
|
|
0x00000001, 0x00101046, 0x00000000, 0x05000036, 0x00100042, 0x00000001, 0x00004001, 0x3f800000,
|
|
|
|
0x08000010, 0x00100012, 0x00000002, 0x00100246, 0x00000001, 0x00208246, 0x00000000, 0x00000000,
|
|
|
|
0x08000010, 0x00100022, 0x00000002, 0x00100246, 0x00000001, 0x00208246, 0x00000000, 0x00000001,
|
2020-02-11 16:50:03 +01:00
|
|
|
0x08000038, 0x00100042, 0x00000000, 0x0020803a, 0x00000000, 0x00000001, 0x00004001, 0x3f000000,
|
|
|
|
0x09000032, 0x00100032, 0x00000001, 0x00100aa6, 0x00000000, 0x00100046, 0x00000000, 0x00100046,
|
|
|
|
0x00000002, 0x05000036, 0x00102032, 0x00000000, 0x00100046, 0x00000001, 0x0800000f, 0x00100012,
|
|
|
|
0x00000002, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000000, 0x0800000f, 0x00100022,
|
|
|
|
0x00000002, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000000, 0x0800000f, 0x00100012,
|
|
|
|
0x00000003, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000001, 0x0800000f, 0x00100022,
|
|
|
|
0x00000003, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000001, 0x08000000, 0x00100032,
|
|
|
|
0x00000002, 0x00100046, 0x00000002, 0x80100046, 0x00000041, 0x00000003, 0x09000032, 0x00100032,
|
|
|
|
0x00000000, 0x00100aa6, 0x00000000, 0x00100046, 0x00000000, 0x00100046, 0x00000002, 0x0800000f,
|
|
|
|
0x00100012, 0x00000002, 0x00208046, 0x00000000, 0x00000002, 0x00100046, 0x00000000, 0x0800000f,
|
|
|
|
0x00100022, 0x00000002, 0x00208046, 0x00000000, 0x00000003, 0x00100046, 0x00000000, 0x0800000f,
|
|
|
|
0x00100012, 0x00000004, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000003, 0x0800000f,
|
|
|
|
0x00100022, 0x00000004, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000003, 0x08000000,
|
|
|
|
0x001000c2, 0x00000002, 0x80100406, 0x00000041, 0x00000003, 0x00100406, 0x00000004, 0x0800000f,
|
|
|
|
0x00100082, 0x00000000, 0x00208046, 0x00000000, 0x00000003, 0x00100ae6, 0x00000002, 0x06000036,
|
|
|
|
0x00100042, 0x00000003, 0x8010003a, 0x00000041, 0x00000000, 0x0800000f, 0x00100082, 0x00000003,
|
|
|
|
0x00208046, 0x00000000, 0x00000002, 0x00100ae6, 0x00000002, 0x0700000f, 0x00100082, 0x00000000,
|
|
|
|
0x00100ae6, 0x00000003, 0x00100ae6, 0x00000003, 0x05000044, 0x00100082, 0x00000000, 0x0010003a,
|
|
|
|
0x00000000, 0x07000038, 0x001000c2, 0x00000003, 0x00100ff6, 0x00000000, 0x00100ea6, 0x00000003,
|
|
|
|
0x0700000f, 0x00100022, 0x00000004, 0x00100046, 0x00000002, 0x00100ae6, 0x00000003, 0x06000036,
|
|
|
|
0x00100042, 0x00000000, 0x8010001a, 0x00000041, 0x00000000, 0x0800000f, 0x00100012, 0x00000002,
|
|
|
|
0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000002, 0x0800000f, 0x00100022, 0x00000002,
|
|
|
|
0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000002, 0x08000000, 0x00100032, 0x00000005,
|
|
|
|
0x80100046, 0x00000041, 0x00000003, 0x00100046, 0x00000002, 0x06000036, 0x00100042, 0x00000005,
|
|
|
|
0x8010001a, 0x00000041, 0x00000005, 0x0700000f, 0x00100022, 0x00000000, 0x00100a26, 0x00000005,
|
|
|
|
0x00100ae6, 0x00000002, 0x0d000032, 0x00100032, 0x00000002, 0x80100ae6, 0x00000041, 0x00000002,
|
|
|
|
0x00004002, 0x3f000000, 0x3f000000, 0x00000000, 0x00000000, 0x00100046, 0x00000005, 0x0800000e,
|
|
|
|
0x00100032, 0x00000000, 0x80100a26, 0x00000041, 0x00000000, 0x00100556, 0x00000000, 0x0700000f,
|
|
|
|
0x00100012, 0x00000002, 0x00100046, 0x00000000, 0x00100046, 0x00000002, 0x0700000f, 0x00100022,
|
|
|
|
0x00000002, 0x00100046, 0x00000000, 0x00100046, 0x00000005, 0x0800000f, 0x00100012, 0x00000000,
|
|
|
|
0x00208046, 0x00000000, 0x00000002, 0x00100046, 0x00000005, 0x0800000f, 0x00100022, 0x00000000,
|
|
|
|
0x00208046, 0x00000000, 0x00000003, 0x00100046, 0x00000005, 0x0700000f, 0x00100012, 0x00000000,
|
|
|
|
0x00100046, 0x00000000, 0x00100ae6, 0x00000003, 0x07000031, 0x00100022, 0x00000000, 0x00004001,
|
|
|
|
0x00000000, 0x0010000a, 0x00000000, 0x07000031, 0x00100042, 0x00000000, 0x0010000a, 0x00000000,
|
|
|
|
0x00004001, 0x00000000, 0x08000031, 0x00100012, 0x00000000, 0x8010000a, 0x00000081, 0x00000000,
|
|
|
|
0x00004001, 0x3f800000, 0x0800001e, 0x00100022, 0x00000000, 0x8010001a, 0x00000041, 0x00000000,
|
|
|
|
0x0010002a, 0x00000000, 0x0500002b, 0x00100022, 0x00000000, 0x0010001a, 0x00000000, 0x07000038,
|
|
|
|
0x001000c2, 0x00000002, 0x00100ea6, 0x00000003, 0x00100556, 0x00000000, 0x08000036, 0x001000d2,
|
|
|
|
0x00000004, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x09000037, 0x001020f2,
|
|
|
|
0x00000001, 0x00100006, 0x00000000, 0x00100e46, 0x00000004, 0x00100e46, 0x00000002, 0x06000036,
|
|
|
|
0x00100032, 0x00000000, 0x00208046, 0x00000000, 0x00000002, 0x06000036, 0x001000c2, 0x00000000,
|
|
|
|
0x00208406, 0x00000000, 0x00000003, 0x08000038, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
|
|
|
|
0x00208ff6, 0x00000000, 0x00000001, 0x0a000038, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
|
|
|
|
0x00004002, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x05000036, 0x00102032, 0x00000002,
|
|
|
|
0x00100086, 0x00000000, 0x05000036, 0x00102032, 0x00000003, 0x001005d6, 0x00000000, 0x05000036,
|
|
|
|
0x00100042, 0x00000001, 0x00004001, 0x3f800000, 0x08000010, 0x00100012, 0x00000000, 0x00208246,
|
|
|
|
0x00000000, 0x00000002, 0x00100246, 0x00000001, 0x08000010, 0x00100022, 0x00000000, 0x00208246,
|
|
|
|
0x00000000, 0x00000003, 0x00100246, 0x00000001, 0x08000038, 0x00100022, 0x00000001, 0x0010001a,
|
|
|
|
0x00000000, 0x0020803a, 0x00000000, 0x00000003, 0x08000038, 0x00100012, 0x00000001, 0x0010000a,
|
|
|
|
0x00000000, 0x0020803a, 0x00000000, 0x00000002, 0x0a000000, 0x00102032, 0x00000004, 0x00100046,
|
|
|
|
0x00000001, 0x00004002, 0xbf800000, 0x3f800000, 0x00000000, 0x00000000, 0x08000036, 0x001020c2,
|
|
|
|
0x00000004, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e,
|
2017-05-21 17:53:43 +02:00
|
|
|
};
|
2020-03-03 18:59:47 +01:00
|
|
|
/* ⎡p0.x p0.y 1⎤
|
|
|
|
* A = ⎢p1.x p1.y 1⎥
|
|
|
|
* ⎣p2.x p2.y 1⎦
|
|
|
|
*
|
|
|
|
* ⎡1 0⎤
|
|
|
|
* B = ⎢1 1⎥
|
|
|
|
* ⎣0 1⎦
|
|
|
|
*
|
|
|
|
* A' = ⎡p1.x-p0.x p1.y-p0.y⎤
|
|
|
|
* ⎣p2.x-p0.x p2.y-p0.y⎦
|
|
|
|
*
|
|
|
|
* B' = ⎡ 0 1⎤
|
|
|
|
* ⎣-1 1⎦
|
|
|
|
*
|
|
|
|
* A'T = B'
|
|
|
|
* T = A'⁻¹B' = (B'⁻¹A')⁻¹
|
|
|
|
*/
|
|
|
|
static const DWORD vs_code_arc_outline[] =
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
float3x2 transform_geometry;
|
|
|
|
float stroke_width;
|
|
|
|
float4 transform_rtx;
|
|
|
|
float4 transform_rty;
|
|
|
|
|
|
|
|
struct output
|
|
|
|
{
|
|
|
|
float2 p : WORLD_POSITION;
|
|
|
|
float4 b : BEZIER;
|
|
|
|
nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM;
|
|
|
|
float4 position : SV_POSITION;
|
|
|
|
};
|
|
|
|
|
|
|
|
void main(float2 position : POSITION, float2 p0 : P0, float2 p1 : P1, float2 p2 : P2,
|
|
|
|
float2 prev : PREV, float2 next : NEXT, out struct output o)
|
|
|
|
{
|
|
|
|
float2 q_prev, q_next, v_p, q_i, p;
|
|
|
|
float2x2 geom, rt, p_inv;
|
|
|
|
float l;
|
|
|
|
float a;
|
|
|
|
float2 bc;
|
|
|
|
|
|
|
|
geom = float2x2(transform_geometry._11_21, transform_geometry._12_22);
|
|
|
|
rt = float2x2(transform_rtx.xy, transform_rty.xy);
|
|
|
|
o.stroke_transform = rt * stroke_width * 0.5f;
|
|
|
|
|
|
|
|
p = mul(geom, position);
|
|
|
|
p0 = mul(geom, p0);
|
|
|
|
p1 = mul(geom, p1);
|
|
|
|
p2 = mul(geom, p2);
|
|
|
|
|
|
|
|
p -= p0;
|
|
|
|
p1 -= p0;
|
|
|
|
p2 -= p0;
|
|
|
|
|
|
|
|
q_prev = normalize(mul(geom, prev));
|
|
|
|
q_next = normalize(mul(geom, next));
|
|
|
|
|
|
|
|
v_p = float2(-q_prev.y, q_prev.x);
|
|
|
|
l = -dot(v_p, q_next) / (1.0f + dot(q_prev, q_next));
|
|
|
|
q_i = l * q_prev + v_p;
|
|
|
|
p += 0.5f * stroke_width * q_i;
|
|
|
|
|
|
|
|
p_inv = float2x2(p1.y, -p1.x, p2.y - p1.y, p1.x - p2.x) / (p1.x * p2.y - p2.x * p1.y);
|
|
|
|
o.b.xy = mul(p_inv, p) + float2(1.0f, 0.0f);
|
|
|
|
o.b.zw = 0.0f;
|
|
|
|
|
|
|
|
o.p = mul(float3(position, 1.0f), transform_geometry) + 0.5f * stroke_width * q_i;
|
|
|
|
position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f))
|
|
|
|
* float2(transform_rtx.w, transform_rty.w);
|
|
|
|
o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
0x43425844, 0xde1911bf, 0xfff8c893, 0xb0bfc24d, 0x78c9bbc4, 0x00000001, 0x00000924, 0x00000003,
|
|
|
|
0x0000002c, 0x000000e4, 0x000001a0, 0x4e475349, 0x000000b0, 0x00000006, 0x00000008, 0x00000098,
|
|
|
|
0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000303, 0x000000a1, 0x00000000, 0x00000000,
|
|
|
|
0x00000003, 0x00000001, 0x00000303, 0x000000a1, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
|
|
|
|
0x00000303, 0x000000a1, 0x00000002, 0x00000000, 0x00000003, 0x00000003, 0x00000303, 0x000000a3,
|
|
|
|
0x00000000, 0x00000000, 0x00000003, 0x00000004, 0x00000303, 0x000000a8, 0x00000000, 0x00000000,
|
|
|
|
0x00000003, 0x00000005, 0x00000303, 0x49534f50, 0x4e4f4954, 0x50005000, 0x00564552, 0x5458454e,
|
|
|
|
0xababab00, 0x4e47534f, 0x000000b4, 0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000000,
|
|
|
|
0x00000003, 0x00000000, 0x00000c03, 0x0000008f, 0x00000000, 0x00000000, 0x00000003, 0x00000001,
|
|
|
|
0x0000000f, 0x00000096, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000c03, 0x00000096,
|
|
|
|
0x00000001, 0x00000000, 0x00000003, 0x00000003, 0x00000c03, 0x000000a7, 0x00000000, 0x00000001,
|
|
|
|
0x00000003, 0x00000004, 0x0000000f, 0x4c524f57, 0x4f505f44, 0x49544953, 0x42004e4f, 0x45495a45,
|
|
|
|
0x54530052, 0x454b4f52, 0x4152545f, 0x4f46534e, 0x53004d52, 0x4f505f56, 0x49544953, 0xab004e4f,
|
|
|
|
0x52444853, 0x0000077c, 0x00010040, 0x000001df, 0x04000059, 0x00208e46, 0x00000000, 0x00000004,
|
|
|
|
0x0300005f, 0x00101032, 0x00000000, 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x00101032,
|
|
|
|
0x00000002, 0x0300005f, 0x00101032, 0x00000003, 0x0300005f, 0x00101032, 0x00000004, 0x0300005f,
|
|
|
|
0x00101032, 0x00000005, 0x03000065, 0x00102032, 0x00000000, 0x03000065, 0x001020f2, 0x00000001,
|
|
|
|
0x03000065, 0x00102032, 0x00000002, 0x03000065, 0x00102032, 0x00000003, 0x04000067, 0x001020f2,
|
|
|
|
0x00000004, 0x00000001, 0x02000068, 0x00000004, 0x0800000f, 0x00100012, 0x00000000, 0x00208046,
|
|
|
|
0x00000000, 0x00000000, 0x00101046, 0x00000005, 0x0800000f, 0x00100022, 0x00000000, 0x00208046,
|
|
|
|
0x00000000, 0x00000001, 0x00101046, 0x00000005, 0x0700000f, 0x00100042, 0x00000000, 0x00100046,
|
|
|
|
0x00000000, 0x00100046, 0x00000000, 0x05000044, 0x00100042, 0x00000000, 0x0010002a, 0x00000000,
|
|
|
|
0x07000038, 0x00100032, 0x00000000, 0x00100aa6, 0x00000000, 0x00100046, 0x00000000, 0x0800000f,
|
|
|
|
0x00100012, 0x00000001, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000004, 0x0800000f,
|
|
|
|
0x00100022, 0x00000001, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000004, 0x0700000f,
|
|
|
|
0x00100042, 0x00000000, 0x00100046, 0x00000001, 0x00100046, 0x00000001, 0x05000044, 0x00100042,
|
|
|
|
0x00000000, 0x0010002a, 0x00000000, 0x07000038, 0x00100032, 0x00000001, 0x00100aa6, 0x00000000,
|
|
|
|
0x00100046, 0x00000001, 0x06000036, 0x001000c2, 0x00000001, 0x80100556, 0x00000041, 0x00000001,
|
|
|
|
0x0700000f, 0x00100042, 0x00000000, 0x00100a26, 0x00000001, 0x00100046, 0x00000000, 0x0700000f,
|
|
|
|
0x00100012, 0x00000000, 0x00100046, 0x00000001, 0x00100046, 0x00000000, 0x07000000, 0x00100012,
|
|
|
|
0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x3f800000, 0x0800000e, 0x00100012, 0x00000000,
|
|
|
|
0x8010002a, 0x00000041, 0x00000000, 0x0010000a, 0x00000000, 0x09000032, 0x00100032, 0x00000000,
|
|
|
|
0x00100006, 0x00000000, 0x00100046, 0x00000001, 0x00100f36, 0x00000001, 0x05000036, 0x00100032,
|
|
|
|
0x00000001, 0x00101046, 0x00000000, 0x05000036, 0x00100042, 0x00000001, 0x00004001, 0x3f800000,
|
|
|
|
0x08000010, 0x00100012, 0x00000002, 0x00100246, 0x00000001, 0x00208246, 0x00000000, 0x00000000,
|
|
|
|
0x08000010, 0x00100022, 0x00000002, 0x00100246, 0x00000001, 0x00208246, 0x00000000, 0x00000001,
|
|
|
|
0x08000038, 0x00100042, 0x00000000, 0x0020803a, 0x00000000, 0x00000001, 0x00004001, 0x3f000000,
|
|
|
|
0x09000032, 0x00100032, 0x00000001, 0x00100aa6, 0x00000000, 0x00100046, 0x00000000, 0x00100046,
|
|
|
|
0x00000002, 0x05000036, 0x00102032, 0x00000000, 0x00100046, 0x00000001, 0x0800000f, 0x00100012,
|
|
|
|
0x00000002, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000000, 0x0800000f, 0x00100022,
|
|
|
|
0x00000002, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000000, 0x0800000f, 0x00100022,
|
|
|
|
0x00000003, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000001, 0x0800000f, 0x00100012,
|
|
|
|
0x00000003, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000001, 0x08000000, 0x00100032,
|
|
|
|
0x00000002, 0x00100046, 0x00000002, 0x80100516, 0x00000041, 0x00000003, 0x09000032, 0x00100032,
|
|
|
|
0x00000000, 0x00100aa6, 0x00000000, 0x00100046, 0x00000000, 0x00100046, 0x00000002, 0x0800000f,
|
|
|
|
0x00100022, 0x00000002, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000003, 0x0800000f,
|
|
|
|
0x00100012, 0x00000002, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000003, 0x08000000,
|
|
|
|
0x001000c2, 0x00000000, 0x80100406, 0x00000041, 0x00000003, 0x00100406, 0x00000002, 0x0800000f,
|
|
|
|
0x00100022, 0x00000002, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000002, 0x0800000f,
|
|
|
|
0x00100012, 0x00000002, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000002, 0x08000000,
|
|
|
|
0x00100032, 0x00000002, 0x80100046, 0x00000041, 0x00000003, 0x00100046, 0x00000002, 0x07000038,
|
|
|
|
0x00100082, 0x00000001, 0x0010003a, 0x00000000, 0x0010000a, 0x00000002, 0x0a000032, 0x00100082,
|
|
|
|
0x00000001, 0x0010001a, 0x00000002, 0x0010002a, 0x00000000, 0x8010003a, 0x00000041, 0x00000001,
|
|
|
|
0x08000000, 0x00100042, 0x00000003, 0x0010002a, 0x00000000, 0x8010000a, 0x00000041, 0x00000002,
|
|
|
|
0x08000000, 0x00100082, 0x00000003, 0x8010003a, 0x00000041, 0x00000000, 0x0010001a, 0x00000002,
|
|
|
|
0x0a000038, 0x00100032, 0x00000003, 0x00100046, 0x00000002, 0x00004002, 0x3f800000, 0xbf800000,
|
|
|
|
0x00000000, 0x00000000, 0x0700000e, 0x001000f2, 0x00000002, 0x00100e46, 0x00000003, 0x00100ff6,
|
|
|
|
0x00000001, 0x0700000f, 0x00100012, 0x00000002, 0x00100046, 0x00000002, 0x00100046, 0x00000000,
|
|
|
|
0x0700000f, 0x00100022, 0x00000002, 0x00100ae6, 0x00000002, 0x00100046, 0x00000000, 0x0a000000,
|
|
|
|
0x00102032, 0x00000001, 0x00100046, 0x00000002, 0x00004002, 0x3f800000, 0x00000000, 0x00000000,
|
|
|
|
0x00000000, 0x08000036, 0x001020c2, 0x00000001, 0x00004002, 0x00000000, 0x00000000, 0x00000000,
|
|
|
|
0x00000000, 0x06000036, 0x00100032, 0x00000000, 0x00208046, 0x00000000, 0x00000002, 0x06000036,
|
|
|
|
0x001000c2, 0x00000000, 0x00208406, 0x00000000, 0x00000003, 0x08000038, 0x001000f2, 0x00000000,
|
|
|
|
0x00100e46, 0x00000000, 0x00208ff6, 0x00000000, 0x00000001, 0x0a000038, 0x001000f2, 0x00000000,
|
|
|
|
0x00100e46, 0x00000000, 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x05000036,
|
|
|
|
0x00102032, 0x00000002, 0x00100086, 0x00000000, 0x05000036, 0x00102032, 0x00000003, 0x001005d6,
|
|
|
|
0x00000000, 0x05000036, 0x00100042, 0x00000001, 0x00004001, 0x3f800000, 0x08000010, 0x00100012,
|
|
|
|
0x00000000, 0x00208246, 0x00000000, 0x00000002, 0x00100246, 0x00000001, 0x08000010, 0x00100022,
|
|
|
|
0x00000000, 0x00208246, 0x00000000, 0x00000003, 0x00100246, 0x00000001, 0x08000038, 0x00100022,
|
|
|
|
0x00000001, 0x0010001a, 0x00000000, 0x0020803a, 0x00000000, 0x00000003, 0x08000038, 0x00100012,
|
|
|
|
0x00000001, 0x0010000a, 0x00000000, 0x0020803a, 0x00000000, 0x00000002, 0x0a000000, 0x00102032,
|
|
|
|
0x00000004, 0x00100046, 0x00000001, 0x00004002, 0xbf800000, 0x3f800000, 0x00000000, 0x00000000,
|
|
|
|
0x08000036, 0x001020c2, 0x00000004, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000,
|
|
|
|
0x0100003e,
|
|
|
|
};
|
2017-09-23 13:36:59 +02:00
|
|
|
static const DWORD vs_code_triangle[] =
|
|
|
|
{
|
|
|
|
#if 0
|
2017-09-23 13:37:01 +02:00
|
|
|
float3x2 transform_geometry;
|
|
|
|
float4 transform_rtx;
|
|
|
|
float4 transform_rty;
|
2017-09-23 13:36:59 +02:00
|
|
|
|
2017-09-23 13:37:00 +02:00
|
|
|
struct output
|
|
|
|
{
|
2017-09-23 13:37:01 +02:00
|
|
|
float2 p : WORLD_POSITION;
|
2017-09-23 13:37:00 +02:00
|
|
|
float4 b : BEZIER;
|
|
|
|
nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM;
|
2017-09-23 13:37:01 +02:00
|
|
|
float4 position : SV_POSITION;
|
2017-09-23 13:37:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
void main(float2 position : POSITION, out struct output o)
|
2017-09-23 13:36:59 +02:00
|
|
|
{
|
2017-09-23 13:37:01 +02:00
|
|
|
o.p = mul(float3(position, 1.0f), transform_geometry);
|
2017-09-23 13:37:00 +02:00
|
|
|
o.b = float4(1.0, 0.0, 1.0, 1.0);
|
|
|
|
o.stroke_transform = float2x2(1.0, 0.0, 0.0, 1.0);
|
2017-09-23 13:37:01 +02:00
|
|
|
position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f))
|
|
|
|
* float2(transform_rtx.w, transform_rty.w);
|
|
|
|
o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f);
|
2017-09-23 13:36:59 +02:00
|
|
|
}
|
|
|
|
#endif
|
2017-09-23 13:37:01 +02:00
|
|
|
0x43425844, 0xda43bf17, 0x06e6d155, 0xdbce2ae5, 0x8aed6fd8, 0x00000001, 0x0000034c, 0x00000003,
|
|
|
|
0x0000002c, 0x00000060, 0x0000011c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
|
2017-09-23 13:37:00 +02:00
|
|
|
0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000303, 0x49534f50, 0x4e4f4954, 0xababab00,
|
2017-09-23 13:37:01 +02:00
|
|
|
0x4e47534f, 0x000000b4, 0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000000, 0x00000003,
|
|
|
|
0x00000000, 0x00000c03, 0x0000008f, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
|
|
|
|
0x00000096, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000c03, 0x00000096, 0x00000001,
|
|
|
|
0x00000000, 0x00000003, 0x00000003, 0x00000c03, 0x000000a7, 0x00000000, 0x00000001, 0x00000003,
|
|
|
|
0x00000004, 0x0000000f, 0x4c524f57, 0x4f505f44, 0x49544953, 0x42004e4f, 0x45495a45, 0x54530052,
|
|
|
|
0x454b4f52, 0x4152545f, 0x4f46534e, 0x53004d52, 0x4f505f56, 0x49544953, 0xab004e4f, 0x52444853,
|
|
|
|
0x00000228, 0x00010040, 0x0000008a, 0x04000059, 0x00208e46, 0x00000000, 0x00000004, 0x0300005f,
|
|
|
|
0x00101032, 0x00000000, 0x03000065, 0x00102032, 0x00000000, 0x03000065, 0x001020f2, 0x00000001,
|
|
|
|
0x03000065, 0x00102032, 0x00000002, 0x03000065, 0x00102032, 0x00000003, 0x04000067, 0x001020f2,
|
|
|
|
0x00000004, 0x00000001, 0x02000068, 0x00000002, 0x05000036, 0x00100032, 0x00000000, 0x00101046,
|
|
|
|
0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x3f800000, 0x08000010, 0x00100012,
|
|
|
|
0x00000001, 0x00100246, 0x00000000, 0x00208246, 0x00000000, 0x00000000, 0x08000010, 0x00100022,
|
|
|
|
0x00000001, 0x00100246, 0x00000000, 0x00208246, 0x00000000, 0x00000001, 0x05000036, 0x00102032,
|
|
|
|
0x00000000, 0x00100046, 0x00000001, 0x08000036, 0x001020f2, 0x00000001, 0x00004002, 0x3f800000,
|
|
|
|
0x00000000, 0x3f800000, 0x3f800000, 0x08000036, 0x00102032, 0x00000002, 0x00004002, 0x3f800000,
|
|
|
|
0x00000000, 0x00000000, 0x00000000, 0x08000036, 0x00102032, 0x00000003, 0x00004002, 0x00000000,
|
|
|
|
0x3f800000, 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000001, 0x00004001, 0x3f800000,
|
|
|
|
0x08000010, 0x00100012, 0x00000000, 0x00208246, 0x00000000, 0x00000002, 0x00100246, 0x00000001,
|
|
|
|
0x08000010, 0x00100022, 0x00000000, 0x00208246, 0x00000000, 0x00000003, 0x00100246, 0x00000001,
|
|
|
|
0x08000038, 0x00100022, 0x00000001, 0x0010001a, 0x00000000, 0x0020803a, 0x00000000, 0x00000003,
|
|
|
|
0x08000038, 0x00100012, 0x00000001, 0x0010000a, 0x00000000, 0x0020803a, 0x00000000, 0x00000002,
|
|
|
|
0x0a000000, 0x00102032, 0x00000004, 0x00100046, 0x00000001, 0x00004002, 0xbf800000, 0x3f800000,
|
|
|
|
0x00000000, 0x00000000, 0x08000036, 0x001020c2, 0x00000004, 0x00004002, 0x00000000, 0x00000000,
|
|
|
|
0x00000000, 0x3f800000, 0x0100003e,
|
2017-09-23 13:36:59 +02:00
|
|
|
};
|
2020-03-03 18:59:46 +01:00
|
|
|
static const DWORD vs_code_curve[] =
|
2015-07-20 11:07:28 +02:00
|
|
|
{
|
|
|
|
#if 0
|
2017-09-23 13:37:01 +02:00
|
|
|
float3x2 transform_geometry;
|
|
|
|
float4 transform_rtx;
|
|
|
|
float4 transform_rty;
|
2015-07-20 11:07:28 +02:00
|
|
|
|
2017-09-23 13:37:00 +02:00
|
|
|
struct output
|
|
|
|
{
|
2017-09-23 13:37:01 +02:00
|
|
|
float2 p : WORLD_POSITION;
|
2017-09-23 13:37:00 +02:00
|
|
|
float4 b : BEZIER;
|
|
|
|
nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM;
|
2017-09-23 13:37:01 +02:00
|
|
|
float4 position : SV_POSITION;
|
2017-09-23 13:37:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
void main(float2 position : POSITION, float3 texcoord : TEXCOORD0, out struct output o)
|
2015-07-20 11:07:28 +02:00
|
|
|
{
|
2017-09-23 13:37:01 +02:00
|
|
|
o.p = mul(float3(position, 1.0f), transform_geometry);
|
2017-09-23 13:37:00 +02:00
|
|
|
o.b = float4(texcoord, 1.0);
|
|
|
|
o.stroke_transform = float2x2(1.0, 0.0, 0.0, 1.0);
|
2017-09-23 13:37:01 +02:00
|
|
|
position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f))
|
|
|
|
* float2(transform_rtx.w, transform_rty.w);
|
|
|
|
o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f);
|
2015-07-20 11:07:28 +02:00
|
|
|
}
|
|
|
|
#endif
|
2017-09-23 13:37:01 +02:00
|
|
|
0x43425844, 0xedb7472a, 0x2c2ea147, 0x36710079, 0xffc2e907, 0x00000001, 0x00000380, 0x00000003,
|
|
|
|
0x0000002c, 0x00000080, 0x0000013c, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
|
2017-09-23 13:37:00 +02:00
|
|
|
0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000303, 0x00000041, 0x00000000, 0x00000000,
|
2015-07-20 11:07:28 +02:00
|
|
|
0x00000003, 0x00000001, 0x00000707, 0x49534f50, 0x4e4f4954, 0x58455400, 0x524f4f43, 0xabab0044,
|
2017-09-23 13:37:01 +02:00
|
|
|
0x4e47534f, 0x000000b4, 0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000000, 0x00000003,
|
|
|
|
0x00000000, 0x00000c03, 0x0000008f, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
|
|
|
|
0x00000096, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000c03, 0x00000096, 0x00000001,
|
|
|
|
0x00000000, 0x00000003, 0x00000003, 0x00000c03, 0x000000a7, 0x00000000, 0x00000001, 0x00000003,
|
|
|
|
0x00000004, 0x0000000f, 0x4c524f57, 0x4f505f44, 0x49544953, 0x42004e4f, 0x45495a45, 0x54530052,
|
|
|
|
0x454b4f52, 0x4152545f, 0x4f46534e, 0x53004d52, 0x4f505f56, 0x49544953, 0xab004e4f, 0x52444853,
|
|
|
|
0x0000023c, 0x00010040, 0x0000008f, 0x04000059, 0x00208e46, 0x00000000, 0x00000004, 0x0300005f,
|
|
|
|
0x00101032, 0x00000000, 0x0300005f, 0x00101072, 0x00000001, 0x03000065, 0x00102032, 0x00000000,
|
|
|
|
0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x00102032, 0x00000002, 0x03000065, 0x00102032,
|
|
|
|
0x00000003, 0x04000067, 0x001020f2, 0x00000004, 0x00000001, 0x02000068, 0x00000002, 0x05000036,
|
|
|
|
0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x00004001,
|
|
|
|
0x3f800000, 0x08000010, 0x00100012, 0x00000001, 0x00100246, 0x00000000, 0x00208246, 0x00000000,
|
|
|
|
0x00000000, 0x08000010, 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00208246, 0x00000000,
|
|
|
|
0x00000001, 0x05000036, 0x00102032, 0x00000000, 0x00100046, 0x00000001, 0x05000036, 0x00102072,
|
|
|
|
0x00000001, 0x00101246, 0x00000001, 0x05000036, 0x00102082, 0x00000001, 0x00004001, 0x3f800000,
|
|
|
|
0x08000036, 0x00102032, 0x00000002, 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x00000000,
|
|
|
|
0x08000036, 0x00102032, 0x00000003, 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x00000000,
|
|
|
|
0x05000036, 0x00100042, 0x00000001, 0x00004001, 0x3f800000, 0x08000010, 0x00100012, 0x00000000,
|
|
|
|
0x00208246, 0x00000000, 0x00000002, 0x00100246, 0x00000001, 0x08000010, 0x00100022, 0x00000000,
|
|
|
|
0x00208246, 0x00000000, 0x00000003, 0x00100246, 0x00000001, 0x08000038, 0x00100022, 0x00000001,
|
|
|
|
0x0010001a, 0x00000000, 0x0020803a, 0x00000000, 0x00000003, 0x08000038, 0x00100012, 0x00000001,
|
|
|
|
0x0010000a, 0x00000000, 0x0020803a, 0x00000000, 0x00000002, 0x0a000000, 0x00102032, 0x00000004,
|
|
|
|
0x00100046, 0x00000001, 0x00004002, 0xbf800000, 0x3f800000, 0x00000000, 0x00000000, 0x08000036,
|
|
|
|
0x001020c2, 0x00000004, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e,
|
2015-07-20 11:07:28 +02:00
|
|
|
};
|
2017-09-23 13:37:00 +02:00
|
|
|
static const DWORD ps_code[] =
|
2015-11-18 22:23:22 +01:00
|
|
|
{
|
|
|
|
#if 0
|
2017-09-23 13:36:59 +02:00
|
|
|
#define BRUSH_TYPE_SOLID 0
|
|
|
|
#define BRUSH_TYPE_LINEAR 1
|
2017-09-26 12:22:40 +02:00
|
|
|
#define BRUSH_TYPE_RADIAL 2
|
|
|
|
#define BRUSH_TYPE_BITMAP 3
|
|
|
|
#define BRUSH_TYPE_COUNT 4
|
2015-11-18 22:23:22 +01:00
|
|
|
|
2017-09-23 13:37:00 +02:00
|
|
|
bool outline;
|
2020-03-03 18:59:46 +01:00
|
|
|
bool is_arc;
|
2017-09-23 13:36:59 +02:00
|
|
|
struct brush
|
|
|
|
{
|
|
|
|
uint type;
|
|
|
|
float opacity;
|
2017-09-28 13:14:18 +02:00
|
|
|
float4 data[3];
|
2017-09-23 13:36:59 +02:00
|
|
|
} colour_brush, opacity_brush;
|
2015-11-18 22:23:22 +01:00
|
|
|
|
2017-09-23 13:36:59 +02:00
|
|
|
SamplerState s0, s1;
|
|
|
|
Texture2D t0, t1;
|
2017-09-26 12:22:39 +02:00
|
|
|
Buffer<float4> b0, b1;
|
2015-11-18 22:23:22 +01:00
|
|
|
|
2017-09-23 13:37:00 +02:00
|
|
|
struct input
|
|
|
|
{
|
2017-09-23 13:37:01 +02:00
|
|
|
float2 p : WORLD_POSITION;
|
2017-09-23 13:37:00 +02:00
|
|
|
float4 b : BEZIER;
|
|
|
|
nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM;
|
|
|
|
};
|
|
|
|
|
2017-09-28 13:14:18 +02:00
|
|
|
float4 sample_gradient(Buffer<float4> gradient, uint stop_count, float position)
|
2017-09-26 12:22:39 +02:00
|
|
|
{
|
|
|
|
float4 c_low, c_high;
|
2017-09-28 13:14:18 +02:00
|
|
|
float p_low, p_high;
|
|
|
|
uint i;
|
2017-09-26 12:22:39 +02:00
|
|
|
|
2017-09-28 13:14:18 +02:00
|
|
|
p_low = gradient.Load(0).x;
|
|
|
|
c_low = gradient.Load(1);
|
2017-09-26 12:22:39 +02:00
|
|
|
c_high = c_low;
|
|
|
|
|
2017-09-28 13:14:18 +02:00
|
|
|
if (position < p_low)
|
2017-09-26 12:22:39 +02:00
|
|
|
return c_low;
|
|
|
|
|
|
|
|
for (i = 1; i < stop_count; ++i)
|
|
|
|
{
|
2017-09-28 13:14:18 +02:00
|
|
|
p_high = gradient.Load(i * 2).x;
|
|
|
|
c_high = gradient.Load(i * 2 + 1);
|
2017-09-26 12:22:39 +02:00
|
|
|
|
2017-09-28 13:14:18 +02:00
|
|
|
if (position >= p_low && position <= p_high)
|
|
|
|
return lerp(c_low, c_high, (position - p_low) / (p_high - p_low));
|
2017-09-26 12:22:39 +02:00
|
|
|
|
|
|
|
p_low = p_high;
|
|
|
|
c_low = c_high;
|
|
|
|
}
|
|
|
|
|
|
|
|
return c_high;
|
|
|
|
}
|
|
|
|
|
2017-09-28 13:14:18 +02:00
|
|
|
float4 brush_linear(struct brush brush, Buffer<float4> gradient, float2 position)
|
|
|
|
{
|
|
|
|
float2 start, end, v_p, v_q;
|
|
|
|
uint stop_count;
|
|
|
|
float p;
|
|
|
|
|
|
|
|
start = brush.data[0].xy;
|
|
|
|
end = brush.data[0].zw;
|
|
|
|
stop_count = asuint(brush.data[1].x);
|
|
|
|
|
|
|
|
v_p = position - start;
|
|
|
|
v_q = end - start;
|
|
|
|
p = dot(v_q, v_p) / dot(v_q, v_q);
|
|
|
|
|
|
|
|
return sample_gradient(gradient, stop_count, p);
|
|
|
|
}
|
|
|
|
|
|
|
|
float4 brush_radial(struct brush brush, Buffer<float4> gradient, float2 position)
|
|
|
|
{
|
|
|
|
float2 centre, offset, ra, rb, v_p, v_q, r;
|
|
|
|
float b, c, l, t;
|
|
|
|
uint stop_count;
|
|
|
|
|
|
|
|
centre = brush.data[0].xy;
|
|
|
|
offset = brush.data[0].zw;
|
|
|
|
ra = brush.data[1].xy;
|
|
|
|
rb = brush.data[1].zw;
|
|
|
|
stop_count = asuint(brush.data[2].x);
|
|
|
|
|
|
|
|
/* Project onto ra, rb. */
|
|
|
|
r = float2(dot(ra, ra), dot(rb, rb));
|
|
|
|
v_p = position - (centre + offset);
|
|
|
|
v_p = float2(dot(v_p, ra), dot(v_p, rb)) / r;
|
|
|
|
v_q = float2(dot(offset, ra), dot(offset, rb)) / r;
|
|
|
|
|
|
|
|
/* ‖t·p̂ + q⃑‖ = 1
|
|
|
|
* (t·p̂ + q⃑) · (t·p̂ + q⃑) = 1
|
|
|
|
* t² + 2·(p̂·q⃑)·t + (q⃑·q⃑) = 1
|
|
|
|
*
|
|
|
|
* b = p̂·q⃑
|
|
|
|
* c = q⃑·q⃑ - 1
|
|
|
|
* t = -b + √(b² - c) */
|
|
|
|
l = length(v_p);
|
|
|
|
b = dot(v_p, v_q) / l;
|
|
|
|
c = dot(v_q, v_q) - 1.0;
|
|
|
|
t = -b + sqrt(b * b - c);
|
|
|
|
|
|
|
|
return sample_gradient(gradient, stop_count, l / t);
|
|
|
|
}
|
|
|
|
|
2017-09-23 13:36:59 +02:00
|
|
|
float4 brush_bitmap(struct brush brush, Texture2D t, SamplerState s, float2 position)
|
2015-11-18 22:23:22 +01:00
|
|
|
{
|
2017-09-23 13:36:59 +02:00
|
|
|
float3 transform[2];
|
|
|
|
bool ignore_alpha;
|
2015-11-18 22:23:22 +01:00
|
|
|
float2 texcoord;
|
2017-09-23 13:36:59 +02:00
|
|
|
float4 colour;
|
2015-11-18 22:23:22 +01:00
|
|
|
|
2017-09-23 13:36:59 +02:00
|
|
|
transform[0] = brush.data[0].xyz;
|
|
|
|
transform[1] = brush.data[1].xyz;
|
|
|
|
ignore_alpha = asuint(brush.data[1].w);
|
2015-11-18 22:23:22 +01:00
|
|
|
|
2017-09-23 13:36:59 +02:00
|
|
|
texcoord.x = dot(position.xy, transform[0].xy) + transform[0].z;
|
|
|
|
texcoord.y = dot(position.xy, transform[1].xy) + transform[1].z;
|
|
|
|
colour = t.Sample(s, texcoord);
|
|
|
|
if (ignore_alpha)
|
|
|
|
colour.a = 1.0;
|
|
|
|
return colour;
|
2015-11-18 22:23:22 +01:00
|
|
|
}
|
2015-02-06 09:57:01 +01:00
|
|
|
|
2017-09-26 12:22:39 +02:00
|
|
|
float4 sample_brush(struct brush brush, Texture2D t, SamplerState s, Buffer<float4> b, float2 position)
|
2015-02-06 09:57:01 +01:00
|
|
|
{
|
2017-09-23 13:36:59 +02:00
|
|
|
if (brush.type == BRUSH_TYPE_SOLID)
|
|
|
|
return brush.data[0] * brush.opacity;
|
2017-09-26 12:22:39 +02:00
|
|
|
if (brush.type == BRUSH_TYPE_LINEAR)
|
|
|
|
return brush_linear(brush, b, position) * brush.opacity;
|
2017-09-28 13:14:18 +02:00
|
|
|
if (brush.type == BRUSH_TYPE_RADIAL)
|
|
|
|
return brush_radial(brush, b, position) * brush.opacity;
|
2017-09-23 13:36:59 +02:00
|
|
|
if (brush.type == BRUSH_TYPE_BITMAP)
|
|
|
|
return brush_bitmap(brush, t, s, position) * brush.opacity;
|
|
|
|
return float4(0.0, 0.0, 0.0, brush.opacity);
|
2015-02-06 09:57:01 +01:00
|
|
|
}
|
2015-11-18 16:10:23 +01:00
|
|
|
|
2017-09-23 13:37:00 +02:00
|
|
|
float4 main(struct input i) : SV_Target
|
2015-11-18 16:10:23 +01:00
|
|
|
{
|
2017-09-23 13:36:59 +02:00
|
|
|
float4 colour;
|
2015-11-18 16:10:23 +01:00
|
|
|
|
2017-09-26 12:22:39 +02:00
|
|
|
colour = sample_brush(colour_brush, t0, s0, b0, i.p);
|
2017-09-23 13:36:59 +02:00
|
|
|
if (opacity_brush.type < BRUSH_TYPE_COUNT)
|
2017-09-26 12:22:39 +02:00
|
|
|
colour *= sample_brush(opacity_brush, t1, s1, b1, i.p).a;
|
2017-09-23 13:36:59 +02:00
|
|
|
|
2017-09-23 13:37:00 +02:00
|
|
|
if (outline)
|
|
|
|
{
|
|
|
|
float2 du, dv, df;
|
|
|
|
float4 uv;
|
|
|
|
|
2020-03-03 18:59:47 +01:00
|
|
|
/* Evaluate the implicit form of the curve (u² - v = 0
|
|
|
|
* for Béziers, u² + v² - 1 = 0 for arcs) in texture
|
|
|
|
* space, using the screen-space partial derivatives
|
|
|
|
* to convert the calculated distance to object space.
|
2017-09-23 13:37:00 +02:00
|
|
|
*
|
|
|
|
* d(x, y) = |f(x, y)| / ‖∇f(x, y)‖
|
|
|
|
* = |f(x, y)| / √((∂f/∂x)² + (∂f/∂y)²)
|
2020-03-03 18:59:47 +01:00
|
|
|
*
|
|
|
|
* For Béziers:
|
2017-09-23 13:37:00 +02:00
|
|
|
* f(x, y) = u(x, y)² - v(x, y)
|
|
|
|
* ∂f/∂x = 2u · ∂u/∂x - ∂v/∂x
|
2020-03-03 18:59:47 +01:00
|
|
|
* ∂f/∂y = 2u · ∂u/∂y - ∂v/∂y
|
|
|
|
*
|
|
|
|
* For arcs:
|
|
|
|
* f(x, y) = u(x, y)² + v(x, y)² - 1
|
|
|
|
* ∂f/∂x = 2u · ∂u/∂x + 2v · ∂v/∂x
|
|
|
|
* ∂f/∂y = 2u · ∂u/∂y + 2v · ∂v/∂y */
|
2017-09-23 13:37:00 +02:00
|
|
|
uv = i.b;
|
|
|
|
du = float2(ddx(uv.x), ddy(uv.x));
|
|
|
|
dv = float2(ddx(uv.y), ddy(uv.y));
|
|
|
|
|
2020-03-03 18:59:47 +01:00
|
|
|
if (!is_arc)
|
|
|
|
{
|
|
|
|
df = 2.0f * uv.x * du - dv;
|
|
|
|
|
|
|
|
clip(dot(df, uv.zw));
|
|
|
|
clip(length(mul(i.stroke_transform, df)) - abs(uv.x * uv.x - uv.y));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
df = 2.0f * uv.x * du + 2.0f * uv.y * dv;
|
|
|
|
|
|
|
|
clip(dot(df, uv.zw));
|
|
|
|
clip(length(mul(i.stroke_transform, df)) - abs(uv.x * uv.x + uv.y * uv.y - 1.0f));
|
|
|
|
}
|
2017-09-23 13:37:00 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Evaluate the implicit form of the curve in texture space.
|
|
|
|
* "i.b.z" determines which side of the curve is shaded. */
|
2020-03-03 18:59:46 +01:00
|
|
|
if (!is_arc)
|
|
|
|
{
|
|
|
|
clip((i.b.x * i.b.x - i.b.y) * i.b.z);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
clip((i.b.x * i.b.x + i.b.y * i.b.y - 1.0) * i.b.z);
|
|
|
|
}
|
2017-09-23 13:37:00 +02:00
|
|
|
}
|
2015-11-18 16:10:23 +01:00
|
|
|
|
2017-09-23 13:36:59 +02:00
|
|
|
return colour;
|
2015-11-18 16:10:23 +01:00
|
|
|
}
|
|
|
|
#endif
|
2020-03-03 18:59:47 +01:00
|
|
|
0x43425844, 0xa8fee730, 0x92fa2196, 0xaf9f3eff, 0x888d4048, 0x00000001, 0x00002000, 0x00000003,
|
2017-09-23 13:37:01 +02:00
|
|
|
0x0000002c, 0x000000c4, 0x000000f8, 0x4e475349, 0x00000090, 0x00000004, 0x00000008, 0x00000068,
|
|
|
|
0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000303, 0x00000077, 0x00000000, 0x00000000,
|
|
|
|
0x00000003, 0x00000001, 0x00000f0f, 0x0000007e, 0x00000000, 0x00000000, 0x00000003, 0x00000002,
|
|
|
|
0x00000303, 0x0000007e, 0x00000001, 0x00000000, 0x00000003, 0x00000003, 0x00000303, 0x4c524f57,
|
|
|
|
0x4f505f44, 0x49544953, 0x42004e4f, 0x45495a45, 0x54530052, 0x454b4f52, 0x4152545f, 0x4f46534e,
|
|
|
|
0xab004d52, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
|
2020-03-03 18:59:47 +01:00
|
|
|
0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00001f00,
|
|
|
|
0x00000040, 0x000007c0, 0x04000059, 0x00208e46, 0x00000000, 0x00000009, 0x0300005a, 0x00106000,
|
2017-09-23 13:37:01 +02:00
|
|
|
0x00000000, 0x0300005a, 0x00106000, 0x00000001, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
|
2017-09-26 12:22:39 +02:00
|
|
|
0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x04000858, 0x00107000, 0x00000002, 0x00005555,
|
|
|
|
0x04000858, 0x00107000, 0x00000003, 0x00005555, 0x03001062, 0x00101032, 0x00000000, 0x03001062,
|
2017-09-23 13:37:00 +02:00
|
|
|
0x001010f2, 0x00000001, 0x03000862, 0x00101032, 0x00000002, 0x03000862, 0x00101032, 0x00000003,
|
2017-09-26 12:22:39 +02:00
|
|
|
0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x0000000a, 0x09000038, 0x001000f2, 0x00000000,
|
2017-09-23 13:37:00 +02:00
|
|
|
0x00208556, 0x00000000, 0x00000001, 0x00208e46, 0x00000000, 0x00000002, 0x0404001f, 0x0020800a,
|
|
|
|
0x00000000, 0x00000001, 0x08000020, 0x00100012, 0x00000001, 0x0020800a, 0x00000000, 0x00000001,
|
2017-09-26 12:22:39 +02:00
|
|
|
0x00004001, 0x00000001, 0x0304001f, 0x0010000a, 0x00000001, 0x09000000, 0x00100062, 0x00000001,
|
|
|
|
0x00101106, 0x00000000, 0x80208106, 0x00000041, 0x00000000, 0x00000002, 0x0a000000, 0x00100032,
|
|
|
|
0x00000002, 0x80208046, 0x00000041, 0x00000000, 0x00000002, 0x00208ae6, 0x00000000, 0x00000002,
|
|
|
|
0x0700000f, 0x00100022, 0x00000001, 0x00100046, 0x00000002, 0x00100596, 0x00000001, 0x0700000f,
|
|
|
|
0x00100042, 0x00000001, 0x00100046, 0x00000002, 0x00100046, 0x00000002, 0x0700000e, 0x00100022,
|
|
|
|
0x00000001, 0x0010001a, 0x00000001, 0x0010002a, 0x00000001, 0x0a00002d, 0x001000f2, 0x00000002,
|
|
|
|
0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00107e46, 0x00000002, 0x0a00002d,
|
|
|
|
0x001000f2, 0x00000003, 0x00004002, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00107e46,
|
|
|
|
0x00000002, 0x0700001d, 0x00100042, 0x00000001, 0x0010001a, 0x00000001, 0x0010000a, 0x00000002,
|
|
|
|
0x0304001f, 0x0010002a, 0x00000001, 0x05000036, 0x001000f2, 0x00000004, 0x00100e46, 0x00000003,
|
|
|
|
0x05000036, 0x001000f2, 0x00000005, 0x00100e46, 0x00000003, 0x05000036, 0x001000f2, 0x00000006,
|
|
|
|
0x00100e46, 0x00000003, 0x05000036, 0x00100042, 0x00000001, 0x0010000a, 0x00000002, 0x05000036,
|
|
|
|
0x00100082, 0x00000001, 0x00004001, 0x00000001, 0x05000036, 0x00100022, 0x00000002, 0x00004001,
|
|
|
|
0x00000000, 0x01000030, 0x08000050, 0x00100042, 0x00000002, 0x0010003a, 0x00000001, 0x0020800a,
|
|
|
|
0x00000000, 0x00000003, 0x05000036, 0x00100022, 0x00000002, 0x00004001, 0x00000000, 0x03040003,
|
|
|
|
0x0010002a, 0x00000002, 0x07000029, 0x00100042, 0x00000002, 0x0010003a, 0x00000001, 0x00004001,
|
|
|
|
0x00000001, 0x0700002d, 0x001000f2, 0x00000007, 0x00100aa6, 0x00000002, 0x00107e46, 0x00000002,
|
|
|
|
0x0700001e, 0x00100042, 0x00000002, 0x0010002a, 0x00000002, 0x00004001, 0x00000001, 0x0700002d,
|
|
|
|
0x001000f2, 0x00000008, 0x00100aa6, 0x00000002, 0x00107e46, 0x00000002, 0x0700001d, 0x00100042,
|
|
|
|
0x00000002, 0x0010001a, 0x00000001, 0x0010002a, 0x00000001, 0x0700001d, 0x00100082, 0x00000002,
|
|
|
|
0x0010000a, 0x00000007, 0x0010001a, 0x00000001, 0x07000001, 0x00100042, 0x00000002, 0x0010003a,
|
|
|
|
0x00000002, 0x0010002a, 0x00000002, 0x0304001f, 0x0010002a, 0x00000002, 0x08000000, 0x00100082,
|
|
|
|
0x00000002, 0x8010002a, 0x00000041, 0x00000001, 0x0010001a, 0x00000001, 0x08000000, 0x00100022,
|
|
|
|
0x00000007, 0x8010002a, 0x00000041, 0x00000001, 0x0010000a, 0x00000007, 0x0700000e, 0x00100082,
|
|
|
|
0x00000002, 0x0010003a, 0x00000002, 0x0010001a, 0x00000007, 0x08000000, 0x001000f2, 0x00000009,
|
|
|
|
0x80100e46, 0x00000041, 0x00000005, 0x00100e46, 0x00000008, 0x09000032, 0x001000f2, 0x00000009,
|
|
|
|
0x00100ff6, 0x00000002, 0x00100e46, 0x00000009, 0x00100e46, 0x00000005, 0x05000036, 0x001000f2,
|
|
|
|
0x00000006, 0x00100e46, 0x00000008, 0x05000036, 0x00100022, 0x00000002, 0x00004001, 0xffffffff,
|
|
|
|
0x05000036, 0x001000f2, 0x00000004, 0x00100e46, 0x00000009, 0x01000002, 0x01000015, 0x05000036,
|
|
|
|
0x001000f2, 0x00000005, 0x00100e46, 0x00000008, 0x05000036, 0x00100042, 0x00000001, 0x0010000a,
|
|
|
|
0x00000007, 0x0700001e, 0x00100082, 0x00000001, 0x0010003a, 0x00000001, 0x00004001, 0x00000001,
|
|
|
|
0x05000036, 0x001000f2, 0x00000006, 0x00100e46, 0x00000008, 0x05000036, 0x00100022, 0x00000002,
|
|
|
|
0x0010002a, 0x00000002, 0x01000016, 0x09000037, 0x001000f2, 0x00000003, 0x00100556, 0x00000002,
|
|
|
|
0x00100e46, 0x00000004, 0x00100e46, 0x00000006, 0x01000015, 0x08000038, 0x001000f2, 0x00000000,
|
|
|
|
0x00100e46, 0x00000003, 0x00208556, 0x00000000, 0x00000001, 0x01000015, 0x0300001f, 0x0010000a,
|
|
|
|
0x00000001, 0x08000020, 0x00100012, 0x00000001, 0x0020800a, 0x00000000, 0x00000001, 0x00004001,
|
2017-09-28 13:14:18 +02:00
|
|
|
0x00000002, 0x0304001f, 0x0010000a, 0x00000001, 0x0900000f, 0x00100012, 0x00000002, 0x00208046,
|
|
|
|
0x00000000, 0x00000003, 0x00208046, 0x00000000, 0x00000003, 0x0900000f, 0x00100022, 0x00000002,
|
|
|
|
0x00208ae6, 0x00000000, 0x00000003, 0x00208ae6, 0x00000000, 0x00000003, 0x09000000, 0x00100062,
|
|
|
|
0x00000001, 0x00208ba6, 0x00000000, 0x00000002, 0x00208106, 0x00000000, 0x00000002, 0x08000000,
|
|
|
|
0x00100062, 0x00000001, 0x80100656, 0x00000041, 0x00000001, 0x00101106, 0x00000000, 0x0800000f,
|
|
|
|
0x00100012, 0x00000003, 0x00100596, 0x00000001, 0x00208046, 0x00000000, 0x00000003, 0x0800000f,
|
|
|
|
0x00100022, 0x00000003, 0x00100596, 0x00000001, 0x00208ae6, 0x00000000, 0x00000003, 0x0700000e,
|
|
|
|
0x00100062, 0x00000001, 0x00100106, 0x00000003, 0x00100106, 0x00000002, 0x0900000f, 0x00100012,
|
|
|
|
0x00000003, 0x00208ae6, 0x00000000, 0x00000002, 0x00208046, 0x00000000, 0x00000003, 0x0900000f,
|
|
|
|
0x00100022, 0x00000003, 0x00208ae6, 0x00000000, 0x00000002, 0x00208ae6, 0x00000000, 0x00000003,
|
|
|
|
0x0700000e, 0x00100032, 0x00000002, 0x00100046, 0x00000003, 0x00100046, 0x00000002, 0x0700000f,
|
|
|
|
0x00100082, 0x00000001, 0x00100596, 0x00000001, 0x00100596, 0x00000001, 0x0500004b, 0x00100082,
|
|
|
|
0x00000001, 0x0010003a, 0x00000001, 0x0700000f, 0x00100022, 0x00000001, 0x00100596, 0x00000001,
|
|
|
|
0x00100046, 0x00000002, 0x0700000e, 0x00100022, 0x00000001, 0x0010001a, 0x00000001, 0x0010003a,
|
|
|
|
0x00000001, 0x0700000f, 0x00100042, 0x00000001, 0x00100046, 0x00000002, 0x00100046, 0x00000002,
|
|
|
|
0x07000000, 0x00100042, 0x00000001, 0x0010002a, 0x00000001, 0x00004001, 0xbf800000, 0x0a000032,
|
|
|
|
0x00100042, 0x00000001, 0x0010001a, 0x00000001, 0x0010001a, 0x00000001, 0x8010002a, 0x00000041,
|
|
|
|
0x00000001, 0x0500004b, 0x00100042, 0x00000001, 0x0010002a, 0x00000001, 0x08000000, 0x00100022,
|
|
|
|
0x00000001, 0x0010002a, 0x00000001, 0x8010001a, 0x00000041, 0x00000001, 0x0700000e, 0x00100022,
|
|
|
|
0x00000001, 0x0010003a, 0x00000001, 0x0010001a, 0x00000001, 0x0a00002d, 0x001000f2, 0x00000002,
|
|
|
|
0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00107e46, 0x00000002, 0x0a00002d,
|
|
|
|
0x001000f2, 0x00000003, 0x00004002, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00107e46,
|
|
|
|
0x00000002, 0x0700001d, 0x00100042, 0x00000001, 0x0010001a, 0x00000001, 0x0010000a, 0x00000002,
|
|
|
|
0x0304001f, 0x0010002a, 0x00000001, 0x05000036, 0x001000f2, 0x00000004, 0x00100e46, 0x00000003,
|
|
|
|
0x05000036, 0x001000f2, 0x00000005, 0x00100e46, 0x00000003, 0x05000036, 0x001000f2, 0x00000006,
|
|
|
|
0x00100e46, 0x00000003, 0x05000036, 0x00100042, 0x00000001, 0x0010000a, 0x00000002, 0x05000036,
|
|
|
|
0x00100082, 0x00000001, 0x00004001, 0x00000001, 0x05000036, 0x00100022, 0x00000002, 0x00004001,
|
|
|
|
0x00000000, 0x01000030, 0x08000050, 0x00100042, 0x00000002, 0x0010003a, 0x00000001, 0x0020800a,
|
|
|
|
0x00000000, 0x00000004, 0x05000036, 0x00100022, 0x00000002, 0x00004001, 0x00000000, 0x03040003,
|
|
|
|
0x0010002a, 0x00000002, 0x07000029, 0x00100042, 0x00000002, 0x0010003a, 0x00000001, 0x00004001,
|
|
|
|
0x00000001, 0x0700002d, 0x001000f2, 0x00000007, 0x00100aa6, 0x00000002, 0x00107e46, 0x00000002,
|
|
|
|
0x0700001e, 0x00100042, 0x00000002, 0x0010002a, 0x00000002, 0x00004001, 0x00000001, 0x0700002d,
|
|
|
|
0x001000f2, 0x00000008, 0x00100aa6, 0x00000002, 0x00107e46, 0x00000002, 0x0700001d, 0x00100042,
|
|
|
|
0x00000002, 0x0010001a, 0x00000001, 0x0010002a, 0x00000001, 0x0700001d, 0x00100082, 0x00000002,
|
|
|
|
0x0010000a, 0x00000007, 0x0010001a, 0x00000001, 0x07000001, 0x00100042, 0x00000002, 0x0010003a,
|
|
|
|
0x00000002, 0x0010002a, 0x00000002, 0x0304001f, 0x0010002a, 0x00000002, 0x08000000, 0x00100082,
|
|
|
|
0x00000002, 0x8010002a, 0x00000041, 0x00000001, 0x0010001a, 0x00000001, 0x08000000, 0x00100022,
|
|
|
|
0x00000007, 0x8010002a, 0x00000041, 0x00000001, 0x0010000a, 0x00000007, 0x0700000e, 0x00100082,
|
|
|
|
0x00000002, 0x0010003a, 0x00000002, 0x0010001a, 0x00000007, 0x08000000, 0x001000f2, 0x00000009,
|
|
|
|
0x80100e46, 0x00000041, 0x00000005, 0x00100e46, 0x00000008, 0x09000032, 0x001000f2, 0x00000009,
|
|
|
|
0x00100ff6, 0x00000002, 0x00100e46, 0x00000009, 0x00100e46, 0x00000005, 0x05000036, 0x001000f2,
|
|
|
|
0x00000006, 0x00100e46, 0x00000008, 0x05000036, 0x00100022, 0x00000002, 0x00004001, 0xffffffff,
|
|
|
|
0x05000036, 0x001000f2, 0x00000004, 0x00100e46, 0x00000009, 0x01000002, 0x01000015, 0x05000036,
|
|
|
|
0x001000f2, 0x00000005, 0x00100e46, 0x00000008, 0x05000036, 0x00100042, 0x00000001, 0x0010000a,
|
|
|
|
0x00000007, 0x0700001e, 0x00100082, 0x00000001, 0x0010003a, 0x00000001, 0x00004001, 0x00000001,
|
|
|
|
0x05000036, 0x001000f2, 0x00000006, 0x00100e46, 0x00000008, 0x05000036, 0x00100022, 0x00000002,
|
|
|
|
0x0010002a, 0x00000002, 0x01000016, 0x09000037, 0x001000f2, 0x00000003, 0x00100556, 0x00000002,
|
|
|
|
0x00100e46, 0x00000004, 0x00100e46, 0x00000006, 0x01000015, 0x08000038, 0x001000f2, 0x00000000,
|
|
|
|
0x00100e46, 0x00000003, 0x00208556, 0x00000000, 0x00000001, 0x01000015, 0x0300001f, 0x0010000a,
|
|
|
|
0x00000001, 0x08000020, 0x00100012, 0x00000001, 0x0020800a, 0x00000000, 0x00000001, 0x00004001,
|
2017-09-26 12:22:40 +02:00
|
|
|
0x00000003, 0x0304001f, 0x0010000a, 0x00000001, 0x0800000f, 0x00100022, 0x00000001, 0x00101046,
|
2017-09-26 12:22:39 +02:00
|
|
|
0x00000000, 0x00208046, 0x00000000, 0x00000002, 0x08000000, 0x00100012, 0x00000002, 0x0010001a,
|
|
|
|
0x00000001, 0x0020802a, 0x00000000, 0x00000002, 0x0800000f, 0x00100022, 0x00000001, 0x00101046,
|
|
|
|
0x00000000, 0x00208046, 0x00000000, 0x00000003, 0x08000000, 0x00100022, 0x00000002, 0x0010001a,
|
|
|
|
0x00000001, 0x0020802a, 0x00000000, 0x00000003, 0x09000045, 0x001000f2, 0x00000002, 0x00100046,
|
|
|
|
0x00000002, 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0a000037, 0x00100082, 0x00000002,
|
|
|
|
0x0020803a, 0x00000000, 0x00000003, 0x00004001, 0x3f800000, 0x0010003a, 0x00000002, 0x08000038,
|
|
|
|
0x001000f2, 0x00000000, 0x00100e46, 0x00000002, 0x00208556, 0x00000000, 0x00000001, 0x01000015,
|
|
|
|
0x05000036, 0x00100012, 0x00000002, 0x00004001, 0x00000000, 0x06000036, 0x00100082, 0x00000002,
|
|
|
|
0x0020801a, 0x00000000, 0x00000001, 0x09000037, 0x001000f2, 0x00000000, 0x00100006, 0x00000001,
|
2017-09-28 13:14:18 +02:00
|
|
|
0x00100e46, 0x00000000, 0x00100c06, 0x00000002, 0x01000015, 0x01000015, 0x01000015, 0x0800004f,
|
|
|
|
0x00100012, 0x00000001, 0x0020800a, 0x00000000, 0x00000005, 0x00004001, 0x00000004, 0x0304001f,
|
|
|
|
0x0010000a, 0x00000001, 0x09000038, 0x00100012, 0x00000001, 0x0020801a, 0x00000000, 0x00000005,
|
|
|
|
0x0020803a, 0x00000000, 0x00000006, 0x0404001f, 0x0020800a, 0x00000000, 0x00000005, 0x08000020,
|
|
|
|
0x00100022, 0x00000001, 0x0020800a, 0x00000000, 0x00000005, 0x00004001, 0x00000001, 0x0304001f,
|
|
|
|
0x0010001a, 0x00000001, 0x09000000, 0x001000c2, 0x00000001, 0x00101406, 0x00000000, 0x80208406,
|
|
|
|
0x00000041, 0x00000000, 0x00000006, 0x0a000000, 0x00100032, 0x00000002, 0x80208046, 0x00000041,
|
|
|
|
0x00000000, 0x00000006, 0x00208ae6, 0x00000000, 0x00000006, 0x0700000f, 0x00100042, 0x00000001,
|
|
|
|
0x00100046, 0x00000002, 0x00100ae6, 0x00000001, 0x0700000f, 0x00100082, 0x00000001, 0x00100046,
|
|
|
|
0x00000002, 0x00100046, 0x00000002, 0x0700000e, 0x00100042, 0x00000001, 0x0010002a, 0x00000001,
|
|
|
|
0x0010003a, 0x00000001, 0x0a00002d, 0x001000f2, 0x00000002, 0x00004002, 0x00000000, 0x00000000,
|
|
|
|
0x00000000, 0x00000000, 0x00107e46, 0x00000003, 0x0a00002d, 0x001000f2, 0x00000003, 0x00004002,
|
|
|
|
0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00107e46, 0x00000003, 0x0700001d, 0x00100082,
|
|
|
|
0x00000001, 0x0010002a, 0x00000001, 0x0010000a, 0x00000002, 0x0304001f, 0x0010003a, 0x00000001,
|
|
|
|
0x05000036, 0x00100082, 0x00000001, 0x0010003a, 0x00000003, 0x05000036, 0x00100062, 0x00000002,
|
|
|
|
0x00100ff6, 0x00000003, 0x05000036, 0x00100082, 0x00000002, 0x0010000a, 0x00000002, 0x08000036,
|
|
|
|
0x00100032, 0x00000003, 0x00004002, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x01000030,
|
|
|
|
0x08000050, 0x00100042, 0x00000003, 0x0010000a, 0x00000003, 0x0020800a, 0x00000000, 0x00000007,
|
|
|
|
0x05000036, 0x00100022, 0x00000003, 0x00004001, 0x00000000, 0x03040003, 0x0010002a, 0x00000003,
|
|
|
|
0x07000029, 0x00100042, 0x00000003, 0x0010000a, 0x00000003, 0x00004001, 0x00000001, 0x0700002d,
|
|
|
|
0x001000f2, 0x00000004, 0x00100aa6, 0x00000003, 0x00107e46, 0x00000003, 0x0700001e, 0x00100042,
|
|
|
|
0x00000003, 0x0010002a, 0x00000003, 0x00004001, 0x00000001, 0x0700002d, 0x001000f2, 0x00000005,
|
|
|
|
0x00100aa6, 0x00000003, 0x00107e46, 0x00000003, 0x0700001d, 0x00100042, 0x00000003, 0x0010002a,
|
|
|
|
0x00000001, 0x0010003a, 0x00000002, 0x0700001d, 0x00100022, 0x00000004, 0x0010000a, 0x00000004,
|
|
|
|
0x0010002a, 0x00000001, 0x07000001, 0x00100042, 0x00000003, 0x0010002a, 0x00000003, 0x0010001a,
|
|
|
|
0x00000004, 0x0304001f, 0x0010002a, 0x00000003, 0x08000000, 0x00100022, 0x00000004, 0x0010002a,
|
|
|
|
0x00000001, 0x8010003a, 0x00000041, 0x00000002, 0x08000000, 0x00100042, 0x00000004, 0x8010003a,
|
|
|
|
0x00000041, 0x00000002, 0x0010000a, 0x00000004, 0x0700000e, 0x00100022, 0x00000004, 0x0010001a,
|
|
|
|
0x00000004, 0x0010002a, 0x00000004, 0x08000000, 0x00100042, 0x00000004, 0x8010001a, 0x00000041,
|
|
|
|
0x00000002, 0x0010003a, 0x00000005, 0x09000032, 0x00100022, 0x00000004, 0x0010001a, 0x00000004,
|
|
|
|
0x0010002a, 0x00000004, 0x0010001a, 0x00000002, 0x05000036, 0x00100042, 0x00000002, 0x0010003a,
|
|
|
|
0x00000005, 0x05000036, 0x00100022, 0x00000003, 0x00004001, 0xffffffff, 0x05000036, 0x00100082,
|
|
|
|
0x00000001, 0x0010001a, 0x00000004, 0x01000002, 0x01000015, 0x05000036, 0x00100022, 0x00000002,
|
|
|
|
0x0010003a, 0x00000005, 0x05000036, 0x00100082, 0x00000002, 0x0010000a, 0x00000004, 0x0700001e,
|
|
|
|
0x00100012, 0x00000003, 0x0010000a, 0x00000003, 0x00004001, 0x00000001, 0x05000036, 0x00100042,
|
|
|
|
0x00000002, 0x0010003a, 0x00000005, 0x05000036, 0x00100032, 0x00000003, 0x00100086, 0x00000003,
|
|
|
|
0x01000016, 0x09000037, 0x00100042, 0x00000001, 0x0010001a, 0x00000003, 0x0010003a, 0x00000001,
|
|
|
|
0x0010002a, 0x00000002, 0x01000012, 0x05000036, 0x00100042, 0x00000001, 0x0010003a, 0x00000003,
|
|
|
|
0x01000015, 0x08000038, 0x00100012, 0x00000001, 0x0010002a, 0x00000001, 0x0020801a, 0x00000000,
|
|
|
|
0x00000005, 0x01000015, 0x0300001f, 0x0010001a, 0x00000001, 0x08000020, 0x00100022, 0x00000001,
|
|
|
|
0x0020800a, 0x00000000, 0x00000005, 0x00004001, 0x00000002, 0x0304001f, 0x0010001a, 0x00000001,
|
|
|
|
0x0900000f, 0x00100012, 0x00000002, 0x00208046, 0x00000000, 0x00000007, 0x00208046, 0x00000000,
|
|
|
|
0x00000007, 0x0900000f, 0x00100022, 0x00000002, 0x00208ae6, 0x00000000, 0x00000007, 0x00208ae6,
|
|
|
|
0x00000000, 0x00000007, 0x09000000, 0x001000c2, 0x00000001, 0x00208ea6, 0x00000000, 0x00000006,
|
|
|
|
0x00208406, 0x00000000, 0x00000006, 0x08000000, 0x001000c2, 0x00000001, 0x80100ea6, 0x00000041,
|
|
|
|
0x00000001, 0x00101406, 0x00000000, 0x0800000f, 0x00100012, 0x00000003, 0x00100ae6, 0x00000001,
|
|
|
|
0x00208046, 0x00000000, 0x00000007, 0x0800000f, 0x00100022, 0x00000003, 0x00100ae6, 0x00000001,
|
|
|
|
0x00208ae6, 0x00000000, 0x00000007, 0x0700000e, 0x001000c2, 0x00000001, 0x00100406, 0x00000003,
|
|
|
|
0x00100406, 0x00000002, 0x0900000f, 0x00100012, 0x00000003, 0x00208ae6, 0x00000000, 0x00000006,
|
|
|
|
0x00208046, 0x00000000, 0x00000007, 0x0900000f, 0x00100022, 0x00000003, 0x00208ae6, 0x00000000,
|
|
|
|
0x00000006, 0x00208ae6, 0x00000000, 0x00000007, 0x0700000e, 0x00100032, 0x00000002, 0x00100046,
|
|
|
|
0x00000003, 0x00100046, 0x00000002, 0x0700000f, 0x00100042, 0x00000002, 0x00100ae6, 0x00000001,
|
|
|
|
0x00100ae6, 0x00000001, 0x0500004b, 0x00100042, 0x00000002, 0x0010002a, 0x00000002, 0x0700000f,
|
|
|
|
0x00100042, 0x00000001, 0x00100ae6, 0x00000001, 0x00100046, 0x00000002, 0x0700000e, 0x00100042,
|
|
|
|
0x00000001, 0x0010002a, 0x00000001, 0x0010002a, 0x00000002, 0x0700000f, 0x00100082, 0x00000001,
|
|
|
|
0x00100046, 0x00000002, 0x00100046, 0x00000002, 0x07000000, 0x00100082, 0x00000001, 0x0010003a,
|
|
|
|
0x00000001, 0x00004001, 0xbf800000, 0x0a000032, 0x00100082, 0x00000001, 0x0010002a, 0x00000001,
|
|
|
|
0x0010002a, 0x00000001, 0x8010003a, 0x00000041, 0x00000001, 0x0500004b, 0x00100082, 0x00000001,
|
|
|
|
0x0010003a, 0x00000001, 0x08000000, 0x00100042, 0x00000001, 0x0010003a, 0x00000001, 0x8010002a,
|
|
|
|
0x00000041, 0x00000001, 0x0700000e, 0x00100042, 0x00000001, 0x0010002a, 0x00000002, 0x0010002a,
|
2017-09-26 12:22:39 +02:00
|
|
|
0x00000001, 0x0a00002d, 0x001000f2, 0x00000002, 0x00004002, 0x00000000, 0x00000000, 0x00000000,
|
|
|
|
0x00000000, 0x00107e46, 0x00000003, 0x0a00002d, 0x001000f2, 0x00000003, 0x00004002, 0x00000001,
|
|
|
|
0x00000001, 0x00000001, 0x00000001, 0x00107e46, 0x00000003, 0x0700001d, 0x00100082, 0x00000001,
|
|
|
|
0x0010002a, 0x00000001, 0x0010000a, 0x00000002, 0x0304001f, 0x0010003a, 0x00000001, 0x05000036,
|
2017-09-28 13:14:18 +02:00
|
|
|
0x00100082, 0x00000001, 0x0010003a, 0x00000003, 0x05000036, 0x00100062, 0x00000002, 0x00100ff6,
|
|
|
|
0x00000003, 0x05000036, 0x00100082, 0x00000002, 0x0010000a, 0x00000002, 0x08000036, 0x00100032,
|
2017-09-26 12:22:39 +02:00
|
|
|
0x00000003, 0x00004002, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x01000030, 0x08000050,
|
2017-09-28 13:14:18 +02:00
|
|
|
0x00100042, 0x00000003, 0x0010000a, 0x00000003, 0x0020800a, 0x00000000, 0x00000008, 0x05000036,
|
2017-09-26 12:22:39 +02:00
|
|
|
0x00100022, 0x00000003, 0x00004001, 0x00000000, 0x03040003, 0x0010002a, 0x00000003, 0x07000029,
|
|
|
|
0x00100042, 0x00000003, 0x0010000a, 0x00000003, 0x00004001, 0x00000001, 0x0700002d, 0x001000f2,
|
|
|
|
0x00000004, 0x00100aa6, 0x00000003, 0x00107e46, 0x00000003, 0x0700001e, 0x00100042, 0x00000003,
|
|
|
|
0x0010002a, 0x00000003, 0x00004001, 0x00000001, 0x0700002d, 0x001000f2, 0x00000005, 0x00100aa6,
|
|
|
|
0x00000003, 0x00107e46, 0x00000003, 0x0700001d, 0x00100042, 0x00000003, 0x0010002a, 0x00000001,
|
2017-09-28 13:14:18 +02:00
|
|
|
0x0010003a, 0x00000002, 0x0700001d, 0x00100022, 0x00000004, 0x0010000a, 0x00000004, 0x0010002a,
|
2017-09-26 12:22:39 +02:00
|
|
|
0x00000001, 0x07000001, 0x00100042, 0x00000003, 0x0010002a, 0x00000003, 0x0010001a, 0x00000004,
|
|
|
|
0x0304001f, 0x0010002a, 0x00000003, 0x08000000, 0x00100022, 0x00000004, 0x0010002a, 0x00000001,
|
2017-09-28 13:14:18 +02:00
|
|
|
0x8010003a, 0x00000041, 0x00000002, 0x08000000, 0x00100042, 0x00000004, 0x8010003a, 0x00000041,
|
2017-09-26 12:22:39 +02:00
|
|
|
0x00000002, 0x0010000a, 0x00000004, 0x0700000e, 0x00100022, 0x00000004, 0x0010001a, 0x00000004,
|
2017-09-28 13:14:18 +02:00
|
|
|
0x0010002a, 0x00000004, 0x08000000, 0x00100042, 0x00000004, 0x8010001a, 0x00000041, 0x00000002,
|
2017-09-26 12:22:39 +02:00
|
|
|
0x0010003a, 0x00000005, 0x09000032, 0x00100022, 0x00000004, 0x0010001a, 0x00000004, 0x0010002a,
|
2017-09-28 13:14:18 +02:00
|
|
|
0x00000004, 0x0010001a, 0x00000002, 0x05000036, 0x00100042, 0x00000002, 0x0010003a, 0x00000005,
|
2017-09-26 12:22:39 +02:00
|
|
|
0x05000036, 0x00100022, 0x00000003, 0x00004001, 0xffffffff, 0x05000036, 0x00100082, 0x00000001,
|
2017-09-28 13:14:18 +02:00
|
|
|
0x0010001a, 0x00000004, 0x01000002, 0x01000015, 0x05000036, 0x00100022, 0x00000002, 0x0010003a,
|
|
|
|
0x00000005, 0x05000036, 0x00100082, 0x00000002, 0x0010000a, 0x00000004, 0x0700001e, 0x00100012,
|
|
|
|
0x00000003, 0x0010000a, 0x00000003, 0x00004001, 0x00000001, 0x05000036, 0x00100042, 0x00000002,
|
2017-09-26 12:22:39 +02:00
|
|
|
0x0010003a, 0x00000005, 0x05000036, 0x00100032, 0x00000003, 0x00100086, 0x00000003, 0x01000016,
|
2017-09-28 13:14:18 +02:00
|
|
|
0x09000037, 0x00100042, 0x00000001, 0x0010001a, 0x00000003, 0x0010003a, 0x00000001, 0x0010002a,
|
2017-09-26 12:22:39 +02:00
|
|
|
0x00000002, 0x01000012, 0x05000036, 0x00100042, 0x00000001, 0x0010003a, 0x00000003, 0x01000015,
|
2017-09-28 13:14:18 +02:00
|
|
|
0x08000038, 0x00100012, 0x00000001, 0x0010002a, 0x00000001, 0x0020801a, 0x00000000, 0x00000005,
|
2017-09-26 12:22:39 +02:00
|
|
|
0x01000015, 0x0300001f, 0x0010001a, 0x00000001, 0x08000020, 0x00100022, 0x00000001, 0x0020800a,
|
2017-09-28 13:14:18 +02:00
|
|
|
0x00000000, 0x00000005, 0x00004001, 0x00000003, 0x0304001f, 0x0010001a, 0x00000001, 0x0800000f,
|
2017-09-26 12:22:39 +02:00
|
|
|
0x00100042, 0x00000001, 0x00101046, 0x00000000, 0x00208046, 0x00000000, 0x00000006, 0x08000000,
|
2017-09-28 13:14:18 +02:00
|
|
|
0x00100012, 0x00000002, 0x0010002a, 0x00000001, 0x0020802a, 0x00000000, 0x00000006, 0x0800000f,
|
|
|
|
0x00100042, 0x00000001, 0x00101046, 0x00000000, 0x00208046, 0x00000000, 0x00000007, 0x08000000,
|
|
|
|
0x00100022, 0x00000002, 0x0010002a, 0x00000001, 0x0020802a, 0x00000000, 0x00000007, 0x09000045,
|
2017-09-26 12:22:39 +02:00
|
|
|
0x001000f2, 0x00000002, 0x00100046, 0x00000002, 0x00107e46, 0x00000001, 0x00106000, 0x00000001,
|
2017-09-28 13:14:18 +02:00
|
|
|
0x0a000037, 0x00100042, 0x00000001, 0x0020803a, 0x00000000, 0x00000007, 0x00004001, 0x3f800000,
|
2017-09-26 12:22:39 +02:00
|
|
|
0x0010003a, 0x00000002, 0x08000038, 0x00100012, 0x00000001, 0x0010002a, 0x00000001, 0x0020801a,
|
2017-09-28 13:14:18 +02:00
|
|
|
0x00000000, 0x00000005, 0x01000015, 0x0a000037, 0x00100012, 0x00000001, 0x0010001a, 0x00000001,
|
|
|
|
0x0010000a, 0x00000001, 0x0020801a, 0x00000000, 0x00000005, 0x01000015, 0x01000015, 0x01000015,
|
|
|
|
0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00100006, 0x00000001, 0x01000012,
|
2020-03-03 18:59:47 +01:00
|
|
|
0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x01000015, 0x0404001f, 0x0020800a,
|
|
|
|
0x00000000, 0x00000000, 0x0500000b, 0x00100032, 0x00000000, 0x00101046, 0x00000001, 0x0500000c,
|
|
|
|
0x001000c2, 0x00000000, 0x00101406, 0x00000001, 0x08000027, 0x00100012, 0x00000001, 0x0020801a,
|
|
|
|
0x00000000, 0x00000000, 0x00004001, 0x00000000, 0x0500003b, 0x00100022, 0x00000001, 0x0010000a,
|
|
|
|
0x00000001, 0x07000000, 0x001000c2, 0x00000001, 0x00101406, 0x00000001, 0x00101406, 0x00000001,
|
|
|
|
0x07000038, 0x001000f2, 0x00000002, 0x00100d86, 0x00000000, 0x00100fa6, 0x00000001, 0x0a000032,
|
|
|
|
0x00100032, 0x00000000, 0x00100aa6, 0x00000001, 0x00100086, 0x00000000, 0x801005d6, 0x00000041,
|
|
|
|
0x00000000, 0x0700000f, 0x00100042, 0x00000000, 0x00100046, 0x00000000, 0x00101ae6, 0x00000001,
|
|
|
|
0x07000031, 0x00100042, 0x00000000, 0x0010002a, 0x00000000, 0x00004001, 0x00000000, 0x07000001,
|
|
|
|
0x00100042, 0x00000000, 0x0010001a, 0x00000001, 0x0010002a, 0x00000000, 0x0304000d, 0x0010002a,
|
|
|
|
0x00000000, 0x07000038, 0x00100062, 0x00000000, 0x00100556, 0x00000000, 0x00101106, 0x00000003,
|
|
|
|
0x09000032, 0x00100032, 0x00000000, 0x00101046, 0x00000002, 0x00100006, 0x00000000, 0x00100596,
|
|
|
|
0x00000000, 0x0700000f, 0x00100012, 0x00000000, 0x00100046, 0x00000000, 0x00100046, 0x00000000,
|
|
|
|
0x0500004b, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x07000038, 0x00100062, 0x00000000,
|
|
|
|
0x00101106, 0x00000001, 0x00101106, 0x00000001, 0x0a000032, 0x00100082, 0x00000000, 0x0010100a,
|
|
|
|
0x00000001, 0x0010100a, 0x00000001, 0x8010101a, 0x00000041, 0x00000001, 0x08000000, 0x00100012,
|
|
|
|
0x00000000, 0x8010003a, 0x000000c1, 0x00000000, 0x0010000a, 0x00000000, 0x07000031, 0x00100012,
|
|
|
|
0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000000, 0x07000001, 0x00100012, 0x00000000,
|
|
|
|
0x0010001a, 0x00000001, 0x0010000a, 0x00000000, 0x0304000d, 0x0010000a, 0x00000000, 0x07000000,
|
|
|
|
0x00100092, 0x00000000, 0x00100ea6, 0x00000002, 0x00100406, 0x00000002, 0x0700000f, 0x00100022,
|
|
|
|
0x00000001, 0x001000c6, 0x00000000, 0x00101ae6, 0x00000001, 0x07000031, 0x00100022, 0x00000001,
|
|
|
|
0x0010001a, 0x00000001, 0x00004001, 0x00000000, 0x07000001, 0x00100022, 0x00000001, 0x0010000a,
|
|
|
|
0x00000001, 0x0010001a, 0x00000001, 0x0304000d, 0x0010001a, 0x00000001, 0x07000038, 0x00100062,
|
|
|
|
0x00000001, 0x00100ff6, 0x00000000, 0x00101106, 0x00000003, 0x09000032, 0x00100092, 0x00000000,
|
|
|
|
0x00101406, 0x00000002, 0x00100006, 0x00000000, 0x00100956, 0x00000001, 0x0700000f, 0x00100012,
|
|
|
|
0x00000000, 0x001000c6, 0x00000000, 0x001000c6, 0x00000000, 0x0500004b, 0x00100012, 0x00000000,
|
|
|
|
0x0010000a, 0x00000000, 0x07000000, 0x00100022, 0x00000000, 0x0010002a, 0x00000000, 0x0010001a,
|
|
|
|
0x00000000, 0x07000000, 0x00100022, 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0xbf800000,
|
|
|
|
0x08000000, 0x00100012, 0x00000000, 0x8010001a, 0x000000c1, 0x00000000, 0x0010000a, 0x00000000,
|
|
|
|
0x07000031, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x00000000, 0x07000001,
|
|
|
|
0x00100012, 0x00000000, 0x0010000a, 0x00000001, 0x0010000a, 0x00000000, 0x0304000d, 0x0010000a,
|
|
|
|
0x00000000, 0x01000012, 0x08000027, 0x00100012, 0x00000000, 0x0020801a, 0x00000000, 0x00000000,
|
|
|
|
0x00004001, 0x00000000, 0x0500003b, 0x00100022, 0x00000000, 0x0010000a, 0x00000000, 0x07000038,
|
|
|
|
0x001000c2, 0x00000000, 0x00101406, 0x00000001, 0x00101406, 0x00000001, 0x0a000032, 0x00100012,
|
|
|
|
0x00000001, 0x0010100a, 0x00000001, 0x0010100a, 0x00000001, 0x8010101a, 0x00000041, 0x00000001,
|
|
|
|
0x07000038, 0x00100012, 0x00000001, 0x0010000a, 0x00000001, 0x0010102a, 0x00000001, 0x07000031,
|
|
|
|
0x00100012, 0x00000001, 0x0010000a, 0x00000001, 0x00004001, 0x00000000, 0x07000001, 0x00100022,
|
|
|
|
0x00000000, 0x0010001a, 0x00000000, 0x0010000a, 0x00000001, 0x0304000d, 0x0010001a, 0x00000000,
|
|
|
|
0x07000000, 0x00100022, 0x00000000, 0x0010003a, 0x00000000, 0x0010002a, 0x00000000, 0x07000000,
|
|
|
|
0x00100022, 0x00000000, 0x0010001a, 0x00000000, 0x00004001, 0xbf800000, 0x07000038, 0x00100022,
|
|
|
|
0x00000000, 0x0010001a, 0x00000000, 0x0010102a, 0x00000001, 0x07000031, 0x00100022, 0x00000000,
|
|
|
|
0x0010001a, 0x00000000, 0x00004001, 0x00000000, 0x07000001, 0x00100012, 0x00000000, 0x0010000a,
|
|
|
|
0x00000000, 0x0010001a, 0x00000000, 0x0304000d, 0x0010000a, 0x00000000, 0x01000015, 0x0100003e,
|
2015-07-20 11:07:28 +02:00
|
|
|
};
|
2017-09-23 13:36:59 +02:00
|
|
|
static const struct shape_info
|
2015-11-18 16:10:22 +01:00
|
|
|
{
|
|
|
|
enum d2d_shape_type shape_type;
|
2021-06-25 09:34:02 +02:00
|
|
|
const D3D11_INPUT_ELEMENT_DESC *il_desc;
|
2017-09-23 13:36:59 +02:00
|
|
|
unsigned int il_element_count;
|
|
|
|
const void *vs_code;
|
|
|
|
size_t vs_code_size;
|
|
|
|
}
|
|
|
|
shape_info[] =
|
|
|
|
{
|
|
|
|
{D2D_SHAPE_TYPE_OUTLINE, il_desc_outline, ARRAY_SIZE(il_desc_outline),
|
2017-09-23 13:37:00 +02:00
|
|
|
vs_code_outline, sizeof(vs_code_outline)},
|
2020-03-03 18:59:47 +01:00
|
|
|
{D2D_SHAPE_TYPE_BEZIER_OUTLINE, il_desc_curve_outline, ARRAY_SIZE(il_desc_curve_outline),
|
2017-09-23 13:37:00 +02:00
|
|
|
vs_code_bezier_outline, sizeof(vs_code_bezier_outline)},
|
2020-03-03 18:59:47 +01:00
|
|
|
{D2D_SHAPE_TYPE_ARC_OUTLINE, il_desc_curve_outline, ARRAY_SIZE(il_desc_curve_outline),
|
|
|
|
vs_code_arc_outline, sizeof(vs_code_arc_outline)},
|
2017-09-23 13:36:59 +02:00
|
|
|
{D2D_SHAPE_TYPE_TRIANGLE, il_desc_triangle, ARRAY_SIZE(il_desc_triangle),
|
2017-09-23 13:37:00 +02:00
|
|
|
vs_code_triangle, sizeof(vs_code_triangle)},
|
2020-03-03 18:59:46 +01:00
|
|
|
{D2D_SHAPE_TYPE_CURVE, il_desc_curve, ARRAY_SIZE(il_desc_curve),
|
|
|
|
vs_code_curve, sizeof(vs_code_curve)},
|
2015-11-18 16:10:22 +01:00
|
|
|
};
|
2014-09-05 15:50:58 +02:00
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
float x, y;
|
|
|
|
}
|
2014-11-06 08:20:14 +01:00
|
|
|
quad[] =
|
2014-09-05 15:50:58 +02:00
|
|
|
{
|
|
|
|
{-1.0f, 1.0f},
|
2014-11-06 08:20:14 +01:00
|
|
|
{-1.0f, -1.0f},
|
2014-09-05 15:50:58 +02:00
|
|
|
{ 1.0f, 1.0f},
|
2014-11-06 08:20:14 +01:00
|
|
|
{ 1.0f, -1.0f},
|
2014-09-05 15:50:58 +02:00
|
|
|
};
|
2015-07-14 15:57:42 +02:00
|
|
|
static const UINT16 indices[] = {0, 1, 2, 2, 1, 3};
|
2021-12-10 16:25:06 +01:00
|
|
|
static const D3D_FEATURE_LEVEL feature_levels = D3D_FEATURE_LEVEL_10_0;
|
2014-05-20 07:38:44 +02:00
|
|
|
|
2018-08-17 16:54:11 +02:00
|
|
|
render_target->ID2D1DeviceContext_iface.lpVtbl = &d2d_device_context_vtbl;
|
2017-02-14 16:19:00 +01:00
|
|
|
render_target->ID2D1GdiInteropRenderTarget_iface.lpVtbl = &d2d_gdi_interop_render_target_vtbl;
|
2014-10-06 08:24:17 +02:00
|
|
|
render_target->IDWriteTextRenderer_iface.lpVtbl = &d2d_text_renderer_vtbl;
|
2018-09-12 17:59:51 +02:00
|
|
|
render_target->IUnknown_iface.lpVtbl = &d2d_device_context_inner_unknown_vtbl;
|
2014-05-20 07:38:44 +02:00
|
|
|
render_target->refcount = 1;
|
2018-09-24 06:58:31 +02:00
|
|
|
ID2D1Device_GetFactory(device, &render_target->factory);
|
|
|
|
render_target->device = device;
|
|
|
|
ID2D1Device_AddRef(render_target->device);
|
2014-07-22 08:44:21 +02:00
|
|
|
|
2018-09-12 17:59:51 +02:00
|
|
|
render_target->outer_unknown = outer_unknown ? outer_unknown : &render_target->IUnknown_iface;
|
|
|
|
render_target->ops = ops;
|
2017-02-14 16:19:00 +01:00
|
|
|
|
2018-09-29 01:02:06 +02:00
|
|
|
device_impl = unsafe_impl_from_ID2D1Device(device);
|
|
|
|
if (FAILED(hr = IDXGIDevice_QueryInterface(device_impl->dxgi_device,
|
2021-06-28 09:17:37 +02:00
|
|
|
&IID_ID3D11Device1, (void **)&render_target->d3d_device)))
|
2021-06-21 09:57:43 +02:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to query ID3D11Device1 interface, hr %#lx.\n", hr);
|
2021-06-21 09:57:43 +02:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreateDeviceContextState(render_target->d3d_device,
|
2021-06-28 09:17:36 +02:00
|
|
|
0, &feature_levels, 1, D3D11_SDK_VERSION, &IID_ID3D11Device1, NULL,
|
|
|
|
&render_target->d3d_state)))
|
2014-09-05 15:50:58 +02:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to create device context state, hr %#lx.\n", hr);
|
2014-09-05 15:50:58 +02:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2017-09-23 13:36:59 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(shape_info); ++i)
|
2015-07-20 11:07:28 +02:00
|
|
|
{
|
2017-09-23 13:36:59 +02:00
|
|
|
const struct shape_info *si = &shape_info[i];
|
2015-07-20 11:07:28 +02:00
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreateInputLayout(render_target->d3d_device, si->il_desc, si->il_element_count,
|
2017-09-23 13:36:59 +02:00
|
|
|
si->vs_code, si->vs_code_size, &render_target->shape_resources[si->shape_type].il)))
|
2015-11-18 16:10:22 +01:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to create input layout for shape type %#x, hr %#lx.\n", si->shape_type, hr);
|
2015-11-18 16:10:22 +01:00
|
|
|
goto err;
|
|
|
|
}
|
2014-09-05 15:50:58 +02:00
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreateVertexShader(render_target->d3d_device, si->vs_code,
|
2021-06-25 09:34:03 +02:00
|
|
|
si->vs_code_size, NULL, &render_target->shape_resources[si->shape_type].vs)))
|
2017-02-03 13:37:09 +01:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to create vertex shader for shape type %#x, hr %#lx.\n", si->shape_type, hr);
|
2017-09-23 13:36:59 +02:00
|
|
|
goto err;
|
|
|
|
}
|
2017-02-03 13:37:09 +01:00
|
|
|
|
2017-09-23 13:37:00 +02:00
|
|
|
}
|
|
|
|
|
2021-06-11 10:35:49 +02:00
|
|
|
buffer_desc.ByteWidth = sizeof(struct d2d_vs_cb);
|
2021-06-25 09:34:01 +02:00
|
|
|
buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
|
2021-06-11 10:35:49 +02:00
|
|
|
buffer_desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
|
|
|
|
buffer_desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
|
|
|
|
buffer_desc.MiscFlags = 0;
|
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, NULL,
|
2021-06-11 10:35:49 +02:00
|
|
|
&render_target->vs_cb)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to create constant buffer, hr %#lx.\n", hr);
|
2021-06-11 10:35:49 +02:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreatePixelShader(render_target->d3d_device,
|
2021-06-25 09:34:04 +02:00
|
|
|
ps_code, sizeof(ps_code), NULL, &render_target->ps)))
|
2017-09-23 13:37:00 +02:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to create pixel shader, hr %#lx.\n", hr);
|
2017-09-23 13:37:00 +02:00
|
|
|
goto err;
|
2017-02-03 13:37:09 +01:00
|
|
|
}
|
|
|
|
|
2021-06-10 14:13:23 +02:00
|
|
|
buffer_desc.ByteWidth = sizeof(struct d2d_ps_cb);
|
2021-06-25 09:34:01 +02:00
|
|
|
buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
|
2021-06-10 14:13:23 +02:00
|
|
|
buffer_desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
|
|
|
|
buffer_desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
|
|
|
|
buffer_desc.MiscFlags = 0;
|
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, NULL,
|
2021-06-10 14:13:23 +02:00
|
|
|
&render_target->ps_cb)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to create constant buffer, hr %#lx.\n", hr);
|
2021-06-10 14:13:23 +02:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2015-07-14 15:57:42 +02:00
|
|
|
buffer_desc.ByteWidth = sizeof(indices);
|
2021-06-25 09:34:01 +02:00
|
|
|
buffer_desc.Usage = D3D11_USAGE_DEFAULT;
|
|
|
|
buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
2014-09-05 15:50:58 +02:00
|
|
|
buffer_desc.CPUAccessFlags = 0;
|
|
|
|
buffer_desc.MiscFlags = 0;
|
|
|
|
|
2015-07-14 15:57:42 +02:00
|
|
|
buffer_data.pSysMem = indices;
|
2014-09-05 15:50:58 +02:00
|
|
|
buffer_data.SysMemPitch = 0;
|
|
|
|
buffer_data.SysMemSlicePitch = 0;
|
|
|
|
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device,
|
2015-07-14 15:57:42 +02:00
|
|
|
&buffer_desc, &buffer_data, &render_target->ib)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to create clear index buffer, hr %#lx.\n", hr);
|
2015-07-14 15:57:42 +02:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer_desc.ByteWidth = sizeof(quad);
|
2021-06-25 09:34:01 +02:00
|
|
|
buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
2015-07-14 15:57:42 +02:00
|
|
|
buffer_data.pSysMem = quad;
|
|
|
|
|
2014-11-06 08:20:14 +01:00
|
|
|
render_target->vb_stride = sizeof(*quad);
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device,
|
2014-11-06 08:20:14 +01:00
|
|
|
&buffer_desc, &buffer_data, &render_target->vb)))
|
2014-09-05 15:50:58 +02:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to create clear vertex buffer, hr %#lx.\n", hr);
|
2014-09-05 15:50:58 +02:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2021-06-28 09:17:33 +02:00
|
|
|
rs_desc.FillMode = D3D11_FILL_SOLID;
|
|
|
|
rs_desc.CullMode = D3D11_CULL_NONE;
|
2014-09-05 15:50:59 +02:00
|
|
|
rs_desc.FrontCounterClockwise = FALSE;
|
|
|
|
rs_desc.DepthBias = 0;
|
|
|
|
rs_desc.DepthBiasClamp = 0.0f;
|
|
|
|
rs_desc.SlopeScaledDepthBias = 0.0f;
|
|
|
|
rs_desc.DepthClipEnable = TRUE;
|
|
|
|
rs_desc.ScissorEnable = TRUE;
|
|
|
|
rs_desc.MultisampleEnable = FALSE;
|
|
|
|
rs_desc.AntialiasedLineEnable = FALSE;
|
2021-06-28 09:17:37 +02:00
|
|
|
if (FAILED(hr = ID3D11Device1_CreateRasterizerState(render_target->d3d_device, &rs_desc, &render_target->rs)))
|
2014-09-05 15:50:59 +02:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to create clear rasteriser state, hr %#lx.\n", hr);
|
2014-09-05 15:50:59 +02:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2015-11-18 22:23:23 +01:00
|
|
|
if (FAILED(hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED,
|
|
|
|
&IID_IDWriteFactory, (IUnknown **)&dwrite_factory)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create dwrite factory, hr %#lx.\n", hr);
|
2015-11-18 22:23:23 +01:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDWriteFactory_CreateRenderingParams(dwrite_factory, &render_target->default_text_rendering_params);
|
|
|
|
IDWriteFactory_Release(dwrite_factory);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
ERR("Failed to create default text rendering parameters, hr %#lx.\n", hr);
|
2015-11-18 22:23:23 +01:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2015-03-27 09:07:06 +01:00
|
|
|
render_target->drawing_state.transform = identity;
|
2014-09-05 15:50:59 +02:00
|
|
|
|
2014-09-15 11:03:33 +02:00
|
|
|
if (!d2d_clip_stack_init(&render_target->clip_stack))
|
2014-09-05 15:50:59 +02:00
|
|
|
{
|
|
|
|
WARN("Failed to initialize clip stack.\n");
|
|
|
|
hr = E_FAIL;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2018-09-29 01:02:06 +02:00
|
|
|
render_target->desc.dpiX = 96.0f;
|
|
|
|
render_target->desc.dpiY = 96.0f;
|
2014-09-03 07:48:23 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2014-09-05 15:50:58 +02:00
|
|
|
|
|
|
|
err:
|
2015-11-18 22:23:23 +01:00
|
|
|
if (render_target->default_text_rendering_params)
|
|
|
|
IDWriteRenderingParams_Release(render_target->default_text_rendering_params);
|
2014-11-06 08:20:14 +01:00
|
|
|
if (render_target->rs)
|
2021-06-28 09:17:33 +02:00
|
|
|
ID3D11RasterizerState_Release(render_target->rs);
|
2014-11-06 08:20:14 +01:00
|
|
|
if (render_target->vb)
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11Buffer_Release(render_target->vb);
|
2015-07-14 15:57:42 +02:00
|
|
|
if (render_target->ib)
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11Buffer_Release(render_target->ib);
|
2021-06-10 14:13:23 +02:00
|
|
|
if (render_target->ps_cb)
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11Buffer_Release(render_target->ps_cb);
|
2017-09-23 13:37:00 +02:00
|
|
|
if (render_target->ps)
|
2021-06-25 09:34:04 +02:00
|
|
|
ID3D11PixelShader_Release(render_target->ps);
|
2021-06-11 10:35:49 +02:00
|
|
|
if (render_target->vs_cb)
|
2021-06-25 09:34:01 +02:00
|
|
|
ID3D11Buffer_Release(render_target->vs_cb);
|
2015-07-20 11:07:28 +02:00
|
|
|
for (i = 0; i < D2D_SHAPE_TYPE_COUNT; ++i)
|
|
|
|
{
|
|
|
|
if (render_target->shape_resources[i].vs)
|
2021-06-25 09:34:03 +02:00
|
|
|
ID3D11VertexShader_Release(render_target->shape_resources[i].vs);
|
2015-07-20 11:07:28 +02:00
|
|
|
if (render_target->shape_resources[i].il)
|
2021-06-25 09:34:02 +02:00
|
|
|
ID3D11InputLayout_Release(render_target->shape_resources[i].il);
|
2015-07-20 11:07:28 +02:00
|
|
|
}
|
2021-06-28 09:17:36 +02:00
|
|
|
if (render_target->d3d_state)
|
|
|
|
ID3DDeviceContextState_Release(render_target->d3d_state);
|
2018-09-24 06:58:31 +02:00
|
|
|
if (render_target->d3d_device)
|
2021-06-28 09:17:37 +02:00
|
|
|
ID3D11Device1_Release(render_target->d3d_device);
|
2018-09-24 06:58:31 +02:00
|
|
|
ID2D1Device_Release(render_target->device);
|
2015-03-26 09:41:16 +01:00
|
|
|
ID2D1Factory_Release(render_target->factory);
|
2014-09-05 15:50:58 +02:00
|
|
|
return hr;
|
2014-05-20 07:38:44 +02:00
|
|
|
}
|
2016-09-13 11:53:19 +02:00
|
|
|
|
2018-09-24 06:58:31 +02:00
|
|
|
HRESULT d2d_d3d_create_render_target(ID2D1Device *device, IDXGISurface *surface, IUnknown *outer_unknown,
|
2018-09-12 17:59:51 +02:00
|
|
|
const struct d2d_device_context_ops *ops, const D2D1_RENDER_TARGET_PROPERTIES *desc, void **render_target)
|
2017-02-14 16:19:00 +01:00
|
|
|
{
|
2018-09-29 01:02:06 +02:00
|
|
|
D2D1_BITMAP_PROPERTIES1 bitmap_desc;
|
2018-08-17 16:54:11 +02:00
|
|
|
struct d2d_device_context *object;
|
2018-09-29 01:02:06 +02:00
|
|
|
ID2D1Bitmap1 *bitmap;
|
2017-02-14 16:19:00 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2018-09-29 01:02:06 +02:00
|
|
|
if (desc->type != D2D1_RENDER_TARGET_TYPE_DEFAULT && desc->type != D2D1_RENDER_TARGET_TYPE_HARDWARE)
|
|
|
|
WARN("Ignoring render target type %#x.\n", desc->type);
|
|
|
|
if (desc->usage != D2D1_RENDER_TARGET_USAGE_NONE)
|
|
|
|
FIXME("Ignoring render target usage %#x.\n", desc->usage);
|
|
|
|
if (desc->minLevel != D2D1_FEATURE_LEVEL_DEFAULT)
|
|
|
|
WARN("Ignoring feature level %#x.\n", desc->minLevel);
|
|
|
|
|
|
|
|
bitmap_desc.dpiX = desc->dpiX;
|
|
|
|
bitmap_desc.dpiY = desc->dpiY;
|
|
|
|
|
|
|
|
if (bitmap_desc.dpiX == 0.0f && bitmap_desc.dpiY == 0.0f)
|
|
|
|
{
|
|
|
|
bitmap_desc.dpiX = 96.0f;
|
|
|
|
bitmap_desc.dpiY = 96.0f;
|
|
|
|
}
|
|
|
|
else if (bitmap_desc.dpiX <= 0.0f || bitmap_desc.dpiY <= 0.0f)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2018-01-30 13:24:39 +01:00
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
2017-02-14 16:19:00 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2018-09-29 01:02:06 +02:00
|
|
|
if (FAILED(hr = d2d_device_context_init(object, device, outer_unknown, ops)))
|
2017-02-14 16:19:00 +01:00
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to initialise render target, hr %#lx.\n", hr);
|
2018-01-30 13:24:39 +01:00
|
|
|
heap_free(object);
|
2017-02-14 16:19:00 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-10-24 16:10:47 +02:00
|
|
|
ID2D1DeviceContext_SetDpi(&object->ID2D1DeviceContext_iface, bitmap_desc.dpiX, bitmap_desc.dpiY);
|
|
|
|
|
2018-09-29 01:02:06 +02:00
|
|
|
if (surface)
|
2016-10-03 17:56:11 +02:00
|
|
|
{
|
2018-09-29 01:02:06 +02:00
|
|
|
bitmap_desc.pixelFormat = desc->pixelFormat;
|
|
|
|
bitmap_desc.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW;
|
|
|
|
bitmap_desc.colorContext = NULL;
|
2016-09-13 11:53:19 +02:00
|
|
|
|
2018-09-29 01:02:06 +02:00
|
|
|
if (FAILED(hr = ID2D1DeviceContext_CreateBitmapFromDxgiSurface(&object->ID2D1DeviceContext_iface,
|
|
|
|
surface, &bitmap_desc, &bitmap)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to create target bitmap, hr %#lx.\n", hr);
|
2018-09-29 01:02:06 +02:00
|
|
|
IUnknown_Release(&object->IUnknown_iface);
|
|
|
|
heap_free(object);
|
|
|
|
return hr;
|
|
|
|
}
|
2016-09-13 11:53:19 +02:00
|
|
|
|
2018-09-29 01:02:06 +02:00
|
|
|
ID2D1DeviceContext_SetTarget(&object->ID2D1DeviceContext_iface, (ID2D1Image *)bitmap);
|
|
|
|
ID2D1Bitmap1_Release(bitmap);
|
2016-09-13 11:53:19 +02:00
|
|
|
}
|
2018-09-29 01:02:06 +02:00
|
|
|
else
|
|
|
|
object->desc.pixelFormat = desc->pixelFormat;
|
2016-09-13 11:53:19 +02:00
|
|
|
|
2018-09-29 01:02:06 +02:00
|
|
|
TRACE("Created render target %p.\n", object);
|
|
|
|
*render_target = outer_unknown ? &object->IUnknown_iface : (IUnknown *)&object->ID2D1DeviceContext_iface;
|
2016-09-13 11:53:19 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2018-05-19 18:20:17 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI d2d_device_QueryInterface(ID2D1Device *iface, REFIID iid, void **out)
|
|
|
|
{
|
|
|
|
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
|
|
|
|
|
|
|
|
if (IsEqualGUID(iid, &IID_ID2D1Device)
|
|
|
|
|| IsEqualGUID(iid, &IID_ID2D1Resource)
|
|
|
|
|| IsEqualGUID(iid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
ID2D1Device_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 WINAPI d2d_device_AddRef(ID2D1Device *iface)
|
|
|
|
{
|
|
|
|
struct d2d_device *device = impl_from_ID2D1Device(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&device->refcount);
|
|
|
|
|
2022-02-01 19:23:14 +01:00
|
|
|
TRACE("%p increasing refcount to %lu.\n", iface, refcount);
|
2018-05-19 18:20:17 +02:00
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI d2d_device_Release(ID2D1Device *iface)
|
|
|
|
{
|
|
|
|
struct d2d_device *device = impl_from_ID2D1Device(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&device->refcount);
|
|
|
|
|
2022-02-01 19:23:14 +01:00
|
|
|
TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
|
2018-05-19 18:20:17 +02:00
|
|
|
|
|
|
|
if (!refcount)
|
|
|
|
{
|
|
|
|
IDXGIDevice_Release(device->dxgi_device);
|
|
|
|
ID2D1Factory1_Release(device->factory);
|
|
|
|
heap_free(device);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI d2d_device_GetFactory(ID2D1Device *iface, ID2D1Factory **factory)
|
|
|
|
{
|
|
|
|
struct d2d_device *device = impl_from_ID2D1Device(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, factory %p.\n", iface, factory);
|
|
|
|
|
|
|
|
*factory = (ID2D1Factory *)device->factory;
|
|
|
|
ID2D1Factory1_AddRef(device->factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d2d_device_CreateDeviceContext(ID2D1Device *iface, D2D1_DEVICE_CONTEXT_OPTIONS options,
|
|
|
|
ID2D1DeviceContext **context)
|
|
|
|
{
|
2018-10-02 08:33:05 +02:00
|
|
|
struct d2d_device_context *object;
|
|
|
|
HRESULT hr;
|
2018-05-19 18:20:17 +02:00
|
|
|
|
2018-10-02 08:33:05 +02:00
|
|
|
TRACE("iface %p, options %#x, context %p.\n", iface, options, context);
|
|
|
|
|
|
|
|
if (options)
|
|
|
|
FIXME("Options are ignored %#x.\n", options);
|
|
|
|
|
|
|
|
if (!(object = heap_alloc_zero(sizeof(*object))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (FAILED(hr = d2d_device_context_init(object, iface, NULL, NULL)))
|
|
|
|
{
|
2022-02-01 19:23:14 +01:00
|
|
|
WARN("Failed to initialise device context, hr %#lx.\n", hr);
|
2018-10-02 08:33:05 +02:00
|
|
|
heap_free(object);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Created device context %p.\n", object);
|
|
|
|
*context = &object->ID2D1DeviceContext_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
2018-05-19 18:20:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d2d_device_CreatePrintControl(ID2D1Device *iface, IWICImagingFactory *wic_factory,
|
|
|
|
IPrintDocumentPackageTarget *document_target, const D2D1_PRINT_CONTROL_PROPERTIES *desc,
|
|
|
|
ID2D1PrintControl **print_control)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, wic_factory %p, document_target %p, desc %p, print_control %p stub!\n", iface, wic_factory,
|
|
|
|
document_target, desc, print_control);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI d2d_device_SetMaximumTextureMemory(ID2D1Device *iface, UINT64 max_texture_memory)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, max_texture_memory %s stub!\n", iface, wine_dbgstr_longlong(max_texture_memory));
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT64 WINAPI d2d_device_GetMaximumTextureMemory(ID2D1Device *iface)
|
|
|
|
{
|
|
|
|
FIXME("iface %p stub!\n", iface);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d2d_device_ClearResources(ID2D1Device *iface, UINT msec_since_use)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, msec_since_use %u stub!\n", iface, msec_since_use);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ID2D1DeviceVtbl d2d_device_vtbl =
|
|
|
|
{
|
|
|
|
d2d_device_QueryInterface,
|
|
|
|
d2d_device_AddRef,
|
|
|
|
d2d_device_Release,
|
|
|
|
d2d_device_GetFactory,
|
|
|
|
d2d_device_CreateDeviceContext,
|
|
|
|
d2d_device_CreatePrintControl,
|
|
|
|
d2d_device_SetMaximumTextureMemory,
|
|
|
|
d2d_device_GetMaximumTextureMemory,
|
|
|
|
d2d_device_ClearResources,
|
|
|
|
};
|
|
|
|
|
2018-09-29 01:02:06 +02:00
|
|
|
static struct d2d_device *unsafe_impl_from_ID2D1Device(ID2D1Device *iface)
|
|
|
|
{
|
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
|
|
|
assert(iface->lpVtbl == &d2d_device_vtbl);
|
|
|
|
return CONTAINING_RECORD(iface, struct d2d_device, ID2D1Device_iface);
|
|
|
|
}
|
|
|
|
|
2018-05-19 18:20:17 +02:00
|
|
|
void d2d_device_init(struct d2d_device *device, ID2D1Factory1 *iface, IDXGIDevice *dxgi_device)
|
|
|
|
{
|
|
|
|
device->ID2D1Device_iface.lpVtbl = &d2d_device_vtbl;
|
|
|
|
device->refcount = 1;
|
|
|
|
device->factory = iface;
|
|
|
|
ID2D1Factory1_AddRef(device->factory);
|
|
|
|
device->dxgi_device = dxgi_device;
|
|
|
|
IDXGIDevice_AddRef(device->dxgi_device);
|
|
|
|
}
|