ReactOS 0.4.17-dev-923-g4c9a150
device.c
Go to the documentation of this file.
1/*
2 * Copyright 2014 Henri Verbeet for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#include "d2d1_private.h"
20#include <d3dcompiler.h>
21
23
24#define INITIAL_CLIP_STACK_SIZE 4
25
27{{{
28 1.0f, 0.0f,
29 0.0f, 1.0f,
30 0.0f, 0.0f,
31}}};
32
34{
37};
38
39static inline struct d2d_device *impl_from_ID2D1Device(ID2D1Device6 *iface)
40{
41 return CONTAINING_RECORD(iface, struct d2d_device, ID2D1Device6_iface);
42}
43
45{
46 ID2D1Brush *brush = NULL;
47
48 if (effect && SUCCEEDED(IUnknown_QueryInterface(effect, &IID_ID2D1Brush, (void**)&brush)))
49 return brush;
50
51 ID2D1Brush_AddRef(context->brush);
52 return context->brush;
53}
54
56{
57 if (src->left > dst->left)
58 dst->left = src->left;
59 if (src->top > dst->top)
60 dst->top = src->top;
61 if (src->right < dst->right)
62 dst->right = src->right;
63 if (src->bottom < dst->bottom)
64 dst->bottom = src->bottom;
65}
66
67static void d2d_rect_set(D2D1_RECT_F *dst, float left, float top, float right, float bottom)
68{
69 dst->left = left;
70 dst->top = top;
71 dst->right = right;
72 dst->bottom = bottom;
73}
74
75static void d2d_size_set(D2D1_SIZE_U *dst, float width, float height)
76{
77 dst->width = width;
78 dst->height = height;
79}
80
82{
83 if (!(stack->stack = malloc(INITIAL_CLIP_STACK_SIZE * sizeof(*stack->stack))))
84 return FALSE;
85
87 stack->count = 0;
88
89 return TRUE;
90}
91
93{
95}
96
98{
100
101 if (!d2d_array_reserve((void **)&stack->stack, &stack->size, stack->count + 1, sizeof(*stack->stack)))
102 return FALSE;
103
104 r = *rect;
105 if (stack->count)
106 d2d_rect_intersect(&r, &stack->stack[stack->count - 1]);
107 stack->stack[stack->count++] = r;
108
109 return TRUE;
110}
111
113{
114 if (!stack->count)
115 return;
116 --stack->count;
117}
118
119static void d2d_device_context_draw(struct d2d_device_context *render_target, enum d2d_shape_type shape_type,
120 ID3D11Buffer *ib, unsigned int index_count, ID3D11Buffer *vb, unsigned int vb_stride,
121 struct d2d_brush *brush, struct d2d_brush *opacity_brush)
122{
123 struct d2d_shape_resources *shape_resources = &render_target->shape_resources[shape_type];
124 ID3DDeviceContextState *prev_state;
125 ID3D11Device1 *device = render_target->d3d_device;
127 ID3D11Buffer *vs_cb = render_target->vs_cb, *ps_cb = render_target->ps_cb;
128 D3D11_RECT scissor_rect;
129 unsigned int offset;
130 D3D11_VIEWPORT vp;
131
132 vp.TopLeftX = 0;
133 vp.TopLeftY = 0;
134 vp.Width = render_target->pixel_size.width;
135 vp.Height = render_target->pixel_size.height;
136 vp.MinDepth = 0.0f;
137 vp.MaxDepth = 1.0f;
138
139 if (render_target->cs)
140 EnterCriticalSection(render_target->cs);
141
142 ID3D11Device1_GetImmediateContext1(device, &context);
143 ID3D11DeviceContext1_SwapDeviceContextState(context, render_target->d3d_state, &prev_state);
144
145 ID3D11DeviceContext1_IASetInputLayout(context, shape_resources->il);
146 ID3D11DeviceContext1_IASetPrimitiveTopology(context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
147 ID3D11DeviceContext1_IASetIndexBuffer(context, ib, DXGI_FORMAT_R16_UINT, 0);
148 offset = 0;
149 ID3D11DeviceContext1_IASetVertexBuffers(context, 0, 1, &vb, &vb_stride, &offset);
150 ID3D11DeviceContext1_VSSetConstantBuffers(context, 0, 1, &vs_cb);
151 ID3D11DeviceContext1_VSSetShader(context, shape_resources->vs, NULL, 0);
152 ID3D11DeviceContext1_PSSetConstantBuffers(context, 0, 1, &ps_cb);
153 ID3D11DeviceContext1_PSSetShader(context, render_target->ps, NULL, 0);
154 ID3D11DeviceContext1_RSSetViewports(context, 1, &vp);
155 if (render_target->clip_stack.count)
156 {
157 const D2D1_RECT_F *clip_rect;
158
159 clip_rect = &render_target->clip_stack.stack[render_target->clip_stack.count - 1];
160 scissor_rect.left = ceilf(clip_rect->left - 0.5f);
161 scissor_rect.top = ceilf(clip_rect->top - 0.5f);
162 scissor_rect.right = ceilf(clip_rect->right - 0.5f);
163 scissor_rect.bottom = ceilf(clip_rect->bottom - 0.5f);
164 }
165 else
166 {
167 scissor_rect.left = 0.0f;
168 scissor_rect.top = 0.0f;
169 scissor_rect.right = render_target->pixel_size.width;
170 scissor_rect.bottom = render_target->pixel_size.height;
171 }
172 ID3D11DeviceContext1_RSSetScissorRects(context, 1, &scissor_rect);
173 ID3D11DeviceContext1_RSSetState(context, render_target->rs);
174 ID3D11DeviceContext1_OMSetRenderTargets(context, 1, &render_target->target.bitmap->rtv, NULL);
175 if (brush)
176 {
177 ID3D11DeviceContext1_OMSetBlendState(context, render_target->bs, NULL, D3D11_DEFAULT_SAMPLE_MASK);
178 d2d_brush_bind_resources(brush, render_target, 0);
179 }
180 else
181 {
182 ID3D11DeviceContext1_OMSetBlendState(context, NULL, NULL, D3D11_DEFAULT_SAMPLE_MASK);
183 }
184 if (opacity_brush)
185 d2d_brush_bind_resources(opacity_brush, render_target, 1);
186
187 if (ib)
188 ID3D11DeviceContext1_DrawIndexed(context, index_count, 0, 0);
189 else
190 ID3D11DeviceContext1_Draw(context, index_count, 0);
191
192 ID3D11DeviceContext1_SwapDeviceContextState(context, prev_state, NULL);
193 ID3D11DeviceContext1_Release(context);
194 ID3DDeviceContextState_Release(prev_state);
195
196 if (render_target->cs)
197 LeaveCriticalSection(render_target->cs);
198}
199
201{
202 context->error.code = code;
203 context->error.tag1 = context->drawing_state.tag1;
204 context->error.tag2 = context->drawing_state.tag2;
205}
206
207static inline struct d2d_device_context *impl_from_IUnknown(IUnknown *iface)
208{
210}
211
213{
215}
216
218{
220
221 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
222
223 if (IsEqualGUID(iid, &IID_ID2D1DeviceContext6)
224 || IsEqualGUID(iid, &IID_ID2D1DeviceContext5)
225 || IsEqualGUID(iid, &IID_ID2D1DeviceContext4)
226 || IsEqualGUID(iid, &IID_ID2D1DeviceContext3)
227 || IsEqualGUID(iid, &IID_ID2D1DeviceContext2)
228 || IsEqualGUID(iid, &IID_ID2D1DeviceContext1)
229 || IsEqualGUID(iid, &IID_ID2D1DeviceContext)
230 || IsEqualGUID(iid, &IID_ID2D1RenderTarget)
231 || IsEqualGUID(iid, &IID_ID2D1Resource)
232 || IsEqualGUID(iid, &IID_IUnknown))
233 {
234 ID2D1DeviceContext6_AddRef(&context->ID2D1DeviceContext6_iface);
235 *out = &context->ID2D1DeviceContext6_iface;
236 return S_OK;
237 }
238 else if (IsEqualGUID(iid, &IID_ID2D1GdiInteropRenderTarget))
239 {
240 ID2D1GdiInteropRenderTarget_AddRef(&context->ID2D1GdiInteropRenderTarget_iface);
241 *out = &context->ID2D1GdiInteropRenderTarget_iface;
242 return S_OK;
243 }
244
245 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
246
247 *out = NULL;
248 return E_NOINTERFACE;
249}
250
252{
255
256 TRACE("%p increasing refcount to %lu.\n", iface, refcount);
257
258 return refcount;
259}
260
262{
265
266 TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
267
268 if (!refcount)
269 {
270 unsigned int i, j, k;
271
272 d2d_clip_stack_cleanup(&context->clip_stack);
273 IDWriteRenderingParams_Release(context->default_text_rendering_params);
274 if (context->text_rendering_params)
275 IDWriteRenderingParams_Release(context->text_rendering_params);
276 if (context->bs)
277 ID3D11BlendState_Release(context->bs);
278 ID3D11RasterizerState_Release(context->rs);
279 ID3D11Buffer_Release(context->vb);
280 ID3D11Buffer_Release(context->ib);
281 ID3D11Buffer_Release(context->ps_cb);
282 ID3D11PixelShader_Release(context->ps);
283 ID3D11Buffer_Release(context->vs_cb);
284 for (i = 0; i < D2D_SHAPE_TYPE_COUNT; ++i)
285 {
286 ID3D11VertexShader_Release(context->shape_resources[i].vs);
287 ID3D11InputLayout_Release(context->shape_resources[i].il);
288 }
290 {
291 for (j = 0; j < D2D_SAMPLER_EXTEND_MODE_COUNT; ++j)
292 {
293 for (k = 0; k < D2D_SAMPLER_EXTEND_MODE_COUNT; ++k)
294 {
295 if (context->sampler_states[i][j][k])
296 ID3D11SamplerState_Release(context->sampler_states[i][j][k]);
297 }
298 }
299 }
300 if (context->d3d_state)
301 ID3DDeviceContextState_Release(context->d3d_state);
302 if (context->target.object)
303 IUnknown_Release(context->target.object);
304 ID3D11Device1_Release(context->d3d_device);
305 ID2D1Factory_Release(context->factory);
306 ID2D1Device6_Release(&context->device->ID2D1Device6_iface);
308 free(context);
309 }
310
311 return refcount;
312}
313
314static const struct IUnknownVtbl d2d_device_context_inner_unknown_vtbl =
315{
319};
320
322 REFIID iid, void **out)
323{
325
326 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
327
328 return IUnknown_QueryInterface(context->outer_unknown, iid, out);
329}
330
332{
334
335 TRACE("iface %p.\n", iface);
336
337 return IUnknown_AddRef(context->outer_unknown);
338}
339
341{
343
344 TRACE("iface %p.\n", iface);
345
346 return IUnknown_Release(context->outer_unknown);
347}
348
350{
351 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
352
353 TRACE("iface %p, factory %p.\n", iface, factory);
354
355 *factory = render_target->factory;
356 ID2D1Factory_AddRef(*factory);
357}
358
360 D2D1_SIZE_U size, const void *src_data, UINT32 pitch, const D2D1_BITMAP_PROPERTIES *desc, ID2D1Bitmap **bitmap)
361{
363 D2D1_BITMAP_PROPERTIES1 bitmap_desc;
364 struct d2d_bitmap *object;
365 HRESULT hr;
366
367 TRACE("iface %p, size {%u, %u}, src_data %p, pitch %u, desc %p, bitmap %p.\n",
368 iface, size.width, size.height, src_data, pitch, desc, bitmap);
369
370 if (desc)
371 {
372 memcpy(&bitmap_desc, desc, sizeof(*desc));
373 bitmap_desc.bitmapOptions = 0;
374 bitmap_desc.colorContext = NULL;
375 }
376
377 if (SUCCEEDED(hr = d2d_bitmap_create(context, size, src_data, pitch, desc ? &bitmap_desc : NULL, &object)))
378 *bitmap = (ID2D1Bitmap *)&object->ID2D1Bitmap1_iface;
379
380 return hr;
381}
382
385{
387 D2D1_BITMAP_PROPERTIES1 bitmap_desc;
388 struct d2d_bitmap *object;
389 HRESULT hr;
390
391 TRACE("iface %p, bitmap_source %p, desc %p, bitmap %p.\n",
392 iface, bitmap_source, desc, bitmap);
393
394 if (desc)
395 {
396 memcpy(&bitmap_desc, desc, sizeof(*desc));
397 bitmap_desc.bitmapOptions = 0;
398 bitmap_desc.colorContext = NULL;
399 }
400
401 if (SUCCEEDED(hr = d2d_bitmap_create_from_wic_bitmap(context, bitmap_source, desc ? &bitmap_desc : NULL, &object)))
402 *bitmap = (ID2D1Bitmap *)&object->ID2D1Bitmap1_iface;
403
404 return hr;
405}
406
409{
411 D2D1_BITMAP_PROPERTIES1 bitmap_desc;
412 struct d2d_bitmap *object;
413 HRESULT hr;
414
415 TRACE("iface %p, iid %s, data %p, desc %p, bitmap %p.\n",
416 iface, debugstr_guid(iid), data, desc, bitmap);
417
418 if (desc)
419 {
420 memcpy(&bitmap_desc, desc, sizeof(*desc));
421 if (IsEqualIID(iid, &IID_IDXGISurface) || IsEqualIID(iid, &IID_IDXGISurface1))
423 else
425 bitmap_desc.colorContext = NULL;
426 }
427
428 if (SUCCEEDED(hr = d2d_bitmap_create_shared(context, iid, data, desc ? &bitmap_desc : NULL, &object)))
429 *bitmap = (ID2D1Bitmap *)&object->ID2D1Bitmap1_iface;
430
431 return hr;
432}
433
435 ID2D1Bitmap *bitmap, const D2D1_BITMAP_BRUSH_PROPERTIES *bitmap_brush_desc,
436 const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1BitmapBrush **brush)
437{
439 struct d2d_brush *object;
440 HRESULT hr;
441
442 TRACE("iface %p, bitmap %p, bitmap_brush_desc %p, brush_desc %p, brush %p.\n",
443 iface, bitmap, bitmap_brush_desc, brush_desc, brush);
444
445 if (SUCCEEDED(hr = d2d_bitmap_brush_create(context->factory, bitmap, (const D2D1_BITMAP_BRUSH_PROPERTIES1 *)bitmap_brush_desc,
446 brush_desc, &object)))
447 *brush = (ID2D1BitmapBrush *)&object->ID2D1Brush_iface;
448
449 return hr;
450}
451
454{
455 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
456 struct d2d_brush *object;
457 HRESULT hr;
458
459 TRACE("iface %p, color %p, desc %p, brush %p.\n", iface, color, desc, brush);
460
461 if (SUCCEEDED(hr = d2d_solid_color_brush_create(render_target->factory, color, desc, &object)))
462 *brush = (ID2D1SolidColorBrush *)&object->ID2D1Brush_iface;
463
464 return hr;
465}
466
468 const D2D1_GRADIENT_STOP *stops, UINT32 stop_count, D2D1_GAMMA gamma, D2D1_EXTEND_MODE extend_mode,
470{
471 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
472 struct d2d_gradient *object;
473 HRESULT hr;
474
475 TRACE("iface %p, stops %p, stop_count %u, gamma %#x, extend_mode %#x, gradient %p.\n",
476 iface, stops, stop_count, gamma, extend_mode, gradient);
477
478 if (SUCCEEDED(hr = d2d_gradient_create(render_target->factory, render_target->d3d_device,
479 stops, stop_count, gamma, extend_mode, &object)))
480 *gradient = &object->ID2D1GradientStopCollection_iface;
481
482 return hr;
483}
484
486 const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES *gradient_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
488{
489 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
490 struct d2d_brush *object;
491 HRESULT hr;
492
493 TRACE("iface %p, gradient_brush_desc %p, brush_desc %p, gradient %p, brush %p.\n",
494 iface, gradient_brush_desc, brush_desc, gradient, brush);
495
496 if (SUCCEEDED(hr = d2d_linear_gradient_brush_create(render_target->factory, gradient_brush_desc, brush_desc,
497 gradient, &object)))
498 *brush = (ID2D1LinearGradientBrush *)&object->ID2D1Brush_iface;
499
500 return hr;
501}
502
504 const D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES *gradient_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
506{
507 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
508 struct d2d_brush *object;
509 HRESULT hr;
510
511 TRACE("iface %p, gradient_brush_desc %p, brush_desc %p, gradient %p, brush %p.\n",
512 iface, gradient_brush_desc, brush_desc, gradient, brush);
513
515 gradient_brush_desc, brush_desc, gradient, &object)))
516 *brush = (ID2D1RadialGradientBrush *)&object->ID2D1Brush_iface;
517
518 return hr;
519}
520
522 const D2D1_SIZE_F *size, const D2D1_SIZE_U *pixel_size, const D2D1_PIXEL_FORMAT *format,
524{
525 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
527 HRESULT hr;
528
529 TRACE("iface %p, size %p, pixel_size %p, format %p, options %#x, render_target %p.\n",
530 iface, size, pixel_size, format, options, rt);
531
532 if (!(object = calloc(1, sizeof(*object))))
533 return E_OUTOFMEMORY;
534
535 if (FAILED(hr = d2d_bitmap_render_target_init(object, render_target, size, pixel_size,
536 format, options)))
537 {
538 WARN("Failed to initialise render target, hr %#lx.\n", hr);
539 free(object);
540 return hr;
541 }
542
543 TRACE("Created render target %p.\n", object);
544 *rt = &object->ID2D1BitmapRenderTarget_iface;
545
546 return S_OK;
547}
548
551{
552 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
553 struct d2d_layer *object;
554 HRESULT hr;
555
556 TRACE("iface %p, size %p, layer %p.\n", iface, size, layer);
557
558 if (SUCCEEDED(hr = d2d_layer_create(render_target->factory, size, &object)))
559 *layer = &object->ID2D1Layer_iface;
560
561 return hr;
562}
563
565{
566 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
567 struct d2d_mesh *object;
568 HRESULT hr;
569
570 TRACE("iface %p, mesh %p.\n", iface, mesh);
571
572 if (SUCCEEDED(hr = d2d_mesh_create(render_target->factory, &object)))
573 *mesh = &object->ID2D1Mesh_iface;
574
575 return hr;
576}
577
579 D2D1_POINT_2F p0, D2D1_POINT_2F p1, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
580{
582 ID2D1PathGeometry *geometry;
584 HRESULT hr;
585
586 TRACE("iface %p, p0 %s, p1 %s, brush %p, stroke_width %.8e, stroke_style %p.\n",
587 iface, debug_d2d_point_2f(&p0), debug_d2d_point_2f(&p1), brush, stroke_width, stroke_style);
588
589 if (context->target.type == D2D_TARGET_COMMAND_LIST)
590 {
591 d2d_command_list_draw_line(context->target.command_list, context, p0, p1, brush, stroke_width, stroke_style);
592 return;
593 }
594
595 if (FAILED(hr = ID2D1Factory_CreatePathGeometry(context->factory, &geometry)))
596 {
597 WARN("Failed to create path geometry, hr %#lx.\n", hr);
598 return;
599 }
600
601 if (FAILED(hr = ID2D1PathGeometry_Open(geometry, &sink)))
602 {
603 WARN("Failed to open geometry sink, hr %#lx.\n", hr);
604 ID2D1PathGeometry_Release(geometry);
605 return;
606 }
607
608 ID2D1GeometrySink_BeginFigure(sink, p0, D2D1_FIGURE_BEGIN_HOLLOW);
609 ID2D1GeometrySink_AddLine(sink, p1);
610 ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_OPEN);
611 if (FAILED(hr = ID2D1GeometrySink_Close(sink)))
612 WARN("Failed to close geometry sink, hr %#lx.\n", hr);
613 ID2D1GeometrySink_Release(sink);
614
615 ID2D1DeviceContext6_DrawGeometry(iface, (ID2D1Geometry *)geometry, brush, stroke_width, stroke_style);
616 ID2D1PathGeometry_Release(geometry);
617}
618
620 const D2D1_RECT_F *rect, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
621{
623 ID2D1RectangleGeometry *geometry;
624 HRESULT hr;
625
626 TRACE("iface %p, rect %s, brush %p, stroke_width %.8e, stroke_style %p.\n",
627 iface, debug_d2d_rect_f(rect), brush, stroke_width, stroke_style);
628
629 if (context->target.type == D2D_TARGET_COMMAND_LIST)
630 {
631 d2d_command_list_draw_rectangle(context->target.command_list, context, rect, brush, stroke_width, stroke_style);
632 return;
633 }
634
635 if (FAILED(hr = ID2D1Factory_CreateRectangleGeometry(context->factory, rect, &geometry)))
636 {
637 ERR("Failed to create geometry, hr %#lx.\n", hr);
638 return;
639 }
640
641 ID2D1DeviceContext6_DrawGeometry(iface, (ID2D1Geometry *)geometry, brush, stroke_width, stroke_style);
642 ID2D1RectangleGeometry_Release(geometry);
643}
644
646 const D2D1_RECT_F *rect, ID2D1Brush *brush)
647{
649 ID2D1RectangleGeometry *geometry;
650 HRESULT hr;
651
652 TRACE("iface %p, rect %s, brush %p.\n", iface, debug_d2d_rect_f(rect), brush);
653
654 if (context->target.type == D2D_TARGET_COMMAND_LIST)
655 {
656 d2d_command_list_fill_rectangle(context->target.command_list, context, rect, brush);
657 return;
658 }
659
660 if (FAILED(hr = ID2D1Factory_CreateRectangleGeometry(context->factory, rect, &geometry)))
661 {
662 ERR("Failed to create geometry, hr %#lx.\n", hr);
663 return;
664 }
665
666 ID2D1DeviceContext6_FillGeometry(iface, (ID2D1Geometry *)geometry, brush, NULL);
667 ID2D1RectangleGeometry_Release(geometry);
668}
669
671 const D2D1_ROUNDED_RECT *rect, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
672{
673 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
675 HRESULT hr;
676
677 TRACE("iface %p, rect %p, brush %p, stroke_width %.8e, stroke_style %p.\n",
678 iface, rect, brush, stroke_width, stroke_style);
679
680 if (FAILED(hr = ID2D1Factory_CreateRoundedRectangleGeometry(render_target->factory, rect, &geometry)))
681 {
682 ERR("Failed to create geometry, hr %#lx.\n", hr);
683 return;
684 }
685
686 ID2D1DeviceContext6_DrawGeometry(iface, (ID2D1Geometry *)geometry, brush, stroke_width, stroke_style);
687 ID2D1RoundedRectangleGeometry_Release(geometry);
688}
689
691 const D2D1_ROUNDED_RECT *rect, ID2D1Brush *brush)
692{
693 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
695 HRESULT hr;
696
697 TRACE("iface %p, rect %p, brush %p.\n", iface, rect, brush);
698
699 if (FAILED(hr = ID2D1Factory_CreateRoundedRectangleGeometry(render_target->factory, rect, &geometry)))
700 {
701 ERR("Failed to create geometry, hr %#lx.\n", hr);
702 return;
703 }
704
705 ID2D1DeviceContext6_FillGeometry(iface, (ID2D1Geometry *)geometry, brush, NULL);
706 ID2D1RoundedRectangleGeometry_Release(geometry);
707}
708
710 const D2D1_ELLIPSE *ellipse, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
711{
712 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
713 ID2D1EllipseGeometry *geometry;
714 HRESULT hr;
715
716 TRACE("iface %p, ellipse %p, brush %p, stroke_width %.8e, stroke_style %p.\n",
717 iface, ellipse, brush, stroke_width, stroke_style);
718
719 if (FAILED(hr = ID2D1Factory_CreateEllipseGeometry(render_target->factory, ellipse, &geometry)))
720 {
721 ERR("Failed to create geometry, hr %#lx.\n", hr);
722 return;
723 }
724
725 ID2D1DeviceContext6_DrawGeometry(iface, (ID2D1Geometry *)geometry, brush, stroke_width, stroke_style);
726 ID2D1EllipseGeometry_Release(geometry);
727}
728
730 const D2D1_ELLIPSE *ellipse, ID2D1Brush *brush)
731{
732 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
733 ID2D1EllipseGeometry *geometry;
734 HRESULT hr;
735
736 TRACE("iface %p, ellipse %p, brush %p.\n", iface, ellipse, brush);
737
738 if (FAILED(hr = ID2D1Factory_CreateEllipseGeometry(render_target->factory, ellipse, &geometry)))
739 {
740 ERR("Failed to create geometry, hr %#lx.\n", hr);
741 return;
742 }
743
744 ID2D1DeviceContext6_FillGeometry(iface, (ID2D1Geometry *)geometry, brush, NULL);
745 ID2D1EllipseGeometry_Release(geometry);
746}
747
749 struct d2d_brush *brush, struct d2d_brush *opacity_brush, BOOL outline, BOOL is_arc)
750{
752 ID3D11DeviceContext *d3d_context;
753 struct d2d_ps_cb *cb_data;
754 HRESULT hr;
755
756 ID3D11Device1_GetImmediateContext(context->d3d_device, &d3d_context);
757
758 if (FAILED(hr = ID3D11DeviceContext_Map(d3d_context, (ID3D11Resource *)context->ps_cb,
759 0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc)))
760 {
761 WARN("Failed to map constant buffer, hr %#lx.\n", hr);
762 ID3D11DeviceContext_Release(d3d_context);
763 return hr;
764 }
765
766 cb_data = map_desc.pData;
767 cb_data->outline = outline;
768 cb_data->is_arc = is_arc;
769 cb_data->pad[0] = 0;
770 cb_data->pad[1] = 0;
771 if (!d2d_brush_fill_cb(brush, &cb_data->colour_brush))
772 WARN("Failed to initialize colour brush buffer.\n");
774 WARN("Failed to initialize opacity brush buffer.\n");
775
776 ID3D11DeviceContext_Unmap(d3d_context, (ID3D11Resource *)context->ps_cb, 0);
777 ID3D11DeviceContext_Release(d3d_context);
778
779 return hr;
780}
781
783 const D2D_MATRIX_3X2_F *geometry_transform, float stroke_width)
784{
786 ID3D11DeviceContext *d3d_context;
787 const D2D1_MATRIX_3X2_F *w;
788 struct d2d_vs_cb *cb_data;
789 float tmp_x, tmp_y;
790 HRESULT hr;
791
792 ID3D11Device1_GetImmediateContext(context->d3d_device, &d3d_context);
793
794 if (FAILED(hr = ID3D11DeviceContext_Map(d3d_context, (ID3D11Resource *)context->vs_cb,
795 0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc)))
796 {
797 WARN("Failed to map constant buffer, hr %#lx.\n", hr);
798 ID3D11DeviceContext_Release(d3d_context);
799 return hr;
800 }
801
802 cb_data = map_desc.pData;
803 cb_data->transform_geometry._11 = geometry_transform->_11;
804 cb_data->transform_geometry._21 = geometry_transform->_21;
805 cb_data->transform_geometry._31 = geometry_transform->_31;
806 cb_data->transform_geometry.pad0 = 0.0f;
807 cb_data->transform_geometry._12 = geometry_transform->_12;
808 cb_data->transform_geometry._22 = geometry_transform->_22;
809 cb_data->transform_geometry._32 = geometry_transform->_32;
810 cb_data->transform_geometry.stroke_width = stroke_width;
811
812 w = &context->drawing_state.transform;
813
814 tmp_x = context->desc.dpiX / 96.0f;
815 cb_data->transform_rtx.x = w->_11 * tmp_x;
816 cb_data->transform_rtx.y = w->_21 * tmp_x;
817 cb_data->transform_rtx.z = w->_31 * tmp_x;
818 cb_data->transform_rtx.w = 2.0f / context->pixel_size.width;
819
820 tmp_y = context->desc.dpiY / 96.0f;
821 cb_data->transform_rty.x = w->_12 * tmp_y;
822 cb_data->transform_rty.y = w->_22 * tmp_y;
823 cb_data->transform_rty.z = w->_32 * tmp_y;
824 cb_data->transform_rty.w = -2.0f / context->pixel_size.height;
825
826 ID3D11DeviceContext_Unmap(d3d_context, (ID3D11Resource *)context->vs_cb, 0);
827 ID3D11DeviceContext_Release(d3d_context);
828
829 return S_OK;
830}
831
832static void d2d_device_context_draw_geometry(struct d2d_device_context *render_target,
833 const struct d2d_geometry *geometry, struct d2d_brush *brush, float stroke_width)
834{
835 D3D11_SUBRESOURCE_DATA buffer_data;
836 D3D11_BUFFER_DESC buffer_desc;
837 ID3D11Buffer *ib, *vb;
838 HRESULT hr;
839
840 if (FAILED(hr = d2d_device_context_update_vs_cb(render_target, &geometry->transform, stroke_width)))
841 {
842 WARN("Failed to update vs constant buffer, hr %#lx.\n", hr);
843 return;
844 }
845
846 if (FAILED(hr = d2d_device_context_update_ps_cb(render_target, brush, NULL, TRUE, FALSE)))
847 {
848 WARN("Failed to update ps constant buffer, hr %#lx.\n", hr);
849 return;
850 }
851
852 buffer_desc.Usage = D3D11_USAGE_DEFAULT;
853 buffer_desc.CPUAccessFlags = 0;
854 buffer_desc.MiscFlags = 0;
855
856 buffer_data.SysMemPitch = 0;
857 buffer_data.SysMemSlicePitch = 0;
858
859 if (geometry->outline.face_count)
860 {
861 buffer_desc.ByteWidth = geometry->outline.face_count * sizeof(*geometry->outline.faces);
862 buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
863 buffer_data.pSysMem = geometry->outline.faces;
864
865 if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &ib)))
866 {
867 WARN("Failed to create index buffer, hr %#lx.\n", hr);
868 return;
869 }
870
871 buffer_desc.ByteWidth = geometry->outline.vertex_count * sizeof(*geometry->outline.vertices);
872 buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
873 buffer_data.pSysMem = geometry->outline.vertices;
874
875 if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb)))
876 {
877 ERR("Failed to create vertex buffer, hr %#lx.\n", hr);
878 ID3D11Buffer_Release(ib);
879 return;
880 }
881
882 d2d_device_context_draw(render_target, D2D_SHAPE_TYPE_OUTLINE, ib, 3 * geometry->outline.face_count, vb,
883 sizeof(*geometry->outline.vertices), brush, NULL);
884
885 ID3D11Buffer_Release(vb);
886 ID3D11Buffer_Release(ib);
887 }
888
889 if (geometry->outline.bezier_face_count)
890 {
891 buffer_desc.ByteWidth = geometry->outline.bezier_face_count * sizeof(*geometry->outline.bezier_faces);
892 buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
893 buffer_data.pSysMem = geometry->outline.bezier_faces;
894
895 if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &ib)))
896 {
897 WARN("Failed to create curves index buffer, hr %#lx.\n", hr);
898 return;
899 }
900
901 buffer_desc.ByteWidth = geometry->outline.bezier_count * sizeof(*geometry->outline.beziers);
902 buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
903 buffer_data.pSysMem = geometry->outline.beziers;
904
905 if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb)))
906 {
907 ERR("Failed to create curves vertex buffer, hr %#lx.\n", hr);
908 ID3D11Buffer_Release(ib);
909 return;
910 }
911
913 3 * geometry->outline.bezier_face_count, vb,
914 sizeof(*geometry->outline.beziers), brush, NULL);
915
916 ID3D11Buffer_Release(vb);
917 ID3D11Buffer_Release(ib);
918 }
919
920 if (geometry->outline.arc_face_count)
921 {
922 buffer_desc.ByteWidth = geometry->outline.arc_face_count * sizeof(*geometry->outline.arc_faces);
923 buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
924 buffer_data.pSysMem = geometry->outline.arc_faces;
925
926 if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &ib)))
927 {
928 WARN("Failed to create arcs index buffer, hr %#lx.\n", hr);
929 return;
930 }
931
932 buffer_desc.ByteWidth = geometry->outline.arc_count * sizeof(*geometry->outline.arcs);
933 buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
934 buffer_data.pSysMem = geometry->outline.arcs;
935
936 if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb)))
937 {
938 ERR("Failed to create arcs vertex buffer, hr %#lx.\n", hr);
939 ID3D11Buffer_Release(ib);
940 return;
941 }
942
943 if (SUCCEEDED(d2d_device_context_update_ps_cb(render_target, brush, NULL, TRUE, TRUE)))
945 3 * geometry->outline.arc_face_count, vb,
946 sizeof(*geometry->outline.arcs), brush, NULL);
947
948 ID3D11Buffer_Release(vb);
949 ID3D11Buffer_Release(ib);
950 }
951}
952
954 ID2D1Geometry *geometry, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
955{
956 const struct d2d_geometry *geometry_impl = unsafe_impl_from_ID2D1Geometry(geometry);
958 struct d2d_brush *brush_impl = unsafe_impl_from_ID2D1Brush(brush);
959 struct d2d_stroke_style *stroke_style_impl = unsafe_impl_from_ID2D1StrokeStyle(stroke_style);
960
961 TRACE("iface %p, geometry %p, brush %p, stroke_width %.8e, stroke_style %p.\n",
962 iface, geometry, brush, stroke_width, stroke_style);
963
964 if (context->target.type == D2D_TARGET_COMMAND_LIST)
965 {
966 d2d_command_list_draw_geometry(context->target.command_list, context, geometry, brush,
967 stroke_width, stroke_style);
968 return;
969 }
970
971 if (stroke_style)
972 FIXME("Ignoring stroke style %p.\n", stroke_style);
973
974 if (stroke_style_impl)
975 {
976 if (stroke_style_impl->desc.transformType == D2D1_STROKE_TRANSFORM_TYPE_FIXED)
977 stroke_width /= context->drawing_state.transform.m11;
978 }
979
980 d2d_device_context_draw_geometry(context, geometry_impl, brush_impl, stroke_width);
981}
982
983static void d2d_device_context_fill_geometry(struct d2d_device_context *render_target,
984 const struct d2d_geometry *geometry, struct d2d_brush *brush, struct d2d_brush *opacity_brush)
985{
986 D3D11_SUBRESOURCE_DATA buffer_data;
987 D3D11_BUFFER_DESC buffer_desc;
988 ID3D11Buffer *ib, *vb;
989 HRESULT hr;
990
991 buffer_desc.Usage = D3D11_USAGE_DEFAULT;
992 buffer_desc.CPUAccessFlags = 0;
993 buffer_desc.MiscFlags = 0;
994
995 buffer_data.SysMemPitch = 0;
996 buffer_data.SysMemSlicePitch = 0;
997
998 if (FAILED(hr = d2d_device_context_update_vs_cb(render_target, &geometry->transform, 0.0f)))
999 {
1000 WARN("Failed to update vs constant buffer, hr %#lx.\n", hr);
1001 return;
1002 }
1003
1004 if (FAILED(hr = d2d_device_context_update_ps_cb(render_target, brush, opacity_brush, FALSE, FALSE)))
1005 {
1006 WARN("Failed to update ps constant buffer, hr %#lx.\n", hr);
1007 return;
1008 }
1009
1010 if (geometry->fill.face_count)
1011 {
1012 buffer_desc.ByteWidth = geometry->fill.face_count * sizeof(*geometry->fill.faces);
1013 buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
1014 buffer_data.pSysMem = geometry->fill.faces;
1015
1016 if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &ib)))
1017 {
1018 WARN("Failed to create index buffer, hr %#lx.\n", hr);
1019 return;
1020 }
1021
1022 buffer_desc.ByteWidth = geometry->fill.vertex_count * sizeof(*geometry->fill.vertices);
1023 buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
1024 buffer_data.pSysMem = geometry->fill.vertices;
1025
1026 if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb)))
1027 {
1028 ERR("Failed to create vertex buffer, hr %#lx.\n", hr);
1029 ID3D11Buffer_Release(ib);
1030 return;
1031 }
1032
1033 d2d_device_context_draw(render_target, D2D_SHAPE_TYPE_TRIANGLE, ib, 3 * geometry->fill.face_count, vb,
1034 sizeof(*geometry->fill.vertices), brush, opacity_brush);
1035
1036 ID3D11Buffer_Release(vb);
1037 ID3D11Buffer_Release(ib);
1038 }
1039
1040 if (geometry->fill.bezier_vertex_count)
1041 {
1042 buffer_desc.ByteWidth = geometry->fill.bezier_vertex_count * sizeof(*geometry->fill.bezier_vertices);
1043 buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
1044 buffer_data.pSysMem = geometry->fill.bezier_vertices;
1045
1046 if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb)))
1047 {
1048 ERR("Failed to create curves vertex buffer, hr %#lx.\n", hr);
1049 return;
1050 }
1051
1052 d2d_device_context_draw(render_target, D2D_SHAPE_TYPE_CURVE, NULL, geometry->fill.bezier_vertex_count, vb,
1053 sizeof(*geometry->fill.bezier_vertices), brush, opacity_brush);
1054
1055 ID3D11Buffer_Release(vb);
1056 }
1057
1058 if (geometry->fill.arc_vertex_count)
1059 {
1060 buffer_desc.ByteWidth = geometry->fill.arc_vertex_count * sizeof(*geometry->fill.arc_vertices);
1061 buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
1062 buffer_data.pSysMem = geometry->fill.arc_vertices;
1063
1064 if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb)))
1065 {
1066 ERR("Failed to create arc vertex buffer, hr %#lx.\n", hr);
1067 return;
1068 }
1069
1070 if (SUCCEEDED(d2d_device_context_update_ps_cb(render_target, brush, opacity_brush, FALSE, TRUE)))
1071 d2d_device_context_draw(render_target, D2D_SHAPE_TYPE_CURVE, NULL, geometry->fill.arc_vertex_count, vb,
1072 sizeof(*geometry->fill.arc_vertices), brush, opacity_brush);
1073
1074 ID3D11Buffer_Release(vb);
1075 }
1076}
1077
1079 ID2D1Geometry *geometry, ID2D1Brush *brush, ID2D1Brush *opacity_brush)
1080{
1081 const struct d2d_geometry *geometry_impl = unsafe_impl_from_ID2D1Geometry(geometry);
1082 struct d2d_brush *opacity_brush_impl = unsafe_impl_from_ID2D1Brush(opacity_brush);
1084 struct d2d_brush *brush_impl = unsafe_impl_from_ID2D1Brush(brush);
1085
1086 TRACE("iface %p, geometry %p, brush %p, opacity_brush %p.\n", iface, geometry, brush, opacity_brush);
1087
1088 if (FAILED(context->error.code))
1089 return;
1090
1091 if (opacity_brush && brush_impl->type != D2D_BRUSH_TYPE_BITMAP)
1092 {
1094 return;
1095 }
1096
1097 if (context->target.type == D2D_TARGET_COMMAND_LIST)
1098 d2d_command_list_fill_geometry(context->target.command_list, context, geometry, brush, opacity_brush);
1099 else
1100 d2d_device_context_fill_geometry(context, geometry_impl, brush_impl, opacity_brush_impl);
1101}
1102
1104 ID2D1Mesh *mesh, ID2D1Brush *brush)
1105{
1107
1108 FIXME("iface %p, mesh %p, brush %p stub!\n", iface, mesh, brush);
1109
1110 if (context->target.type == D2D_TARGET_COMMAND_LIST)
1111 d2d_command_list_fill_mesh(context->target.command_list, context, mesh, brush);
1112}
1113
1116 const D2D1_RECT_F *dst_rect, const D2D1_RECT_F *src_rect)
1117{
1119
1120 FIXME("iface %p, mask %p, brush %p, content %#x, dst_rect %s, src_rect %s stub!\n",
1121 iface, mask, brush, content, debug_d2d_rect_f(dst_rect), debug_d2d_rect_f(src_rect));
1122
1123 if (FAILED(context->error.code))
1124 return;
1125
1126 if (context->drawing_state.antialiasMode != D2D1_ANTIALIAS_MODE_ALIASED)
1127 {
1129 return;
1130 }
1131
1133 {
1135 return;
1136 }
1137
1138 if (context->target.type == D2D_TARGET_COMMAND_LIST)
1139 d2d_command_list_fill_opacity_mask(context->target.command_list, context, mask, brush, dst_rect, src_rect);
1140}
1141
1143 const D2D1_RECT_F *dst_rect, float opacity, D2D1_INTERPOLATION_MODE interpolation_mode,
1144 const D2D1_RECT_F *src_rect, const D2D1_POINT_2F *offset,
1145 const D2D1_MATRIX_4X4_F *perspective_transform)
1146{
1147 D2D1_BITMAP_BRUSH_PROPERTIES1 bitmap_brush_desc;
1148 D2D1_BRUSH_PROPERTIES brush_desc;
1149 struct d2d_brush *brush;
1151 D2D1_RECT_F s, d;
1152 HRESULT hr;
1153
1154 if (perspective_transform)
1155 FIXME("Perspective transform is ignored.\n");
1156
1157 size = ID2D1Bitmap_GetSize(bitmap);
1158 d2d_rect_set(&s, 0.0f, 0.0f, size.width, size.height);
1159 if (src_rect && src_rect->left <= src_rect->right
1160 && src_rect->top <= src_rect->bottom)
1161 {
1162 d2d_rect_intersect(&s, src_rect);
1163 }
1164
1165 if (s.left == s.right || s.top == s.bottom)
1166 return;
1167
1168 if (dst_rect)
1169 {
1170 d = *dst_rect;
1171 }
1172 else
1173 {
1174 d.left = 0.0f;
1175 d.top = 0.0f;
1176 d.right = s.right - s.left;
1177 d.bottom = s.bottom - s.top;
1178 }
1179
1180 if (offset)
1181 {
1182 d.left += offset->x;
1183 d.top += offset->y;
1184 d.right += offset->x;
1185 d.bottom += offset->y;
1186 }
1187
1188 bitmap_brush_desc.extendModeX = D2D1_EXTEND_MODE_CLAMP;
1189 bitmap_brush_desc.extendModeY = D2D1_EXTEND_MODE_CLAMP;
1190 bitmap_brush_desc.interpolationMode = interpolation_mode;
1191
1192 brush_desc.opacity = opacity;
1193 brush_desc.transform._11 = fabsf((d.right - d.left) / (s.right - s.left));
1194 brush_desc.transform._21 = 0.0f;
1195 brush_desc.transform._31 = min(d.left, d.right) - min(s.left, s.right) * brush_desc.transform._11;
1196 brush_desc.transform._12 = 0.0f;
1197 brush_desc.transform._22 = fabsf((d.bottom - d.top) / (s.bottom - s.top));
1198 brush_desc.transform._32 = min(d.top, d.bottom) - min(s.top, s.bottom) * brush_desc.transform._22;
1199
1200 if (FAILED(hr = d2d_bitmap_brush_create(context->factory, bitmap, &bitmap_brush_desc, &brush_desc, &brush)))
1201 {
1202 ERR("Failed to create bitmap brush, hr %#lx.\n", hr);
1203 return;
1204 }
1205
1206 d2d_device_context_FillRectangle(&context->ID2D1DeviceContext6_iface, &d, &brush->ID2D1Brush_iface);
1207 ID2D1Brush_Release(&brush->ID2D1Brush_iface);
1208}
1209
1211 ID2D1Bitmap *bitmap, const D2D1_RECT_F *dst_rect, float opacity,
1213{
1215
1216 TRACE("iface %p, bitmap %p, dst_rect %s, opacity %.8e, interpolation_mode %#x, src_rect %s.\n",
1217 iface, bitmap, debug_d2d_rect_f(dst_rect), opacity, interpolation_mode, debug_d2d_rect_f(src_rect));
1218
1219 if (interpolation_mode != D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR
1220 && interpolation_mode != D2D1_BITMAP_INTERPOLATION_MODE_LINEAR)
1221 {
1223 return;
1224 }
1225
1226 if (context->target.type == D2D_TARGET_COMMAND_LIST)
1227 {
1228 d2d_command_list_draw_bitmap(context->target.command_list, bitmap, dst_rect, opacity,
1229 d2d1_1_interp_mode_from_d2d1(interpolation_mode), src_rect, NULL);
1230 }
1231 else
1232 {
1233 d2d_device_context_draw_bitmap(context, bitmap, dst_rect, opacity,
1234 d2d1_1_interp_mode_from_d2d1(interpolation_mode), src_rect, NULL, NULL);
1235 }
1236}
1237
1239 const WCHAR *string, UINT32 string_len, IDWriteTextFormat *text_format, const D2D1_RECT_F *layout_rect,
1241{
1242 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
1243 IDWriteTextLayout *text_layout;
1244 IDWriteFactory *dwrite_factory;
1246 float width, height;
1247 HRESULT hr;
1248
1249 TRACE("iface %p, string %s, string_len %u, text_format %p, layout_rect %s, "
1250 "brush %p, options %#x, measuring_mode %#x.\n",
1251 iface, debugstr_wn(string, string_len), string_len, text_format, debug_d2d_rect_f(layout_rect),
1252 brush, options, measuring_mode);
1253
1255 &IID_IDWriteFactory, (IUnknown **)&dwrite_factory)))
1256 {
1257 ERR("Failed to create dwrite factory, hr %#lx.\n", hr);
1258 return;
1259 }
1260
1261 width = max(0.0f, layout_rect->right - layout_rect->left);
1262 height = max(0.0f, layout_rect->bottom - layout_rect->top);
1263 if (measuring_mode == DWRITE_MEASURING_MODE_NATURAL)
1264 hr = IDWriteFactory_CreateTextLayout(dwrite_factory, string, string_len, text_format,
1265 width, height, &text_layout);
1266 else
1267 hr = IDWriteFactory_CreateGdiCompatibleTextLayout(dwrite_factory, string, string_len, text_format,
1268 width, height, render_target->desc.dpiX / 96.0f, (DWRITE_MATRIX *)&render_target->drawing_state.transform,
1269 measuring_mode == DWRITE_MEASURING_MODE_GDI_NATURAL, &text_layout);
1270 IDWriteFactory_Release(dwrite_factory);
1271 if (FAILED(hr))
1272 {
1273 ERR("Failed to create text layout, hr %#lx.\n", hr);
1274 return;
1275 }
1276
1277 d2d_point_set(&origin, min(layout_rect->left, layout_rect->right), min(layout_rect->top, layout_rect->bottom));
1278 ID2D1DeviceContext1_DrawTextLayout((ID2D1DeviceContext1 *)iface, origin, text_layout, brush, options);
1279 IDWriteTextLayout_Release(text_layout);
1280}
1281
1284{
1285 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
1287 HRESULT hr;
1288
1289 TRACE("iface %p, origin %s, layout %p, brush %p, options %#x.\n",
1290 iface, debug_d2d_point_2f(&origin), layout, brush, options);
1291
1292 ctx.brush = brush;
1293 ctx.options = options;
1294
1295 if (FAILED(hr = IDWriteTextLayout_Draw(layout,
1296 &ctx, &render_target->IDWriteTextRenderer_iface, origin.x, origin.y)))
1297 FIXME("Failed to draw text layout, hr %#lx.\n", hr);
1298}
1299
1301{
1302 D2D1_ANTIALIAS_MODE prev_antialias_mode = rt->drawing_state.antialiasMode;
1305 return prev_antialias_mode;
1306}
1307
1309 D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run, ID2D1Brush *brush)
1310{
1311 D2D1_MATRIX_3X2_F *transform, prev_transform;
1312 D2D1_ANTIALIAS_MODE prev_antialias_mode;
1313 ID2D1PathGeometry *geometry;
1315 HRESULT hr;
1316
1317 if (FAILED(hr = ID2D1Factory_CreatePathGeometry(render_target->factory, &geometry)))
1318 {
1319 ERR("Failed to create geometry, hr %#lx.\n", hr);
1320 return;
1321 }
1322
1323 if (FAILED(hr = ID2D1PathGeometry_Open(geometry, &sink)))
1324 {
1325 ERR("Failed to open geometry sink, hr %#lx.\n", hr);
1326 ID2D1PathGeometry_Release(geometry);
1327 return;
1328 }
1329
1330 if (FAILED(hr = IDWriteFontFace_GetGlyphRunOutline(glyph_run->fontFace, glyph_run->fontEmSize,
1331 glyph_run->glyphIndices, glyph_run->glyphAdvances, glyph_run->glyphOffsets, glyph_run->glyphCount,
1332 glyph_run->isSideways, glyph_run->bidiLevel & 1, (IDWriteGeometrySink *)sink)))
1333 {
1334 ERR("Failed to get glyph run outline, hr %#lx.\n", hr);
1335 ID2D1GeometrySink_Release(sink);
1336 ID2D1PathGeometry_Release(geometry);
1337 return;
1338 }
1339
1340 if (FAILED(hr = ID2D1GeometrySink_Close(sink)))
1341 ERR("Failed to close geometry sink, hr %#lx.\n", hr);
1342 ID2D1GeometrySink_Release(sink);
1343
1344 transform = &render_target->drawing_state.transform;
1345 prev_transform = *transform;
1346 transform->_31 += baseline_origin.x * transform->_11 + baseline_origin.y * transform->_21;
1347 transform->_32 += baseline_origin.x * transform->_12 + baseline_origin.y * transform->_22;
1348 prev_antialias_mode = d2d_device_context_set_aa_mode_from_text_aa_mode(render_target);
1351 render_target->drawing_state.antialiasMode = prev_antialias_mode;
1352 *transform = prev_transform;
1353
1354 ID2D1PathGeometry_Release(geometry);
1355}
1356
1358 D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run, ID2D1Brush *brush,
1359 DWRITE_RENDERING_MODE rendering_mode, DWRITE_MEASURING_MODE measuring_mode,
1360 DWRITE_TEXT_ANTIALIAS_MODE antialias_mode)
1361{
1362 ID2D1RectangleGeometry *geometry = NULL;
1363 ID2D1BitmapBrush *opacity_brush = NULL;
1364 D2D1_BITMAP_PROPERTIES bitmap_desc;
1365 ID2D1Bitmap *opacity_bitmap = NULL;
1366 IDWriteGlyphRunAnalysis *analysis;
1367 DWRITE_TEXTURE_TYPE texture_type;
1368 D2D1_BRUSH_PROPERTIES brush_desc;
1369 IDWriteFactory2 *dwrite_factory;
1371 void *opacity_values = NULL;
1372 size_t opacity_values_size;
1373 D2D1_SIZE_U bitmap_size;
1374 float scale_x, scale_y;
1375 D2D1_RECT_F run_rect;
1376 RECT bounds;
1377 HRESULT hr;
1378
1380 &IID_IDWriteFactory2, (IUnknown **)&dwrite_factory)))
1381 {
1382 ERR("Failed to create dwrite factory, hr %#lx.\n", hr);
1383 return;
1384 }
1385
1386 transform = &context->drawing_state.transform;
1387
1388 scale_x = context->desc.dpiX / 96.0f;
1389 m._11 = transform->_11 * scale_x;
1390 m._21 = transform->_21 * scale_x;
1391 m._31 = transform->_31 * scale_x;
1392
1393 scale_y = context->desc.dpiY / 96.0f;
1394 m._12 = transform->_12 * scale_y;
1395 m._22 = transform->_22 * scale_y;
1396 m._32 = transform->_32 * scale_y;
1397
1398 hr = IDWriteFactory2_CreateGlyphRunAnalysis(dwrite_factory, glyph_run, (DWRITE_MATRIX *)&m,
1399 rendering_mode, measuring_mode, DWRITE_GRID_FIT_MODE_DEFAULT, antialias_mode,
1400 baseline_origin.x, baseline_origin.y, &analysis);
1401 IDWriteFactory2_Release(dwrite_factory);
1402 if (FAILED(hr))
1403 {
1404 ERR("Failed to create glyph run analysis, hr %#lx.\n", hr);
1405 return;
1406 }
1407
1408 if (rendering_mode == DWRITE_RENDERING_MODE_ALIASED || antialias_mode == DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE)
1409 texture_type = DWRITE_TEXTURE_ALIASED_1x1;
1410 else
1411 texture_type = DWRITE_TEXTURE_CLEARTYPE_3x1;
1412
1413 if (FAILED(hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, texture_type, &bounds)))
1414 {
1415 ERR("Failed to get alpha texture bounds, hr %#lx.\n", hr);
1416 goto done;
1417 }
1418
1419 d2d_size_set(&bitmap_size, bounds.right - bounds.left, bounds.bottom - bounds.top);
1420 if (!bitmap_size.width || !bitmap_size.height)
1421 {
1422 /* Empty run, nothing to do. */
1423 goto done;
1424 }
1425
1426 if (texture_type == DWRITE_TEXTURE_CLEARTYPE_3x1)
1427 bitmap_size.width *= 3;
1428 if (!(opacity_values = calloc(bitmap_size.height, bitmap_size.width)))
1429 {
1430 ERR("Failed to allocate opacity values.\n");
1431 goto done;
1432 }
1433 opacity_values_size = bitmap_size.height * bitmap_size.width;
1434
1435 if (FAILED(hr = IDWriteGlyphRunAnalysis_CreateAlphaTexture(analysis,
1436 texture_type, &bounds, opacity_values, opacity_values_size)))
1437 {
1438 ERR("Failed to create alpha texture, hr %#lx.\n", hr);
1439 goto done;
1440 }
1441
1443 bitmap_desc.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED;
1444 bitmap_desc.dpiX = context->desc.dpiX;
1445 if (texture_type == DWRITE_TEXTURE_CLEARTYPE_3x1)
1446 bitmap_desc.dpiX *= 3.0f;
1447 bitmap_desc.dpiY = context->desc.dpiY;
1448 if (FAILED(hr = d2d_device_context_CreateBitmap(&context->ID2D1DeviceContext6_iface,
1449 bitmap_size, opacity_values, bitmap_size.width, &bitmap_desc, &opacity_bitmap)))
1450 {
1451 ERR("Failed to create opacity bitmap, hr %#lx.\n", hr);
1452 goto done;
1453 }
1454
1455 d2d_rect_set(&run_rect, bounds.left / scale_x, bounds.top / scale_y,
1456 bounds.right / scale_x, bounds.bottom / scale_y);
1457
1458 brush_desc.opacity = 1.0f;
1459 brush_desc.transform._11 = 1.0f;
1460 brush_desc.transform._12 = 0.0f;
1461 brush_desc.transform._21 = 0.0f;
1462 brush_desc.transform._22 = 1.0f;
1463 brush_desc.transform._31 = run_rect.left;
1464 brush_desc.transform._32 = run_rect.top;
1465 if (FAILED(hr = d2d_device_context_CreateBitmapBrush(&context->ID2D1DeviceContext6_iface,
1466 opacity_bitmap, NULL, &brush_desc, &opacity_brush)))
1467 {
1468 ERR("Failed to create opacity bitmap brush, hr %#lx.\n", hr);
1469 goto done;
1470 }
1471
1472 if (FAILED(hr = ID2D1Factory_CreateRectangleGeometry(context->factory, &run_rect, &geometry)))
1473 {
1474 ERR("Failed to create geometry, hr %#lx.\n", hr);
1475 goto done;
1476 }
1477
1478 m = *transform;
1482 *transform = m;
1483
1484done:
1485 if (geometry)
1486 ID2D1RectangleGeometry_Release(geometry);
1487 if (opacity_brush)
1488 ID2D1BitmapBrush_Release(opacity_brush);
1489 if (opacity_bitmap)
1490 ID2D1Bitmap_Release(opacity_bitmap);
1491 free(opacity_values);
1492 IDWriteGlyphRunAnalysis_Release(analysis);
1493}
1494
1496 D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run,
1497 const DWRITE_GLYPH_RUN_DESCRIPTION *glyph_run_desc, ID2D1Brush *brush, DWRITE_MEASURING_MODE measuring_mode)
1498{
1499 DWRITE_TEXT_ANTIALIAS_MODE antialias_mode = DWRITE_TEXT_ANTIALIAS_MODE_GRAYSCALE;
1500 IDWriteRenderingParams *rendering_params;
1501 DWRITE_RENDERING_MODE rendering_mode;
1502 HRESULT hr;
1503
1504 if (FAILED(context->error.code))
1505 return;
1506
1507 if (context->target.type == D2D_TARGET_COMMAND_LIST)
1508 {
1509 d2d_command_list_draw_glyph_run(context->target.command_list, context, baseline_origin, glyph_run,
1510 glyph_run_desc, brush, measuring_mode);
1511 return;
1512 }
1513
1514 rendering_params = context->text_rendering_params ? context->text_rendering_params
1515 : context->default_text_rendering_params;
1516
1517 rendering_mode = IDWriteRenderingParams_GetRenderingMode(rendering_params);
1518
1519 switch (context->drawing_state.textAntialiasMode)
1520 {
1522 if (rendering_mode == DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL
1527 break;
1528
1530 if (rendering_mode == DWRITE_RENDERING_MODE_ALIASED
1531 || rendering_mode == DWRITE_RENDERING_MODE_OUTLINE)
1533 break;
1534
1536 if (rendering_mode == DWRITE_RENDERING_MODE_ALIASED)
1538 break;
1539
1540 default:
1541 break;
1542 }
1543
1544 if (FAILED(context->error.code))
1545 return;
1546
1547 rendering_mode = DWRITE_RENDERING_MODE_DEFAULT;
1548 switch (context->drawing_state.textAntialiasMode)
1549 {
1551 if (IDWriteRenderingParams_GetClearTypeLevel(rendering_params) > 0.0f)
1552 antialias_mode = DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE;
1553 break;
1554
1556 antialias_mode = DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE;
1557 break;
1558
1560 rendering_mode = DWRITE_RENDERING_MODE_ALIASED;
1561 break;
1562
1563 default:
1564 break;
1565 }
1566
1567 if (rendering_mode == DWRITE_RENDERING_MODE_DEFAULT)
1568 {
1569 if (FAILED(hr = IDWriteFontFace_GetRecommendedRenderingMode(glyph_run->fontFace, glyph_run->fontEmSize,
1570 max(context->desc.dpiX, context->desc.dpiY) / 96.0f,
1571 measuring_mode, rendering_params, &rendering_mode)))
1572 {
1573 ERR("Failed to get recommended rendering mode, hr %#lx.\n", hr);
1574 rendering_mode = DWRITE_RENDERING_MODE_OUTLINE;
1575 }
1576 }
1577
1578 if (rendering_mode == DWRITE_RENDERING_MODE_OUTLINE)
1579 d2d_device_context_draw_glyph_run_outline(context, baseline_origin, glyph_run, brush);
1580 else
1581 d2d_device_context_draw_glyph_run_bitmap(context, baseline_origin, glyph_run, brush,
1582 rendering_mode, measuring_mode, antialias_mode);
1583}
1584
1586 D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run, ID2D1Brush *brush,
1587 DWRITE_MEASURING_MODE measuring_mode)
1588{
1590
1591 TRACE("iface %p, baseline_origin %s, glyph_run %p, brush %p, measuring_mode %#x.\n",
1592 iface, debug_d2d_point_2f(&baseline_origin), glyph_run, brush, measuring_mode);
1593
1594 d2d_device_context_draw_glyph_run(context, baseline_origin, glyph_run, NULL, brush, measuring_mode);
1595}
1596
1599{
1601
1602 TRACE("iface %p, transform %p.\n", iface, transform);
1603
1604 if (context->target.type == D2D_TARGET_COMMAND_LIST)
1605 d2d_command_list_set_transform(context->target.command_list, transform);
1606
1607 context->drawing_state.transform = *transform;
1608}
1609
1612{
1613 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
1614
1615 TRACE("iface %p, transform %p.\n", iface, transform);
1616
1617 *transform = render_target->drawing_state.transform;
1618}
1619
1621 D2D1_ANTIALIAS_MODE antialias_mode)
1622{
1624
1625 TRACE("iface %p, antialias_mode %#x stub!\n", iface, antialias_mode);
1626
1627 if (context->target.type == D2D_TARGET_COMMAND_LIST)
1628 d2d_command_list_set_antialias_mode(context->target.command_list, antialias_mode);
1629
1630 context->drawing_state.antialiasMode = antialias_mode;
1631}
1632
1634{
1635 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
1636
1637 TRACE("iface %p.\n", iface);
1638
1639 return render_target->drawing_state.antialiasMode;
1640}
1641
1643 D2D1_TEXT_ANTIALIAS_MODE antialias_mode)
1644{
1646
1647 TRACE("iface %p, antialias_mode %#x.\n", iface, antialias_mode);
1648
1649 if (context->target.type == D2D_TARGET_COMMAND_LIST)
1650 d2d_command_list_set_text_antialias_mode(context->target.command_list, antialias_mode);
1651
1652 context->drawing_state.textAntialiasMode = antialias_mode;
1653}
1654
1656{
1657 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
1658
1659 TRACE("iface %p.\n", iface);
1660
1661 return render_target->drawing_state.textAntialiasMode;
1662}
1663
1666{
1668
1669 TRACE("iface %p, text_rendering_params %p.\n", iface, text_rendering_params);
1670
1671 if (context->target.type == D2D_TARGET_COMMAND_LIST)
1673
1675 IDWriteRenderingParams_AddRef(text_rendering_params);
1676 if (context->text_rendering_params)
1677 IDWriteRenderingParams_Release(context->text_rendering_params);
1678 context->text_rendering_params = text_rendering_params;
1679}
1680
1683{
1684 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
1685
1686 TRACE("iface %p, text_rendering_params %p.\n", iface, text_rendering_params);
1687
1688 if ((*text_rendering_params = render_target->text_rendering_params))
1689 IDWriteRenderingParams_AddRef(*text_rendering_params);
1690}
1691
1693{
1695
1696 TRACE("iface %p, tag1 %s, tag2 %s.\n", iface, wine_dbgstr_longlong(tag1), wine_dbgstr_longlong(tag2));
1697
1698 if (context->target.type == D2D_TARGET_COMMAND_LIST)
1699 d2d_command_list_set_tags(context->target.command_list, tag1, tag2);
1700
1701 context->drawing_state.tag1 = tag1;
1702 context->drawing_state.tag2 = tag2;
1703}
1704
1706{
1707 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
1708
1709 TRACE("iface %p, tag1 %p, tag2 %p.\n", iface, tag1, tag2);
1710
1711 *tag1 = render_target->drawing_state.tag1;
1712 *tag2 = render_target->drawing_state.tag2;
1713}
1714
1716 const D2D1_LAYER_PARAMETERS *layer_parameters, ID2D1Layer *layer)
1717{
1719
1720 FIXME("iface %p, layer_parameters %p, layer %p stub!\n", iface, layer_parameters, layer);
1721
1722 if (context->target.type == D2D_TARGET_COMMAND_LIST)
1723 {
1725
1726 memcpy(&parameters, layer_parameters, sizeof(*layer_parameters));
1727 parameters.layerOptions = D2D1_LAYER_OPTIONS1_NONE;
1729 }
1730}
1731
1733{
1735
1736 FIXME("iface %p stub!\n", iface);
1737
1738 if (context->target.type == D2D_TARGET_COMMAND_LIST)
1739 d2d_command_list_pop_layer(context->target.command_list);
1740}
1741
1743{
1745
1746 FIXME("iface %p, tag1 %p, tag2 %p stub!\n", iface, tag1, tag2);
1747
1748 if (context->ops && context->ops->device_context_present)
1749 context->ops->device_context_present(context->outer_unknown);
1750
1751 return E_NOTIMPL;
1752}
1753
1755 ID2D1DrawingStateBlock *state_block)
1756{
1757 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
1758 struct d2d_state_block *state_block_impl;
1759
1760 TRACE("iface %p, state_block %p.\n", iface, state_block);
1761
1762 if (!(state_block_impl = unsafe_impl_from_ID2D1DrawingStateBlock(state_block))) return;
1763 state_block_impl->drawing_state = render_target->drawing_state;
1764 if (render_target->text_rendering_params)
1765 IDWriteRenderingParams_AddRef(render_target->text_rendering_params);
1766 if (state_block_impl->text_rendering_params)
1767 IDWriteRenderingParams_Release(state_block_impl->text_rendering_params);
1768 state_block_impl->text_rendering_params = render_target->text_rendering_params;
1769}
1770
1772 ID2D1DrawingStateBlock *state_block)
1773{
1775 struct d2d_state_block *state_block_impl;
1776
1777 TRACE("iface %p, state_block %p.\n", iface, state_block);
1778
1779 if (!(state_block_impl = unsafe_impl_from_ID2D1DrawingStateBlock(state_block))) return;
1780 if (context->target.type == D2D_TARGET_COMMAND_LIST)
1781 {
1782 struct d2d_command_list *command_list = context->target.command_list;
1783
1784 if (context->drawing_state.antialiasMode != state_block_impl->drawing_state.antialiasMode)
1785 d2d_command_list_set_antialias_mode(command_list, state_block_impl->drawing_state.antialiasMode);
1787 d2d_command_list_set_tags(command_list, state_block_impl->drawing_state.tag1, state_block_impl->drawing_state.tag2);
1788 d2d_command_list_set_transform(command_list, &state_block_impl->drawing_state.transform);
1789 d2d_command_list_set_primitive_blend(command_list, state_block_impl->drawing_state.primitiveBlend);
1790 d2d_command_list_set_unit_mode(command_list, state_block_impl->drawing_state.unitMode);
1792 }
1793
1794 context->drawing_state = state_block_impl->drawing_state;
1795 if (state_block_impl->text_rendering_params)
1796 IDWriteRenderingParams_AddRef(state_block_impl->text_rendering_params);
1797 if (context->text_rendering_params)
1798 IDWriteRenderingParams_Release(context->text_rendering_params);
1799 context->text_rendering_params = state_block_impl->text_rendering_params;
1800}
1801
1803 const D2D1_RECT_F *clip_rect, D2D1_ANTIALIAS_MODE antialias_mode)
1804{
1806 D2D1_RECT_F transformed_rect;
1807 float x_scale, y_scale;
1809
1810 TRACE("iface %p, clip_rect %s, antialias_mode %#x.\n", iface, debug_d2d_rect_f(clip_rect), antialias_mode);
1811
1812 if (context->target.type == D2D_TARGET_COMMAND_LIST)
1813 d2d_command_list_push_clip(context->target.command_list, clip_rect, antialias_mode);
1814
1815 if (antialias_mode != D2D1_ANTIALIAS_MODE_ALIASED)
1816 FIXME("Ignoring antialias_mode %#x.\n", antialias_mode);
1817
1818 x_scale = context->desc.dpiX / 96.0f;
1819 y_scale = context->desc.dpiY / 96.0f;
1820 d2d_point_transform(&point, &context->drawing_state.transform,
1821 clip_rect->left * x_scale, clip_rect->top * y_scale);
1822 d2d_rect_set(&transformed_rect, point.x, point.y, point.x, point.y);
1823 d2d_point_transform(&point, &context->drawing_state.transform,
1824 clip_rect->left * x_scale, clip_rect->bottom * y_scale);
1825 d2d_rect_expand(&transformed_rect, &point);
1826 d2d_point_transform(&point, &context->drawing_state.transform,
1827 clip_rect->right * x_scale, clip_rect->top * y_scale);
1828 d2d_rect_expand(&transformed_rect, &point);
1829 d2d_point_transform(&point, &context->drawing_state.transform,
1830 clip_rect->right * x_scale, clip_rect->bottom * y_scale);
1831 d2d_rect_expand(&transformed_rect, &point);
1832
1833 if (!d2d_clip_stack_push(&context->clip_stack, &transformed_rect))
1834 WARN("Failed to push clip rect.\n");
1835}
1836
1838{
1840
1841 TRACE("iface %p.\n", iface);
1842
1843 if (context->target.type == D2D_TARGET_COMMAND_LIST)
1844 d2d_command_list_pop_clip(context->target.command_list);
1845
1846 d2d_clip_stack_pop(&context->clip_stack);
1847}
1848
1850{
1852 D3D11_MAPPED_SUBRESOURCE map_desc;
1853 ID3D11DeviceContext *d3d_context;
1854 struct d2d_ps_cb *ps_cb_data;
1855 struct d2d_vs_cb *vs_cb_data;
1856 D2D1_COLOR_F *c;
1857 HRESULT hr;
1858
1859 TRACE("iface %p, colour %p.\n", iface, colour);
1860
1861 if (context->target.type == D2D_TARGET_COMMAND_LIST)
1862 {
1863 d2d_command_list_clear(context->target.command_list, colour);
1864 return;
1865 }
1866
1867 ID3D11Device1_GetImmediateContext(context->d3d_device, &d3d_context);
1868
1869 if (FAILED(hr = ID3D11DeviceContext_Map(d3d_context, (ID3D11Resource *)context->vs_cb,
1870 0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc)))
1871 {
1872 WARN("Failed to map vs constant buffer, hr %#lx.\n", hr);
1873 ID3D11DeviceContext_Release(d3d_context);
1874 return;
1875 }
1876
1877 vs_cb_data = map_desc.pData;
1878 vs_cb_data->transform_geometry._11 = 1.0f;
1879 vs_cb_data->transform_geometry._21 = 0.0f;
1880 vs_cb_data->transform_geometry._31 = 0.0f;
1881 vs_cb_data->transform_geometry.pad0 = 0.0f;
1882 vs_cb_data->transform_geometry._12 = 0.0f;
1883 vs_cb_data->transform_geometry._22 = 1.0f;
1884 vs_cb_data->transform_geometry._32 = 0.0f;
1885 vs_cb_data->transform_geometry.stroke_width = 0.0f;
1886 vs_cb_data->transform_rtx.x = 1.0f;
1887 vs_cb_data->transform_rtx.y = 0.0f;
1888 vs_cb_data->transform_rtx.z = 1.0f;
1889 vs_cb_data->transform_rtx.w = 1.0f;
1890 vs_cb_data->transform_rty.x = 0.0f;
1891 vs_cb_data->transform_rty.y = 1.0f;
1892 vs_cb_data->transform_rty.z = 1.0f;
1893 vs_cb_data->transform_rty.w = -1.0f;
1894
1895 ID3D11DeviceContext_Unmap(d3d_context, (ID3D11Resource *)context->vs_cb, 0);
1896
1897 if (FAILED(hr = ID3D11DeviceContext_Map(d3d_context, (ID3D11Resource *)context->ps_cb,
1898 0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc)))
1899 {
1900 WARN("Failed to map ps constant buffer, hr %#lx.\n", hr);
1901 ID3D11DeviceContext_Release(d3d_context);
1902 return;
1903 }
1904
1905 ps_cb_data = map_desc.pData;
1906 memset(ps_cb_data, 0, sizeof(*ps_cb_data));
1907 ps_cb_data->colour_brush.type = D2D_BRUSH_TYPE_SOLID;
1908 ps_cb_data->colour_brush.opacity = 1.0f;
1909 ps_cb_data->opacity_brush.type = D2D_BRUSH_TYPE_COUNT;
1910 c = &ps_cb_data->colour_brush.u.solid.colour;
1911 if (colour)
1912 *c = *colour;
1913 if (context->desc.pixelFormat.alphaMode == D2D1_ALPHA_MODE_IGNORE)
1914 c->a = 1.0f;
1915 c->r *= c->a;
1916 c->g *= c->a;
1917 c->b *= c->a;
1918
1919 ID3D11DeviceContext_Unmap(d3d_context, (ID3D11Resource *)context->ps_cb, 0);
1920 ID3D11DeviceContext_Release(d3d_context);
1921
1923 context->vb, context->vb_stride, NULL, NULL);
1924}
1925
1927{
1929
1930 TRACE("iface %p.\n", iface);
1931
1932 if (context->target.type == D2D_TARGET_COMMAND_LIST)
1933 d2d_command_list_begin_draw(context->target.command_list, context);
1934
1935 memset(&context->error, 0, sizeof(context->error));
1936}
1937
1939 D2D1_TAG *tag1, D2D1_TAG *tag2)
1940{
1942 HRESULT hr;
1943
1944 TRACE("iface %p, tag1 %p, tag2 %p.\n", iface, tag1, tag2);
1945
1946 if (context->target.type == D2D_TARGET_COMMAND_LIST)
1947 {
1948 FIXME("Unimplemented for command list target.\n");
1949 return E_NOTIMPL;
1950 }
1951
1952 if (tag1)
1953 *tag1 = context->error.tag1;
1954 if (tag2)
1955 *tag2 = context->error.tag2;
1956
1957 if (context->ops && context->ops->device_context_present)
1958 {
1959 if (FAILED(hr = context->ops->device_context_present(context->outer_unknown)))
1960 context->error.code = hr;
1961 }
1962
1963 return context->error.code;
1964}
1965
1968{
1969 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
1970
1971 TRACE("iface %p, format %p.\n", iface, format);
1972
1973 *format = render_target->desc.pixelFormat;
1974 return format;
1975}
1976
1977static void STDMETHODCALLTYPE d2d_device_context_SetDpi(ID2D1DeviceContext6 *iface, float dpi_x, float dpi_y)
1978{
1979 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
1980
1981 TRACE("iface %p, dpi_x %.8e, dpi_y %.8e.\n", iface, dpi_x, dpi_y);
1982
1983 if (dpi_x == 0.0f && dpi_y == 0.0f)
1984 {
1985 dpi_x = 96.0f;
1986 dpi_y = 96.0f;
1987 }
1988 else if (dpi_x <= 0.0f || dpi_y <= 0.0f)
1989 return;
1990
1991 render_target->desc.dpiX = dpi_x;
1992 render_target->desc.dpiY = dpi_y;
1993}
1994
1995static void STDMETHODCALLTYPE d2d_device_context_GetDpi(ID2D1DeviceContext6 *iface, float *dpi_x, float *dpi_y)
1996{
1997 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
1998
1999 TRACE("iface %p, dpi_x %p, dpi_y %p.\n", iface, dpi_x, dpi_y);
2000
2001 *dpi_x = render_target->desc.dpiX;
2002 *dpi_y = render_target->desc.dpiY;
2003}
2004
2006{
2007 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
2008
2009 TRACE("iface %p, size %p.\n", iface, size);
2010
2011 size->width = render_target->pixel_size.width / (render_target->desc.dpiX / 96.0f);
2012 size->height = render_target->pixel_size.height / (render_target->desc.dpiY / 96.0f);
2013 return size;
2014}
2015
2018{
2019 struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface);
2020
2021 TRACE("iface %p, pixel_size %p.\n", iface, pixel_size);
2022
2023 *pixel_size = render_target->pixel_size;
2024 return pixel_size;
2025}
2026
2028{
2029 TRACE("iface %p.\n", iface);
2030
2032}
2033
2036{
2037 FIXME("iface %p, desc %p stub!\n", iface, desc);
2038
2039 return FALSE;
2040}
2041
2043 D2D1_SIZE_U size, const void *src_data, UINT32 pitch,
2045{
2047 struct d2d_bitmap *object;
2048 HRESULT hr;
2049
2050 TRACE("iface %p, size {%u, %u}, src_data %p, pitch %u, desc %p, bitmap %p.\n",
2051 iface, size.width, size.height, src_data, pitch, desc, bitmap);
2052
2053 if (SUCCEEDED(hr = d2d_bitmap_create(context, size, src_data, pitch, desc, &object)))
2054 *bitmap = &object->ID2D1Bitmap1_iface;
2055
2056 return hr;
2057}
2058
2060 ID2D1DeviceContext6 *iface, IWICBitmapSource *bitmap_source,
2062{
2064 struct d2d_bitmap *object;
2065 HRESULT hr;
2066
2067 TRACE("iface %p, bitmap_source %p, desc %p, bitmap %p.\n", iface, bitmap_source, desc, bitmap);
2068
2069 if (SUCCEEDED(hr = d2d_bitmap_create_from_wic_bitmap(context, bitmap_source, desc, &object)))
2070 *bitmap = &object->ID2D1Bitmap1_iface;
2071
2072 return hr;
2073}
2074
2076 D2D1_COLOR_SPACE space, const BYTE *profile, UINT32 profile_size, ID2D1ColorContext **color_context)
2077{
2078 FIXME("iface %p, space %#x, profile %p, profile_size %u, color_context %p stub!\n",
2079 iface, space, profile, profile_size, color_context);
2080
2081 return E_NOTIMPL;
2082}
2083
2085 const WCHAR *filename, ID2D1ColorContext **color_context)
2086{
2087 FIXME("iface %p, filename %s, color_context %p stub!\n", iface, debugstr_w(filename), color_context);
2088
2089 return E_NOTIMPL;
2090}
2091
2093 IWICColorContext *wic_color_context, ID2D1ColorContext **color_context)
2094{
2095 FIXME("iface %p, wic_color_context %p, color_context %p stub!\n", iface, wic_color_context, color_context);
2096
2097 return E_NOTIMPL;
2098}
2099
2100static BOOL d2d_bitmap_check_options_with_surface(unsigned int options, unsigned int surface_options)
2101{
2102 switch (options)
2103 {
2111 break;
2112 default:
2113 WARN("Invalid bitmap options %#x.\n", options);
2114 return FALSE;
2115 }
2116
2117 if (options && (options & D2D1_BITMAP_OPTIONS_TARGET) != (surface_options & D2D1_BITMAP_OPTIONS_TARGET))
2118 return FALSE;
2120 return FALSE;
2122 {
2124 return FALSE;
2125 return TRUE;
2126 }
2127
2129 {
2130 if (!(surface_options & D2D1_BITMAP_OPTIONS_CANNOT_DRAW))
2131 return FALSE;
2132
2134 return FALSE;
2135 }
2136
2137 return TRUE;
2138}
2139
2142{
2144 D2D1_BITMAP_PROPERTIES1 bitmap_desc;
2145 unsigned int surface_options;
2146 struct d2d_bitmap *object;
2147 HRESULT hr;
2148
2149 TRACE("iface %p, surface %p, desc %p, bitmap %p.\n", iface, surface, desc, bitmap);
2150
2152
2153 if (desc)
2154 {
2155 if (!d2d_bitmap_check_options_with_surface(desc->bitmapOptions, surface_options))
2156 {
2157 WARN("Incompatible bitmap options %#x, surface options %#x.\n",
2158 desc->bitmapOptions, surface_options);
2159 return E_INVALIDARG;
2160 }
2161 }
2162 else
2163 {
2164 DXGI_SURFACE_DESC surface_desc;
2165
2166 if (FAILED(hr = IDXGISurface_GetDesc(surface, &surface_desc)))
2167 {
2168 WARN("Failed to get surface desc, hr %#lx.\n", hr);
2169 return hr;
2170 }
2171
2172 memset(&bitmap_desc, 0, sizeof(bitmap_desc));
2173 bitmap_desc.pixelFormat.format = surface_desc.Format;
2174 bitmap_desc.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED;
2175 bitmap_desc.bitmapOptions = surface_options;
2176 desc = &bitmap_desc;
2177 }
2178
2179 if (SUCCEEDED(hr = d2d_bitmap_create_shared(context, &IID_IDXGISurface, surface, desc, &object)))
2180 *bitmap = &object->ID2D1Bitmap1_iface;
2181
2182 return hr;
2183}
2184
2186 REFCLSID effect_id, ID2D1Effect **effect)
2187{
2189
2190 TRACE("iface %p, effect_id %s, effect %p.\n", iface, debugstr_guid(effect_id), effect);
2191
2192 return d2d_effect_create(context, effect_id, effect);
2193}
2194
2196 ID2D1DeviceContext6 *iface, const D2D1_GRADIENT_STOP *stops, UINT32 stop_count,
2197 D2D1_COLOR_SPACE preinterpolation_space, D2D1_COLOR_SPACE postinterpolation_space,
2198 D2D1_BUFFER_PRECISION buffer_precision, D2D1_EXTEND_MODE extend_mode,
2199 D2D1_COLOR_INTERPOLATION_MODE color_interpolation_mode, ID2D1GradientStopCollection1 **gradient)
2200{
2201 FIXME("iface %p, stops %p, stop_count %u, preinterpolation_space %#x, postinterpolation_space %#x, "
2202 "buffer_precision %#x, extend_mode %#x, color_interpolation_mode %#x, gradient %p stub!\n",
2203 iface, stops, stop_count, preinterpolation_space, postinterpolation_space,
2204 buffer_precision, extend_mode, color_interpolation_mode, gradient);
2205
2206 return E_NOTIMPL;
2207}
2208
2210 ID2D1Image *image, const D2D1_IMAGE_BRUSH_PROPERTIES *image_brush_desc,
2211 const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1ImageBrush **brush)
2212{
2214 struct d2d_brush *object;
2215 HRESULT hr;
2216
2217 TRACE("iface %p, image %p, image_brush_desc %p, brush_desc %p, brush %p.\n", iface, image, image_brush_desc,
2218 brush_desc, brush);
2219
2220 if (SUCCEEDED(hr = d2d_image_brush_create(context->factory, image, image_brush_desc,
2221 brush_desc, &object)))
2222 *brush = (ID2D1ImageBrush *)&object->ID2D1Brush_iface;
2223
2224 return hr;
2225}
2226
2228 ID2D1Bitmap *bitmap, const D2D1_BITMAP_BRUSH_PROPERTIES1 *bitmap_brush_desc,
2229 const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1BitmapBrush1 **brush)
2230{
2232 struct d2d_brush *object;
2233 HRESULT hr;
2234
2235 TRACE("iface %p, bitmap %p, bitmap_brush_desc %p, brush_desc %p, brush %p.\n", iface, bitmap, bitmap_brush_desc,
2236 brush_desc, brush);
2237
2238 if (SUCCEEDED(hr = d2d_bitmap_brush_create(context->factory, bitmap, bitmap_brush_desc, brush_desc, &object)))
2239 *brush = (ID2D1BitmapBrush1 *)&object->ID2D1Brush_iface;
2240
2241 return hr;
2242}
2243
2245 ID2D1CommandList **command_list)
2246{
2248 struct d2d_command_list *object;
2249 HRESULT hr;
2250
2251 TRACE("iface %p, command_list %p.\n", iface, command_list);
2252
2253 if (SUCCEEDED(hr = d2d_command_list_create(context->factory, &object)))
2254 *command_list = &object->ID2D1CommandList_iface;
2255
2256 return hr;
2257}
2258
2260{
2261 FIXME("iface %p, format %#x stub!\n", iface, format);
2262
2263 return FALSE;
2264}
2265
2267 D2D1_BUFFER_PRECISION buffer_precision)
2268{
2271 UINT support = 0;
2272 HRESULT hr;
2273
2274 TRACE("iface %p, buffer_precision %u.\n", iface, buffer_precision);
2275
2276 switch (buffer_precision)
2277 {
2283 default:
2284 WARN("Unexpected precision %u.\n", buffer_precision);
2285 return FALSE;
2286 }
2287
2288 if (FAILED(hr = ID3D11Device1_CheckFormatSupport(context->d3d_device, format, &support)))
2289 {
2290 WARN("Format support check failed, hr %#lx.\n", hr);
2291 }
2292
2293 return !!(support & D3D11_FORMAT_SUPPORT_BUFFER);
2294}
2295
2297 ID2D1Image *image, D2D1_RECT_F *local_bounds)
2298{
2303
2304 TRACE("iface %p, image %p, local_bounds %p.\n", iface, image, local_bounds);
2305
2306 if (SUCCEEDED(ID2D1Image_QueryInterface(image, &IID_ID2D1Bitmap, (void **)&bitmap)))
2307 {
2308 local_bounds->left = 0.0f;
2309 local_bounds->top = 0.0f;
2310 switch (context->drawing_state.unitMode)
2311 {
2313 size = ID2D1Bitmap_GetSize(bitmap);
2314 local_bounds->right = size.width;
2315 local_bounds->bottom = size.height;
2316 break;
2317
2319 pixel_size = ID2D1Bitmap_GetPixelSize(bitmap);
2320 local_bounds->right = pixel_size.width;
2321 local_bounds->bottom = pixel_size.height;
2322 break;
2323
2324 default:
2325 WARN("Unknown unit mode %#x.\n", context->drawing_state.unitMode);
2326 break;
2327 }
2328 ID2D1Bitmap_Release(bitmap);
2329
2330 return S_OK;
2331 }
2332 else
2333 {
2334 FIXME("Unable to get local bounds of image %p.\n", image);
2335
2336 return E_NOTIMPL;
2337 }
2338}
2339
2341 ID2D1Image *image, D2D1_RECT_F *world_bounds)
2342{
2343 FIXME("iface %p, image %p, world_bounds %p stub!\n", iface, image, world_bounds);
2344
2345 return E_NOTIMPL;
2346}
2347
2349 D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run,
2350 DWRITE_MEASURING_MODE measuring_mode, D2D1_RECT_F *bounds)
2351{
2352 FIXME("iface %p, baseline_origin %s, glyph_run %p, measuring_mode %#x, bounds %p stub!\n",
2353 iface, debug_d2d_point_2f(&baseline_origin), glyph_run, measuring_mode, bounds);
2354
2355 return E_NOTIMPL;
2356}
2357
2359{
2361
2362 TRACE("iface %p, device %p.\n", iface, device);
2363
2364 *device = (ID2D1Device *)&context->device->ID2D1Device6_iface;
2365 ID2D1Device_AddRef(*device);
2366}
2367
2369{
2370 if (!context->target.object)
2371 return;
2372
2373 IUnknown_Release(context->target.object);
2374 memset(&context->target, 0, sizeof(context->target));
2375
2376 /* Note that DPI settings are kept. */
2377 memset(&context->desc.pixelFormat, 0, sizeof(context->desc.pixelFormat));
2378 memset(&context->pixel_size, 0, sizeof(context->pixel_size));
2379
2380 if (context->bs)
2381 ID3D11BlendState_Release(context->bs);
2382 context->bs = NULL;
2383}
2384
2386{
2388 struct d2d_command_list *command_list_impl;
2389 struct d2d_bitmap *bitmap_impl;
2390 ID2D1CommandList *command_list;
2391 D3D11_BLEND_DESC blend_desc;
2393 HRESULT hr;
2394
2395 TRACE("iface %p, target %p.\n", iface, target);
2396
2397 if (!target)
2398 {
2400 return;
2401 }
2402
2403 if (SUCCEEDED(ID2D1Image_QueryInterface(target, &IID_ID2D1Bitmap, (void **)&bitmap)))
2404 {
2405 bitmap_impl = unsafe_impl_from_ID2D1Bitmap(bitmap);
2406
2407 if (!(bitmap_impl->options & D2D1_BITMAP_OPTIONS_TARGET))
2408 {
2409 ID2D1Bitmap_Release(bitmap);
2411 return;
2412 }
2413
2415
2416 /* Set sizes and pixel format. */
2417 context->pixel_size = bitmap_impl->pixel_size;
2418 context->desc.pixelFormat = bitmap_impl->format;
2419 context->target.bitmap = bitmap_impl;
2420 context->target.object = target;
2421 context->target.type = D2D_TARGET_BITMAP;
2422
2423 memset(&blend_desc, 0, sizeof(blend_desc));
2424 blend_desc.IndependentBlendEnable = FALSE;
2425 blend_desc.RenderTarget[0].BlendEnable = TRUE;
2426 blend_desc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
2427 blend_desc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
2428 blend_desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
2429 blend_desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
2430 blend_desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
2431 blend_desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
2432 blend_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
2433 if (FAILED(hr = ID3D11Device1_CreateBlendState(context->d3d_device, &blend_desc, &context->bs)))
2434 WARN("Failed to create blend state, hr %#lx.\n", hr);
2435 }
2436 else if (SUCCEEDED(ID2D1Image_QueryInterface(target, &IID_ID2D1CommandList, (void **)&command_list)))
2437 {
2438 command_list_impl = unsafe_impl_from_ID2D1CommandList(command_list);
2439
2441
2442 context->target.command_list = command_list_impl;
2443 context->target.object = target;
2444 context->target.type = D2D_TARGET_COMMAND_LIST;
2445 }
2446 else
2447 {
2448 WARN("Unsupported target type.\n");
2449 }
2450}
2451
2453{
2455
2456 TRACE("iface %p, target %p.\n", iface, target);
2457
2458 *target = context->target.object ? context->target.object : NULL;
2459 if (*target)
2460 ID2D1Image_AddRef(*target);
2461}
2462
2464 const D2D1_RENDERING_CONTROLS *rendering_controls)
2465{
2466 FIXME("iface %p, rendering_controls %p stub!\n", iface, rendering_controls);
2467}
2468
2470 D2D1_RENDERING_CONTROLS *rendering_controls)
2471{
2472 FIXME("iface %p, rendering_controls %p stub!\n", iface, rendering_controls);
2473}
2474
2476 D2D1_PRIMITIVE_BLEND primitive_blend)
2477{
2479
2480 TRACE("iface %p, primitive_blend %u.\n", iface, primitive_blend);
2481
2482 if (primitive_blend > D2D1_PRIMITIVE_BLEND_MAX)
2483 {
2484 WARN("Unknown blend mode %u.\n", primitive_blend);
2485 return;
2486 }
2487
2488 if (context->target.type == D2D_TARGET_COMMAND_LIST)
2489 d2d_command_list_set_primitive_blend(context->target.command_list, primitive_blend);
2490
2491 context->drawing_state.primitiveBlend = primitive_blend;
2492}
2493
2495{
2497
2498 TRACE("iface %p.\n", iface);
2499
2500 return context->drawing_state.primitiveBlend;
2501}
2502
2504{
2506
2507 TRACE("iface %p, unit_mode %#x.\n", iface, unit_mode);
2508
2509 if (unit_mode != D2D1_UNIT_MODE_DIPS && unit_mode != D2D1_UNIT_MODE_PIXELS)
2510 {
2511 WARN("Unknown unit mode %#x.\n", unit_mode);
2512 return;
2513 }
2514
2515 if (context->target.type == D2D_TARGET_COMMAND_LIST)
2516 d2d_command_list_set_unit_mode(context->target.command_list, unit_mode);
2517
2518 context->drawing_state.unitMode = unit_mode;
2519}
2520
2522{
2524
2525 TRACE("iface %p.\n", iface);
2526
2527 return context->drawing_state.unitMode;
2528}
2529
2531 D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run,
2532 const DWRITE_GLYPH_RUN_DESCRIPTION *glyph_run_desc, ID2D1Brush *brush, DWRITE_MEASURING_MODE measuring_mode)
2533{
2535
2536 TRACE("iface %p, baseline_origin %s, glyph_run %p, glyph_run_desc %p, brush %p, measuring_mode %#x.\n",
2537 iface, debug_d2d_point_2f(&baseline_origin), glyph_run, glyph_run_desc, brush, measuring_mode);
2538
2539 d2d_device_context_draw_glyph_run(context, baseline_origin, glyph_run, glyph_run_desc, brush, measuring_mode);
2540}
2541
2543 const D2D1_POINT_2F *target_offset, const D2D1_RECT_F *image_rect, D2D1_INTERPOLATION_MODE interpolation_mode,
2544 D2D1_COMPOSITE_MODE composite_mode)
2545{
2548
2549 TRACE("iface %p, image %p, target_offset %s, image_rect %s, interpolation_mode %#x, composite_mode %#x.\n",
2550 iface, image, debug_d2d_point_2f(target_offset), debug_d2d_rect_f(image_rect),
2551 interpolation_mode, composite_mode);
2552
2553 if (context->target.type == D2D_TARGET_COMMAND_LIST)
2554 {
2555 d2d_command_list_draw_image(context->target.command_list, image, target_offset, image_rect,
2556 interpolation_mode, composite_mode);
2557 return;
2558 }
2559
2560 if (composite_mode != D2D1_COMPOSITE_MODE_SOURCE_OVER)
2561 FIXME("Unhandled composite mode %#x.\n", composite_mode);
2562
2563 if (SUCCEEDED(ID2D1Image_QueryInterface(image, &IID_ID2D1Bitmap, (void **)&bitmap)))
2564 {
2565 d2d_device_context_draw_bitmap(context, bitmap, NULL, 1.0f, interpolation_mode, image_rect, target_offset, NULL);
2566
2567 ID2D1Bitmap_Release(bitmap);
2568 return;
2569 }
2570
2571 FIXME("Unhandled image %p.\n", image);
2572}
2573
2575 ID2D1GdiMetafile *metafile, const D2D1_POINT_2F *target_offset)
2576{
2577 FIXME("iface %p, metafile %p, target_offset %s stub!\n",
2578 iface, metafile, debug_d2d_point_2f(target_offset));
2579}
2580
2582 ID2D1Bitmap *bitmap, const D2D1_RECT_F *dst_rect, float opacity, D2D1_INTERPOLATION_MODE interpolation_mode,
2583 const D2D1_RECT_F *src_rect, const D2D1_MATRIX_4X4_F *perspective_transform)
2584{
2586
2587 TRACE("iface %p, bitmap %p, dst_rect %s, opacity %.8e, interpolation_mode %#x, "
2588 "src_rect %s, perspective_transform %p.\n",
2589 iface, bitmap, debug_d2d_rect_f(dst_rect), opacity, interpolation_mode,
2590 debug_d2d_rect_f(src_rect), perspective_transform);
2591
2592 if (context->target.type == D2D_TARGET_COMMAND_LIST)
2593 {
2594 d2d_command_list_draw_bitmap(context->target.command_list, bitmap, dst_rect, opacity, interpolation_mode,
2595 src_rect, perspective_transform);
2596 }
2597 else
2598 {
2599 d2d_device_context_draw_bitmap(context, bitmap, dst_rect, opacity, interpolation_mode, src_rect,
2600 NULL, perspective_transform);
2601 }
2602}
2603
2605 const D2D1_LAYER_PARAMETERS1 *layer_parameters, ID2D1Layer *layer)
2606{
2608
2609 FIXME("iface %p, layer_parameters %p, layer %p stub!\n", iface, layer_parameters, layer);
2610
2611 if (context->target.type == D2D_TARGET_COMMAND_LIST)
2612 d2d_command_list_push_layer(context->target.command_list, context, layer_parameters, layer);
2613}
2614
2616 ID2D1Effect *effect, UINT32 input, const D2D1_RECT_F *input_rect)
2617{
2618 FIXME("iface %p, effect %p, input %u, input_rect %s stub!\n",
2619 iface, effect, input, debug_d2d_rect_f(input_rect));
2620
2621 return E_NOTIMPL;
2622}
2623
2625 ID2D1Effect *effect, UINT32 *rect_count)
2626{
2627 FIXME("iface %p, effect %p, rect_count %p stub!\n", iface, effect, rect_count);
2628
2629 return E_NOTIMPL;
2630}
2631
2633 ID2D1Effect *effect, D2D1_RECT_F *rectangles, UINT32 rect_count)
2634{
2635 FIXME("iface %p, effect %p, rectangles %p, rect_count %u stub!\n", iface, effect, rectangles, rect_count);
2636
2637 return E_NOTIMPL;
2638}
2639
2641 ID2D1Effect *effect, const D2D1_RECT_F *image_rect, const D2D1_EFFECT_INPUT_DESCRIPTION *desc,
2642 D2D1_RECT_F *input_rect, UINT32 input_count)
2643{
2644 FIXME("iface %p, effect %p, image_rect %s, desc %p, input_rect %p, input_count %u stub!\n",
2645 iface, effect, debug_d2d_rect_f(image_rect), desc, input_rect, input_count);
2646
2647 return E_NOTIMPL;
2648}
2649
2651 ID2D1Bitmap *mask, ID2D1Brush *brush, const D2D1_RECT_F *dst_rect, const D2D1_RECT_F *src_rect)
2652{
2654
2655 FIXME("iface %p, mask %p, brush %p, dst_rect %s, src_rect %s stub!\n",
2656 iface, mask, brush, debug_d2d_rect_f(dst_rect), debug_d2d_rect_f(src_rect));
2657
2658 if (FAILED(context->error.code))
2659 return;
2660
2661 if (context->drawing_state.antialiasMode != D2D1_ANTIALIAS_MODE_ALIASED)
2662 {
2664 return;
2665 }
2666
2667 if (context->target.type == D2D_TARGET_COMMAND_LIST)
2668 d2d_command_list_fill_opacity_mask(context->target.command_list, context, mask, brush, dst_rect, src_rect);
2669}
2670
2672 ID2D1Geometry *geometry, float tolerance, ID2D1GeometryRealization **realization)
2673{
2674 FIXME("iface %p, geometry %p, tolerance %.8e, realization %p stub!\n", iface, geometry, tolerance,
2675 realization);
2676
2677 return E_NOTIMPL;
2678}
2679
2681 ID2D1DeviceContext6 *iface, ID2D1Geometry *geometry, float tolerance, float stroke_width,
2682 ID2D1StrokeStyle *stroke_style, ID2D1GeometryRealization **realization)
2683{
2684 FIXME("iface %p, geometry %p, tolerance %.8e, stroke_width %.8e, stroke_style %p, realization %p stub!\n",
2685 iface, geometry, tolerance, stroke_width, stroke_style, realization);
2686
2687 return E_NOTIMPL;
2688}
2689
2691 ID2D1GeometryRealization *realization, ID2D1Brush *brush)
2692{
2693 FIXME("iface %p, realization %p, brush %p stub!\n", iface, realization, brush);
2694}
2695
2697 const D2D1_INK_POINT *start_point, ID2D1Ink **ink)
2698{
2699 FIXME("iface %p, start_point %p, ink %p stub!\n", iface, start_point, ink);
2700
2701 return E_NOTIMPL;
2702}
2703
2705 const D2D1_INK_STYLE_PROPERTIES *ink_style_properties, ID2D1InkStyle **ink_style)
2706{
2707 FIXME("iface %p, ink_style_properties %p, ink_style %p stub!\n", iface, ink_style_properties, ink_style);
2708
2709 return E_NOTIMPL;
2710}
2711
2713 const D2D1_GRADIENT_MESH_PATCH *patches, UINT32 patches_count,
2714 ID2D1GradientMesh **gradient_mesh)
2715{
2716 FIXME("iface %p, patches %p, patches_count %u, gradient_mesh %p stub!\n", iface, patches,
2717 patches_count, gradient_mesh);
2718
2719 return E_NOTIMPL;
2720}
2721
2723 IWICBitmapSource *wic_bitmap_source, D2D1_IMAGE_SOURCE_LOADING_OPTIONS loading_options,
2724 D2D1_ALPHA_MODE alpha_mode, ID2D1ImageSourceFromWic **image_source)
2725{
2726 FIXME("iface %p, wic_bitmap_source %p, loading_options %#x, alpha_mode %u, image_source %p stub!\n",
2727 iface, wic_bitmap_source, loading_options, alpha_mode, image_source);
2728
2729 return E_NOTIMPL;
2730}
2731
2733 D2D1_BUFFER_PRECISION precision, const UINT32 *extents, const BYTE *data,
2734 UINT32 data_count, const UINT32 *strides, ID2D1LookupTable3D **lookup_table)
2735{
2736 FIXME("iface %p, precision %u, extents %p, data %p, data_count %u, strides %p, lookup_table %p stub!\n",
2737 iface, precision, extents, data, data_count, strides, lookup_table);
2738
2739 return E_NOTIMPL;
2740}
2741
2743 IDXGISurface **surfaces, UINT32 surface_count, DXGI_COLOR_SPACE_TYPE color_space,
2745{
2746 FIXME("iface %p, surfaces %p, surface_count %u, color_space %u, options %#x, image_source %p stub!\n",
2747 iface, surfaces, surface_count, color_space, options, image_source);
2748
2749 return E_NOTIMPL;
2750}
2751
2753 ID2D1GradientMesh *gradient_mesh, D2D1_RECT_F *bounds)
2754{
2755 FIXME("iface %p, gradient_mesh %p, bounds %p stub!\n", iface, gradient_mesh, bounds);
2756
2757 return E_NOTIMPL;
2758}
2759
2761 ID2D1Brush *brush, ID2D1InkStyle *ink_style)
2762{
2763 FIXME("iface %p, ink %p, brush %p, ink_style %p stub!\n", iface, ink, brush, ink_style);
2764}
2765
2767 ID2D1GradientMesh *gradient_mesh)
2768{
2769 FIXME("iface %p, gradient_mesh %p stub!\n", iface, gradient_mesh);
2770}
2771
2773 ID2D1DeviceContext6 *iface, ID2D1GdiMetafile *gdi_metafile, const D2D1_RECT_F *dst_rect,
2774 const D2D1_RECT_F *src_rect)
2775{
2776 FIXME("iface %p, gdi_metafile %p, dst_rect %s, src_rect %s stub!\n", iface, gdi_metafile,
2777 debug_d2d_rect_f(dst_rect), debug_d2d_rect_f(src_rect));
2778}
2779
2782 ID2D1TransformedImageSource **transformed)
2783{
2784 FIXME("iface %p, source %p, props %p, transformed %p stub!\n", iface, source, props, transformed);
2785
2786 return E_NOTIMPL;
2787}
2788
2790 ID2D1SpriteBatch **sprite_batch)
2791{
2792 FIXME("iface %p, sprite_batch %p stub!\n", iface, sprite_batch);
2793
2794 return E_NOTIMPL;
2795}
2796
2798 ID2D1SpriteBatch *sprite_batch, UINT32 start_index, UINT32 sprite_count, ID2D1Bitmap *bitmap,
2799 D2D1_BITMAP_INTERPOLATION_MODE interpolation_mode, D2D1_SPRITE_OPTIONS sprite_options)
2800{
2801 FIXME("iface %p, sprite_batch %p, start_index %u, sprite_count %u, bitmap %p, interpolation_mode %u,"
2802 "sprite_options %u stub!\n", iface, sprite_batch, start_index, sprite_count, bitmap,
2803 interpolation_mode, sprite_options);
2804}
2805
2807 ID2D1SvgGlyphStyle **svg_glyph_style)
2808{
2809 FIXME("iface %p, svg_glyph_style %p stub!\n", iface, svg_glyph_style);
2810
2811 return E_NOTIMPL;
2812}
2813
2815 const WCHAR *string, UINT32 string_length, IDWriteTextFormat *text_format, const D2D1_RECT_F *layout_rect,
2816 ID2D1Brush *default_fill_brush, ID2D1SvgGlyphStyle *svg_glyph_style, UINT32 color_palette_index,
2818{
2819 FIXME("iface %p, string %s, string_length %u, text_format %p, layout_rect %s, default_fill_brush %p,"
2820 "svg_glyph_style %p, color_palette_index %u, options %#x, measuring_mode %u stub!\n",
2821 iface, debugstr_wn(string, string_length), string_length, text_format, debug_d2d_rect_f(layout_rect),
2822 default_fill_brush, svg_glyph_style, color_palette_index, options, measuring_mode);
2823}
2824
2826 D2D1_POINT_2F origin, IDWriteTextLayout *text_layout, ID2D1Brush *default_fill_brush,
2827 ID2D1SvgGlyphStyle *svg_glyph_style, UINT32 color_palette_index, D2D1_DRAW_TEXT_OPTIONS options)
2828{
2829 FIXME("iface %p, origin %s, text_layout %p, default_fill_brush %p, svg_glyph_style %p, color_palette_index %u,"
2830 "options %#x stub!\n", iface, debug_d2d_point_2f(&origin), text_layout, default_fill_brush,
2831 svg_glyph_style, color_palette_index, options);
2832}
2833
2835 DWRITE_GLYPH_IMAGE_FORMATS glyph_image_format, D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run,
2836 DWRITE_MEASURING_MODE measuring_mode, D2D1_COLOR_BITMAP_GLYPH_SNAP_OPTION bitmap_snap_option)
2837{
2838 FIXME("iface %p, glyph_image_format %#x, baseline_origin %s, glyph_run %p, measuring_mode %u, bitmap_snap_option %#x stub!\n",
2839 iface, glyph_image_format, debug_d2d_point_2f(&baseline_origin), glyph_run, measuring_mode, bitmap_snap_option);
2840}
2841
2843 D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run, ID2D1Brush *default_fill_brush,
2844 ID2D1SvgGlyphStyle *svg_glyph_style, UINT32 color_palette_index, DWRITE_MEASURING_MODE measuring_mode)
2845{
2846 FIXME("iface %p, baseline_origin %s, glyph_run %p, default_fill_brush %p, svg_glyph_style %p,"
2847 "color_palette_index %u, measuring_mode %u stub!\n", iface, debug_d2d_point_2f(&baseline_origin),
2848 glyph_run, default_fill_brush, svg_glyph_style, color_palette_index, measuring_mode);
2849}
2850
2852 DWRITE_GLYPH_IMAGE_FORMATS glyph_image_format, D2D1_POINT_2F glyph_origin, IDWriteFontFace *font_face,
2853 FLOAT font_em_size, UINT16 glyph_index, BOOL is_sideways, const D2D1_MATRIX_3X2_F *world_transform,
2854 FLOAT dpi_x, FLOAT dpi_y, D2D1_MATRIX_3X2_F *glyph_transform, ID2D1Image **glyph_image)
2855{
2856 FIXME("iface %p, glyph_image_format %u, glyph_origin %s, font_face %p, font_em_size %f, glyph_index %u,"
2857 "is_sideways %d, world_transform %p, dpi_x %f, dpi_y %f, glyph_transform %p, glyph_image %p stub!\n",
2858 iface, glyph_image_format, debug_d2d_point_2f(&glyph_origin), font_face, font_em_size, glyph_index,
2859 is_sideways, world_transform, dpi_x, dpi_y, glyph_transform, glyph_image);
2860
2861 return E_NOTIMPL;
2862}
2863
2865 D2D1_POINT_2F glyph_origin, IDWriteFontFace *font_face, FLOAT font_em_size, UINT16 glyph_index,
2866 BOOL is_sideways, const D2D1_MATRIX_3X2_F *world_transform, ID2D1Brush *default_fill_brush,
2867 ID2D1SvgGlyphStyle *svg_glyph_style, UINT32 color_palette_index, D2D1_MATRIX_3X2_F *glyph_transform,
2868 ID2D1CommandList **glyph_image)
2869{
2870 FIXME("iface %p, glyph_origin %s, font_face %p, font_em_size %f, glyph_index %u, is_sideways %d,"
2871 "world_transform %p, default_fill_brush %p, svg_glyph_style %p, color_palette_index %u,"
2872 "glyph_transform %p, glyph_image %p stub!\n", iface, debug_d2d_point_2f(&glyph_origin),
2873 font_face, font_em_size, glyph_index, is_sideways, world_transform, default_fill_brush,
2874 svg_glyph_style, color_palette_index, glyph_transform, glyph_image);
2875
2876 return E_NOTIMPL;
2877}
2878
2880 IStream *input_xml_stream, D2D1_SIZE_F viewport_size, ID2D1SvgDocument **svg_document)
2881{
2882 FIXME("iface %p, input_xml_stream %p, svg_document %p stub!\n", iface, input_xml_stream,
2883 svg_document);
2884
2885 return E_NOTIMPL;
2886}
2887
2889 ID2D1SvgDocument *svg_document)
2890{
2891 FIXME("iface %p, svg_document %p stub!\n", iface, svg_document);
2892}
2893
2895 ID2D1DeviceContext6 *iface, DXGI_COLOR_SPACE_TYPE color_space, ID2D1ColorContext1 **color_context)
2896{
2897 FIXME("iface %p, color_space %u, color_context %p stub!\n", iface, color_space, color_context);
2898
2899 return E_NOTIMPL;
2900}
2901
2903 ID2D1DeviceContext6 *iface, const D2D1_SIMPLE_COLOR_PROFILE *simple_profile, ID2D1ColorContext1 **color_context)
2904{
2905 FIXME("iface %p, simple_profile %p, color_context %p stub!\n", iface, simple_profile, color_context);
2906
2907 return E_NOTIMPL;
2908}
2909
2911 D2D1_BLEND_MODE blend_mode, const D2D1_POINT_2F *target_offset, const D2D1_RECT_F *image_rect,
2912 D2D1_INTERPOLATION_MODE interpolation_mode)
2913{
2914 FIXME("iface %p, image %p, blend_mode %u, target_offset %s, image_rect %s, interpolation_mode %u stub!\n",
2915 iface, image, blend_mode, debug_d2d_point_2f(target_offset), debug_d2d_rect_f(image_rect),
2916 interpolation_mode);
2917}
2918
2919static const struct ID2D1DeviceContext6Vtbl d2d_device_context_vtbl =
2920{
3041};
3042
3044{
3046}
3047
3049{
3050 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
3051
3052 if (IsEqualGUID(iid, &IID_IDWriteTextRenderer)
3053 || IsEqualGUID(iid, &IID_IDWritePixelSnapping)
3054 || IsEqualGUID(iid, &IID_IUnknown))
3055 {
3056 IDWriteTextRenderer_AddRef(iface);
3057 *out = iface;
3058 return S_OK;
3059 }
3060
3061 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
3062
3063 *out = NULL;
3064 return E_NOINTERFACE;
3065}
3066
3068{
3070
3071 TRACE("iface %p.\n", iface);
3072
3073 return d2d_device_context_AddRef(&context->ID2D1DeviceContext6_iface);
3074}
3075
3077{
3079
3080 TRACE("iface %p.\n", iface);
3081
3082 return d2d_device_context_Release(&context->ID2D1DeviceContext6_iface);
3083}
3084
3086 void *ctx, BOOL *disabled)
3087{
3089
3090 TRACE("iface %p, ctx %p, disabled %p.\n", iface, ctx, disabled);
3091
3092 *disabled = context->options & D2D1_DRAW_TEXT_OPTIONS_NO_SNAP;
3093
3094 return S_OK;
3095}
3096
3098 void *ctx, DWRITE_MATRIX *transform)
3099{
3101
3102 TRACE("iface %p, ctx %p, transform %p.\n", iface, ctx, transform);
3103
3104 d2d_device_context_GetTransform(&context->ID2D1DeviceContext6_iface, (D2D1_MATRIX_3X2_F *)transform);
3105
3106 return S_OK;
3107}
3108
3110{
3111 struct d2d_device_context *render_target = impl_from_IDWriteTextRenderer(iface);
3112
3113 TRACE("iface %p, ctx %p, ppd %p.\n", iface, ctx, ppd);
3114
3115 *ppd = render_target->desc.dpiY / 96.0f;
3116
3117 return S_OK;
3118}
3119
3121 float baseline_origin_x, float baseline_origin_y, DWRITE_MEASURING_MODE measuring_mode,
3122 const DWRITE_GLYPH_RUN *glyph_run, const DWRITE_GLYPH_RUN_DESCRIPTION *glyph_run_desc, IUnknown *effect)
3123{
3124 struct d2d_device_context *render_target = impl_from_IDWriteTextRenderer(iface);
3125 D2D1_POINT_2F baseline_origin = {baseline_origin_x, baseline_origin_y};
3127 BOOL color_font = FALSE;
3129
3130 TRACE("iface %p, ctx %p, baseline_origin_x %.8e, baseline_origin_y %.8e, "
3131 "measuring_mode %#x, glyph_run %p, glyph_run_desc %p, effect %p.\n",
3132 iface, ctx, baseline_origin_x, baseline_origin_y,
3133 measuring_mode, glyph_run, glyph_run_desc, effect);
3134
3136 FIXME("Ignoring options %#x.\n", context->options);
3137
3139
3140 TRACE("%s\n", debugstr_wn(glyph_run_desc->string, glyph_run_desc->stringLength));
3141
3143 {
3144 IDWriteFontFace2 *fontface;
3145
3146 if (SUCCEEDED(IDWriteFontFace_QueryInterface(glyph_run->fontFace,
3147 &IID_IDWriteFontFace2, (void **)&fontface)))
3148 {
3149 color_font = IDWriteFontFace2_IsColorFont(fontface);
3150 IDWriteFontFace2_Release(fontface);
3151 }
3152 }
3153
3154 if (color_font)
3155 {
3157 IDWriteFactory2 *dwrite_factory;
3158 HRESULT hr;
3159
3160 if (FAILED(hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, &IID_IDWriteFactory2,
3161 (IUnknown **)&dwrite_factory)))
3162 {
3163 ERR("Failed to create dwrite factory, hr %#lx.\n", hr);
3164 ID2D1Brush_Release(brush);
3165 return hr;
3166 }
3167
3168 hr = IDWriteFactory2_TranslateColorGlyphRun(dwrite_factory, baseline_origin_x, baseline_origin_y,
3169 glyph_run, glyph_run_desc, measuring_mode, (DWRITE_MATRIX *)&render_target->drawing_state.transform, 0, &layers);
3170 IDWriteFactory2_Release(dwrite_factory);
3171 if (FAILED(hr))
3172 {
3173 ERR("Failed to create colour glyph run enumerator, hr %#lx.\n", hr);
3174 ID2D1Brush_Release(brush);
3175 return hr;
3176 }
3177
3178 for (;;)
3179 {
3180 const DWRITE_COLOR_GLYPH_RUN *color_run;
3181 ID2D1Brush *color_brush;
3183 BOOL has_run = FALSE;
3184
3185 if (FAILED(hr = IDWriteColorGlyphRunEnumerator_MoveNext(layers, &has_run)))
3186 {
3187 ERR("Failed to switch colour glyph layer, hr %#lx.\n", hr);
3188 break;
3189 }
3190
3191 if (!has_run)
3192 break;
3193
3194 if (FAILED(hr = IDWriteColorGlyphRunEnumerator_GetCurrentRun(layers, &color_run)))
3195 {
3196 ERR("Failed to get current colour run, hr %#lx.\n", hr);
3197 break;
3198 }
3199
3200 if (color_run->paletteIndex == 0xffff)
3201 color_brush = brush;
3202 else
3203 {
3205 &color_run->runColor, NULL, (ID2D1SolidColorBrush **)&color_brush)))
3206 {
3207 ERR("Failed to create solid colour brush, hr %#lx.\n", hr);
3208 break;
3209 }
3210 }
3211
3212 origin.x = color_run->baselineOriginX;
3213 origin.y = color_run->baselineOriginY;
3214 d2d_device_context_draw_glyph_run(render_target, origin, &color_run->glyphRun,
3215 color_run->glyphRunDescription, color_brush, measuring_mode);
3216
3217 if (color_brush != brush)
3218 ID2D1Brush_Release(color_brush);
3219 }
3220
3221 IDWriteColorGlyphRunEnumerator_Release(layers);
3222 }
3223 else
3224 d2d_device_context_draw_glyph_run(render_target, baseline_origin, glyph_run, glyph_run_desc,
3225 brush, measuring_mode);
3226
3227 ID2D1Brush_Release(brush);
3228
3229 return S_OK;
3230}
3231
3233 float baseline_origin_x, float baseline_origin_y, const DWRITE_UNDERLINE *underline, IUnknown *effect)
3234{
3235 struct d2d_device_context *render_target = impl_from_IDWriteTextRenderer(iface);
3236 const D2D1_MATRIX_3X2_F *m = &render_target->drawing_state.transform;
3238 D2D1_ANTIALIAS_MODE prev_antialias_mode;
3241 float thickness;
3242
3243 TRACE("iface %p, ctx %p, baseline_origin_x %.8e, baseline_origin_y %.8e, underline %p, effect %p\n",
3244 iface, ctx, baseline_origin_x, baseline_origin_y, underline, effect);
3245
3246 /* minimal thickness in DIPs that will result in at least 1 pixel thick line */
3247 thickness = max(96.0f / (render_target->desc.dpiY * sqrtf(m->_21 * m->_21 + m->_22 * m->_22)),
3248 underline->thickness);
3249
3251
3252 start.x = baseline_origin_x;
3253 start.y = baseline_origin_y + underline->offset + thickness / 2.0f;
3254 end.x = start.x + underline->width;
3255 end.y = start.y;
3256 prev_antialias_mode = d2d_device_context_set_aa_mode_from_text_aa_mode(render_target);
3258 render_target->drawing_state.antialiasMode = prev_antialias_mode;
3259
3260 ID2D1Brush_Release(brush);
3261
3262 return S_OK;
3263}
3264
3266 float baseline_origin_x, float baseline_origin_y, const DWRITE_STRIKETHROUGH *strikethrough, IUnknown *effect)
3267{
3268 struct d2d_device_context *render_target = impl_from_IDWriteTextRenderer(iface);
3269 const D2D1_MATRIX_3X2_F *m = &render_target->drawing_state.transform;
3271 D2D1_ANTIALIAS_MODE prev_antialias_mode;
3274 float thickness;
3275
3276 TRACE("iface %p, ctx %p, baseline_origin_x %.8e, baseline_origin_y %.8e, strikethrough %p, effect %p.\n",
3277 iface, ctx, baseline_origin_x, baseline_origin_y, strikethrough, effect);
3278
3279 /* minimal thickness in DIPs that will result in at least 1 pixel thick line */
3280 thickness = max(96.0f / (render_target->desc.dpiY * sqrtf(m->_21 * m->_21 + m->_22 * m->_22)),
3281 strikethrough->thickness);
3282
3284
3285 start.x = baseline_origin_x;
3286 start.y = baseline_origin_y + strikethrough->offset + thickness / 2.0f;
3287 end.x = start.x + strikethrough->width;
3288 end.y = start.y;
3289 prev_antialias_mode = d2d_device_context_set_aa_mode_from_text_aa_mode(render_target);
3291 render_target->drawing_state.antialiasMode = prev_antialias_mode;
3292
3293 ID2D1Brush_Release(brush);
3294
3295 return S_OK;
3296}
3297
3299 float origin_x, float origin_y, IDWriteInlineObject *object, BOOL is_sideways, BOOL is_rtl, IUnknown *effect)
3300{
3303 HRESULT hr;
3304
3305 TRACE("iface %p, ctx %p, origin_x %.8e, origin_y %.8e, object %p, is_sideways %#x, is_rtl %#x, effect %p.\n",
3306 iface, ctx, origin_x, origin_y, object, is_sideways, is_rtl, effect);
3307
3308 /* Inline objects may not pass effects all the way down, when using layout object internally for example.
3309 This is how default trimming sign object in DirectWrite works - it does not use effect passed to Draw(),
3310 and resulting DrawGlyphRun() is always called with NULL effect, however original effect is used and correct
3311 brush is selected at Direct2D level. */
3312 brush = context->brush;
3313 context->brush = d2d_draw_get_text_brush(context, effect);
3314
3315 hr = IDWriteInlineObject_Draw(object, ctx, iface, origin_x, origin_y, is_sideways, is_rtl, effect);
3316
3317 ID2D1Brush_Release(context->brush);
3318 context->brush = brush;
3319
3320 return hr;
3321}
3322
3323static const struct IDWriteTextRendererVtbl d2d_text_renderer_vtbl =
3324{
3335};
3336
3338{
3340}
3341
3343 REFIID iid, void **out)
3344{
3345 struct d2d_device_context *render_target = impl_from_ID2D1GdiInteropRenderTarget(iface);
3346
3347 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
3348
3349 return IUnknown_QueryInterface(render_target->outer_unknown, iid, out);
3350}
3351
3353{
3354 struct d2d_device_context *render_target = impl_from_ID2D1GdiInteropRenderTarget(iface);
3355
3356 TRACE("iface %p.\n", iface);
3357
3358 return IUnknown_AddRef(render_target->outer_unknown);
3359}
3360
3362{
3363 struct d2d_device_context *render_target = impl_from_ID2D1GdiInteropRenderTarget(iface);
3364
3365 TRACE("iface %p.\n", iface);
3366
3367 return IUnknown_Release(render_target->outer_unknown);
3368}
3369
3371{
3372 ID3D11Resource *resource;
3373 HRESULT hr;
3374
3375 if (context->target.type != D2D_TARGET_BITMAP)
3376 {
3377 FIXME("Unimplemented for target type %u.\n", context->target.type);
3378 return E_NOTIMPL;
3379 }
3380
3381 if (!(context->target.bitmap->options & D2D1_BITMAP_OPTIONS_GDI_COMPATIBLE))
3383
3384 ID3D11RenderTargetView_GetResource(context->target.bitmap->rtv, &resource);
3385 hr = ID3D11Resource_QueryInterface(resource, &IID_IDXGISurface1, (void **)surface);
3386 ID3D11Resource_Release(resource);
3387 if (FAILED(hr))
3388 {
3389 *surface = NULL;
3390 WARN("Failed to get DXGI surface, %#lx.\n", hr);
3391 return hr;
3392 }
3393
3394 return hr;
3395}
3396
3399{
3400 struct d2d_device_context *render_target = impl_from_ID2D1GdiInteropRenderTarget(iface);
3401 IDXGISurface1 *surface;
3402 HRESULT hr;
3403
3404 TRACE("iface %p, mode %d, dc %p.\n", iface, mode, dc);
3405
3406 *dc = NULL;
3407
3408 if (render_target->target.hdc)
3409 return D2DERR_WRONG_STATE;
3410
3411 if (FAILED(hr = d2d_gdi_interop_get_surface(render_target, &surface)))
3412 return hr;
3413
3414 hr = IDXGISurface1_GetDC(surface, mode != D2D1_DC_INITIALIZE_MODE_COPY, &render_target->target.hdc);
3415 IDXGISurface1_Release(surface);
3416
3417 if (SUCCEEDED(hr))
3418 *dc = render_target->target.hdc;
3419
3420 return hr;
3421}
3422
3424 const RECT *update)
3425{
3426 struct d2d_device_context *render_target = impl_from_ID2D1GdiInteropRenderTarget(iface);
3427 IDXGISurface1 *surface;
3428 RECT update_rect;
3429 HRESULT hr;
3430
3431 TRACE("iface %p, update rect %s.\n", iface, wine_dbgstr_rect(update));
3432
3433 if (!render_target->target.hdc)
3434 return D2DERR_WRONG_STATE;
3435
3436 if (FAILED(hr = d2d_gdi_interop_get_surface(render_target, &surface)))
3437 return hr;
3438
3439 render_target->target.hdc = NULL;
3440 if (update)
3441 update_rect = *update;
3442 hr = IDXGISurface1_ReleaseDC(surface, update ? &update_rect : NULL);
3443 IDXGISurface1_Release(surface);
3444
3445 return hr;
3446}
3447
3448static const struct ID2D1GdiInteropRenderTargetVtbl d2d_gdi_interop_render_target_vtbl =
3449{
3455};
3456
3458 struct d2d_device *device, IUnknown *outer_unknown, const struct d2d_device_context_ops *ops)
3459{
3460 D3D11_SUBRESOURCE_DATA buffer_data;
3461 IDWriteFactory *dwrite_factory;
3462 D3D11_RASTERIZER_DESC rs_desc;
3463 D3D11_BUFFER_DESC buffer_desc;
3464 struct d2d_factory *factory;
3465 ID3D10Blob *compiled;
3466 unsigned int i;
3467 HRESULT hr;
3468
3469 static const D3D11_INPUT_ELEMENT_DESC il_desc_outline[] =
3470 {
3471 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
3474 };
3475 static const D3D11_INPUT_ELEMENT_DESC il_desc_curve_outline[] =
3476 {
3477 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
3483 };
3484 static const D3D11_INPUT_ELEMENT_DESC il_desc_triangle[] =
3485 {
3486 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
3487 };
3488 static const D3D11_INPUT_ELEMENT_DESC il_desc_curve[] =
3489 {
3490 {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
3492 };
3493 static const char vs_code_outline[] =
3494 "float3x2 transform_geometry;\n"
3495 "float stroke_width;\n"
3496 "float4 transform_rtx;\n"
3497 "float4 transform_rty;\n"
3498 "\n"
3499 "struct output\n"
3500 "{\n"
3501 " float2 p : WORLD_POSITION;\n"
3502 " float4 b : BEZIER;\n"
3503 " nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM;\n"
3504 " float4 position : SV_POSITION;\n"
3505 "};\n"
3506 "\n"
3507 "/* The lines PₚᵣₑᵥP₀ and P₀Pₙₑₓₜ, both offset by ±½w, intersect each other at:\n"
3508 " *\n"
3509 " * Pᵢ = P₀ ± w · ½q⃑ᵢ.\n"
3510 " *\n"
3511 " * Where:\n"
3512 " *\n"
3513 " * q⃑ᵢ = q̂ₚᵣₑᵥ⊥ + tan(½θ) · -q̂ₚᵣₑᵥ\n"
3514 " * θ = ∠PₚᵣₑᵥP₀Pₙₑₓₜ\n"
3515 " * q⃑ₚᵣₑᵥ = P₀ - Pₚᵣₑᵥ */\n"
3516 "void main(float2 position : POSITION, float2 prev : PREV, float2 next : NEXT, out struct output o)\n"
3517 "{\n"
3518 " float2 q_prev, q_next, v_p, q_i;\n"
3519 " float2x2 geom;\n"
3520 " float l;\n"
3521 "\n"
3522 " o.stroke_transform = float2x2(transform_rtx.xy, transform_rty.xy) * stroke_width * 0.5f;\n"
3523 "\n"
3524 " geom = float2x2(transform_geometry._11_21, transform_geometry._12_22);\n"
3525 " q_prev = normalize(mul(geom, prev));\n"
3526 " q_next = normalize(mul(geom, next));\n"
3527 "\n"
3528 " /* tan(½θ) = sin(θ) / (1 + cos(θ))\n"
3529 " * = (q̂ₚᵣₑᵥ⊥ · q̂ₙₑₓₜ) / (1 + (q̂ₚᵣₑᵥ · q̂ₙₑₓₜ)) */\n"
3530 " v_p = float2(-q_prev.y, q_prev.x);\n"
3531 " l = -dot(v_p, q_next) / (1.0f + dot(q_prev, q_next));\n"
3532 " q_i = l * q_prev + v_p;\n"
3533 "\n"
3534 " o.b = float4(0.0, 0.0, 0.0, 0.0);\n"
3535 "\n"
3536 " o.p = mul(float3(position, 1.0f), transform_geometry) + stroke_width * 0.5f * q_i;\n"
3537 " position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f))\n"
3538 " * float2(transform_rtx.w, transform_rty.w);\n"
3539 " o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f);\n"
3540 "}\n";
3541 /* ⎡p0.x p0.y 1⎤
3542 * A = ⎢p1.x p1.y 1⎥
3543 * ⎣p2.x p2.y 1⎦
3544 *
3545 * ⎡0 0⎤
3546 * B = ⎢½ 0⎥
3547 * ⎣1 1⎦
3548 *
3549 * A' = ⎡p1.x-p0.x p1.y-p0.y⎤
3550 * ⎣p2.x-p0.x p2.y-p0.y⎦
3551 *
3552 * B' = ⎡½ 0⎤
3553 * ⎣1 1⎦
3554 *
3555 * A'T = B'
3556 * T = A'⁻¹B'
3557 */
3558 static const char vs_code_bezier_outline[] =
3559 "float3x2 transform_geometry;\n"
3560 "float stroke_width;\n"
3561 "float4 transform_rtx;\n"
3562 "float4 transform_rty;\n"
3563 "\n"
3564 "struct output\n"
3565 "{\n"
3566 " float2 p : WORLD_POSITION;\n"
3567 " float4 b : BEZIER;\n"
3568 " nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM;\n"
3569 " float4 position : SV_POSITION;\n"
3570 "};\n"
3571 "\n"
3572 "void main(float2 position : POSITION, float2 p0 : P0, float2 p1 : P1, float2 p2 : P2,\n"
3573 " float2 prev : PREV, float2 next : NEXT, out struct output o)\n"
3574 "{\n"
3575 " float2 q_prev, q_next, v_p, q_i, p;\n"
3576 " float2x2 geom, rt;\n"
3577 " float l;\n"
3578 "\n"
3579 " geom = float2x2(transform_geometry._11_21, transform_geometry._12_22);\n"
3580 " rt = float2x2(transform_rtx.xy, transform_rty.xy);\n"
3581 " o.stroke_transform = rt * stroke_width * 0.5f;\n"
3582 "\n"
3583 " p = mul(geom, position);\n"
3584 " p0 = mul(geom, p0);\n"
3585 " p1 = mul(geom, p1);\n"
3586 " p2 = mul(geom, p2);\n"
3587 "\n"
3588 " p -= p0;\n"
3589 " p1 -= p0;\n"
3590 " p2 -= p0;\n"
3591 "\n"
3592 " q_prev = normalize(mul(geom, prev));\n"
3593 " q_next = normalize(mul(geom, next));\n"
3594 "\n"
3595 " v_p = float2(-q_prev.y, q_prev.x);\n"
3596 " l = -dot(v_p, q_next) / (1.0f + dot(q_prev, q_next));\n"
3597 " q_i = l * q_prev + v_p;\n"
3598 " p += 0.5f * stroke_width * q_i;\n"
3599 "\n"
3600 " v_p = mul(rt, p2);\n"
3601 " v_p = normalize(float2(-v_p.y, v_p.x));\n"
3602 " if (abs(dot(mul(rt, p1), v_p)) < 1.0f)\n"
3603 " {\n"
3604 " o.b.xzw = float3(0.0f, 0.0f, 0.0f);\n"
3605 " o.b.y = dot(mul(rt, p), v_p);\n"
3606 " }\n"
3607 " else\n"
3608 " {\n"
3609 " o.b.zw = sign(dot(mul(rt, p1), v_p)) * v_p;\n"
3610 " v_p = -float2(-p.y, p.x) / dot(float2(-p1.y, p1.x), p2);\n"
3611 " o.b.x = dot(v_p, p1 - 0.5f * p2);\n"
3612 " o.b.y = dot(v_p, p1);\n"
3613 " }\n"
3614 "\n"
3615 " o.p = mul(float3(position, 1.0f), transform_geometry) + 0.5f * stroke_width * q_i;\n"
3616 " position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f))\n"
3617 " * float2(transform_rtx.w, transform_rty.w);\n"
3618 " o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f);\n"
3619 "}\n";
3620 /* ⎡p0.x p0.y 1⎤
3621 * A = ⎢p1.x p1.y 1⎥
3622 * ⎣p2.x p2.y 1⎦
3623 *
3624 * ⎡1 0⎤
3625 * B = ⎢1 1⎥
3626 * ⎣0 1⎦
3627 *
3628 * A' = ⎡p1.x-p0.x p1.y-p0.y⎤
3629 * ⎣p2.x-p0.x p2.y-p0.y⎦
3630 *
3631 * B' = ⎡ 0 1⎤
3632 * ⎣-1 1⎦
3633 *
3634 * A'T = B'
3635 * T = A'⁻¹B' = (B'⁻¹A')⁻¹
3636 */
3637 static const char vs_code_arc_outline[] =
3638 "float3x2 transform_geometry;\n"
3639 "float stroke_width;\n"
3640 "float4 transform_rtx;\n"
3641 "float4 transform_rty;\n"
3642 "\n"
3643 "struct output\n"
3644 "{\n"
3645 " float2 p : WORLD_POSITION;\n"
3646 " float4 b : BEZIER;\n"
3647 " nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM;\n"
3648 " float4 position : SV_POSITION;\n"
3649 "};\n"
3650 "\n"
3651 "void main(float2 position : POSITION, float2 p0 : P0, float2 p1 : P1, float2 p2 : P2,\n"
3652 " float2 prev : PREV, float2 next : NEXT, out struct output o)\n"
3653 "{\n"
3654 " float2 q_prev, q_next, v_p, q_i, p;\n"
3655 " float2x2 geom, rt, p_inv;\n"
3656 " float l;\n"
3657 " float a;\n"
3658 " float2 bc;\n"
3659 "\n"
3660 " geom = float2x2(transform_geometry._11_21, transform_geometry._12_22);\n"
3661 " rt = float2x2(transform_rtx.xy, transform_rty.xy);\n"
3662 " o.stroke_transform = rt * stroke_width * 0.5f;\n"
3663 "\n"
3664 " p = mul(geom, position);\n"
3665 " p0 = mul(geom, p0);\n"
3666 " p1 = mul(geom, p1);\n"
3667 " p2 = mul(geom, p2);\n"
3668 "\n"
3669 " p -= p0;\n"
3670 " p1 -= p0;\n"
3671 " p2 -= p0;\n"
3672 "\n"
3673 " q_prev = normalize(mul(geom, prev));\n"
3674 " q_next = normalize(mul(geom, next));\n"
3675 "\n"
3676 " v_p = float2(-q_prev.y, q_prev.x);\n"
3677 " l = -dot(v_p, q_next) / (1.0f + dot(q_prev, q_next));\n"
3678 " q_i = l * q_prev + v_p;\n"
3679 " p += 0.5f * stroke_width * q_i;\n"
3680 "\n"
3681 " p_inv = float2x2(p1.y, -p1.x, p2.y - p1.y, p1.x - p2.x) / (p1.x * p2.y - p2.x * p1.y);\n"
3682 " o.b.xy = mul(p_inv, p) + float2(1.0f, 0.0f);\n"
3683 " o.b.zw = 0.0f;\n"
3684 "\n"
3685 " o.p = mul(float3(position, 1.0f), transform_geometry) + 0.5f * stroke_width * q_i;\n"
3686 " position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f))\n"
3687 " * float2(transform_rtx.w, transform_rty.w);\n"
3688 " o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f);\n"
3689 "}\n";
3690 static const char vs_code_triangle[] =
3691 "float3x2 transform_geometry;\n"
3692 "float4 transform_rtx;\n"
3693 "float4 transform_rty;\n"
3694 "\n"
3695 "struct output\n"
3696 "{\n"
3697 " float2 p : WORLD_POSITION;\n"
3698 " float4 b : BEZIER;\n"
3699 " nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM;\n"
3700 " float4 position : SV_POSITION;\n"
3701 "};\n"
3702 "\n"
3703 "void main(float2 position : POSITION, out struct output o)\n"
3704 "{\n"
3705 " o.p = mul(float3(position, 1.0f), transform_geometry);\n"
3706 " o.b = float4(1.0, 0.0, 1.0, 1.0);\n"
3707 " o.stroke_transform = float2x2(1.0, 0.0, 0.0, 1.0);\n"
3708 " position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f))\n"
3709 " * float2(transform_rtx.w, transform_rty.w);\n"
3710 " o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f);\n"
3711 "}\n";
3712 static const char vs_code_curve[] =
3713 "float3x2 transform_geometry;\n"
3714 "float4 transform_rtx;\n"
3715 "float4 transform_rty;\n"
3716 "\n"
3717 "struct output\n"
3718 "{\n"
3719 " float2 p : WORLD_POSITION;\n"
3720 " float4 b : BEZIER;\n"
3721 " nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM;\n"
3722 " float4 position : SV_POSITION;\n"
3723 "};\n"
3724 "\n"
3725 "void main(float2 position : POSITION, float3 texcoord : TEXCOORD0, out struct output o)\n"
3726 "{\n"
3727 " o.p = mul(float3(position, 1.0f), transform_geometry);\n"
3728 " o.b = float4(texcoord, 1.0);\n"
3729 " o.stroke_transform = float2x2(1.0, 0.0, 0.0, 1.0);\n"
3730 " position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f))\n"
3731 " * float2(transform_rtx.w, transform_rty.w);\n"
3732 " o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f);\n"
3733 "}\n";
3734 static const char ps_code[] =
3735 "#define BRUSH_TYPE_SOLID 0\n"
3736 "#define BRUSH_TYPE_LINEAR 1\n"
3737 "#define BRUSH_TYPE_RADIAL 2\n"
3738 "#define BRUSH_TYPE_BITMAP 3\n"
3739 "#define BRUSH_TYPE_COUNT 4\n"
3740 "\n"
3741 "bool outline;\n"
3742 "bool is_arc;\n"
3743 "struct brush\n"
3744 "{\n"
3745 " uint type;\n"
3746 " float opacity;\n"
3747 " float4 data[3];\n"
3748 "} colour_brush, opacity_brush;\n"
3749 "\n"
3750 "SamplerState s0, s1;\n"
3751 "Texture2D t0, t1;\n"
3752 "Buffer<float4> b0, b1;\n"
3753 "\n"
3754 "struct input\n"
3755 "{\n"
3756 " float2 p : WORLD_POSITION;\n"
3757 " float4 b : BEZIER;\n"
3758 " nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM;\n"
3759 "};\n"
3760 "\n"
3761 "float4 sample_gradient(Buffer<float4> gradient, uint stop_count, float position)\n"
3762 "{\n"
3763 " float4 c_low, c_high;\n"
3764 " float p_low, p_high;\n"
3765 " uint i;\n"
3766 "\n"
3767 " p_low = gradient.Load(0).x;\n"
3768 " c_low = gradient.Load(1);\n"
3769 " c_high = c_low;\n"
3770 "\n"
3771 " if (position < p_low)\n"
3772 " return c_low;\n"
3773 "\n"
3774 " for (i = 1; i < stop_count; ++i)\n"
3775 " {\n"
3776 " p_high = gradient.Load(i * 2).x;\n"
3777 " c_high = gradient.Load(i * 2 + 1);\n"
3778 "\n"
3779 " if (position >= p_low && position <= p_high)\n"
3780 " return lerp(c_low, c_high, (position - p_low) / (p_high - p_low));\n"
3781 "\n"
3782 " p_low = p_high;\n"
3783 " c_low = c_high;\n"
3784 " }\n"
3785 "\n"
3786 " return c_high;\n"
3787 "}\n"
3788 "\n"
3789 "float4 brush_linear(struct brush brush, Buffer<float4> gradient, float2 position)\n"
3790 "{\n"
3791 " float2 start, end, v_p, v_q;\n"
3792 " uint stop_count;\n"
3793 " float p;\n"
3794 "\n"
3795 " start = brush.data[0].xy;\n"
3796 " end = brush.data[0].zw;\n"
3797 " stop_count = asuint(brush.data[1].x);\n"
3798 "\n"
3799 " v_p = position - start;\n"
3800 " v_q = end - start;\n"
3801 " p = dot(v_q, v_p) / dot(v_q, v_q);\n"
3802 "\n"
3803 " return sample_gradient(gradient, stop_count, p);\n"
3804 "}\n"
3805 "\n"
3806 "float4 brush_radial(struct brush brush, Buffer<float4> gradient, float2 position)\n"
3807 "{\n"
3808 " float2 centre, offset, ra, rb, v_p, v_q, r;\n"
3809 " float b, c, l, t;\n"
3810 " uint stop_count;\n"
3811 "\n"
3812 " centre = brush.data[0].xy;\n"
3813 " offset = brush.data[0].zw;\n"
3814 " ra = brush.data[1].xy;\n"
3815 " rb = brush.data[1].zw;\n"
3816 " stop_count = asuint(brush.data[2].x);\n"
3817 "\n"
3818 " /* Project onto ra, rb. */\n"
3819 " r = float2(dot(ra, ra), dot(rb, rb));\n"
3820 " v_p = position - (centre + offset);\n"
3821 " v_p = float2(dot(v_p, ra), dot(v_p, rb)) / r;\n"
3822 " v_q = float2(dot(offset, ra), dot(offset, rb)) / r;\n"
3823 "\n"
3824 " /* ‖t·p̂ + q⃑‖ = 1\n"
3825 " * (t·p̂ + q⃑) · (t·p̂ + q⃑) = 1\n"
3826 " * t² + 2·(p̂·q⃑)·t + (q⃑·q⃑) = 1\n"
3827 " *\n"
3828 " * b = p̂·q⃑\n"
3829 " * c = q⃑·q⃑ - 1\n"
3830 " * t = -b + √(b² - c) */\n"
3831 " l = length(v_p);\n"
3832 " b = dot(v_p, v_q) / l;\n"
3833 " c = dot(v_q, v_q) - 1.0;\n"
3834 " t = -b + sqrt(b * b - c);\n"
3835 "\n"
3836 " return sample_gradient(gradient, stop_count, l / t);\n"
3837 "}\n"
3838 "\n"
3839 "float4 brush_bitmap(struct brush brush, Texture2D t, SamplerState s, float2 position)\n"
3840 "{\n"
3841 " float3 transform[2];\n"
3842 " bool ignore_alpha;\n"
3843 " float2 texcoord;\n"
3844 " float4 colour;\n"
3845 "\n"
3846 " transform[0] = brush.data[0].xyz;\n"
3847 " transform[1] = brush.data[1].xyz;\n"
3848 " ignore_alpha = asuint(brush.data[1].w);\n"
3849 "\n"
3850 " texcoord.x = dot(position.xy, transform[0].xy) + transform[0].z;\n"
3851 " texcoord.y = dot(position.xy, transform[1].xy) + transform[1].z;\n"
3852 " colour = t.Sample(s, texcoord);\n"
3853 " if (ignore_alpha)\n"
3854 " colour.a = 1.0;\n"
3855 " return colour;\n"
3856 "}\n"
3857 "\n"
3858 "float4 sample_brush(struct brush brush, Texture2D t, SamplerState s, Buffer<float4> b, float2 position)\n"
3859 "{\n"
3860 " if (brush.type == BRUSH_TYPE_SOLID)\n"
3861 " return brush.data[0] * brush.opacity;\n"
3862 " if (brush.type == BRUSH_TYPE_LINEAR)\n"
3863 " return brush_linear(brush, b, position) * brush.opacity;\n"
3864 " if (brush.type == BRUSH_TYPE_RADIAL)\n"
3865 " return brush_radial(brush, b, position) * brush.opacity;\n"
3866 " if (brush.type == BRUSH_TYPE_BITMAP)\n"
3867 " return brush_bitmap(brush, t, s, position) * brush.opacity;\n"
3868 " return float4(0.0, 0.0, 0.0, brush.opacity);\n"
3869 "}\n"
3870 "\n"
3871 "float4 main(struct input i) : SV_Target\n"
3872 "{\n"
3873 " float4 colour;\n"
3874 "\n"
3875 " colour = sample_brush(colour_brush, t0, s0, b0, i.p);\n"
3876 " if (opacity_brush.type < BRUSH_TYPE_COUNT)\n"
3877 " colour *= sample_brush(opacity_brush, t1, s1, b1, i.p).a;\n"
3878 "\n"
3879 " if (outline)\n"
3880 " {\n"
3881 " float2 du, dv, df;\n"
3882 " float4 uv;\n"
3883 "\n"
3884 " /* Evaluate the implicit form of the curve (u² - v = 0\n"
3885 " * for Béziers, u² + v² - 1 = 0 for arcs) in texture\n"
3886 " * space, using the screen-space partial derivatives\n"
3887 " * to convert the calculated distance to object space.\n"
3888 " *\n"
3889 " * d(x, y) = |f(x, y)| / ‖∇f(x, y)‖\n"
3890 " * = |f(x, y)| / √((∂f/∂x)² + (∂f/∂y)²)\n"
3891 " *\n"
3892 " * For Béziers:\n"
3893 " * f(x, y) = u(x, y)² - v(x, y)\n"
3894 " * ∂f/∂x = 2u · ∂u/∂x - ∂v/∂x\n"
3895 " * ∂f/∂y = 2u · ∂u/∂y - ∂v/∂y\n"
3896 " *\n"
3897 " * For arcs:\n"
3898 " * f(x, y) = u(x, y)² + v(x, y)² - 1\n"
3899 " * ∂f/∂x = 2u · ∂u/∂x + 2v · ∂v/∂x\n"
3900 " * ∂f/∂y = 2u · ∂u/∂y + 2v · ∂v/∂y */\n"
3901 " uv = i.b;\n"
3902 " du = float2(ddx(uv.x), ddy(uv.x));\n"
3903 " dv = float2(ddx(uv.y), ddy(uv.y));\n"
3904 "\n"
3905 " if (!is_arc)\n"
3906 " {\n"
3907 " df = 2.0f * uv.x * du - dv;\n"
3908 "\n"
3909 " clip(dot(df, uv.zw));\n"
3910 " clip(length(mul(i.stroke_transform, df)) - abs(uv.x * uv.x - uv.y));\n"
3911 " }\n"
3912 " else\n"
3913 " {\n"
3914 " df = 2.0f * uv.x * du + 2.0f * uv.y * dv;\n"
3915 "\n"
3916 " clip(dot(df, uv.zw));\n"
3917 " clip(length(mul(i.stroke_transform, df)) - abs(uv.x * uv.x + uv.y * uv.y - 1.0f));\n"
3918 " }\n"
3919 " }\n"
3920 " else\n"
3921 " {\n"
3922 " /* Evaluate the implicit form of the curve in texture space.\n"
3923 " * \"i.b.z\" determines which side of the curve is shaded. */\n"
3924 " if (!is_arc)\n"
3925 " {\n"
3926 " clip((i.b.x * i.b.x - i.b.y) * i.b.z);\n"
3927 " }\n"
3928 " else\n"
3929 " {\n"
3930 " clip((i.b.x * i.b.x + i.b.y * i.b.y - 1.0) * i.b.z);\n"
3931 " }\n"
3932 " }\n"
3933 "\n"
3934 " return colour;\n"
3935 "}\n";
3936 static const struct shape_info
3937 {
3938 enum d2d_shape_type shape_type;
3939 const D3D11_INPUT_ELEMENT_DESC *il_desc;
3940 unsigned int il_element_count;
3941 const char *name;
3942 const char *vs_code;
3943 size_t vs_code_size;
3944 }
3945 shape_info[] =
3946 {
3947 {D2D_SHAPE_TYPE_OUTLINE, il_desc_outline, ARRAY_SIZE(il_desc_outline),
3948 "outline", vs_code_outline, sizeof(vs_code_outline) - 1},
3949 {D2D_SHAPE_TYPE_BEZIER_OUTLINE, il_desc_curve_outline, ARRAY_SIZE(il_desc_curve_outline),
3950 "bezier_outline", vs_code_bezier_outline, sizeof(vs_code_bezier_outline) - 1},
3951 {D2D_SHAPE_TYPE_ARC_OUTLINE, il_desc_curve_outline, ARRAY_SIZE(il_desc_curve_outline),
3952 "arc_outline", vs_code_arc_outline, sizeof(vs_code_arc_outline) - 1},
3953 {D2D_SHAPE_TYPE_TRIANGLE, il_desc_triangle, ARRAY_SIZE(il_desc_triangle),
3954 "triangle", vs_code_triangle, sizeof(vs_code_triangle) - 1},
3955 {D2D_SHAPE_TYPE_CURVE, il_desc_curve, ARRAY_SIZE(il_desc_curve),
3956 "curve", vs_code_curve, sizeof(vs_code_curve) - 1},
3957 };
3958 static const struct
3959 {
3960 float x, y;
3961 }
3962 quad[] =
3963 {
3964 {-1.0f, 1.0f},
3965 {-1.0f, -1.0f},
3966 { 1.0f, 1.0f},
3967 { 1.0f, -1.0f},
3968 };
3969 static const UINT16 indices[] = {0, 1, 2, 2, 1, 3};
3971
3972 render_target->ID2D1DeviceContext6_iface.lpVtbl = &d2d_device_context_vtbl;
3974 render_target->IDWriteTextRenderer_iface.lpVtbl = &d2d_text_renderer_vtbl;
3976 render_target->refcount = 1;
3977 ID2D1Device1_GetFactory((ID2D1Device1 *)&device->ID2D1Device6_iface, &render_target->factory);
3978 render_target->device = device;
3979 ID2D1Device6_AddRef(&render_target->device->ID2D1Device6_iface);
3980
3982 if (factory->factory_type == D2D1_FACTORY_TYPE_MULTI_THREADED)
3983 render_target->cs = &factory->cs;
3984
3985 render_target->outer_unknown = outer_unknown ? outer_unknown : &render_target->IUnknown_iface;
3986 render_target->ops = ops;
3987
3988 if (FAILED(hr = IDXGIDevice_QueryInterface(device->dxgi_device,
3989 &IID_ID3D11Device1, (void **)&render_target->d3d_device)))
3990 {
3991 WARN("Failed to query ID3D11Device1 interface, hr %#lx.\n", hr);
3992 goto err;
3993 }
3994
3995 if (FAILED(hr = ID3D11Device1_CreateDeviceContextState(render_target->d3d_device,
3996 0, &feature_levels, 1, D3D11_SDK_VERSION, &IID_ID3D11Device1, NULL,
3997 &render_target->d3d_state)))
3998 {
3999 WARN("Failed to create device context state, hr %#lx.\n", hr);
4000 goto err;
4001 }
4002
4003 for (i = 0; i < ARRAY_SIZE(shape_info); ++i)
4004 {
4005 const struct shape_info *si = &shape_info[i];
4006
4007 if (FAILED(hr = D3DCompile(si->vs_code, si->vs_code_size, si->name, NULL, NULL,
4008 "main", "vs_4_0", 0, 0, &compiled, NULL)))
4009 {
4010 WARN("Failed to compile shader for shape type %#x, hr %#lx.\n", si->shape_type, hr);
4011 goto err;
4012 }
4013
4014 if (FAILED(hr = ID3D11Device1_CreateInputLayout(render_target->d3d_device, si->il_desc, si->il_element_count,
4015 ID3D10Blob_GetBufferPointer(compiled), ID3D10Blob_GetBufferSize(compiled),
4016 &render_target->shape_resources[si->shape_type].il)))
4017 {
4018 WARN("Failed to create input layout for shape type %#x, hr %#lx.\n", si->shape_type, hr);
4019 ID3D10Blob_Release(compiled);
4020 goto err;
4021 }
4022
4023 if (FAILED(hr = ID3D11Device1_CreateVertexShader(render_target->d3d_device,
4024 ID3D10Blob_GetBufferPointer(compiled), ID3D10Blob_GetBufferSize(compiled),
4025 NULL, &render_target->shape_resources[si->shape_type].vs)))
4026 {
4027 WARN("Failed to create vertex shader for shape type %#x, hr %#lx.\n", si->shape_type, hr);
4028 ID3D10Blob_Release(compiled);
4029 goto err;
4030 }
4031
4032 ID3D10Blob_Release(compiled);
4033 }
4034
4035 buffer_desc.ByteWidth = sizeof(struct d2d_vs_cb);
4036 buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
4037 buffer_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
4038 buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
4039 buffer_desc.MiscFlags = 0;
4040
4041 if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, NULL,
4042 &render_target->vs_cb)))
4043 {
4044 WARN("Failed to create constant buffer, hr %#lx.\n", hr);
4045 goto err;
4046 }
4047
4048 if (FAILED(hr = D3DCompile(ps_code, sizeof(ps_code) - 1, "ps", NULL, NULL, "main", "ps_4_0", 0, 0, &compiled, NULL)))
4049 {
4050 WARN("Failed to compile the pixel shader, hr %#lx.\n", hr);
4051 goto err;
4052 }
4053
4054 if (FAILED(hr = ID3D11Device1_CreatePixelShader(render_target->d3d_device,
4055 ID3D10Blob_GetBufferPointer(compiled), ID3D10Blob_GetBufferSize(compiled),
4056 NULL, &render_target->ps)))
4057 {
4058 WARN("Failed to create pixel shader, hr %#lx.\n", hr);
4059 ID3D10Blob_Release(compiled);
4060 goto err;
4061 }
4062
4063 ID3D10Blob_Release(compiled);
4064
4065 buffer_desc.ByteWidth = sizeof(struct d2d_ps_cb);
4066 buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
4067 buffer_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
4068 buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
4069 buffer_desc.MiscFlags = 0;
4070
4071 if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, NULL,
4072 &render_target->ps_cb)))
4073 {
4074 WARN("Failed to create constant buffer, hr %#lx.\n", hr);
4075 goto err;
4076 }
4077
4078 buffer_desc.ByteWidth = sizeof(indices);
4079 buffer_desc.Usage = D3D11_USAGE_DEFAULT;
4080 buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
4081 buffer_desc.CPUAccessFlags = 0;
4082 buffer_desc.MiscFlags = 0;
4083
4084 buffer_data.pSysMem = indices;
4085 buffer_data.SysMemPitch = 0;
4086 buffer_data.SysMemSlicePitch = 0;
4087
4088 if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device,
4089 &buffer_desc, &buffer_data, &render_target->ib)))
4090 {
4091 WARN("Failed to create clear index buffer, hr %#lx.\n", hr);
4092 goto err;
4093 }
4094
4095 buffer_desc.ByteWidth = sizeof(quad);
4096 buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
4097 buffer_data.pSysMem = quad;
4098
4099 render_target->vb_stride = sizeof(*quad);
4100 if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device,
4101 &buffer_desc, &buffer_data, &render_target->vb)))
4102 {
4103 WARN("Failed to create clear vertex buffer, hr %#lx.\n", hr);
4104 goto err;
4105 }
4106
4107 rs_desc.FillMode = D3D11_FILL_SOLID;
4108 rs_desc.CullMode = D3D11_CULL_NONE;
4109 rs_desc.FrontCounterClockwise = FALSE;
4110 rs_desc.DepthBias = 0;
4111 rs_desc.DepthBiasClamp = 0.0f;
4112 rs_desc.SlopeScaledDepthBias = 0.0f;
4113 rs_desc.DepthClipEnable = TRUE;
4114 rs_desc.ScissorEnable = TRUE;
4115 rs_desc.MultisampleEnable = FALSE;
4116 rs_desc.AntialiasedLineEnable = FALSE;
4117 if (FAILED(hr = ID3D11Device1_CreateRasterizerState(render_target->d3d_device, &rs_desc, &render_target->rs)))
4118 {
4119 WARN("Failed to create clear rasteriser state, hr %#lx.\n", hr);
4120 goto err;
4121 }
4122
4124 &IID_IDWriteFactory, (IUnknown **)&dwrite_factory)))
4125 {
4126 ERR("Failed to create dwrite factory, hr %#lx.\n", hr);
4127 goto err;
4128 }
4129
4130 hr = IDWriteFactory_CreateRenderingParams(dwrite_factory, &render_target->default_text_rendering_params);
4131 IDWriteFactory_Release(dwrite_factory);
4132 if (FAILED(hr))
4133 {
4134 ERR("Failed to create default text rendering parameters, hr %#lx.\n", hr);
4135 goto err;
4136 }
4137
4138 render_target->drawing_state.transform = identity;
4139
4140 if (!d2d_clip_stack_init(&render_target->clip_stack))
4141 {
4142 WARN("Failed to initialize clip stack.\n");
4143 hr = E_FAIL;
4144 goto err;
4145 }
4146
4147 render_target->desc.dpiX = 96.0f;
4148 render_target->desc.dpiY = 96.0f;
4149
4150 return S_OK;
4151
4152err:
4153 if (render_target->default_text_rendering_params)
4154 IDWriteRenderingParams_Release(render_target->default_text_rendering_params);
4155 if (render_target->rs)
4156 ID3D11RasterizerState_Release(render_target->rs);
4157 if (render_target->vb)
4158 ID3D11Buffer_Release(render_target->vb);
4159 if (render_target->ib)
4160 ID3D11Buffer_Release(render_target->ib);
4161 if (render_target->ps_cb)
4162 ID3D11Buffer_Release(render_target->ps_cb);
4163 if (render_target->ps)
4164 ID3D11PixelShader_Release(render_target->ps);
4165 if (render_target->vs_cb)
4166 ID3D11Buffer_Release(render_target->vs_cb);
4167 for (i = 0; i < D2D_SHAPE_TYPE_COUNT; ++i)
4168 {
4169 if (render_target->shape_resources[i].vs)
4170 ID3D11VertexShader_Release(render_target->shape_resources[i].vs);
4171 if (render_target->shape_resources[i].il)
4172 ID3D11InputLayout_Release(render_target->shape_resources[i].il);
4173 }
4174 if (render_target->d3d_state)
4175 ID3DDeviceContextState_Release(render_target->d3d_state);
4176 if (render_target->d3d_device)
4177 ID3D11Device1_Release(render_target->d3d_device);
4178 ID2D1Device6_Release(&render_target->device->ID2D1Device6_iface);
4179 ID2D1Factory_Release(render_target->factory);
4180 return hr;
4181}
4182
4184 const struct d2d_device_context_ops *ops, const D2D1_RENDER_TARGET_PROPERTIES *desc, void **render_target)
4185{
4186 D2D1_BITMAP_PROPERTIES1 bitmap_desc;
4187 struct d2d_device_context *object;
4189 HRESULT hr;
4190
4192 WARN("Ignoring render target type %#x.\n", desc->type);
4193 if (desc->usage != D2D1_RENDER_TARGET_USAGE_NONE)
4194 FIXME("Ignoring render target usage %#x.\n", desc->usage);
4195 if (desc->minLevel != D2D1_FEATURE_LEVEL_DEFAULT)
4196 WARN("Ignoring feature level %#x.\n", desc->minLevel);
4197
4198 bitmap_desc.dpiX = desc->dpiX;
4199 bitmap_desc.dpiY = desc->dpiY;
4200
4201 if (bitmap_desc.dpiX == 0.0f && bitmap_desc.dpiY == 0.0f)
4202 {
4203 bitmap_desc.dpiX = 96.0f;
4204 bitmap_desc.dpiY = 96.0f;
4205 }
4206 else if (bitmap_desc.dpiX <= 0.0f || bitmap_desc.dpiY <= 0.0f)
4207 return E_INVALIDARG;
4208
4209 if (!(object = calloc(1, sizeof(*object))))
4210 return E_OUTOFMEMORY;
4211
4213 {
4214 WARN("Failed to initialise render target, hr %#lx.\n", hr);
4215 free(object);
4216 return hr;
4217 }
4218
4219 ID2D1DeviceContext6_SetDpi(&object->ID2D1DeviceContext6_iface, bitmap_desc.dpiX, bitmap_desc.dpiY);
4220
4221 if (surface)
4222 {
4223 bitmap_desc.pixelFormat = desc->pixelFormat;
4227 bitmap_desc.colorContext = NULL;
4228
4229 if (FAILED(hr = ID2D1DeviceContext6_CreateBitmapFromDxgiSurface(&object->ID2D1DeviceContext6_iface,
4230 surface, &bitmap_desc, &bitmap)))
4231 {
4232 WARN("Failed to create target bitmap, hr %#lx.\n", hr);
4233 IUnknown_Release(&object->IUnknown_iface);
4234 return hr;
4235 }
4236
4237 ID2D1DeviceContext6_SetTarget(&object->ID2D1DeviceContext6_iface, (ID2D1Image *)bitmap);
4238 ID2D1Bitmap1_Release(bitmap);
4239 }
4240 else
4241 object->desc.pixelFormat = desc->pixelFormat;
4242
4243 TRACE("Created render target %p.\n", object);
4244 *render_target = outer_unknown ? &object->IUnknown_iface : (IUnknown *)&object->ID2D1DeviceContext6_iface;
4245
4246 return S_OK;
4247}
4248
4250{
4251 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
4252
4253 if (IsEqualGUID(iid, &IID_ID2D1Device6)
4254 || IsEqualGUID(iid, &IID_ID2D1Device5)
4255 || IsEqualGUID(iid, &IID_ID2D1Device4)
4256 || IsEqualGUID(iid, &IID_ID2D1Device3)
4257 || IsEqualGUID(iid, &IID_ID2D1Device2)
4258 || IsEqualGUID(iid, &IID_ID2D1Device1)
4259 || IsEqualGUID(iid, &IID_ID2D1Device)
4260 || IsEqualGUID(iid, &IID_ID2D1Resource)
4261 || IsEqualGUID(iid, &IID_IUnknown))
4262 {
4263 ID2D1Device6_AddRef(iface);
4264 *out = iface;
4265 return S_OK;
4266 }
4267
4268 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
4269
4270 *out = NULL;
4271 return E_NOINTERFACE;
4272}
4273
4275{
4276 struct d2d_device *device = impl_from_ID2D1Device(iface);
4278
4279 TRACE("%p increasing refcount to %lu.\n", iface, refcount);
4280
4281 return refcount;
4282}
4283
4285{
4286 size_t i;
4287
4288 for (i = 0; i < objects->count; ++i)
4289 IUnknown_Release(objects->elements[i].object);
4290 free(objects->elements);
4291 objects->elements = NULL;
4292}
4293
4295{
4296 struct d2d_device *device = impl_from_ID2D1Device(iface);
4298
4299 TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
4300
4301 if (!refcount)
4302 {
4303 IDXGIDevice_Release(device->dxgi_device);
4304 ID2D1Factory1_Release(device->factory);
4306 free(device);
4307 }
4308
4309 return refcount;
4310}
4311
4313{
4314 struct d2d_device *device = impl_from_ID2D1Device(iface);
4315
4316 TRACE("iface %p, factory %p.\n", iface, factory);
4317
4318 *factory = (ID2D1Factory *)device->factory;
4319 ID2D1Factory1_AddRef(device->factory);
4320}
4321
4324{
4325 struct d2d_device_context *object;
4326 HRESULT hr;
4327
4328 if (options)
4329 FIXME("Options are ignored %#x.\n", options);
4330
4331 if (!(object = calloc(1, sizeof(*object))))
4332 return E_OUTOFMEMORY;
4333
4334 if (FAILED(hr = d2d_device_context_init(object, device, NULL, NULL)))
4335 {
4336 WARN("Failed to initialise device context, hr %#lx.\n", hr);
4337 free(object);
4338 return hr;
4339 }
4340
4341 TRACE("Created device context %p.\n", object);
4342
4343 hr = ID2D1DeviceContext6_QueryInterface(&object->ID2D1DeviceContext6_iface, iid, context);
4344 ID2D1DeviceContext6_Release(&object->ID2D1DeviceContext6_iface);
4345
4346 return hr;
4347}
4348
4351{
4352 struct d2d_device *device = impl_from_ID2D1Device(iface);
4353
4354 TRACE("iface %p, options %#x, context %p.\n", iface, options, context);
4355
4356 return d2d_device_create_device_context(device, options, &IID_ID2D1DeviceContext, (void **)context);
4357}
4358
4360 IPrintDocumentPackageTarget *document_target, const D2D1_PRINT_CONTROL_PROPERTIES *desc,
4361 ID2D1PrintControl **print_control)
4362{
4363 FIXME("iface %p, wic_factory %p, document_target %p, desc %p, print_control %p stub!\n", iface, wic_factory,
4364 document_target, desc, print_control);
4365
4366 return E_NOTIMPL;
4367}
4368
4369static void WINAPI d2d_device_SetMaximumTextureMemory(ID2D1Device6 *iface, UINT64 max_texture_memory)
4370{
4371 FIXME("iface %p, max_texture_memory %s stub!\n", iface, wine_dbgstr_longlong(max_texture_memory));
4372}
4373
4375{
4376 FIXME("iface %p stub!\n", iface);
4377
4378 return 0;
4379}
4380
4382{
4383 FIXME("iface %p, msec_since_use %u stub!\n", iface, msec_since_use);
4384
4385 return E_NOTIMPL;
4386}
4387
4389{
4390 FIXME("iface %p stub!\n", iface);
4391
4393}
4394
4396{
4397 FIXME("iface %p, priority %#x stub!\n", iface, priority);
4398}
4399
4402{
4403 struct d2d_device *device = impl_from_ID2D1Device(iface);
4404
4405 TRACE("iface %p, options %#x, context %p.\n", iface, options, context);
4406
4407 return d2d_device_create_device_context(device, options, &IID_ID2D1DeviceContext1, (void **)context);
4408}
4409
4412{
4413 struct d2d_device *device = impl_from_ID2D1Device(iface);
4414
4415 TRACE("iface %p, options %#x, context %p.\n", iface, options, context);
4416
4417 return d2d_device_create_device_context(device, options, &IID_ID2D1DeviceContext2, (void **)context);
4418}
4419
4422{
4423 FIXME("iface %p, bitmap %p stub!\n", iface, bitmap);
4424}
4425
4427 IDXGIDevice **dxgi_device)
4428{
4429 struct d2d_device *device = impl_from_ID2D1Device(iface);
4430
4431 TRACE("iface %p, dxgi_device %p.\n", iface, dxgi_device);
4432
4433 if (!device->allow_get_dxgi_device)
4434 {
4435 *dxgi_device = NULL;
4436 return D2DERR_INVALID_CALL;
4437 }
4438
4439 IDXGIDevice_AddRef(device->dxgi_device);
4440 *dxgi_device = device->dxgi_device;
4441 return S_OK;
4442}
4443
4446{
4447 struct d2d_device *device = impl_from_ID2D1Device(iface);
4448
4449 TRACE("iface %p, options %#x, context %p.\n", iface, options, context);
4450
4451 return d2d_device_create_device_context(device, options, &IID_ID2D1DeviceContext3, (void **)context);
4452}
4453
4456{
4457 struct d2d_device *device = impl_from_ID2D1Device(iface);
4458
4459 TRACE("iface %p, options %#x, context %p.\n", iface, options, context);
4460
4461 return d2d_device_create_device_context(device, options, &IID_ID2D1DeviceContext4, (void **)context);
4462}
4463
4465 UINT64 size)
4466{
4467 FIXME("iface %p, size %s stub!\n", iface, wine_dbgstr_longlong(size));
4468}
4469
4471{
4472 FIXME("iface %p stub!\n", iface);
4473
4474 return 0;
4475}
4476
4479{
4480 struct d2d_device *device = impl_from_ID2D1Device(iface);
4481
4482 TRACE("iface %p, options %#x, context %p.\n", iface, options, context);
4483
4484 return d2d_device_create_device_context(device, options, &IID_ID2D1DeviceContext5, (void **)context);
4485}
4486
4489{
4490 struct d2d_device *device = impl_from_ID2D1Device(iface);
4491
4492 TRACE("iface %p, options %#x, context %p.\n", iface, options, context);
4493
4494 return d2d_device_create_device_context(device, options, &IID_ID2D1DeviceContext6, (void **)context);
4495}
4496
4497static const struct ID2D1Device6Vtbl d2d_device_vtbl =
4498{
4520};
4521
4523{
4524 if (!iface)
4525 return NULL;
4526 assert(iface->lpVtbl == (ID2D1Device1Vtbl *)&d2d_device_vtbl);
4527 return CONTAINING_RECORD(iface, struct d2d_device, ID2D1Device6_iface);
4528}
4529
4532{
4533 device->ID2D1Device6_iface.lpVtbl = &d2d_device_vtbl;
4534 device->refcount = 1;
4535 device->factory = factory;
4536 ID2D1Factory1_AddRef(device->factory);
4537 device->dxgi_device = dxgi_device;
4538 IDXGIDevice_AddRef(device->dxgi_device);
4539 device->allow_get_dxgi_device = allow_get_dxgi_device;
4540}
4541
4543 const GUID *id, IUnknown *object)
4544{
4545 if (!d2d_array_reserve((void **)&objects->elements, &objects->size, objects->count + 1,
4546 sizeof(*objects->elements)))
4547 {
4548 WARN("Failed to resize elements array.\n");
4549 return E_OUTOFMEMORY;
4550 }
4551
4552 objects->elements[objects->count].id = *id;
4553 objects->elements[objects->count].object = object;
4554 IUnknown_AddRef(object);
4555 objects->count++;
4556
4557 return S_OK;
4558}
4559
4561 IUnknown **object)
4562{
4563 size_t i;
4564
4565 for (i = 0; i < objects->count; ++i)
4566 {
4567 if (IsEqualGUID(id, &objects->elements[i].id))
4568 {
4569 if (object)
4570 {
4571 *object = objects->elements[i].object;
4572 IUnknown_AddRef(*object);
4573 }
4574 return TRUE;
4575 }
4576 }
4577
4578 if (object) *object = NULL;
4579 return FALSE;
4580}
unsigned short UINT16
Definition: actypes.h:129
COMPILER_DEPENDENT_UINT64 UINT64
Definition: actypes.h:131
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
const GUID IID_IUnknown
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
HRESULT d2d_bitmap_render_target_init(struct d2d_bitmap_render_target *render_target, const struct d2d_device_context *parent_target, const D2D1_SIZE_F *size, const D2D1_SIZE_U *pixel_size, const D2D1_PIXEL_FORMAT *pixel_format, D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS options)
RECT rect
Definition: combotst.c:67
void d2d_command_list_draw_geometry(struct d2d_command_list *command_list, const struct d2d_device_context *context, ID2D1Geometry *geometry, ID2D1Brush *orig_brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
Definition: command_list.c:780
void d2d_command_list_fill_opacity_mask(struct d2d_command_list *command_list, const struct d2d_device_context *context, ID2D1Bitmap *bitmap, ID2D1Brush *orig_brush, const D2D1_RECT_F *dst_rect, const D2D1_RECT_F *src_rect)
void d2d_command_list_set_unit_mode(struct d2d_command_list *command_list, D2D1_UNIT_MODE mode)
Definition: command_list.c:637
void d2d_command_list_pop_layer(struct d2d_command_list *command_list)
Definition: command_list.c:738
void d2d_command_list_push_layer(struct d2d_command_list *command_list, const struct d2d_device_context *context, const D2D1_LAYER_PARAMETERS1 *params, ID2D1Layer *layer)
Definition: command_list.c:715
void d2d_command_list_set_text_rendering_params(struct d2d_command_list *command_list, IDWriteRenderingParams *params)
Definition: command_list.c:898
void d2d_command_list_draw_line(struct d2d_command_list *command_list, const struct d2d_device_context *context, D2D1_POINT_2F p0, D2D1_POINT_2F p1, ID2D1Brush *orig_brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
Definition: command_list.c:756
void d2d_command_list_fill_mesh(struct d2d_command_list *command_list, const struct d2d_device_context *context, ID2D1Mesh *mesh, ID2D1Brush *orig_brush)
void d2d_command_list_set_transform(struct d2d_command_list *command_list, const D2D1_MATRIX_3X2_F *transform)
Definition: command_list.c:666
void d2d_command_list_set_text_antialias_mode(struct d2d_command_list *command_list, D2D1_TEXT_ANTIALIAS_MODE mode)
Definition: command_list.c:646
HRESULT d2d_command_list_create(ID2D1Factory *factory, struct d2d_command_list **command_list)
Definition: command_list.c:498
void d2d_command_list_set_tags(struct d2d_command_list *command_list, D2D1_TAG tag1, D2D1_TAG tag2)
Definition: command_list.c:656
void d2d_command_list_set_primitive_blend(struct d2d_command_list *command_list, D2D1_PRIMITIVE_BLEND primitive_blend)
Definition: command_list.c:627
void d2d_command_list_draw_bitmap(struct d2d_command_list *command_list, 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)
Definition: command_list.c:999
void d2d_command_list_draw_rectangle(struct d2d_command_list *command_list, const struct d2d_device_context *context, const D2D1_RECT_F *rect, ID2D1Brush *orig_brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
Definition: command_list.c:803
void d2d_command_list_push_clip(struct d2d_command_list *command_list, const D2D1_RECT_F *rect, D2D1_ANTIALIAS_MODE mode)
Definition: command_list.c:696
void d2d_command_list_fill_geometry(struct d2d_command_list *command_list, const struct d2d_device_context *context, ID2D1Geometry *geometry, ID2D1Brush *orig_brush, ID2D1Brush *orig_opacity_brush)
Definition: command_list.c:825
void d2d_command_list_draw_glyph_run(struct d2d_command_list *command_list, const struct d2d_device_context *context, D2D1_POINT_2F origin, const DWRITE_GLYPH_RUN *run, const DWRITE_GLYPH_RUN_DESCRIPTION *run_desc, ID2D1Brush *orig_brush, DWRITE_MEASURING_MODE measuring_mode)
Definition: command_list.c:919
struct d2d_command_list * unsafe_impl_from_ID2D1CommandList(ID2D1CommandList *iface)
Definition: command_list.c:512
void d2d_command_list_clear(struct d2d_command_list *command_list, const D2D1_COLOR_F *color)
Definition: command_list.c:746
void d2d_command_list_draw_image(struct d2d_command_list *command_list, ID2D1Image *image, const D2D1_POINT_2F *target_offset, const D2D1_RECT_F *image_rect, D2D1_INTERPOLATION_MODE interpolation_mode, D2D1_COMPOSITE_MODE composite_mode)
void d2d_command_list_set_antialias_mode(struct d2d_command_list *command_list, D2D1_ANTIALIAS_MODE mode)
Definition: command_list.c:617
void d2d_command_list_begin_draw(struct d2d_command_list *command_list, const struct d2d_device_context *context)
Definition: command_list.c:676
void d2d_command_list_fill_rectangle(struct d2d_command_list *command_list, const struct d2d_device_context *context, const D2D1_RECT_F *rect, ID2D1Brush *orig_brush)
Definition: command_list.c:855
void d2d_command_list_pop_clip(struct d2d_command_list *command_list)
Definition: command_list.c:707
HDC dc
Definition: cylfrac.c:34
D2D1_BITMAP_INTERPOLATION_MODE
Definition: d2d1.idl:206
@ D2D1_BITMAP_INTERPOLATION_MODE_LINEAR
Definition: d2d1.idl:208
@ D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR
Definition: d2d1.idl:207
@ D2D1_FACTORY_TYPE_MULTI_THREADED
Definition: d2d1.idl:79
D2D1_OPACITY_MASK_CONTENT
Definition: d2d1.idl:227
@ D2D1_OPACITY_MASK_CONTENT_TEXT_GDI_COMPATIBLE
Definition: d2d1.idl:230
UINT64 D2D1_TAG
Definition: d2d1.idl:48
@ D2D1_FEATURE_LEVEL_DEFAULT
Definition: d2d1.idl:269
@ D2D1_FIGURE_BEGIN_HOLLOW
Definition: d2d1.idl:101
D2D1_EXTEND_MODE
Definition: d2d1.idl:198
@ D2D1_EXTEND_MODE_CLAMP
Definition: d2d1.idl:199
D2D1_DRAW_TEXT_OPTIONS
Definition: d2d1.idl:235
@ D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT
Definition: d2d1.idl:238
@ D2D1_DRAW_TEXT_OPTIONS_NO_SNAP
Definition: d2d1.idl:236
D2D1_GAMMA
Definition: d2d1.idl:213
@ D2D1_RENDER_TARGET_TYPE_DEFAULT
Definition: d2d1.idl:253
@ D2D1_RENDER_TARGET_TYPE_HARDWARE
Definition: d2d1.idl:255
D2D1_TEXT_ANTIALIAS_MODE
Definition: d2d1.idl:189
@ D2D1_TEXT_ANTIALIAS_MODE_DEFAULT
Definition: d2d1.idl:190
@ D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE
Definition: d2d1.idl:191
@ D2D1_TEXT_ANTIALIAS_MODE_ALIASED
Definition: d2d1.idl:193
@ D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE
Definition: d2d1.idl:192
D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS
Definition: d2d1.idl:220
@ D2D1_RENDER_TARGET_USAGE_GDI_COMPATIBLE
Definition: d2d1.idl:263
@ D2D1_RENDER_TARGET_USAGE_NONE
Definition: d2d1.idl:261
D2D1_ANTIALIAS_MODE
Definition: d2d1.idl:182
@ D2D1_ANTIALIAS_MODE_PER_PRIMITIVE
Definition: d2d1.idl:183
@ D2D1_ANTIALIAS_MODE_ALIASED
Definition: d2d1.idl:184
D2D1_DC_INITIALIZE_MODE
Definition: d2d1.idl:283
@ D2D1_DC_INITIALIZE_MODE_COPY
Definition: d2d1.idl:284
@ D2D1_FIGURE_END_OPEN
Definition: d2d1.idl:107
D2D1_INTERPOLATION_MODE
Definition: d2d1_1.idl:124
@ D2D1_BITMAP_OPTIONS_GDI_COMPATIBLE
Definition: d2d1_1.idl:92
@ D2D1_BITMAP_OPTIONS_CANNOT_DRAW
Definition: d2d1_1.idl:90
@ D2D1_BITMAP_OPTIONS_CPU_READ
Definition: d2d1_1.idl:91
@ D2D1_BITMAP_OPTIONS_NONE
Definition: d2d1_1.idl:88
@ D2D1_BITMAP_OPTIONS_TARGET
Definition: d2d1_1.idl:89
D2D1_COLOR_SPACE
Definition: d2d1_1.idl:79
D2D1_DEVICE_CONTEXT_OPTIONS
Definition: d2d1_1.idl:39
D2D1_UNIT_MODE
Definition: d2d1_1.idl:64
@ D2D1_UNIT_MODE_PIXELS
Definition: d2d1_1.idl:66
@ D2D1_UNIT_MODE_DIPS
Definition: d2d1_1.idl:65
D2D1_PRIMITIVE_BLEND
Definition: d2d1_1.idl:54
@ D2D1_PRIMITIVE_BLEND_MAX
Definition: d2d1_1.idl:59
@ D2D1_STROKE_TRANSFORM_TYPE_FIXED
Definition: d2d1_1.idl:48
D2D1_COMPOSITE_MODE
Definition: d2d1_1.idl:135
@ D2D1_COMPOSITE_MODE_SOURCE_OVER
Definition: d2d1_1.idl:136
D2D1_COLOR_INTERPOLATION_MODE
Definition: d2d1_1.idl:117
D2D1_BUFFER_PRECISION
Definition: d2d1_1.idl:106
@ D2D1_BUFFER_PRECISION_32BPC_FLOAT
Definition: d2d1_1.idl:112
@ D2D1_BUFFER_PRECISION_8BPC_UNORM
Definition: d2d1_1.idl:108
@ D2D1_BUFFER_PRECISION_16BPC_UNORM
Definition: d2d1_1.idl:110
@ D2D1_BUFFER_PRECISION_8BPC_UNORM_SRGB
Definition: d2d1_1.idl:109
@ D2D1_BUFFER_PRECISION_16BPC_FLOAT
Definition: d2d1_1.idl:111
@ D2D1_LAYER_OPTIONS1_NONE
Definition: d2d1_1.idl:154
D2D1_RENDERING_PRIORITY
Definition: d2d1_2.idl:23
@ D2D1_RENDERING_PRIORITY_NORMAL
Definition: d2d1_2.idl:24
D2D1_COLOR_BITMAP_GLYPH_SNAP_OPTION
Definition: d2d1_3.idl:82
D2D1_IMAGE_SOURCE_FROM_DXGI_OPTIONS
Definition: d2d1_3.idl:68
D2D1_IMAGE_SOURCE_LOADING_OPTIONS
Definition: d2d1_3.idl:60
D2D1_SPRITE_OPTIONS
Definition: d2d1_3.idl:75
@ D2D_TARGET_COMMAND_LIST
Definition: d2d1_private.h:159
@ D2D_TARGET_BITMAP
Definition: d2d1_private.h:158
static const char * debug_d2d_point_2f(const D2D1_POINT_2F *point)
Definition: d2d1_private.h:993
HRESULT d2d_effect_create(struct d2d_device_context *context, const CLSID *effect_id, ID2D1Effect **effect)
Definition: effect.c:2660
@ D2D_BRUSH_TYPE_SOLID
Definition: d2d1_private.h:41
@ D2D_BRUSH_TYPE_COUNT
Definition: d2d1_private.h:46
@ D2D_BRUSH_TYPE_BITMAP
Definition: d2d1_private.h:44
@ D2D_SAMPLER_EXTEND_MODE_COUNT
Definition: d2d1_private.h:152
@ D2D_SAMPLER_INTERPOLATION_MODE_COUNT
Definition: d2d1_private.h:151
HRESULT d2d_layer_create(ID2D1Factory *factory, const D2D1_SIZE_F *size, struct d2d_layer **layer)
Definition: layer.c:101
static void d2d_rect_expand(D2D1_RECT_F *dst, const D2D1_POINT_2F *point)
Definition: d2d1_private.h:969
struct d2d_geometry * unsafe_impl_from_ID2D1Geometry(ID2D1Geometry *iface)
Definition: geometry.c:5520
static struct d2d_factory * unsafe_impl_from_ID2D1Factory(ID2D1Factory *iface)
Definition: d2d1_private.h:704
static BOOL d2d_array_reserve(void **elements, size_t *capacity, size_t count, size_t size)
Definition: d2d1_private.h:897
static const char * debug_d2d_rect_f(const D2D1_RECT_F *rect)
static D2D1_INTERPOLATION_MODE d2d1_1_interp_mode_from_d2d1(D2D1_BITMAP_INTERPOLATION_MODE mode)
Definition: d2d1_private.h:981
struct d2d_state_block * unsafe_impl_from_ID2D1DrawingStateBlock(ID2D1DrawingStateBlock *iface)
Definition: state_block.c:185
struct d2d_stroke_style * unsafe_impl_from_ID2D1StrokeStyle(ID2D1StrokeStyle *iface)
Definition: stroke.c:194
static void d2d_point_set(D2D1_POINT_2F *dst, float x, float y)
Definition: d2d1_private.h:952
HRESULT d2d_mesh_create(ID2D1Factory *factory, struct d2d_mesh **mesh)
Definition: mesh.c:98
d2d_shape_type
Definition: d2d1_private.h:50
@ D2D_SHAPE_TYPE_OUTLINE
Definition: d2d1_private.h:51
@ D2D_SHAPE_TYPE_COUNT
Definition: d2d1_private.h:56
@ D2D_SHAPE_TYPE_CURVE
Definition: d2d1_private.h:55
@ D2D_SHAPE_TYPE_TRIANGLE
Definition: d2d1_private.h:54
@ D2D_SHAPE_TYPE_BEZIER_OUTLINE
Definition: d2d1_private.h:52
@ D2D_SHAPE_TYPE_ARC_OUTLINE
Definition: d2d1_private.h:53
static void d2d_point_transform(D2D1_POINT_2F *dst, const D2D1_MATRIX_3X2_F *matrix, float x, float y)
Definition: d2d1_private.h:963
D2D1_BLEND_MODE
const UINT D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION
Definition: d3d11.idl:242
@ D3D11_BLEND_ONE
Definition: d3d11.idl:301
@ D3D11_BLEND_INV_SRC_ALPHA
Definition: d3d11.idl:305
@ D3D11_BLEND_OP_ADD
Definition: d3d11.idl:321
const UINT D3D11_DEFAULT_SAMPLE_MASK
Definition: d3d11.idl:140
@ D3D11_CULL_NONE
Definition: d3d11.idl:625
@ D3D11_MAP_WRITE_DISCARD
Definition: d3d11.idl:975
@ D3D11_FILL_SOLID
Definition: d3d11.idl:849
@ D3D11_INPUT_PER_VERTEX_DATA
Definition: d3d11.idl:953
D3D_FEATURE_LEVEL
Definition: d3dcommon.idl:102
@ D3D_FEATURE_LEVEL_10_0
Definition: d3dcommon.idl:107
@ D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST
Definition: d3dcommon.idl:441
HRESULT WINAPI D3DCompile(const void *data, SIZE_T data_size, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint, const char *target, UINT sflags, UINT eflags, ID3DBlob **shader, ID3DBlob **error_messages)
Definition: compiler.c:639
DWRITE_GLYPH_IMAGE_FORMATS
Definition: dcommon.idl:43
DWRITE_MEASURING_MODE
Definition: dcommon.idl:36
@ DWRITE_MEASURING_MODE_NATURAL
Definition: dcommon.idl:37
@ DWRITE_MEASURING_MODE_GDI_NATURAL
Definition: dcommon.idl:39
D2D1_ALPHA_MODE
Definition: dcommon.idl:66
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size, const void *src_data, UINT32 pitch, const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap)
Definition: bitmap.c:423
HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid, void *data, const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap)
Definition: bitmap.c:522
HRESULT d2d_bitmap_create_from_wic_bitmap(struct d2d_device_context *context, IWICBitmapSource *bitmap_source, const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap)
Definition: bitmap.c:659
struct d2d_bitmap * unsafe_impl_from_ID2D1Bitmap(ID2D1Bitmap *iface)
Definition: bitmap.c:769
unsigned int d2d_get_bitmap_options_for_surface(IDXGISurface *surface)
Definition: bitmap.c:498
BOOL d2d_brush_fill_cb(const struct d2d_brush *brush, struct d2d_brush_cb *cb)
Definition: brush.c:1372
HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D11Device1 *device, const D2D1_GRADIENT_STOP *stops, UINT32 stop_count, D2D1_GAMMA gamma, D2D1_EXTEND_MODE extend_mode, struct d2d_gradient **out)
Definition: brush.c:130
HRESULT d2d_image_brush_create(ID2D1Factory *factory, ID2D1Image *image, const D2D1_IMAGE_BRUSH_PROPERTIES *image_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc, struct d2d_brush **brush)
Definition: brush.c:1323
HRESULT d2d_solid_color_brush_create(ID2D1Factory *factory, const D2D1_COLOR_F *color, const D2D1_BRUSH_PROPERTIES *desc, struct d2d_brush **brush)
Definition: brush.c:389
HRESULT d2d_linear_gradient_brush_create(ID2D1Factory *factory, const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES *gradient_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1GradientStopCollection *gradient, struct d2d_brush **brush)
Definition: brush.c:572
HRESULT d2d_bitmap_brush_create(ID2D1Factory *factory, ID2D1Bitmap *bitmap, const D2D1_BITMAP_BRUSH_PROPERTIES1 *bitmap_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc, struct d2d_brush **brush)
Definition: brush.c:1076
struct d2d_brush * unsafe_impl_from_ID2D1Brush(ID2D1Brush *iface)
Definition: brush.c:1344
void d2d_brush_bind_resources(struct d2d_brush *brush, struct d2d_device_context *context, unsigned int brush_idx)
Definition: brush.c:1573
HRESULT d2d_radial_gradient_brush_create(ID2D1Factory *factory, const D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES *gradient_desc, const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1GradientStopCollection *gradient, struct d2d_brush **brush)
Definition: brush.c:799
static struct d2d_device_context * impl_from_ID2D1DeviceContext(ID2D1DeviceContext6 *iface)
Definition: device.c:212
static void d2d_device_context_draw_glyph_run_bitmap(struct d2d_device_context *context, D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run, ID2D1Brush *brush, DWRITE_RENDERING_MODE rendering_mode, DWRITE_MEASURING_MODE measuring_mode, DWRITE_TEXT_ANTIALIAS_MODE antialias_mode)
Definition: device.c:1357
static void d2d_rect_set(D2D1_RECT_F *dst, float left, float top, float right, float bottom)
Definition: device.c:67
static HRESULT STDMETHODCALLTYPE d2d_device_context_inner_QueryInterface(IUnknown *iface, REFIID iid, void **out)
Definition: device.c:217
static HRESULT STDMETHODCALLTYPE d2d_device_context_EndDraw(ID2D1DeviceContext6 *iface, D2D1_TAG *tag1, D2D1_TAG *tag2)
Definition: device.c:1938
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateCompatibleRenderTarget(ID2D1DeviceContext6 *iface, const D2D1_SIZE_F *size, const D2D1_SIZE_U *pixel_size, const D2D1_PIXEL_FORMAT *format, D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS options, ID2D1BitmapRenderTarget **rt)
Definition: device.c:521
struct d2d_device * unsafe_impl_from_ID2D1Device(ID2D1Device1 *iface)
Definition: device.c:4522
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateColorContextFromDxgiColorSpace(ID2D1DeviceContext6 *iface, DXGI_COLOR_SPACE_TYPE color_space, ID2D1ColorContext1 **color_context)
Definition: device.c:2894
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateMesh(ID2D1DeviceContext6 *iface, ID2D1Mesh **mesh)
Definition: device.c:564
HRESULT d2d_device_add_indexed_object(struct d2d_indexed_objects *objects, const GUID *id, IUnknown *object)
Definition: device.c:4542
static const struct ID2D1Device6Vtbl d2d_device_vtbl
Definition: device.c:4497
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateColorContext(ID2D1DeviceContext6 *iface, D2D1_COLOR_SPACE space, const BYTE *profile, UINT32 profile_size, ID2D1ColorContext **color_context)
Definition: device.c:2075
static HRESULT WINAPI d2d_device_QueryInterface(ID2D1Device6 *iface, REFIID iid, void **out)
Definition: device.c:4249
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateImageSourceFromWic(ID2D1DeviceContext6 *iface, IWICBitmapSource *wic_bitmap_source, D2D1_IMAGE_SOURCE_LOADING_OPTIONS loading_options, D2D1_ALPHA_MODE alpha_mode, ID2D1ImageSourceFromWic **image_source)
Definition: device.c:2722
static void STDMETHODCALLTYPE d2d_device_context_GetFactory(ID2D1DeviceContext6 *iface, ID2D1Factory **factory)
Definition: device.c:349
static BOOL d2d_clip_stack_init(struct d2d_clip_stack *stack)
Definition: device.c:81
static void STDMETHODCALLTYPE d2d_device_context_SaveDrawingState(ID2D1DeviceContext6 *iface, ID2D1DrawingStateBlock *state_block)
Definition: device.c:1754
static HRESULT WINAPI d2d_device_CreateDeviceContext(ID2D1Device6 *iface, D2D1_DEVICE_CONTEXT_OPTIONS options, ID2D1DeviceContext **context)
Definition: device.c:4349
static void STDMETHODCALLTYPE d2d_device_context_DrawSvgDocument(ID2D1DeviceContext6 *iface, ID2D1SvgDocument *svg_document)
Definition: device.c:2888
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateColorContextFromWicColorContext(ID2D1DeviceContext6 *iface, IWICColorContext *wic_color_context, ID2D1ColorContext **color_context)
Definition: device.c:2092
static void STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_DrawGlyphRun(ID2D1DeviceContext6 *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)
Definition: device.c:2530
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateImageBrush(ID2D1DeviceContext6 *iface, ID2D1Image *image, const D2D1_IMAGE_BRUSH_PROPERTIES *image_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1ImageBrush **brush)
Definition: device.c:2209
static void STDMETHODCALLTYPE d2d_device_context_GetRenderingControls(ID2D1DeviceContext6 *iface, D2D1_RENDERING_CONTROLS *rendering_controls)
Definition: device.c:2469
static BOOL STDMETHODCALLTYPE d2d_device_context_IsDxgiFormatSupported(ID2D1DeviceContext6 *iface, DXGI_FORMAT format)
Definition: device.c:2259
static void STDMETHODCALLTYPE d2d_device_context_GetTarget(ID2D1DeviceContext6 *iface, ID2D1Image **target)
Definition: device.c:2452
static void STDMETHODCALLTYPE d2d_device_context_FillOpacityMask(ID2D1DeviceContext6 *iface, ID2D1Bitmap *mask, ID2D1Brush *brush, D2D1_OPACITY_MASK_CONTENT content, const D2D1_RECT_F *dst_rect, const D2D1_RECT_F *src_rect)
Definition: device.c:1114
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateEffect(ID2D1DeviceContext6 *iface, REFCLSID effect_id, ID2D1Effect **effect)
Definition: device.c:2185
static HRESULT STDMETHODCALLTYPE d2d_gdi_interop_render_target_QueryInterface(ID2D1GdiInteropRenderTarget *iface, REFIID iid, void **out)
Definition: device.c:3342
static void STDMETHODCALLTYPE d2d_device_context_SetTags(ID2D1DeviceContext6 *iface, D2D1_TAG tag1, D2D1_TAG tag2)
Definition: device.c:1692
static HRESULT STDMETHODCALLTYPE d2d_text_renderer_GetPixelsPerDip(IDWriteTextRenderer *iface, void *ctx, float *ppd)
Definition: device.c:3109
static void STDMETHODCALLTYPE d2d_device_context_RestoreDrawingState(ID2D1DeviceContext6 *iface, ID2D1DrawingStateBlock *state_block)
Definition: device.c:1771
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateLinearGradientBrush(ID2D1DeviceContext6 *iface, const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES *gradient_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1GradientStopCollection *gradient, ID2D1LinearGradientBrush **brush)
Definition: device.c:485
static const D2D1_MATRIX_3X2_F identity
Definition: device.c:26
static void STDMETHODCALLTYPE d2d_device_context_DrawGlyphRun(ID2D1DeviceContext6 *iface, D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run, ID2D1Brush *brush, DWRITE_MEASURING_MODE measuring_mode)
Definition: device.c:1585
static const struct ID2D1GdiInteropRenderTargetVtbl d2d_gdi_interop_render_target_vtbl
Definition: device.c:3448
static struct d2d_device_context * impl_from_IUnknown(IUnknown *iface)
Definition: device.c:207
static void STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext4_DrawText(ID2D1DeviceContext6 *iface, const WCHAR *string, UINT32 string_length, IDWriteTextFormat *text_format, const D2D1_RECT_F *layout_rect, ID2D1Brush *default_fill_brush, ID2D1SvgGlyphStyle *svg_glyph_style, UINT32 color_palette_index, D2D1_DRAW_TEXT_OPTIONS options, DWRITE_MEASURING_MODE measuring_mode)
Definition: device.c:2814
static HRESULT STDMETHODCALLTYPE d2d_text_renderer_DrawStrikethrough(IDWriteTextRenderer *iface, void *ctx, float baseline_origin_x, float baseline_origin_y, const DWRITE_STRIKETHROUGH *strikethrough, IUnknown *effect)
Definition: device.c:3265
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateSvgGlyphStyle(ID2D1DeviceContext6 *iface, ID2D1SvgGlyphStyle **svg_glyph_style)
Definition: device.c:2806
static BOOL STDMETHODCALLTYPE d2d_device_context_IsSupported(ID2D1DeviceContext6 *iface, const D2D1_RENDER_TARGET_PROPERTIES *desc)
Definition: device.c:2034
static HRESULT STDMETHODCALLTYPE d2d_gdi_interop_render_target_GetDC(ID2D1GdiInteropRenderTarget *iface, D2D1_DC_INITIALIZE_MODE mode, HDC *dc)
Definition: device.c:3397
static HRESULT STDMETHODCALLTYPE d2d_device_ID2D1Device5_CreateDeviceContext(ID2D1Device6 *iface, D2D1_DEVICE_CONTEXT_OPTIONS options, ID2D1DeviceContext5 **context)
Definition: device.c:4477
static void STDMETHODCALLTYPE d2d_device_context_DrawSvgGlyphRun(ID2D1DeviceContext6 *iface, D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run, ID2D1Brush *default_fill_brush, ID2D1SvgGlyphStyle *svg_glyph_style, UINT32 color_palette_index, DWRITE_MEASURING_MODE measuring_mode)
Definition: device.c:2842
static D2D1_PRIMITIVE_BLEND STDMETHODCALLTYPE d2d_device_context_GetPrimitiveBlend(ID2D1DeviceContext6 *iface)
Definition: device.c:2494
static void STDMETHODCALLTYPE d2d_device_context_GetDpi(ID2D1DeviceContext6 *iface, float *dpi_x, float *dpi_y)
Definition: device.c:1995
static void STDMETHODCALLTYPE d2d_device_context_SetTextRenderingParams(ID2D1DeviceContext6 *iface, IDWriteRenderingParams *text_rendering_params)
Definition: device.c:1664
static void WINAPI d2d_device_SetRenderingPriority(ID2D1Device6 *iface, D2D1_RENDERING_PRIORITY priority)
Definition: device.c:4395
static void STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_PushLayer(ID2D1DeviceContext6 *iface, const D2D1_LAYER_PARAMETERS1 *layer_parameters, ID2D1Layer *layer)
Definition: device.c:2604
static void d2d_rect_intersect(D2D1_RECT_F *dst, const D2D1_RECT_F *src)
Definition: device.c:55
static HRESULT STDMETHODCALLTYPE d2d_text_renderer_IsPixelSnappingDisabled(IDWriteTextRenderer *iface, void *ctx, BOOL *disabled)
Definition: device.c:3085
static HRESULT STDMETHODCALLTYPE d2d_device_ID2D1Device4_CreateDeviceContext(ID2D1Device6 *iface, D2D1_DEVICE_CONTEXT_OPTIONS options, ID2D1DeviceContext4 **context)
Definition: device.c:4454
static void STDMETHODCALLTYPE d2d_device_context_SetUnitMode(ID2D1DeviceContext6 *iface, D2D1_UNIT_MODE unit_mode)
Definition: device.c:2503
static D2D1_RENDERING_PRIORITY WINAPI d2d_device_GetRenderingPriority(ID2D1Device6 *iface)
Definition: device.c:4388
static void STDMETHODCALLTYPE d2d_device_context_DrawImage(ID2D1DeviceContext6 *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)
Definition: device.c:2542
static void STDMETHODCALLTYPE d2d_device_context_SetTransform(ID2D1DeviceContext6 *iface, const D2D1_MATRIX_3X2_F *transform)
Definition: device.c:1597
static BOOL d2d_clip_stack_push(struct d2d_clip_stack *stack, const D2D1_RECT_F *rect)
Definition: device.c:97
static void STDMETHODCALLTYPE d2d_device_context_FillGeometry(ID2D1DeviceContext6 *iface, ID2D1Geometry *geometry, ID2D1Brush *brush, ID2D1Brush *opacity_brush)
Definition: device.c:1078
static void STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext4_DrawTextLayout(ID2D1DeviceContext6 *iface, D2D1_POINT_2F origin, IDWriteTextLayout *text_layout, ID2D1Brush *default_fill_brush, ID2D1SvgGlyphStyle *svg_glyph_style, UINT32 color_palette_index, D2D1_DRAW_TEXT_OPTIONS options)
Definition: device.c:2825
static ULONG WINAPI d2d_device_Release(ID2D1Device6 *iface)
Definition: device.c:4294
static HRESULT STDMETHODCALLTYPE d2d_device_ID2D1Device6_CreateDeviceContext(ID2D1Device6 *iface, D2D1_DEVICE_CONTEXT_OPTIONS options, ID2D1DeviceContext6 **context)
Definition: device.c:4487
static void STDMETHODCALLTYPE d2d_device_context_DrawRoundedRectangle(ID2D1DeviceContext6 *iface, const D2D1_ROUNDED_RECT *rect, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
Definition: device.c:670
static HRESULT STDMETHODCALLTYPE d2d_text_renderer_DrawInlineObject(IDWriteTextRenderer *iface, void *ctx, float origin_x, float origin_y, IDWriteInlineObject *object, BOOL is_sideways, BOOL is_rtl, IUnknown *effect)
Definition: device.c:3298
void d2d_device_init(struct d2d_device *device, ID2D1Factory1 *factory, IDXGIDevice *dxgi_device, bool allow_get_dxgi_device)
Definition: device.c:4530
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, const D2D1_RECT_F *src_rect, const D2D1_POINT_2F *offset, const D2D1_MATRIX_4X4_F *perspective_transform)
Definition: device.c:1142
static void d2d_device_context_set_error(struct d2d_device_context *context, HRESULT code)
Definition: device.c:200
static HRESULT STDMETHODCALLTYPE d2d_device_context_Flush(ID2D1DeviceContext6 *iface, D2D1_TAG *tag1, D2D1_TAG *tag2)
Definition: device.c:1742
static void STDMETHODCALLTYPE d2d_device_context_PopLayer(ID2D1DeviceContext6 *iface)
Definition: device.c:1732
static void d2d_size_set(D2D1_SIZE_U *dst, float width, float height)
Definition: device.c:75
static void d2d_device_context_draw(struct d2d_device_context *render_target, enum d2d_shape_type shape_type, ID3D11Buffer *ib, unsigned int index_count, ID3D11Buffer *vb, unsigned int vb_stride, struct d2d_brush *brush, struct d2d_brush *opacity_brush)
Definition: device.c:119
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateColorContextFromSimpleColorProfile(ID2D1DeviceContext6 *iface, const D2D1_SIMPLE_COLOR_PROFILE *simple_profile, ID2D1ColorContext1 **color_context)
Definition: device.c:2902
static void STDMETHODCALLTYPE d2d_device_context_SetRenderingControls(ID2D1DeviceContext6 *iface, const D2D1_RENDERING_CONTROLS *rendering_controls)
Definition: device.c:2463
static ULONG WINAPI d2d_device_AddRef(ID2D1Device6 *iface)
Definition: device.c:4274
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateSpriteBatch(ID2D1DeviceContext6 *iface, ID2D1SpriteBatch **sprite_batch)
Definition: device.c:2789
static D2D1_SIZE_U *STDMETHODCALLTYPE d2d_device_context_GetPixelSize(ID2D1DeviceContext6 *iface, D2D1_SIZE_U *pixel_size)
Definition: device.c:2016
static void STDMETHODCALLTYPE d2d_device_context_GetTags(ID2D1DeviceContext6 *iface, D2D1_TAG *tag1, D2D1_TAG *tag2)
Definition: device.c:1705
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateFilledGeometryRealization(ID2D1DeviceContext6 *iface, ID2D1Geometry *geometry, float tolerance, ID2D1GeometryRealization **realization)
Definition: device.c:2671
static void STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_FillOpacityMask(ID2D1DeviceContext6 *iface, ID2D1Bitmap *mask, ID2D1Brush *brush, const D2D1_RECT_F *dst_rect, const D2D1_RECT_F *src_rect)
Definition: device.c:2650
static void WINAPI d2d_device_GetFactory(ID2D1Device6 *iface, ID2D1Factory **factory)
Definition: device.c:4312
static void STDMETHODCALLTYPE d2d_device_context_DrawGdiMetafile(ID2D1DeviceContext6 *iface, ID2D1GdiMetafile *metafile, const D2D1_POINT_2F *target_offset)
Definition: device.c:2574
static void d2d_clip_stack_pop(struct d2d_clip_stack *stack)
Definition: device.c:112
static void STDMETHODCALLTYPE d2d_device_context_DrawEllipse(ID2D1DeviceContext6 *iface, const D2D1_ELLIPSE *ellipse, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
Definition: device.c:709
static D2D1_TEXT_ANTIALIAS_MODE STDMETHODCALLTYPE d2d_device_context_GetTextAntialiasMode(ID2D1DeviceContext6 *iface)
Definition: device.c:1655
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateBitmapFromWicBitmap(ID2D1DeviceContext6 *iface, IWICBitmapSource *bitmap_source, const D2D1_BITMAP_PROPERTIES *desc, ID2D1Bitmap **bitmap)
Definition: device.c:383
static HRESULT STDMETHODCALLTYPE d2d_device_context_GetGlyphRunWorldBounds(ID2D1DeviceContext6 *iface, D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run, DWRITE_MEASURING_MODE measuring_mode, D2D1_RECT_F *bounds)
Definition: device.c:2348
static HRESULT STDMETHODCALLTYPE d2d_device_ID2D1Device2_CreateDeviceContext(ID2D1Device6 *iface, D2D1_DEVICE_CONTEXT_OPTIONS options, ID2D1DeviceContext2 **context)
Definition: device.c:4410
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateStrokedGeometryRealization(ID2D1DeviceContext6 *iface, ID2D1Geometry *geometry, float tolerance, float stroke_width, ID2D1StrokeStyle *stroke_style, ID2D1GeometryRealization **realization)
Definition: device.c:2680
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateBitmapFromDxgiSurface(ID2D1DeviceContext6 *iface, IDXGISurface *surface, const D2D1_BITMAP_PROPERTIES1 *desc, ID2D1Bitmap1 **bitmap)
Definition: device.c:2140
static HRESULT STDMETHODCALLTYPE d2d_text_renderer_QueryInterface(IDWriteTextRenderer *iface, REFIID iid, void **out)
Definition: device.c:3048
static HRESULT STDMETHODCALLTYPE d2d_text_renderer_GetCurrentTransform(IDWriteTextRenderer *iface, void *ctx, DWRITE_MATRIX *transform)
Definition: device.c:3097
static ULONG STDMETHODCALLTYPE d2d_gdi_interop_render_target_AddRef(ID2D1GdiInteropRenderTarget *iface)
Definition: device.c:3352
static HRESULT d2d_gdi_interop_get_surface(struct d2d_device_context *context, IDXGISurface1 **surface)
Definition: device.c:3370
static UINT64 STDMETHODCALLTYPE d2d_device_GetMaximumColorGlyphCacheMemory(ID2D1Device6 *iface)
Definition: device.c:4470
static D2D1_PIXEL_FORMAT *STDMETHODCALLTYPE d2d_device_context_GetPixelFormat(ID2D1DeviceContext6 *iface, D2D1_PIXEL_FORMAT *format)
Definition: device.c:1966
static void STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_DrawBitmap(ID2D1DeviceContext6 *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)
Definition: device.c:2581
static HRESULT WINAPI d2d_device_CreatePrintControl(ID2D1Device6 *iface, IWICImagingFactory *wic_factory, IPrintDocumentPackageTarget *document_target, const D2D1_PRINT_CONTROL_PROPERTIES *desc, ID2D1PrintControl **print_control)
Definition: device.c:4359
static HRESULT STDMETHODCALLTYPE d2d_text_renderer_DrawGlyphRun(IDWriteTextRenderer *iface, void *ctx, float baseline_origin_x, float baseline_origin_y, DWRITE_MEASURING_MODE measuring_mode, const DWRITE_GLYPH_RUN *glyph_run, const DWRITE_GLYPH_RUN_DESCRIPTION *glyph_run_desc, IUnknown *effect)
Definition: device.c:3120
static HRESULT STDMETHODCALLTYPE d2d_device_context_GetSvgGlyphImage(ID2D1DeviceContext6 *iface, D2D1_POINT_2F glyph_origin, IDWriteFontFace *font_face, FLOAT font_em_size, UINT16 glyph_index, BOOL is_sideways, const D2D1_MATRIX_3X2_F *world_transform, ID2D1Brush *default_fill_brush, ID2D1SvgGlyphStyle *svg_glyph_style, UINT32 color_palette_index, D2D1_MATRIX_3X2_F *glyph_transform, ID2D1CommandList **glyph_image)
Definition: device.c:2864
static HRESULT STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_CreateBitmapFromWicBitmap(ID2D1DeviceContext6 *iface, IWICBitmapSource *bitmap_source, const D2D1_BITMAP_PROPERTIES1 *desc, ID2D1Bitmap1 **bitmap)
Definition: device.c:2059
static void WINAPI d2d_device_SetMaximumTextureMemory(ID2D1Device6 *iface, UINT64 max_texture_memory)
Definition: device.c:4369
static void d2d_device_context_draw_glyph_run(struct d2d_device_context *context, 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)
Definition: device.c:1495
static void STDMETHODCALLTYPE d2d_device_context_FillRoundedRectangle(ID2D1DeviceContext6 *iface, const D2D1_ROUNDED_RECT *rect, ID2D1Brush *brush)
Definition: device.c:690
static D2D1_UNIT_MODE STDMETHODCALLTYPE d2d_device_context_GetUnitMode(ID2D1DeviceContext6 *iface)
Definition: device.c:2521
static void STDMETHODCALLTYPE d2d_device_context_FillMesh(ID2D1DeviceContext6 *iface, ID2D1Mesh *mesh, ID2D1Brush *brush)
Definition: device.c:1103
static void d2d_device_context_reset_target(struct d2d_device_context *context)
Definition: device.c:2368
static void d2d_device_context_fill_geometry(struct d2d_device_context *render_target, const struct d2d_geometry *geometry, struct d2d_brush *brush, struct d2d_brush *opacity_brush)
Definition: device.c:983
static ID2D1Brush * d2d_draw_get_text_brush(struct d2d_draw_text_layout_ctx *context, IUnknown *effect)
Definition: device.c:44
void d2d_device_indexed_objects_clear(struct d2d_indexed_objects *objects)
Definition: device.c:4284
static D2D1_SIZE_F *STDMETHODCALLTYPE d2d_device_context_GetSize(ID2D1DeviceContext6 *iface, D2D1_SIZE_F *size)
Definition: device.c:2005
static void STDMETHODCALLTYPE d2d_device_context_DrawGradientMesh(ID2D1DeviceContext6 *iface, ID2D1GradientMesh *gradient_mesh)
Definition: device.c:2766
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateRadialGradientBrush(ID2D1DeviceContext6 *iface, const D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES *gradient_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1GradientStopCollection *gradient, ID2D1RadialGradientBrush **brush)
Definition: device.c:503
static void STDMETHODCALLTYPE d2d_device_context_DrawLine(ID2D1DeviceContext6 *iface, D2D1_POINT_2F p0, D2D1_POINT_2F p1, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
Definition: device.c:578
static ULONG STDMETHODCALLTYPE d2d_gdi_interop_render_target_Release(ID2D1GdiInteropRenderTarget *iface)
Definition: device.c:3361
static void STDMETHODCALLTYPE d2d_device_context_GetDevice(ID2D1DeviceContext6 *iface, ID2D1Device **device)
Definition: device.c:2358
static void STDMETHODCALLTYPE d2d_device_context_FillEllipse(ID2D1DeviceContext6 *iface, const D2D1_ELLIPSE *ellipse, ID2D1Brush *brush)
Definition: device.c:729
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateSolidColorBrush(ID2D1DeviceContext6 *iface, const D2D1_COLOR_F *color, const D2D1_BRUSH_PROPERTIES *desc, ID2D1SolidColorBrush **brush)
Definition: device.c:452
static void STDMETHODCALLTYPE d2d_device_context_SetDpi(ID2D1DeviceContext6 *iface, float dpi_x, float dpi_y)
Definition: device.c:1977
static void STDMETHODCALLTYPE d2d_device_context_SetTextAntialiasMode(ID2D1DeviceContext6 *iface, D2D1_TEXT_ANTIALIAS_MODE antialias_mode)
Definition: device.c:1642
HRESULT d2d_d3d_create_render_target(struct d2d_device *device, IDXGISurface *surface, IUnknown *outer_unknown, const struct d2d_device_context_ops *ops, const D2D1_RENDER_TARGET_PROPERTIES *desc, void **render_target)
Definition: device.c:4183
static UINT64 WINAPI d2d_device_GetMaximumTextureMemory(ID2D1Device6 *iface)
Definition: device.c:4374
static ULONG STDMETHODCALLTYPE d2d_text_renderer_Release(IDWriteTextRenderer *iface)
Definition: device.c:3076
static void STDMETHODCALLTYPE d2d_device_context_DrawGeometryRealization(ID2D1DeviceContext6 *iface, ID2D1GeometryRealization *realization, ID2D1Brush *brush)
Definition: device.c:2690
#define INITIAL_CLIP_STACK_SIZE
Definition: device.c:24
static HRESULT STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_CreateBitmap(ID2D1DeviceContext6 *iface, D2D1_SIZE_U size, const void *src_data, UINT32 pitch, const D2D1_BITMAP_PROPERTIES1 *desc, ID2D1Bitmap1 **bitmap)
Definition: device.c:2042
static HRESULT STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_CreateBitmapBrush(ID2D1DeviceContext6 *iface, ID2D1Bitmap *bitmap, const D2D1_BITMAP_BRUSH_PROPERTIES1 *bitmap_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1BitmapBrush1 **brush)
Definition: device.c:2227
static void STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext2_DrawGdiMetafile(ID2D1DeviceContext6 *iface, ID2D1GdiMetafile *gdi_metafile, const D2D1_RECT_F *dst_rect, const D2D1_RECT_F *src_rect)
Definition: device.c:2772
static void STDMETHODCALLTYPE d2d_device_context_GetTransform(ID2D1DeviceContext6 *iface, D2D1_MATRIX_3X2_F *transform)
Definition: device.c:1610
static const struct ID2D1DeviceContext6Vtbl d2d_device_context_vtbl
Definition: device.c:2919
static void STDMETHODCALLTYPE d2d_device_context_SetAntialiasMode(ID2D1DeviceContext6 *iface, D2D1_ANTIALIAS_MODE antialias_mode)
Definition: device.c:1620
static void STDMETHODCALLTYPE d2d_device_context_DrawSpriteBatch(ID2D1DeviceContext6 *iface, ID2D1SpriteBatch *sprite_batch, UINT32 start_index, UINT32 sprite_count, ID2D1Bitmap *bitmap, D2D1_BITMAP_INTERPOLATION_MODE interpolation_mode, D2D1_SPRITE_OPTIONS sprite_options)
Definition: device.c:2797
static void STDMETHODCALLTYPE d2d_device_context_GetTextRenderingParams(ID2D1DeviceContext6 *iface, IDWriteRenderingParams **text_rendering_params)
Definition: device.c:1681
static HRESULT STDMETHODCALLTYPE d2d_text_renderer_DrawUnderline(IDWriteTextRenderer *iface, void *ctx, float baseline_origin_x, float baseline_origin_y, const DWRITE_UNDERLINE *underline, IUnknown *effect)
Definition: device.c:3232
static void STDMETHODCALLTYPE d2d_device_FlushDeviceContexts(ID2D1Device6 *iface, ID2D1Bitmap *bitmap)
Definition: device.c:4420
static struct d2d_device_context * impl_from_IDWriteTextRenderer(IDWriteTextRenderer *iface)
Definition: device.c:3043
static HRESULT STDMETHODCALLTYPE d2d_device_context_GetImageLocalBounds(ID2D1DeviceContext6 *iface, ID2D1Image *image, D2D1_RECT_F *local_bounds)
Definition: device.c:2296
static void d2d_clip_stack_cleanup(struct d2d_clip_stack *stack)
Definition: device.c:92
static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, struct d2d_device *device, IUnknown *outer_unknown, const struct d2d_device_context_ops *ops)
Definition: device.c:3457
static void STDMETHODCALLTYPE d2d_device_context_BlendImage(ID2D1DeviceContext6 *iface, ID2D1Image *image, D2D1_BLEND_MODE blend_mode, const D2D1_POINT_2F *target_offset, const D2D1_RECT_F *image_rect, D2D1_INTERPOLATION_MODE interpolation_mode)
Definition: device.c:2910
static void STDMETHODCALLTYPE d2d_device_context_DrawText(ID2D1DeviceContext6 *iface, 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)
Definition: device.c:1238
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateSharedBitmap(ID2D1DeviceContext6 *iface, REFIID iid, void *data, const D2D1_BITMAP_PROPERTIES *desc, ID2D1Bitmap **bitmap)
Definition: device.c:407
static void STDMETHODCALLTYPE d2d_device_context_BeginDraw(ID2D1DeviceContext6 *iface)
Definition: device.c:1926
static const struct IDWriteTextRendererVtbl d2d_text_renderer_vtbl
Definition: device.c:3323
static ULONG STDMETHODCALLTYPE d2d_text_renderer_AddRef(IDWriteTextRenderer *iface)
Definition: device.c:3067
static D2D1_ANTIALIAS_MODE d2d_device_context_set_aa_mode_from_text_aa_mode(struct d2d_device_context *rt)
Definition: device.c:1300
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateGradientStopCollection(ID2D1DeviceContext6 *iface, const D2D1_GRADIENT_STOP *stops, UINT32 stop_count, D2D1_GAMMA gamma, D2D1_EXTEND_MODE extend_mode, ID2D1GradientStopCollection **gradient)
Definition: device.c:467
static void STDMETHODCALLTYPE d2d_device_context_Clear(ID2D1DeviceContext6 *iface, const D2D1_COLOR_F *colour)
Definition: device.c:1849
static ULONG STDMETHODCALLTYPE d2d_device_context_AddRef(ID2D1DeviceContext6 *iface)
Definition: device.c:331
static HRESULT STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_CreateGradientStopCollection(ID2D1DeviceContext6 *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)
Definition: device.c:2195
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateTransformedImageSource(ID2D1DeviceContext6 *iface, ID2D1ImageSource *source, const D2D1_TRANSFORMED_IMAGE_SOURCE_PROPERTIES *props, ID2D1TransformedImageSource **transformed)
Definition: device.c:2780
static void STDMETHODCALLTYPE d2d_device_context_DrawColorBitmapGlyphRun(ID2D1DeviceContext6 *iface, DWRITE_GLYPH_IMAGE_FORMATS glyph_image_format, D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run, DWRITE_MEASURING_MODE measuring_mode, D2D1_COLOR_BITMAP_GLYPH_SNAP_OPTION bitmap_snap_option)
Definition: device.c:2834
static HRESULT STDMETHODCALLTYPE d2d_device_context_InvalidateEffectInputRectangle(ID2D1DeviceContext6 *iface, ID2D1Effect *effect, UINT32 input, const D2D1_RECT_F *input_rect)
Definition: device.c:2615
static BOOL STDMETHODCALLTYPE d2d_device_context_IsBufferPrecisionSupported(ID2D1DeviceContext6 *iface, D2D1_BUFFER_PRECISION buffer_precision)
Definition: device.c:2266
static struct d2d_device * impl_from_ID2D1Device(ID2D1Device6 *iface)
Definition: device.c:39
static struct d2d_device_context * impl_from_ID2D1GdiInteropRenderTarget(ID2D1GdiInteropRenderTarget *iface)
Definition: device.c:3337
static void STDMETHODCALLTYPE d2d_device_context_DrawGeometry(ID2D1DeviceContext6 *iface, ID2D1Geometry *geometry, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
Definition: device.c:953
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateLookupTable3D(ID2D1DeviceContext6 *iface, D2D1_BUFFER_PRECISION precision, const UINT32 *extents, const BYTE *data, UINT32 data_count, const UINT32 *strides, ID2D1LookupTable3D **lookup_table)
Definition: device.c:2732
static void STDMETHODCALLTYPE d2d_device_context_FillRectangle(ID2D1DeviceContext6 *iface, const D2D1_RECT_F *rect, ID2D1Brush *brush)
Definition: device.c:645
BOOL d2d_device_get_indexed_object(struct d2d_indexed_objects *objects, const GUID *id, IUnknown **object)
Definition: device.c:4560
static D2D1_ANTIALIAS_MODE STDMETHODCALLTYPE d2d_device_context_GetAntialiasMode(ID2D1DeviceContext6 *iface)
Definition: device.c:1633
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateLayer(ID2D1DeviceContext6 *iface, const D2D1_SIZE_F *size, ID2D1Layer **layer)
Definition: device.c:549
static void STDMETHODCALLTYPE d2d_device_context_DrawBitmap(ID2D1DeviceContext6 *iface, ID2D1Bitmap *bitmap, const D2D1_RECT_F *dst_rect, float opacity, D2D1_BITMAP_INTERPOLATION_MODE interpolation_mode, const D2D1_RECT_F *src_rect)
Definition: device.c:1210
static HRESULT STDMETHODCALLTYPE d2d_device_context_GetEffectInvalidRectangleCount(ID2D1DeviceContext6 *iface, ID2D1Effect *effect, UINT32 *rect_count)
Definition: device.c:2624
static void d2d_device_context_draw_glyph_run_outline(struct d2d_device_context *render_target, D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run, ID2D1Brush *brush)
Definition: device.c:1308
static ULONG STDMETHODCALLTYPE d2d_device_context_Release(ID2D1DeviceContext6 *iface)
Definition: device.c:340
static BOOL d2d_bitmap_check_options_with_surface(unsigned int options, unsigned int surface_options)
Definition: device.c:2100
static UINT32 STDMETHODCALLTYPE d2d_device_context_GetMaximumBitmapSize(ID2D1DeviceContext6 *iface)
Definition: device.c:2027
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateCommandList(ID2D1DeviceContext6 *iface, ID2D1CommandList **command_list)
Definition: device.c:2244
static HRESULT STDMETHODCALLTYPE d2d_device_context_GetGradientMeshWorldBounds(ID2D1DeviceContext6 *iface, ID2D1GradientMesh *gradient_mesh, D2D1_RECT_F *bounds)
Definition: device.c:2752
static void STDMETHODCALLTYPE d2d_device_context_SetPrimitiveBlend(ID2D1DeviceContext6 *iface, D2D1_PRIMITIVE_BLEND primitive_blend)
Definition: device.c:2475
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateImageSourceFromDxgi(ID2D1DeviceContext6 *iface, IDXGISurface **surfaces, UINT32 surface_count, DXGI_COLOR_SPACE_TYPE color_space, D2D1_IMAGE_SOURCE_FROM_DXGI_OPTIONS options, ID2D1ImageSource **image_source)
Definition: device.c:2742
static HRESULT STDMETHODCALLTYPE d2d_device_context_GetEffectRequiredInputRectangles(ID2D1DeviceContext6 *iface, ID2D1Effect *effect, const D2D1_RECT_F *image_rect, const D2D1_EFFECT_INPUT_DESCRIPTION *desc, D2D1_RECT_F *input_rect, UINT32 input_count)
Definition: device.c:2640
static void STDMETHODCALLTYPE d2d_device_context_PushAxisAlignedClip(ID2D1DeviceContext6 *iface, const D2D1_RECT_F *clip_rect, D2D1_ANTIALIAS_MODE antialias_mode)
Definition: device.c:1802
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateBitmap(ID2D1DeviceContext6 *iface, D2D1_SIZE_U size, const void *src_data, UINT32 pitch, const D2D1_BITMAP_PROPERTIES *desc, ID2D1Bitmap **bitmap)
Definition: device.c:359
static const struct IUnknownVtbl d2d_device_context_inner_unknown_vtbl
Definition: device.c:314
static HRESULT STDMETHODCALLTYPE d2d_device_context_GetImageWorldBounds(ID2D1DeviceContext6 *iface, ID2D1Image *image, D2D1_RECT_F *world_bounds)
Definition: device.c:2340
static void STDMETHODCALLTYPE d2d_device_context_SetTarget(ID2D1DeviceContext6 *iface, ID2D1Image *target)
Definition: device.c:2385
static HRESULT STDMETHODCALLTYPE d2d_device_context_GetEffectInvalidRectangles(ID2D1DeviceContext6 *iface, ID2D1Effect *effect, D2D1_RECT_F *rectangles, UINT32 rect_count)
Definition: device.c:2632
static HRESULT d2d_device_context_update_vs_cb(struct d2d_device_context *context, const D2D_MATRIX_3X2_F *geometry_transform, float stroke_width)
Definition: device.c:782
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateSvgDocument(ID2D1DeviceContext6 *iface, IStream *input_xml_stream, D2D1_SIZE_F viewport_size, ID2D1SvgDocument **svg_document)
Definition: device.c:2879
static void STDMETHODCALLTYPE d2d_device_context_PopAxisAlignedClip(ID2D1DeviceContext6 *iface)
Definition: device.c:1837
static void STDMETHODCALLTYPE d2d_device_context_DrawTextLayout(ID2D1DeviceContext6 *iface, D2D1_POINT_2F origin, IDWriteTextLayout *layout, ID2D1Brush *brush, D2D1_DRAW_TEXT_OPTIONS options)
Definition: device.c:1282
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateBitmapBrush(ID2D1DeviceContext6 *iface, ID2D1Bitmap *bitmap, const D2D1_BITMAP_BRUSH_PROPERTIES *bitmap_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1BitmapBrush **brush)
Definition: device.c:434
static HRESULT STDMETHODCALLTYPE d2d_device_ID2D1Device3_CreateDeviceContext(ID2D1Device6 *iface, D2D1_DEVICE_CONTEXT_OPTIONS options, ID2D1DeviceContext3 **context)
Definition: device.c:4444
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)
Definition: device.c:832
static ULONG STDMETHODCALLTYPE d2d_device_context_inner_Release(IUnknown *iface)
Definition: device.c:261
static void STDMETHODCALLTYPE d2d_device_SetMaximumColorGlyphCacheMemory(ID2D1Device6 *iface, UINT64 size)
Definition: device.c:4464
static void STDMETHODCALLTYPE d2d_device_context_DrawRectangle(ID2D1DeviceContext6 *iface, const D2D1_RECT_F *rect, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
Definition: device.c:619
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateInk(ID2D1DeviceContext6 *iface, const D2D1_INK_POINT *start_point, ID2D1Ink **ink)
Definition: device.c:2696
static HRESULT STDMETHODCALLTYPE d2d_gdi_interop_render_target_ReleaseDC(ID2D1GdiInteropRenderTarget *iface, const RECT *update)
Definition: device.c:3423
static ULONG STDMETHODCALLTYPE d2d_device_context_inner_AddRef(IUnknown *iface)
Definition: device.c:251
static void STDMETHODCALLTYPE d2d_device_context_DrawInk(ID2D1DeviceContext6 *iface, ID2D1Ink *ink, ID2D1Brush *brush, ID2D1InkStyle *ink_style)
Definition: device.c:2760
static void STDMETHODCALLTYPE d2d_device_context_PushLayer(ID2D1DeviceContext6 *iface, const D2D1_LAYER_PARAMETERS *layer_parameters, ID2D1Layer *layer)
Definition: device.c:1715
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateColorContextFromFilename(ID2D1DeviceContext6 *iface, const WCHAR *filename, ID2D1ColorContext **color_context)
Definition: device.c:2084
static HRESULT STDMETHODCALLTYPE d2d_device_GetDxgiDevice(ID2D1Device6 *iface, IDXGIDevice **dxgi_device)
Definition: device.c:4426
static HRESULT WINAPI d2d_device_CreateDeviceContext1(ID2D1Device6 *iface, D2D1_DEVICE_CONTEXT_OPTIONS options, ID2D1DeviceContext1 **context)
Definition: device.c:4400
static HRESULT STDMETHODCALLTYPE d2d_device_context_QueryInterface(ID2D1DeviceContext6 *iface, REFIID iid, void **out)
Definition: device.c:321
static HRESULT WINAPI d2d_device_ClearResources(ID2D1Device6 *iface, UINT msec_since_use)
Definition: device.c:4381
static HRESULT d2d_device_create_device_context(struct d2d_device *device, D2D1_DEVICE_CONTEXT_OPTIONS options, REFIID iid, void **context)
Definition: device.c:4322
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateInkStyle(ID2D1DeviceContext6 *iface, const D2D1_INK_STYLE_PROPERTIES *ink_style_properties, ID2D1InkStyle **ink_style)
Definition: device.c:2704
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)
Definition: device.c:748
static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateGradientMesh(ID2D1DeviceContext6 *iface, const D2D1_GRADIENT_MESH_PATCH *patches, UINT32 patches_count, ID2D1GradientMesh **gradient_mesh)
Definition: device.c:2712
static HRESULT STDMETHODCALLTYPE d2d_device_context_GetColorBitmapGlyphImage(ID2D1DeviceContext6 *iface, DWRITE_GLYPH_IMAGE_FORMATS glyph_image_format, D2D1_POINT_2F glyph_origin, IDWriteFontFace *font_face, FLOAT font_em_size, UINT16 glyph_index, BOOL is_sideways, const D2D1_MATRIX_3X2_F *world_transform, FLOAT dpi_x, FLOAT dpi_y, D2D1_MATRIX_3X2_F *glyph_transform, ID2D1Image **glyph_image)
Definition: device.c:2851
HRESULT WINAPI DWriteCreateFactory(DWRITE_FACTORY_TYPE type, REFIID riid, IUnknown **ret)
Definition: main.c:2110
content
Definition: atl_ax.c:990
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define assert(_expr)
Definition: assert.h:32
_ACRTIMP float __cdecl fabsf(float)
DWRITE_RENDERING_MODE
Definition: dwrite.idl:160
@ DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL
Definition: dwrite.idl:170
@ DWRITE_RENDERING_MODE_OUTLINE
Definition: dwrite.idl:167
@ DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC
Definition: dwrite.idl:171
@ DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL
Definition: dwrite.idl:169
@ DWRITE_RENDERING_MODE_DEFAULT
Definition: dwrite.idl:161
@ DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC
Definition: dwrite.idl:168
@ DWRITE_RENDERING_MODE_ALIASED
Definition: dwrite.idl:162
@ DWRITE_FACTORY_TYPE_SHARED
Definition: dwrite.idl:42
DWRITE_TEXTURE_TYPE
Definition: dwrite.idl:346
@ DWRITE_TEXTURE_ALIASED_1x1
Definition: dwrite.idl:347
@ DWRITE_TEXTURE_CLEARTYPE_3x1
Definition: dwrite.idl:348
@ DWRITE_GRID_FIT_MODE_DEFAULT
Definition: dwrite_2.idl:29
DXGI_COLOR_SPACE_TYPE
Definition: dxgicommon.idl:27
DXGI_FORMAT
Definition: dxgiformat.idl:22
@ DXGI_FORMAT_R16_UINT
Definition: dxgiformat.idl:80
@ DXGI_FORMAT_R16G16B16A16_UNORM
Definition: dxgiformat.idl:34
@ DXGI_FORMAT_R32G32B32_FLOAT
Definition: dxgiformat.idl:29
@ DXGI_FORMAT_A8_UNORM
Definition: dxgiformat.idl:88
@ DXGI_FORMAT_R32G32_FLOAT
Definition: dxgiformat.idl:39
@ DXGI_FORMAT_R16G16B16A16_FLOAT
Definition: dxgiformat.idl:33
@ DXGI_FORMAT_R8G8B8A8_UNORM
Definition: dxgiformat.idl:51
@ DXGI_FORMAT_R32G32B32A32_FLOAT
Definition: dxgiformat.idl:25
@ DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
Definition: dxgiformat.idl:52
POINTL point
Definition: edittest.c:50
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint start
Definition: gl.h:1545
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLdouble s
Definition: gl.h:2039
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint GLuint end
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLint GLint GLsizei width
Definition: gl.h:1546
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
GLuint GLenum GLenum transform
Definition: glext.h:9407
GLenum src
Definition: glext.h:6340
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
GLuint color
Definition: glext.h:6243
const GLubyte * c
Definition: glext.h:8905
GLenum GLint GLuint mask
Definition: glext.h:6028
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLdouble GLdouble right
Definition: glext.h:10859
GLenum mode
Definition: glext.h:6217
const GLvdpauSurfaceNV * surfaces
Definition: glext.h:11586
GLint left
Definition: glext.h:7726
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint bottom
Definition: glext.h:7726
GLsizei GLenum GLboolean sink
Definition: glext.h:5672
GLenum GLint GLint * precision
Definition: glext.h:7539
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
GLenum GLenum GLenum input
Definition: glext.h:9031
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLuint id
Definition: glext.h:5910
const GLfloat * m
Definition: glext.h:10848
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
unsigned int UINT
Definition: sysinfo.c:13
static D3D_DRIVER_TYPE HMODULE UINT const D3D_FEATURE_LEVEL * feature_levels
Definition: hlsl_d3d11.c:28
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
const char * filename
Definition: ioapi.h:137
voidpf uLong int origin
Definition: ioapi.h:144
#define d
Definition: ke_i.h:81
#define c
Definition: ke_i.h:80
#define resource
Definition: kernel32.h:9
#define debugstr_guid
Definition: kernel32.h:35
#define profile
Definition: kernel32.h:12
#define debugstr_wn
Definition: kernel32.h:33
#define debugstr_w
Definition: kernel32.h:32
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const CLSID * objects[]
Definition: apphelp.c:112
static HDC
Definition: imagelist.c:88
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
static const RECT rectangles[]
Definition: dib.c:1586
static SYSTEM_INFO si
Definition: virtual.c:39
static const unsigned char metafile[]
Definition: olepicture.c:126
static BOOL is_rtl(void)
Definition: editor.c:53
static int priority
Definition: timer.c:163
static BYTE parameters[]
Definition: asn.c:558
#define min(a, b)
Definition: monoChain.cc:55
int k
Definition: mpi.c:3369
#define ceilf(x)
Definition: mymath.h:62
#define sqrtf(x)
Definition: mymath.h:59
short WCHAR
Definition: pedump.c:58
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
static void quad(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3, GLuint pv)
Definition: quads.c:63
#define err(...)
#define calloc
Definition: rosglue.h:14
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
D2D1_INTERPOLATION_MODE interpolationMode
Definition: d2d1_1.idl:285
D2D1_EXTEND_MODE extendModeY
Definition: d2d1_1.idl:284
D2D1_EXTEND_MODE extendModeX
Definition: d2d1_1.idl:283
D2D1_PIXEL_FORMAT pixelFormat
Definition: d2d1_1.idl:266
ID2D1ColorContext * colorContext
Definition: d2d1_1.idl:270
D2D1_BITMAP_OPTIONS bitmapOptions
Definition: d2d1_1.idl:269
D2D1_PIXEL_FORMAT pixelFormat
Definition: d2d1.idl:362
D2D1_MATRIX_3X2_F transform
Definition: d2d1.idl:377
D2D1_TEXT_ANTIALIAS_MODE textAntialiasMode
Definition: d2d1_1.idl:243
D2D1_ANTIALIAS_MODE antialiasMode
Definition: d2d1_1.idl:242
D2D1_MATRIX_3X2_F transform
Definition: d2d1_1.idl:246
D2D1_PRIMITIVE_BLEND primitiveBlend
Definition: d2d1_1.idl:247
D2D1_ALPHA_MODE alphaMode
Definition: dcommon.idl:71
DXGI_FORMAT format
Definition: dcommon.idl:70
D2D1_PIXEL_FORMAT pixelFormat
Definition: d2d1.idl:408
D2D1_STROKE_TRANSFORM_TYPE transformType
Definition: d2d1_1.idl:237
float top
Definition: dcommon.idl:106
float bottom
Definition: dcommon.idl:108
float right
Definition: dcommon.idl:107
float left
Definition: dcommon.idl:105
UINT32 height
Definition: dcommon.idl:116
UINT32 width
Definition: dcommon.idl:115
D3D11_CULL_MODE CullMode
Definition: d3d11.idl:1079
FLOAT SlopeScaledDepthBias
Definition: d3d11.idl:1083
D3D11_FILL_MODE FillMode
Definition: d3d11.idl:1078
DWRITE_COLOR_F runColor
Definition: dwrite_2.idl:81
DWRITE_GLYPH_RUN glyphRun
Definition: dwrite_2.idl:77
DWRITE_GLYPH_RUN_DESCRIPTION * glyphRunDescription
Definition: dwrite_2.idl:78
IDWriteFontFace * fontFace
Definition: dwrite.idl:405
DWRITE_GLYPH_OFFSET const * glyphOffsets
Definition: dwrite.idl:410
UINT32 bidiLevel
Definition: dwrite.idl:412
FLOAT fontEmSize
Definition: dwrite.idl:406
UINT16 const * glyphIndices
Definition: dwrite.idl:408
FLOAT const * glyphAdvances
Definition: dwrite.idl:409
UINT32 glyphCount
Definition: dwrite.idl:407
DXGI_FORMAT Format
Definition: dxgi.idl:80
Definition: dcommon.idl:28
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
LONG y
Definition: windef.h:130
LONG x
Definition: windef.h:129
Definition: uimain.c:89
Definition: inflate.c:139
Definition: http.c:7252
D2D1_BITMAP_OPTIONS options
Definition: d2d1_private.h:438
D2D1_SIZE_U pixel_size
Definition: d2d1_private.h:434
IDXGISurface * surface
Definition: d2d1_private.h:431
D2D1_PIXEL_FORMAT format
Definition: d2d1_private.h:435
ID2D1Brush ID2D1Brush_iface
Definition: d2d1_private.h:323
float opacity
Definition: d2d1_private.h:327
enum d2d_brush_type type
Definition: d2d1_private.h:330
struct d2d_gradient * gradient
Definition: d2d1_private.h:339
D2D1_INTERPOLATION_MODE interpolation_mode
Definition: d2d1_private.h:355
IDWriteRenderingParams * default_text_rendering_params
Definition: d2d1_private.h:217
ID3D11RasterizerState * rs
Definition: d2d1_private.h:207
ID3D11Device1 * d3d_device
Definition: d2d1_private.h:187
D2D1_SIZE_U pixel_size
Definition: d2d1_private.h:220
ID2D1DeviceContext6 ID2D1DeviceContext6_iface
Definition: d2d1_private.h:175
ID3D11Buffer * vs_cb
Definition: d2d1_private.h:201
ID3DDeviceContextState * d3d_state
Definition: d2d1_private.h:188
ID2D1GdiInteropRenderTarget ID2D1GdiInteropRenderTarget_iface
Definition: d2d1_private.h:176
ID3D11Buffer * ps_cb
Definition: d2d1_private.h:203
struct d2d_device_context::@231 target
const struct d2d_device_context_ops * ops
Definition: d2d1_private.h:182
struct d2d_device * device
Definition: d2d1_private.h:186
D2D1_RENDER_TARGET_PROPERTIES desc
Definition: d2d1_private.h:219
unsigned int vb_stride
Definition: d2d1_private.h:205
ID3D11Buffer * ib
Definition: d2d1_private.h:204
D2D1_DRAWING_STATE_DESCRIPTION1 drawing_state
Definition: d2d1_private.h:215
struct d2d_shape_resources shape_resources[D2D_SHAPE_TYPE_COUNT]
Definition: d2d1_private.h:200
IDWriteRenderingParams * text_rendering_params
Definition: d2d1_private.h:216
ID3D11BlendState * bs
Definition: d2d1_private.h:208
CRITICAL_SECTION * cs
Definition: d2d1_private.h:185
ID2D1Image * object
Definition: d2d1_private.h:191
IUnknown * outer_unknown
Definition: d2d1_private.h:181
ID2D1Factory * factory
Definition: d2d1_private.h:184
struct d2d_bitmap * bitmap
Definition: d2d1_private.h:195
ID3D11Buffer * vb
Definition: d2d1_private.h:206
IDWriteTextRenderer IDWriteTextRenderer_iface
Definition: d2d1_private.h:177
IUnknown IUnknown_iface
Definition: d2d1_private.h:178
ID3D11PixelShader * ps
Definition: d2d1_private.h:202
struct d2d_clip_stack clip_stack
Definition: d2d1_private.h:221
bool allow_get_dxgi_device
Definition: d2d1_private.h:616
IDXGIDevice * dxgi_device
Definition: d2d1_private.h:615
ID2D1Factory1 * factory
Definition: d2d1_private.h:614
ID2D1Device6 ID2D1Device6_iface
Definition: d2d1_private.h:612
ID2D1Brush * brush
Definition: device.c:35
D2D1_DRAW_TEXT_OPTIONS options
Definition: device.c:36
D2D_MATRIX_3X2_F transform
Definition: d2d1_private.h:508
struct d2d_geometry::@241 fill
struct d2d_geometry::@242 outline
D2D1_GRADIENT_STOP * stops
Definition: d2d1_private.h:313
UINT32 stop_count
Definition: d2d1_private.h:314
BOOL pad[2]
Definition: d2d1_private.h:123
struct d2d_brush_cb opacity_brush
Definition: d2d1_private.h:125
BOOL outline
Definition: d2d1_private.h:121
struct d2d_brush_cb colour_brush
Definition: d2d1_private.h:124
ID3D11VertexShader * vs
Definition: d2d1_private.h:81
ID3D11InputLayout * il
Definition: d2d1_private.h:80
IDWriteRenderingParams * text_rendering_params
Definition: d2d1_private.h:457
D2D1_DRAWING_STATE_DESCRIPTION1 drawing_state
Definition: d2d1_private.h:456
D2D1_STROKE_STYLE_PROPERTIES1 desc
Definition: d2d1_private.h:393
float stroke_width
Definition: d2d1_private.h:138
struct d2d_vec4 transform_rtx
Definition: d2d1_private.h:140
struct d2d_vec4 transform_rty
Definition: d2d1_private.h:141
struct d2d_vs_cb::@229 transform_geometry
Definition: devices.h:37
Definition: main.c:439
Definition: image.c:84
Definition: mesh.c:189
Definition: name.c:39
Definition: mesh.c:5437
Definition: format.c:80
stack()
Definition: _stack.h:74
size_type size() const
Definition: _stack.h:83
Definition: tools.h:99
#define max(a, b)
Definition: svc.c:63
float FLOAT
Definition: typedefs.h:69
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t UINT32
Definition: typedefs.h:59
uint32_t ULONG
Definition: typedefs.h:59
static const WCHAR props[]
Definition: wbemdisp.c:288
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define WINAPI
Definition: msvc.h:6
#define D2DERR_WRONG_STATE
Definition: winerror.h:7352
#define E_NOINTERFACE
Definition: winerror.h:3479
#define D2DERR_INVALID_CALL
Definition: winerror.h:7361
#define D2DERR_TARGET_NOT_GDI_COMPATIBLE
Definition: winerror.h:7377
#define D2DERR_INVALID_TARGET
Definition: winerror.h:7387
#define D2DERR_INCOMPATIBLE_BRUSH_TYPES
Definition: winerror.h:7375
unsigned char BYTE
Definition: xxhash.c:193