include/mscvpdb.h: Use flexible array members for the rest of structures.
[wine.git] / dlls / d2d1 / d2d1_private.h
blob58507fd2c0b28131bbddfa992f6859acf3daf12f
1 /*
2 * Copyright 2014 Henri Verbeet for CodeWeavers
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.
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.
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
19 #ifndef __WINE_D2D1_PRIVATE_H
20 #define __WINE_D2D1_PRIVATE_H
22 #include "wine/debug.h"
23 #include "wine/list.h"
25 #include <assert.h>
26 #include <limits.h>
27 #include <stdint.h>
28 #include <stdbool.h>
29 #include <math.h>
30 #define COBJMACROS
31 #include "d2d1_3.h"
32 #include "d2d1effectauthor.h"
33 #include "d3d11_1.h"
34 #ifdef D2D1_INIT_GUID
35 #include "initguid.h"
36 #endif
37 #include "dwrite_2.h"
39 enum d2d_brush_type
41 D2D_BRUSH_TYPE_SOLID,
42 D2D_BRUSH_TYPE_LINEAR,
43 D2D_BRUSH_TYPE_RADIAL,
44 D2D_BRUSH_TYPE_BITMAP,
45 D2D_BRUSH_TYPE_IMAGE,
46 D2D_BRUSH_TYPE_COUNT,
49 enum d2d_shape_type
51 D2D_SHAPE_TYPE_OUTLINE,
52 D2D_SHAPE_TYPE_BEZIER_OUTLINE,
53 D2D_SHAPE_TYPE_ARC_OUTLINE,
54 D2D_SHAPE_TYPE_TRIANGLE,
55 D2D_SHAPE_TYPE_CURVE,
56 D2D_SHAPE_TYPE_COUNT,
59 struct d2d_settings
61 unsigned int max_version_factory;
63 extern struct d2d_settings d2d_settings;
65 struct d2d_clip_stack
67 D2D1_RECT_F *stack;
68 size_t size;
69 size_t count;
72 struct d2d_error_state
74 HRESULT code;
75 D2D1_TAG tag1, tag2;
78 struct d2d_shape_resources
80 ID3D11InputLayout *il;
81 ID3D11VertexShader *vs;
84 struct d2d_brush_cb
86 enum d2d_brush_type type;
87 float opacity;
88 unsigned int pad[2];
89 union
91 struct
93 D2D1_COLOR_F colour;
94 } solid;
95 struct
97 D2D1_POINT_2F start;
98 D2D1_POINT_2F end;
99 unsigned int stop_count;
100 } linear;
101 struct
103 D2D1_POINT_2F centre;
104 D2D1_POINT_2F offset;
105 D2D1_POINT_2F ra;
106 D2D1_POINT_2F rb;
107 unsigned int stop_count;
108 float pad[3];
109 } radial;
110 struct
112 float _11, _21, _31, pad;
113 float _12, _22, _32;
114 BOOL ignore_alpha;
115 } bitmap;
116 } u;
119 struct d2d_ps_cb
121 BOOL outline;
122 BOOL is_arc;
123 BOOL pad[2];
124 struct d2d_brush_cb colour_brush;
125 struct d2d_brush_cb opacity_brush;
128 struct d2d_vec4
130 float x, y, z, w;
133 struct d2d_vs_cb
135 struct
137 float _11, _21, _31, pad0;
138 float _12, _22, _32, stroke_width;
139 } transform_geometry;
140 struct d2d_vec4 transform_rtx;
141 struct d2d_vec4 transform_rty;
144 struct d2d_device_context_ops
146 HRESULT (*device_context_present)(IUnknown *outer_unknown);
149 enum d2d_device_context_sampler_limits
151 D2D_SAMPLER_INTERPOLATION_MODE_COUNT = 2,
152 D2D_SAMPLER_EXTEND_MODE_COUNT = 3,
155 enum d2d_device_context_target_type
157 D2D_TARGET_UNKNOWN = 0,
158 D2D_TARGET_BITMAP,
159 D2D_TARGET_COMMAND_LIST,
162 struct d2d_indexed_objects
164 struct
166 GUID id;
167 IUnknown *object;
168 } *elements;
169 size_t size;
170 size_t count;
173 struct d2d_device_context
175 ID2D1DeviceContext6 ID2D1DeviceContext6_iface;
176 ID2D1GdiInteropRenderTarget ID2D1GdiInteropRenderTarget_iface;
177 IDWriteTextRenderer IDWriteTextRenderer_iface;
178 IUnknown IUnknown_iface;
179 LONG refcount;
181 IUnknown *outer_unknown;
182 const struct d2d_device_context_ops *ops;
184 ID2D1Factory *factory;
185 CRITICAL_SECTION *cs;
186 struct d2d_device *device;
187 ID3D11Device1 *d3d_device;
188 ID3DDeviceContextState *d3d_state;
189 struct
191 ID2D1Image *object;
192 enum d2d_device_context_target_type type;
193 union
195 struct d2d_bitmap *bitmap;
196 struct d2d_command_list *command_list;
198 HDC hdc;
199 } target;
200 struct d2d_shape_resources shape_resources[D2D_SHAPE_TYPE_COUNT];
201 ID3D11Buffer *vs_cb;
202 ID3D11PixelShader *ps;
203 ID3D11Buffer *ps_cb;
204 ID3D11Buffer *ib;
205 unsigned int vb_stride;
206 ID3D11Buffer *vb;
207 ID3D11RasterizerState *rs;
208 ID3D11BlendState *bs;
209 ID3D11SamplerState *sampler_states
210 [D2D_SAMPLER_INTERPOLATION_MODE_COUNT]
211 [D2D_SAMPLER_EXTEND_MODE_COUNT]
212 [D2D_SAMPLER_EXTEND_MODE_COUNT];
214 struct d2d_error_state error;
215 D2D1_DRAWING_STATE_DESCRIPTION1 drawing_state;
216 IDWriteRenderingParams *text_rendering_params;
217 IDWriteRenderingParams *default_text_rendering_params;
219 D2D1_RENDER_TARGET_PROPERTIES desc;
220 D2D1_SIZE_U pixel_size;
221 struct d2d_clip_stack clip_stack;
223 struct d2d_indexed_objects vertex_buffers;
226 HRESULT d2d_d3d_create_render_target(struct d2d_device *device, IDXGISurface *surface, IUnknown *outer_unknown,
227 const struct d2d_device_context_ops *ops, const D2D1_RENDER_TARGET_PROPERTIES *desc,
228 void **render_target);
230 static inline BOOL d2d_device_context_is_dxgi_target(const struct d2d_device_context *context)
232 return !context->ops;
235 struct d2d_wic_render_target
237 IUnknown IUnknown_iface;
238 LONG refcount;
240 IDXGISurface *dxgi_surface;
241 ID2D1RenderTarget *dxgi_target;
242 IUnknown *dxgi_inner;
243 ID3D10Texture2D *readback_texture;
244 IWICBitmap *bitmap;
246 unsigned int width;
247 unsigned int height;
248 unsigned int bpp;
251 HRESULT d2d_wic_render_target_init(struct d2d_wic_render_target *render_target, ID2D1Factory1 *factory,
252 ID3D10Device1 *d3d_device, IWICBitmap *bitmap, const D2D1_RENDER_TARGET_PROPERTIES *desc);
254 struct d2d_dc_render_target
256 ID2D1DCRenderTarget ID2D1DCRenderTarget_iface;
257 LONG refcount;
259 IDXGISurface1 *dxgi_surface;
260 ID3D10Device1 *d3d_device;
261 ID2D1RenderTarget *dxgi_target;
262 IUnknown *dxgi_inner;
264 RECT dst_rect;
265 HDC hdc;
267 D2D1_RENDER_TARGET_PROPERTIES desc;
270 HRESULT d2d_dc_render_target_init(struct d2d_dc_render_target *render_target, ID2D1Factory1 *factory,
271 ID3D10Device1 *d3d_device, const D2D1_RENDER_TARGET_PROPERTIES *desc);
273 struct d2d_hwnd_render_target
275 ID2D1HwndRenderTarget ID2D1HwndRenderTarget_iface;
276 LONG refcount;
278 ID2D1RenderTarget *dxgi_target;
279 IUnknown *dxgi_inner;
280 IDXGISwapChain *swapchain;
281 UINT sync_interval;
282 HWND hwnd;
284 D2D1_RENDER_TARGET_PROPERTIES desc;
287 HRESULT d2d_hwnd_render_target_init(struct d2d_hwnd_render_target *render_target, ID2D1Factory1 *factory,
288 ID3D10Device1 *d3d_device, const D2D1_RENDER_TARGET_PROPERTIES *desc,
289 const D2D1_HWND_RENDER_TARGET_PROPERTIES *hwnd_desc);
291 struct d2d_bitmap_render_target
293 ID2D1BitmapRenderTarget ID2D1BitmapRenderTarget_iface;
294 LONG refcount;
296 ID2D1RenderTarget *dxgi_target;
297 IUnknown *dxgi_inner;
298 ID2D1Bitmap *bitmap;
301 HRESULT d2d_bitmap_render_target_init(struct d2d_bitmap_render_target *render_target,
302 const struct d2d_device_context *parent_target, const D2D1_SIZE_F *size,
303 const D2D1_SIZE_U *pixel_size, const D2D1_PIXEL_FORMAT *format,
304 D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS options);
306 struct d2d_gradient
308 ID2D1GradientStopCollection ID2D1GradientStopCollection_iface;
309 LONG refcount;
311 ID2D1Factory *factory;
312 ID3D11ShaderResourceView *view;
313 D2D1_GRADIENT_STOP *stops;
314 UINT32 stop_count;
317 HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D11Device1 *device, const D2D1_GRADIENT_STOP *stops,
318 UINT32 stop_count, D2D1_GAMMA gamma, D2D1_EXTEND_MODE extend_mode,
319 struct d2d_gradient **gradient);
321 struct d2d_brush
323 ID2D1Brush ID2D1Brush_iface;
324 LONG refcount;
326 ID2D1Factory *factory;
327 float opacity;
328 D2D1_MATRIX_3X2_F transform;
330 enum d2d_brush_type type;
331 union
333 struct
335 D2D1_COLOR_F color;
336 } solid;
337 struct
339 struct d2d_gradient *gradient;
340 D2D1_POINT_2F start;
341 D2D1_POINT_2F end;
342 } linear;
343 struct
345 struct d2d_gradient *gradient;
346 D2D1_POINT_2F centre;
347 D2D1_POINT_2F offset;
348 D2D1_POINT_2F radius;
349 } radial;
350 struct
352 struct d2d_bitmap *bitmap;
353 D2D1_EXTEND_MODE extend_mode_x;
354 D2D1_EXTEND_MODE extend_mode_y;
355 D2D1_INTERPOLATION_MODE interpolation_mode;
356 } bitmap;
357 struct
359 ID2D1Image *image;
360 D2D1_EXTEND_MODE extend_mode_x;
361 D2D1_EXTEND_MODE extend_mode_y;
362 D2D1_INTERPOLATION_MODE interpolation_mode;
363 D2D1_RECT_F source_rect;
364 } image;
365 } u;
368 HRESULT d2d_solid_color_brush_create(ID2D1Factory *factory, const D2D1_COLOR_F *color,
369 const D2D1_BRUSH_PROPERTIES *desc, struct d2d_brush **brush);
370 HRESULT d2d_linear_gradient_brush_create(ID2D1Factory *factory,
371 const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES *gradient_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
372 ID2D1GradientStopCollection *gradient, struct d2d_brush **brush);
373 HRESULT d2d_radial_gradient_brush_create(ID2D1Factory *factory,
374 const D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES *gradient_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
375 ID2D1GradientStopCollection *gradient, struct d2d_brush **brush);
376 HRESULT d2d_bitmap_brush_create(ID2D1Factory *factory, ID2D1Bitmap *bitmap,
377 const D2D1_BITMAP_BRUSH_PROPERTIES1 *bitmap_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
378 struct d2d_brush **brush);
379 HRESULT d2d_image_brush_create(ID2D1Factory *factory, ID2D1Image *image,
380 const D2D1_IMAGE_BRUSH_PROPERTIES *image_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
381 struct d2d_brush **brush);
382 void d2d_brush_bind_resources(struct d2d_brush *brush, struct d2d_device_context *context,
383 unsigned int brush_idx);
384 BOOL d2d_brush_fill_cb(const struct d2d_brush *brush, struct d2d_brush_cb *cb);
385 struct d2d_brush *unsafe_impl_from_ID2D1Brush(ID2D1Brush *iface);
387 struct d2d_stroke_style
389 ID2D1StrokeStyle1 ID2D1StrokeStyle1_iface;
390 LONG refcount;
392 ID2D1Factory *factory;
393 D2D1_STROKE_STYLE_PROPERTIES1 desc;
394 float *dashes;
395 UINT32 dash_count;
398 HRESULT d2d_stroke_style_init(struct d2d_stroke_style *style, ID2D1Factory *factory,
399 const D2D1_STROKE_STYLE_PROPERTIES1 *desc, const float *dashes, UINT32 dash_count);
400 struct d2d_stroke_style *unsafe_impl_from_ID2D1StrokeStyle(ID2D1StrokeStyle *iface);
402 struct d2d_layer
404 ID2D1Layer ID2D1Layer_iface;
405 LONG refcount;
407 ID2D1Factory *factory;
408 D2D1_SIZE_F size;
411 HRESULT d2d_layer_create(ID2D1Factory *factory, const D2D1_SIZE_F *size, struct d2d_layer **layer);
413 struct d2d_mesh
415 ID2D1Mesh ID2D1Mesh_iface;
416 LONG refcount;
418 ID2D1Factory *factory;
421 HRESULT d2d_mesh_create(ID2D1Factory *factory, struct d2d_mesh **mesh);
423 struct d2d_bitmap
425 ID2D1Bitmap1 ID2D1Bitmap1_iface;
426 LONG refcount;
428 ID2D1Factory *factory;
429 ID3D11ShaderResourceView *srv;
430 ID3D11RenderTargetView *rtv;
431 IDXGISurface *surface;
432 ID3D11Resource *resource;
433 D3D11_MAPPED_SUBRESOURCE mapped_resource;
434 D2D1_SIZE_U pixel_size;
435 D2D1_PIXEL_FORMAT format;
436 float dpi_x;
437 float dpi_y;
438 D2D1_BITMAP_OPTIONS options;
441 HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size, const void *src_data,
442 UINT32 pitch, const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap);
443 HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid, void *data,
444 const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap);
445 HRESULT d2d_bitmap_create_from_wic_bitmap(struct d2d_device_context *context, IWICBitmapSource *bitmap_source,
446 const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap);
447 unsigned int d2d_get_bitmap_options_for_surface(IDXGISurface *surface);
448 struct d2d_bitmap *unsafe_impl_from_ID2D1Bitmap(ID2D1Bitmap *iface);
450 struct d2d_state_block
452 ID2D1DrawingStateBlock1 ID2D1DrawingStateBlock1_iface;
453 LONG refcount;
455 ID2D1Factory *factory;
456 D2D1_DRAWING_STATE_DESCRIPTION1 drawing_state;
457 IDWriteRenderingParams *text_rendering_params;
460 void d2d_state_block_init(struct d2d_state_block *state_block, ID2D1Factory *factory,
461 const D2D1_DRAWING_STATE_DESCRIPTION1 *desc, IDWriteRenderingParams *text_rendering_params);
462 struct d2d_state_block *unsafe_impl_from_ID2D1DrawingStateBlock(ID2D1DrawingStateBlock *iface);
464 enum d2d_geometry_state
466 D2D_GEOMETRY_STATE_INITIAL = 0,
467 D2D_GEOMETRY_STATE_ERROR,
468 D2D_GEOMETRY_STATE_OPEN,
469 D2D_GEOMETRY_STATE_CLOSED,
470 D2D_GEOMETRY_STATE_FIGURE,
473 struct d2d_curve_vertex
475 D2D1_POINT_2F position;
476 struct
478 float u, v, sign;
479 } texcoord;
482 struct d2d_face
484 UINT16 v[3];
487 struct d2d_outline_vertex
489 D2D1_POINT_2F position;
490 D2D1_POINT_2F prev;
491 D2D1_POINT_2F next;
494 struct d2d_curve_outline_vertex
496 D2D1_POINT_2F position;
497 D2D1_POINT_2F p0, p1, p2;
498 D2D1_POINT_2F prev, next;
501 struct d2d_geometry
503 ID2D1Geometry ID2D1Geometry_iface;
504 LONG refcount;
506 ID2D1Factory *factory;
508 D2D_MATRIX_3X2_F transform;
510 struct
512 D2D1_POINT_2F *vertices;
513 size_t vertex_count;
515 struct d2d_face *faces;
516 size_t faces_size;
517 size_t face_count;
519 struct d2d_curve_vertex *bezier_vertices;
520 size_t bezier_vertices_size;
521 size_t bezier_vertex_count;
523 struct d2d_curve_vertex *arc_vertices;
524 size_t arc_vertices_size;
525 size_t arc_vertex_count;
526 } fill;
528 struct
530 struct d2d_outline_vertex *vertices;
531 size_t vertices_size;
532 size_t vertex_count;
534 struct d2d_face *faces;
535 size_t faces_size;
536 size_t face_count;
538 struct d2d_curve_outline_vertex *beziers;
539 size_t beziers_size;
540 size_t bezier_count;
542 struct d2d_face *bezier_faces;
543 size_t bezier_faces_size;
544 size_t bezier_face_count;
546 struct d2d_curve_outline_vertex *arcs;
547 size_t arcs_size;
548 size_t arc_count;
550 struct d2d_face *arc_faces;
551 size_t arc_faces_size;
552 size_t arc_face_count;
553 } outline;
555 union
557 struct
559 D2D1_ELLIPSE ellipse;
560 } ellipse;
561 struct
563 ID2D1GeometrySink ID2D1GeometrySink_iface;
565 struct d2d_figure *figures;
566 size_t figures_size;
567 size_t figure_count;
569 enum d2d_geometry_state state;
570 D2D1_FILL_MODE fill_mode;
571 UINT32 segment_count;
573 D2D1_RECT_F bounds;
574 } path;
575 struct
577 D2D1_RECT_F rect;
578 } rectangle;
579 struct
581 D2D1_ROUNDED_RECT rounded_rect;
582 } rounded_rectangle;
583 struct
585 ID2D1Geometry *src_geometry;
586 D2D_MATRIX_3X2_F transform;
587 } transformed;
588 struct
590 ID2D1Geometry **src_geometries;
591 UINT32 geometry_count;
592 D2D1_FILL_MODE fill_mode;
593 } group;
594 } u;
597 HRESULT d2d_ellipse_geometry_init(struct d2d_geometry *geometry,
598 ID2D1Factory *factory, const D2D1_ELLIPSE *ellipse);
599 void d2d_path_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *factory);
600 HRESULT d2d_rectangle_geometry_init(struct d2d_geometry *geometry,
601 ID2D1Factory *factory, const D2D1_RECT_F *rect);
602 HRESULT d2d_rounded_rectangle_geometry_init(struct d2d_geometry *geometry,
603 ID2D1Factory *factory, const D2D1_ROUNDED_RECT *rounded_rect);
604 void d2d_transformed_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *factory,
605 ID2D1Geometry *src_geometry, const D2D_MATRIX_3X2_F *transform);
606 HRESULT d2d_geometry_group_init(struct d2d_geometry *geometry, ID2D1Factory *factory,
607 D2D1_FILL_MODE fill_mode, ID2D1Geometry **src_geometries, unsigned int geometry_count);
608 struct d2d_geometry *unsafe_impl_from_ID2D1Geometry(ID2D1Geometry *iface);
610 struct d2d_device
612 ID2D1Device6 ID2D1Device6_iface;
613 LONG refcount;
614 ID2D1Factory1 *factory;
615 IDXGIDevice *dxgi_device;
617 struct d2d_indexed_objects shaders;
620 struct d2d_device *unsafe_impl_from_ID2D1Device(ID2D1Device1 *iface);
621 HRESULT d2d_device_add_indexed_object(struct d2d_indexed_objects *objects, const GUID *id,
622 IUnknown *object);
623 BOOL d2d_device_get_indexed_object(struct d2d_indexed_objects *objects, const GUID *id,
624 IUnknown **object);
625 void d2d_device_indexed_objects_clear(struct d2d_indexed_objects *objects);
627 struct d2d_effect_context
629 ID2D1EffectContext ID2D1EffectContext_iface;
630 LONG refcount;
632 struct d2d_device_context *device_context;
635 void d2d_effect_context_init(struct d2d_effect_context *effect_context,
636 struct d2d_device_context *device_context);
638 struct d2d_effect_property
640 WCHAR *name;
641 D2D1_PROPERTY_TYPE type;
642 UINT32 index;
643 BOOL readonly;
644 union
646 size_t offset;
647 void *ptr;
648 } data;
649 UINT32 size;
650 PD2D1_PROPERTY_SET_FUNCTION set_function;
651 PD2D1_PROPERTY_GET_FUNCTION get_function;
652 struct d2d_effect_properties *subproperties;
655 struct d2d_effect_properties
657 ID2D1Properties ID2D1Properties_iface;
658 LONG refcount;
659 struct d2d_effect *effect;
661 struct d2d_effect_property *properties;
662 size_t offset;
663 size_t size;
664 size_t count;
665 size_t custom_count;
666 struct
668 BYTE *ptr;
669 size_t size;
670 size_t count;
671 } data;
674 struct d2d_effect_registration
676 struct list entry;
677 PD2D1_EFFECT_FACTORY factory;
678 UINT32 registration_count;
679 BOOL builtin;
680 CLSID id;
682 struct d2d_effect_properties *properties;
685 struct d2d_factory
687 ID2D1Factory7 ID2D1Factory7_iface;
688 ID2D1Multithread ID2D1Multithread_iface;
689 LONG refcount;
691 ID3D10Device1 *device;
693 float dpi_x;
694 float dpi_y;
696 struct list effects;
697 INIT_ONCE init_builtins;
699 CRITICAL_SECTION cs;
700 D2D1_FACTORY_TYPE factory_type;
703 static inline struct d2d_factory *unsafe_impl_from_ID2D1Factory(ID2D1Factory *iface)
705 return CONTAINING_RECORD(iface, struct d2d_factory, ID2D1Factory7_iface);
708 void d2d_effects_init_builtins(struct d2d_factory *factory);
709 struct d2d_effect_registration * d2d_factory_get_registered_effect(ID2D1Factory *factory,
710 const GUID *effect_id);
711 void d2d_factory_register_effect(struct d2d_factory *factory,
712 struct d2d_effect_registration *effect);
713 HRESULT d2d_effect_property_get_uint32_value(const struct d2d_effect_properties *properties,
714 const struct d2d_effect_property *prop, UINT32 *value);
715 void d2d_device_init(struct d2d_device *device, struct d2d_factory *factory, IDXGIDevice *dxgi_device);
717 struct d2d_transform
719 ID2D1TransformNode ID2D1TransformNode_iface;
720 LONG refcount;
722 union
724 D2D1_POINT_2L offset;
725 D2D1_BLEND_DESCRIPTION blend_desc;
726 struct
728 D2D1_EXTEND_MODE mode_x;
729 D2D1_EXTEND_MODE mode_y;
730 } border;
731 D2D1_RECT_L bounds;
734 UINT32 input_count;
737 enum d2d_render_info_mask
739 D2D_RENDER_INFO_PIXEL_SHADER = 0x1,
742 struct d2d_render_info
744 ID2D1DrawInfo ID2D1DrawInfo_iface;
745 LONG refcount;
747 unsigned int mask;
748 GUID pixel_shader;
751 struct d2d_transform_node
753 struct list entry;
754 ID2D1TransformNode *object;
755 struct d2d_render_info *render_info;
756 struct d2d_transform_node **inputs;
757 unsigned int input_count;
758 struct d2d_transform_node *output;
761 struct d2d_transform_node_connection
763 struct d2d_transform_node *node;
764 unsigned int index;
767 struct d2d_transform_graph
769 ID2D1TransformGraph ID2D1TransformGraph_iface;
770 LONG refcount;
772 struct d2d_transform_node_connection *inputs;
773 unsigned int input_count;
775 struct d2d_transform_node *output;
777 bool passthrough;
778 unsigned int passthrough_input;
780 struct list nodes;
783 struct d2d_effect
785 ID2D1Effect ID2D1Effect_iface;
786 ID2D1Image ID2D1Image_iface;
787 LONG refcount;
789 ID2D1EffectImpl *impl;
790 struct d2d_effect_properties properties;
791 struct d2d_effect_context *effect_context;
792 struct d2d_transform_graph *graph;
793 ID2D1Image **inputs;
794 size_t inputs_size;
795 size_t input_count;
798 HRESULT d2d_effect_create(struct d2d_device_context *context, const CLSID *effect_id,
799 ID2D1Effect **effect);
800 void d2d_effect_init_properties(struct d2d_effect *effect, struct d2d_effect_properties *properties);
801 HRESULT d2d_effect_properties_add(struct d2d_effect_properties *props, const WCHAR *name,
802 UINT32 index, D2D1_PROPERTY_TYPE type, const WCHAR *value);
803 HRESULT d2d_effect_subproperties_add(struct d2d_effect_properties *props, const WCHAR *name,
804 UINT32 index, D2D1_PROPERTY_TYPE type, const WCHAR *value);
805 struct d2d_effect_property * d2d_effect_properties_get_property_by_name(
806 const struct d2d_effect_properties *properties, const WCHAR *name);
807 void d2d_effect_properties_cleanup(struct d2d_effect_properties *props);
808 HRESULT d2d_factory_register_builtin_effect(struct d2d_factory *factory, REFCLSID effect_id,
809 const WCHAR *property_xml, const D2D1_PROPERTY_BINDING *bindings, UINT32 binding_count,
810 PD2D1_EFFECT_FACTORY effect_factory);
812 struct d2d_vertex_buffer
814 ID2D1VertexBuffer ID2D1VertexBuffer_iface;
815 LONG refcount;
818 enum d2d_command_list_state
820 D2D_COMMAND_LIST_STATE_INITIAL = 0,
821 D2D_COMMAND_LIST_STATE_ERROR,
822 D2D_COMMAND_LIST_STATE_OPEN,
823 D2D_COMMAND_LIST_STATE_CLOSED,
826 struct d2d_command_list
828 ID2D1CommandList ID2D1CommandList_iface;
829 LONG refcount;
831 ID2D1Factory *factory;
832 enum d2d_command_list_state state;
833 unsigned int flags;
835 size_t size;
836 size_t capacity;
837 void *data;
839 size_t objects_count;
840 size_t objects_capacity;
841 IUnknown **objects;
844 HRESULT d2d_command_list_create(ID2D1Factory *factory, struct d2d_command_list **command_list);
845 struct d2d_command_list *unsafe_impl_from_ID2D1CommandList(ID2D1CommandList *iface);
846 void d2d_command_list_begin_draw(struct d2d_command_list *command_list, const struct d2d_device_context *context);
847 void d2d_command_list_set_antialias_mode(struct d2d_command_list *command_list, D2D1_ANTIALIAS_MODE mode);
848 void d2d_command_list_set_primitive_blend(struct d2d_command_list *command_list,
849 D2D1_PRIMITIVE_BLEND primitive_blend);
850 void d2d_command_list_set_unit_mode(struct d2d_command_list *command_list, D2D1_UNIT_MODE mode);
851 void d2d_command_list_set_text_antialias_mode(struct d2d_command_list *command_list,
852 D2D1_TEXT_ANTIALIAS_MODE mode);
853 void d2d_command_list_set_tags(struct d2d_command_list *command_list, D2D1_TAG tag1, D2D1_TAG tag2);
854 void d2d_command_list_set_transform(struct d2d_command_list *command_list,
855 const D2D1_MATRIX_3X2_F *transform);
856 void d2d_command_list_push_clip(struct d2d_command_list *command_list, const D2D1_RECT_F *rect,
857 D2D1_ANTIALIAS_MODE antialias_mode);
858 void d2d_command_list_pop_clip(struct d2d_command_list *command_list);
859 void d2d_command_list_clear(struct d2d_command_list *command_list, const D2D1_COLOR_F *color);
860 void d2d_command_list_draw_line(struct d2d_command_list *command_list, const struct d2d_device_context *context,
861 D2D1_POINT_2F p0, D2D1_POINT_2F p1, ID2D1Brush *orig_brush, float stroke_width,
862 ID2D1StrokeStyle *stroke_style);
863 void d2d_command_list_draw_geometry(struct d2d_command_list *command_list,
864 const struct d2d_device_context *context, ID2D1Geometry *geometry, ID2D1Brush *orig_brush,
865 float stroke_width, ID2D1StrokeStyle *stroke_style);
866 void d2d_command_list_draw_rectangle(struct d2d_command_list *command_list, const struct d2d_device_context *context,
867 const D2D1_RECT_F *rect, ID2D1Brush *orig_brush, float stroke_width, ID2D1StrokeStyle *stroke_style);
868 void d2d_command_list_fill_geometry(struct d2d_command_list *command_list,
869 const struct d2d_device_context *context, ID2D1Geometry *geometry, ID2D1Brush *orig_brush,
870 ID2D1Brush *orig_opacity_brush);
871 void d2d_command_list_fill_rectangle(struct d2d_command_list *command_list,
872 const struct d2d_device_context *context, const D2D1_RECT_F *rect, ID2D1Brush *orig_brush);
873 void d2d_command_list_set_text_rendering_params(struct d2d_command_list *command_list,
874 IDWriteRenderingParams *params);
875 void d2d_command_list_draw_glyph_run(struct d2d_command_list *command_list,
876 const struct d2d_device_context *context, D2D1_POINT_2F origin, const DWRITE_GLYPH_RUN *run,
877 const DWRITE_GLYPH_RUN_DESCRIPTION *run_desc, ID2D1Brush *orig_brush,
878 DWRITE_MEASURING_MODE measuring_mode);
879 void d2d_command_list_draw_bitmap(struct d2d_command_list *command_list, ID2D1Bitmap *bitmap,
880 const D2D1_RECT_F *dst_rect, float opacity, D2D1_INTERPOLATION_MODE interpolation_mode,
881 const D2D1_RECT_F *src_rect, const D2D1_MATRIX_4X4_F *perspective_transform);
882 void d2d_command_list_draw_image(struct d2d_command_list *command_list, ID2D1Image *image,
883 const D2D1_POINT_2F *target_offset, const D2D1_RECT_F *image_rect, D2D1_INTERPOLATION_MODE interpolation_mode,
884 D2D1_COMPOSITE_MODE composite_mode);
885 void d2d_command_list_fill_mesh(struct d2d_command_list *command_list, const struct d2d_device_context *context,
886 ID2D1Mesh *mesh, ID2D1Brush *orig_brush);
887 void d2d_command_list_fill_opacity_mask(struct d2d_command_list *command_list, const struct d2d_device_context *context,
888 ID2D1Bitmap *bitmap, ID2D1Brush *orig_brush, const D2D1_RECT_F *dst_rect, const D2D1_RECT_F *src_rect);
889 void d2d_command_list_push_layer(struct d2d_command_list *command_list, const struct d2d_device_context *context,
890 const D2D1_LAYER_PARAMETERS1 *params, ID2D1Layer *layer);
891 void d2d_command_list_pop_layer(struct d2d_command_list *command_list);
893 static inline BOOL d2d_array_reserve(void **elements, size_t *capacity, size_t count, size_t size)
895 size_t new_capacity, max_capacity;
896 void *new_elements;
898 if (count <= *capacity)
899 return TRUE;
901 max_capacity = ~(SIZE_T)0 / size;
902 if (count > max_capacity)
903 return FALSE;
905 new_capacity = max(4, *capacity);
906 while (new_capacity < count && new_capacity <= max_capacity / 2)
907 new_capacity *= 2;
908 if (new_capacity < count)
909 new_capacity = max_capacity;
911 if (!(new_elements = realloc(*elements, new_capacity * size)))
912 return FALSE;
914 *elements = new_elements;
915 *capacity = new_capacity;
916 return TRUE;
919 static inline void d2d_matrix_multiply(D2D_MATRIX_3X2_F *a, const D2D_MATRIX_3X2_F *b)
921 D2D_MATRIX_3X2_F tmp = *a;
923 a->_11 = tmp._11 * b->_11 + tmp._12 * b->_21;
924 a->_12 = tmp._11 * b->_12 + tmp._12 * b->_22;
925 a->_21 = tmp._21 * b->_11 + tmp._22 * b->_21;
926 a->_22 = tmp._21 * b->_12 + tmp._22 * b->_22;
927 a->_31 = tmp._31 * b->_11 + tmp._32 * b->_21 + b->_31;
928 a->_32 = tmp._31 * b->_12 + tmp._32 * b->_22 + b->_32;
931 /* Dst must be different from src. */
932 static inline BOOL d2d_matrix_invert(D2D_MATRIX_3X2_F *dst, const D2D_MATRIX_3X2_F *src)
934 float d = src->_11 * src->_22 - src->_21 * src->_12;
936 if (d == 0.0f)
937 return FALSE;
938 dst->_11 = src->_22 / d;
939 dst->_21 = -src->_21 / d;
940 dst->_31 = (src->_21 * src->_32 - src->_31 * src->_22) / d;
941 dst->_12 = -src->_12 / d;
942 dst->_22 = src->_11 / d;
943 dst->_32 = -(src->_11 * src->_32 - src->_31 * src->_12) / d;
945 return TRUE;
948 static inline void d2d_point_set(D2D1_POINT_2F *dst, float x, float y)
950 dst->x = x;
951 dst->y = y;
954 static inline float d2d_point_dot(const D2D1_POINT_2F *p0, const D2D1_POINT_2F *p1)
956 return p0->x * p1->x + p0->y * p1->y;
959 static inline void d2d_point_transform(D2D1_POINT_2F *dst, const D2D1_MATRIX_3X2_F *matrix, float x, float y)
961 dst->x = x * matrix->_11 + y * matrix->_21 + matrix->_31;
962 dst->y = x * matrix->_12 + y * matrix->_22 + matrix->_32;
965 static inline void d2d_rect_expand(D2D1_RECT_F *dst, const D2D1_POINT_2F *point)
967 if (point->x < dst->left)
968 dst->left = point->x;
969 if (point->x > dst->right)
970 dst->right = point->x;
971 if (point->y < dst->top)
972 dst->top = point->y;
973 if (point->y > dst->bottom)
974 dst->bottom = point->y;
977 static inline D2D1_INTERPOLATION_MODE d2d1_1_interp_mode_from_d2d1(D2D1_BITMAP_INTERPOLATION_MODE mode)
979 return (D2D1_INTERPOLATION_MODE)mode;
982 static inline const char *debug_d2d_color_f(const D2D1_COLOR_F *colour)
984 if (!colour)
985 return "(null)";
986 return wine_dbg_sprintf("{%.8e, %.8e, %.8e, %.8e}", colour->r, colour->g, colour->b, colour->a);
989 static inline const char *debug_d2d_point_2f(const D2D1_POINT_2F *point)
991 if (!point)
992 return "(null)";
993 return wine_dbg_sprintf("{%.8e, %.8e}", point->x, point->y);
996 static inline const char *debug_d2d_point_2l(const D2D1_POINT_2L *point)
998 if (!point)
999 return "(null)";
1000 return wine_dbg_sprintf("{%ld, %ld}", point->x, point->y);
1003 static inline const char *debug_d2d_rect_f(const D2D1_RECT_F *rect)
1005 if (!rect)
1006 return "(null)";
1007 return wine_dbg_sprintf("(%.8e, %.8e)-(%.8e, %.8e)", rect->left, rect->top, rect->right, rect->bottom);
1010 static inline const char *debug_d2d_rect_l(const D2D1_RECT_L *rect)
1012 if (!rect)
1013 return "(null)";
1014 return wine_dbg_sprintf("(%ld, %ld)-(%ld, %ld)", rect->left, rect->top, rect->right, rect->bottom);
1017 static inline const char *debug_d2d_rounded_rect(const D2D1_ROUNDED_RECT *rounded_rect)
1019 if (!rounded_rect)
1020 return "(null)";
1021 return wine_dbg_sprintf("(%.8e, %.8e)-(%.8e, %.8e)[%.8e, %.8e]", rounded_rect->rect.left, rounded_rect->rect.top,
1022 rounded_rect->rect.right, rounded_rect->rect.bottom, rounded_rect->radiusX, rounded_rect->radiusY);
1025 static inline const char *debug_d2d_ellipse(const D2D1_ELLIPSE *ellipse)
1027 if (!ellipse)
1028 return "(null)";
1029 return wine_dbg_sprintf("(%.8e, %.8e)[%.8e, %.8e]",
1030 ellipse->point.x, ellipse->point.y, ellipse->radiusX, ellipse->radiusY);
1033 #endif /* __WINE_D2D1_PRIVATE_H */