widl: Properly align name table entries.
[wine.git] / dlls / d2d1 / d2d1_private.h
blob3589b5087041bd76d54362c43613032356973b19
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_device_context
164 ID2D1DeviceContext1 ID2D1DeviceContext1_iface;
165 ID2D1GdiInteropRenderTarget ID2D1GdiInteropRenderTarget_iface;
166 IDWriteTextRenderer IDWriteTextRenderer_iface;
167 IUnknown IUnknown_iface;
168 LONG refcount;
170 IUnknown *outer_unknown;
171 const struct d2d_device_context_ops *ops;
173 ID2D1Factory *factory;
174 CRITICAL_SECTION *cs;
175 struct d2d_device *device;
176 ID3D11Device1 *d3d_device;
177 ID3DDeviceContextState *d3d_state;
178 struct
180 ID2D1Image *object;
181 enum d2d_device_context_target_type type;
182 union
184 struct d2d_bitmap *bitmap;
185 struct d2d_command_list *command_list;
187 HDC hdc;
188 } target;
189 struct d2d_shape_resources shape_resources[D2D_SHAPE_TYPE_COUNT];
190 ID3D11Buffer *vs_cb;
191 ID3D11PixelShader *ps;
192 ID3D11Buffer *ps_cb;
193 ID3D11Buffer *ib;
194 unsigned int vb_stride;
195 ID3D11Buffer *vb;
196 ID3D11RasterizerState *rs;
197 ID3D11BlendState *bs;
198 ID3D11SamplerState *sampler_states
199 [D2D_SAMPLER_INTERPOLATION_MODE_COUNT]
200 [D2D_SAMPLER_EXTEND_MODE_COUNT]
201 [D2D_SAMPLER_EXTEND_MODE_COUNT];
203 struct d2d_error_state error;
204 D2D1_DRAWING_STATE_DESCRIPTION1 drawing_state;
205 IDWriteRenderingParams *text_rendering_params;
206 IDWriteRenderingParams *default_text_rendering_params;
208 D2D1_RENDER_TARGET_PROPERTIES desc;
209 D2D1_SIZE_U pixel_size;
210 struct d2d_clip_stack clip_stack;
213 HRESULT d2d_d3d_create_render_target(struct d2d_device *device, IDXGISurface *surface, IUnknown *outer_unknown,
214 const struct d2d_device_context_ops *ops, const D2D1_RENDER_TARGET_PROPERTIES *desc,
215 void **render_target);
217 static inline BOOL d2d_device_context_is_dxgi_target(const struct d2d_device_context *context)
219 return !context->ops;
222 struct d2d_wic_render_target
224 IUnknown IUnknown_iface;
225 LONG refcount;
227 IDXGISurface *dxgi_surface;
228 ID2D1RenderTarget *dxgi_target;
229 IUnknown *dxgi_inner;
230 ID3D10Texture2D *readback_texture;
231 IWICBitmap *bitmap;
233 unsigned int width;
234 unsigned int height;
235 unsigned int bpp;
238 HRESULT d2d_wic_render_target_init(struct d2d_wic_render_target *render_target, ID2D1Factory1 *factory,
239 ID3D10Device1 *d3d_device, IWICBitmap *bitmap, const D2D1_RENDER_TARGET_PROPERTIES *desc);
241 struct d2d_dc_render_target
243 ID2D1DCRenderTarget ID2D1DCRenderTarget_iface;
244 LONG refcount;
246 IDXGISurface1 *dxgi_surface;
247 ID3D10Device1 *d3d_device;
248 ID2D1RenderTarget *dxgi_target;
249 IUnknown *dxgi_inner;
251 RECT dst_rect;
252 HDC hdc;
254 D2D1_RENDER_TARGET_PROPERTIES desc;
257 HRESULT d2d_dc_render_target_init(struct d2d_dc_render_target *render_target, ID2D1Factory1 *factory,
258 ID3D10Device1 *d3d_device, const D2D1_RENDER_TARGET_PROPERTIES *desc);
260 struct d2d_hwnd_render_target
262 ID2D1HwndRenderTarget ID2D1HwndRenderTarget_iface;
263 LONG refcount;
265 ID2D1RenderTarget *dxgi_target;
266 IUnknown *dxgi_inner;
267 IDXGISwapChain *swapchain;
268 UINT sync_interval;
269 HWND hwnd;
271 D2D1_RENDER_TARGET_PROPERTIES desc;
274 HRESULT d2d_hwnd_render_target_init(struct d2d_hwnd_render_target *render_target, ID2D1Factory1 *factory,
275 ID3D10Device1 *d3d_device, const D2D1_RENDER_TARGET_PROPERTIES *desc,
276 const D2D1_HWND_RENDER_TARGET_PROPERTIES *hwnd_desc);
278 struct d2d_bitmap_render_target
280 ID2D1BitmapRenderTarget ID2D1BitmapRenderTarget_iface;
281 LONG refcount;
283 ID2D1RenderTarget *dxgi_target;
284 IUnknown *dxgi_inner;
285 ID2D1Bitmap *bitmap;
288 HRESULT d2d_bitmap_render_target_init(struct d2d_bitmap_render_target *render_target,
289 const struct d2d_device_context *parent_target, const D2D1_SIZE_F *size,
290 const D2D1_SIZE_U *pixel_size, const D2D1_PIXEL_FORMAT *format,
291 D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS options);
293 struct d2d_gradient
295 ID2D1GradientStopCollection ID2D1GradientStopCollection_iface;
296 LONG refcount;
298 ID2D1Factory *factory;
299 ID3D11ShaderResourceView *view;
300 D2D1_GRADIENT_STOP *stops;
301 UINT32 stop_count;
304 HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D11Device1 *device, const D2D1_GRADIENT_STOP *stops,
305 UINT32 stop_count, D2D1_GAMMA gamma, D2D1_EXTEND_MODE extend_mode,
306 struct d2d_gradient **gradient);
308 struct d2d_brush
310 ID2D1Brush ID2D1Brush_iface;
311 LONG refcount;
313 ID2D1Factory *factory;
314 float opacity;
315 D2D1_MATRIX_3X2_F transform;
317 enum d2d_brush_type type;
318 union
320 struct
322 D2D1_COLOR_F color;
323 } solid;
324 struct
326 struct d2d_gradient *gradient;
327 D2D1_POINT_2F start;
328 D2D1_POINT_2F end;
329 } linear;
330 struct
332 struct d2d_gradient *gradient;
333 D2D1_POINT_2F centre;
334 D2D1_POINT_2F offset;
335 D2D1_POINT_2F radius;
336 } radial;
337 struct
339 struct d2d_bitmap *bitmap;
340 D2D1_EXTEND_MODE extend_mode_x;
341 D2D1_EXTEND_MODE extend_mode_y;
342 D2D1_INTERPOLATION_MODE interpolation_mode;
343 } bitmap;
344 struct
346 ID2D1Image *image;
347 D2D1_EXTEND_MODE extend_mode_x;
348 D2D1_EXTEND_MODE extend_mode_y;
349 D2D1_INTERPOLATION_MODE interpolation_mode;
350 D2D1_RECT_F source_rect;
351 } image;
352 } u;
355 HRESULT d2d_solid_color_brush_create(ID2D1Factory *factory, const D2D1_COLOR_F *color,
356 const D2D1_BRUSH_PROPERTIES *desc, struct d2d_brush **brush);
357 HRESULT d2d_linear_gradient_brush_create(ID2D1Factory *factory,
358 const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES *gradient_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
359 ID2D1GradientStopCollection *gradient, struct d2d_brush **brush);
360 HRESULT d2d_radial_gradient_brush_create(ID2D1Factory *factory,
361 const D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES *gradient_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
362 ID2D1GradientStopCollection *gradient, struct d2d_brush **brush);
363 HRESULT d2d_bitmap_brush_create(ID2D1Factory *factory, ID2D1Bitmap *bitmap,
364 const D2D1_BITMAP_BRUSH_PROPERTIES1 *bitmap_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
365 struct d2d_brush **brush);
366 HRESULT d2d_image_brush_create(ID2D1Factory *factory, ID2D1Image *image,
367 const D2D1_IMAGE_BRUSH_PROPERTIES *image_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
368 struct d2d_brush **brush);
369 void d2d_brush_bind_resources(struct d2d_brush *brush, struct d2d_device_context *context,
370 unsigned int brush_idx);
371 BOOL d2d_brush_fill_cb(const struct d2d_brush *brush, struct d2d_brush_cb *cb);
372 struct d2d_brush *unsafe_impl_from_ID2D1Brush(ID2D1Brush *iface);
374 struct d2d_stroke_style
376 ID2D1StrokeStyle1 ID2D1StrokeStyle1_iface;
377 LONG refcount;
379 ID2D1Factory *factory;
380 D2D1_STROKE_STYLE_PROPERTIES1 desc;
381 float *dashes;
382 UINT32 dash_count;
385 HRESULT d2d_stroke_style_init(struct d2d_stroke_style *style, ID2D1Factory *factory,
386 const D2D1_STROKE_STYLE_PROPERTIES1 *desc, const float *dashes, UINT32 dash_count);
387 struct d2d_stroke_style *unsafe_impl_from_ID2D1StrokeStyle(ID2D1StrokeStyle *iface);
389 struct d2d_layer
391 ID2D1Layer ID2D1Layer_iface;
392 LONG refcount;
394 ID2D1Factory *factory;
395 D2D1_SIZE_F size;
398 HRESULT d2d_layer_create(ID2D1Factory *factory, const D2D1_SIZE_F *size, struct d2d_layer **layer);
400 struct d2d_mesh
402 ID2D1Mesh ID2D1Mesh_iface;
403 LONG refcount;
405 ID2D1Factory *factory;
408 HRESULT d2d_mesh_create(ID2D1Factory *factory, struct d2d_mesh **mesh);
410 struct d2d_bitmap
412 ID2D1Bitmap1 ID2D1Bitmap1_iface;
413 LONG refcount;
415 ID2D1Factory *factory;
416 ID3D11ShaderResourceView *srv;
417 ID3D11RenderTargetView *rtv;
418 IDXGISurface *surface;
419 ID3D11Resource *resource;
420 D3D11_MAPPED_SUBRESOURCE mapped_resource;
421 D2D1_SIZE_U pixel_size;
422 D2D1_PIXEL_FORMAT format;
423 float dpi_x;
424 float dpi_y;
425 D2D1_BITMAP_OPTIONS options;
428 HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size, const void *src_data,
429 UINT32 pitch, const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap);
430 HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid, void *data,
431 const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap);
432 HRESULT d2d_bitmap_create_from_wic_bitmap(struct d2d_device_context *context, IWICBitmapSource *bitmap_source,
433 const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap);
434 unsigned int d2d_get_bitmap_options_for_surface(IDXGISurface *surface);
435 struct d2d_bitmap *unsafe_impl_from_ID2D1Bitmap(ID2D1Bitmap *iface);
437 struct d2d_state_block
439 ID2D1DrawingStateBlock1 ID2D1DrawingStateBlock1_iface;
440 LONG refcount;
442 ID2D1Factory *factory;
443 D2D1_DRAWING_STATE_DESCRIPTION1 drawing_state;
444 IDWriteRenderingParams *text_rendering_params;
447 void d2d_state_block_init(struct d2d_state_block *state_block, ID2D1Factory *factory,
448 const D2D1_DRAWING_STATE_DESCRIPTION1 *desc, IDWriteRenderingParams *text_rendering_params);
449 struct d2d_state_block *unsafe_impl_from_ID2D1DrawingStateBlock(ID2D1DrawingStateBlock *iface);
451 enum d2d_geometry_state
453 D2D_GEOMETRY_STATE_INITIAL = 0,
454 D2D_GEOMETRY_STATE_ERROR,
455 D2D_GEOMETRY_STATE_OPEN,
456 D2D_GEOMETRY_STATE_CLOSED,
457 D2D_GEOMETRY_STATE_FIGURE,
460 struct d2d_curve_vertex
462 D2D1_POINT_2F position;
463 struct
465 float u, v, sign;
466 } texcoord;
469 struct d2d_face
471 UINT16 v[3];
474 struct d2d_outline_vertex
476 D2D1_POINT_2F position;
477 D2D1_POINT_2F prev;
478 D2D1_POINT_2F next;
481 struct d2d_curve_outline_vertex
483 D2D1_POINT_2F position;
484 D2D1_POINT_2F p0, p1, p2;
485 D2D1_POINT_2F prev, next;
488 struct d2d_geometry
490 ID2D1Geometry ID2D1Geometry_iface;
491 LONG refcount;
493 ID2D1Factory *factory;
495 D2D_MATRIX_3X2_F transform;
497 struct
499 D2D1_POINT_2F *vertices;
500 size_t vertex_count;
502 struct d2d_face *faces;
503 size_t faces_size;
504 size_t face_count;
506 struct d2d_curve_vertex *bezier_vertices;
507 size_t bezier_vertices_size;
508 size_t bezier_vertex_count;
510 struct d2d_curve_vertex *arc_vertices;
511 size_t arc_vertices_size;
512 size_t arc_vertex_count;
513 } fill;
515 struct
517 struct d2d_outline_vertex *vertices;
518 size_t vertices_size;
519 size_t vertex_count;
521 struct d2d_face *faces;
522 size_t faces_size;
523 size_t face_count;
525 struct d2d_curve_outline_vertex *beziers;
526 size_t beziers_size;
527 size_t bezier_count;
529 struct d2d_face *bezier_faces;
530 size_t bezier_faces_size;
531 size_t bezier_face_count;
533 struct d2d_curve_outline_vertex *arcs;
534 size_t arcs_size;
535 size_t arc_count;
537 struct d2d_face *arc_faces;
538 size_t arc_faces_size;
539 size_t arc_face_count;
540 } outline;
542 union
544 struct
546 D2D1_ELLIPSE ellipse;
547 } ellipse;
548 struct
550 ID2D1GeometrySink ID2D1GeometrySink_iface;
552 struct d2d_figure *figures;
553 size_t figures_size;
554 size_t figure_count;
556 enum d2d_geometry_state state;
557 D2D1_FILL_MODE fill_mode;
558 UINT32 segment_count;
560 D2D1_RECT_F bounds;
561 } path;
562 struct
564 D2D1_RECT_F rect;
565 } rectangle;
566 struct
568 D2D1_ROUNDED_RECT rounded_rect;
569 } rounded_rectangle;
570 struct
572 ID2D1Geometry *src_geometry;
573 D2D_MATRIX_3X2_F transform;
574 } transformed;
575 struct
577 ID2D1Geometry **src_geometries;
578 UINT32 geometry_count;
579 D2D1_FILL_MODE fill_mode;
580 } group;
581 } u;
584 HRESULT d2d_ellipse_geometry_init(struct d2d_geometry *geometry,
585 ID2D1Factory *factory, const D2D1_ELLIPSE *ellipse);
586 void d2d_path_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *factory);
587 HRESULT d2d_rectangle_geometry_init(struct d2d_geometry *geometry,
588 ID2D1Factory *factory, const D2D1_RECT_F *rect);
589 HRESULT d2d_rounded_rectangle_geometry_init(struct d2d_geometry *geometry,
590 ID2D1Factory *factory, const D2D1_ROUNDED_RECT *rounded_rect);
591 void d2d_transformed_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *factory,
592 ID2D1Geometry *src_geometry, const D2D_MATRIX_3X2_F *transform);
593 HRESULT d2d_geometry_group_init(struct d2d_geometry *geometry, ID2D1Factory *factory,
594 D2D1_FILL_MODE fill_mode, ID2D1Geometry **src_geometries, unsigned int geometry_count);
595 struct d2d_geometry *unsafe_impl_from_ID2D1Geometry(ID2D1Geometry *iface);
597 struct d2d_shader
599 GUID id;
600 IUnknown *shader;
603 struct d2d_device
605 ID2D1Device1 ID2D1Device1_iface;
606 LONG refcount;
607 ID2D1Factory1 *factory;
608 IDXGIDevice *dxgi_device;
610 struct
612 struct d2d_shader *objects;
613 size_t size;
614 size_t count;
615 } shaders;
618 void d2d_device_init(struct d2d_device *device, ID2D1Factory1 *factory, IDXGIDevice *dxgi_device);
619 struct d2d_device *unsafe_impl_from_ID2D1Device(ID2D1Device1 *iface);
620 HRESULT d2d_device_add_shader(struct d2d_device *device, REFGUID shader_id, IUnknown *shader);
621 BOOL d2d_device_is_shader_loaded(struct d2d_device *device, REFGUID shader_id);
623 struct d2d_effect_context
625 ID2D1EffectContext ID2D1EffectContext_iface;
626 LONG refcount;
628 struct d2d_device_context *device_context;
631 void d2d_effect_context_init(struct d2d_effect_context *effect_context,
632 struct d2d_device_context *device_context);
634 struct d2d_effect_property
636 WCHAR *name;
637 D2D1_PROPERTY_TYPE type;
638 UINT32 index;
639 BOOL readonly;
640 union
642 size_t offset;
643 void *ptr;
644 } data;
645 UINT32 size;
646 PD2D1_PROPERTY_SET_FUNCTION set_function;
647 PD2D1_PROPERTY_GET_FUNCTION get_function;
648 struct d2d_effect_properties *subproperties;
651 struct d2d_effect_properties
653 ID2D1Properties ID2D1Properties_iface;
654 struct d2d_effect *effect;
656 struct d2d_effect_property *properties;
657 size_t offset;
658 size_t size;
659 size_t count;
660 size_t custom_count;
661 struct
663 BYTE *ptr;
664 size_t size;
665 size_t count;
666 } data;
669 struct d2d_effect_registration
671 struct list entry;
672 PD2D1_EFFECT_FACTORY factory;
673 UINT32 registration_count;
674 BOOL builtin;
675 CLSID id;
677 struct d2d_effect_properties properties;
680 struct d2d_factory
682 ID2D1Factory3 ID2D1Factory3_iface;
683 ID2D1Multithread ID2D1Multithread_iface;
684 LONG refcount;
686 ID3D10Device1 *device;
688 float dpi_x;
689 float dpi_y;
691 struct list effects;
692 INIT_ONCE init_builtins;
694 CRITICAL_SECTION cs;
695 D2D1_FACTORY_TYPE factory_type;
698 static inline struct d2d_factory *unsafe_impl_from_ID2D1Factory(ID2D1Factory *iface)
700 return CONTAINING_RECORD(iface, struct d2d_factory, ID2D1Factory3_iface);
703 void d2d_effects_init_builtins(struct d2d_factory *factory);
704 struct d2d_effect_registration * d2d_factory_get_registered_effect(ID2D1Factory *factory,
705 const GUID *effect_id);
706 void d2d_factory_register_effect(struct d2d_factory *factory,
707 struct d2d_effect_registration *effect);
708 HRESULT d2d_effect_property_get_uint32_value(const struct d2d_effect_properties *properties,
709 const struct d2d_effect_property *prop, UINT32 *value);
711 struct d2d_transform
713 ID2D1TransformNode ID2D1TransformNode_iface;
714 LONG refcount;
716 union
718 D2D1_POINT_2L offset;
719 D2D1_BLEND_DESCRIPTION blend_desc;
722 UINT32 input_count;
725 struct d2d_transform_node
727 struct list entry;
728 ID2D1TransformNode *object;
731 struct d2d_transform_node_connection
733 struct d2d_transform_node *node;
734 unsigned int index;
737 struct d2d_transform_graph
739 ID2D1TransformGraph ID2D1TransformGraph_iface;
740 LONG refcount;
742 struct d2d_transform_node_connection *inputs;
743 unsigned int input_count;
745 struct d2d_transform_node *output;
747 struct list nodes;
750 struct d2d_effect
752 ID2D1Effect ID2D1Effect_iface;
753 ID2D1Image ID2D1Image_iface;
754 LONG refcount;
756 ID2D1EffectImpl *impl;
757 struct d2d_effect_properties properties;
758 struct d2d_effect_context *effect_context;
759 struct d2d_transform_graph *graph;
760 ID2D1Image **inputs;
761 size_t inputs_size;
762 size_t input_count;
765 HRESULT d2d_effect_create(struct d2d_device_context *context, const CLSID *effect_id,
766 ID2D1Effect **effect);
767 HRESULT d2d_effect_properties_add(struct d2d_effect_properties *props, const WCHAR *name,
768 UINT32 index, D2D1_PROPERTY_TYPE type, const WCHAR *value);
769 HRESULT d2d_effect_subproperties_add(struct d2d_effect_properties *props, const WCHAR *name,
770 UINT32 index, D2D1_PROPERTY_TYPE type, const WCHAR *value);
771 struct d2d_effect_property * d2d_effect_properties_get_property_by_name(
772 const struct d2d_effect_properties *properties, const WCHAR *name);
773 void d2d_effect_properties_cleanup(struct d2d_effect_properties *props);
774 HRESULT d2d_factory_register_builtin_effect(struct d2d_factory *factory, REFCLSID effect_id,
775 const WCHAR *property_xml, const D2D1_PROPERTY_BINDING *bindings, UINT32 binding_count,
776 PD2D1_EFFECT_FACTORY effect_factory);
778 enum d2d_command_list_state
780 D2D_COMMAND_LIST_STATE_INITIAL = 0,
781 D2D_COMMAND_LIST_STATE_ERROR,
782 D2D_COMMAND_LIST_STATE_OPEN,
783 D2D_COMMAND_LIST_STATE_CLOSED,
786 struct d2d_command_list
788 ID2D1CommandList ID2D1CommandList_iface;
789 LONG refcount;
791 ID2D1Factory *factory;
792 enum d2d_command_list_state state;
793 unsigned int flags;
795 size_t size;
796 size_t capacity;
797 void *data;
799 size_t objects_count;
800 size_t objects_capacity;
801 IUnknown **objects;
804 HRESULT d2d_command_list_create(ID2D1Factory *factory, struct d2d_command_list **command_list);
805 struct d2d_command_list *unsafe_impl_from_ID2D1CommandList(ID2D1CommandList *iface);
806 void d2d_command_list_begin_draw(struct d2d_command_list *command_list, const struct d2d_device_context *context);
807 void d2d_command_list_set_antialias_mode(struct d2d_command_list *command_list, D2D1_ANTIALIAS_MODE mode);
808 void d2d_command_list_set_primitive_blend(struct d2d_command_list *command_list,
809 D2D1_PRIMITIVE_BLEND primitive_blend);
810 void d2d_command_list_set_unit_mode(struct d2d_command_list *command_list, D2D1_UNIT_MODE mode);
811 void d2d_command_list_set_text_antialias_mode(struct d2d_command_list *command_list,
812 D2D1_TEXT_ANTIALIAS_MODE mode);
813 void d2d_command_list_set_tags(struct d2d_command_list *command_list, D2D1_TAG tag1, D2D1_TAG tag2);
814 void d2d_command_list_set_transform(struct d2d_command_list *command_list,
815 const D2D1_MATRIX_3X2_F *transform);
816 void d2d_command_list_push_clip(struct d2d_command_list *command_list, const D2D1_RECT_F *rect,
817 D2D1_ANTIALIAS_MODE antialias_mode);
818 void d2d_command_list_pop_clip(struct d2d_command_list *command_list);
819 void d2d_command_list_clear(struct d2d_command_list *command_list, const D2D1_COLOR_F *color);
820 void d2d_command_list_draw_line(struct d2d_command_list *command_list, const struct d2d_device_context *context,
821 D2D1_POINT_2F p0, D2D1_POINT_2F p1, ID2D1Brush *orig_brush, float stroke_width,
822 ID2D1StrokeStyle *stroke_style);
823 void d2d_command_list_draw_geometry(struct d2d_command_list *command_list,
824 const struct d2d_device_context *context, ID2D1Geometry *geometry, ID2D1Brush *orig_brush,
825 float stroke_width, ID2D1StrokeStyle *stroke_style);
826 void d2d_command_list_draw_rectangle(struct d2d_command_list *command_list, const struct d2d_device_context *context,
827 const D2D1_RECT_F *rect, ID2D1Brush *orig_brush, float stroke_width, ID2D1StrokeStyle *stroke_style);
828 void d2d_command_list_fill_geometry(struct d2d_command_list *command_list,
829 const struct d2d_device_context *context, ID2D1Geometry *geometry, ID2D1Brush *orig_brush,
830 ID2D1Brush *orig_opacity_brush);
831 void d2d_command_list_fill_rectangle(struct d2d_command_list *command_list,
832 const struct d2d_device_context *context, const D2D1_RECT_F *rect, ID2D1Brush *orig_brush);
833 void d2d_command_list_set_text_rendering_params(struct d2d_command_list *command_list,
834 IDWriteRenderingParams *params);
835 void d2d_command_list_draw_glyph_run(struct d2d_command_list *command_list,
836 const struct d2d_device_context *context, D2D1_POINT_2F origin, const DWRITE_GLYPH_RUN *run,
837 const DWRITE_GLYPH_RUN_DESCRIPTION *run_desc, ID2D1Brush *orig_brush,
838 DWRITE_MEASURING_MODE measuring_mode);
839 void d2d_command_list_draw_bitmap(struct d2d_command_list *command_list, ID2D1Bitmap *bitmap,
840 const D2D1_RECT_F *dst_rect, float opacity, D2D1_INTERPOLATION_MODE interpolation_mode,
841 const D2D1_RECT_F *src_rect, const D2D1_MATRIX_4X4_F *perspective_transform);
842 void d2d_command_list_draw_image(struct d2d_command_list *command_list, ID2D1Image *image,
843 const D2D1_POINT_2F *target_offset, const D2D1_RECT_F *image_rect, D2D1_INTERPOLATION_MODE interpolation_mode,
844 D2D1_COMPOSITE_MODE composite_mode);
845 void d2d_command_list_fill_mesh(struct d2d_command_list *command_list, const struct d2d_device_context *context,
846 ID2D1Mesh *mesh, ID2D1Brush *orig_brush);
847 void d2d_command_list_fill_opacity_mask(struct d2d_command_list *command_list, const struct d2d_device_context *context,
848 ID2D1Bitmap *bitmap, ID2D1Brush *orig_brush, const D2D1_RECT_F *dst_rect, const D2D1_RECT_F *src_rect);
849 void d2d_command_list_push_layer(struct d2d_command_list *command_list, const struct d2d_device_context *context,
850 const D2D1_LAYER_PARAMETERS1 *params, ID2D1Layer *layer);
851 void d2d_command_list_pop_layer(struct d2d_command_list *command_list);
853 static inline BOOL d2d_array_reserve(void **elements, size_t *capacity, size_t count, size_t size)
855 size_t new_capacity, max_capacity;
856 void *new_elements;
858 if (count <= *capacity)
859 return TRUE;
861 max_capacity = ~(SIZE_T)0 / size;
862 if (count > max_capacity)
863 return FALSE;
865 new_capacity = max(4, *capacity);
866 while (new_capacity < count && new_capacity <= max_capacity / 2)
867 new_capacity *= 2;
868 if (new_capacity < count)
869 new_capacity = max_capacity;
871 if (!(new_elements = realloc(*elements, new_capacity * size)))
872 return FALSE;
874 *elements = new_elements;
875 *capacity = new_capacity;
876 return TRUE;
879 static inline void d2d_matrix_multiply(D2D_MATRIX_3X2_F *a, const D2D_MATRIX_3X2_F *b)
881 D2D_MATRIX_3X2_F tmp = *a;
883 a->_11 = tmp._11 * b->_11 + tmp._12 * b->_21;
884 a->_12 = tmp._11 * b->_12 + tmp._12 * b->_22;
885 a->_21 = tmp._21 * b->_11 + tmp._22 * b->_21;
886 a->_22 = tmp._21 * b->_12 + tmp._22 * b->_22;
887 a->_31 = tmp._31 * b->_11 + tmp._32 * b->_21 + b->_31;
888 a->_32 = tmp._31 * b->_12 + tmp._32 * b->_22 + b->_32;
891 /* Dst must be different from src. */
892 static inline BOOL d2d_matrix_invert(D2D_MATRIX_3X2_F *dst, const D2D_MATRIX_3X2_F *src)
894 float d = src->_11 * src->_22 - src->_21 * src->_12;
896 if (d == 0.0f)
897 return FALSE;
898 dst->_11 = src->_22 / d;
899 dst->_21 = -src->_21 / d;
900 dst->_31 = (src->_21 * src->_32 - src->_31 * src->_22) / d;
901 dst->_12 = -src->_12 / d;
902 dst->_22 = src->_11 / d;
903 dst->_32 = -(src->_11 * src->_32 - src->_31 * src->_12) / d;
905 return TRUE;
908 static inline void d2d_point_set(D2D1_POINT_2F *dst, float x, float y)
910 dst->x = x;
911 dst->y = y;
914 static inline float d2d_point_dot(const D2D1_POINT_2F *p0, const D2D1_POINT_2F *p1)
916 return p0->x * p1->x + p0->y * p1->y;
919 static inline void d2d_point_transform(D2D1_POINT_2F *dst, const D2D1_MATRIX_3X2_F *matrix, float x, float y)
921 dst->x = x * matrix->_11 + y * matrix->_21 + matrix->_31;
922 dst->y = x * matrix->_12 + y * matrix->_22 + matrix->_32;
925 static inline void d2d_rect_expand(D2D1_RECT_F *dst, const D2D1_POINT_2F *point)
927 if (point->x < dst->left)
928 dst->left = point->x;
929 if (point->x > dst->right)
930 dst->right = point->x;
931 if (point->y < dst->top)
932 dst->top = point->y;
933 if (point->y > dst->bottom)
934 dst->bottom = point->y;
937 static inline D2D1_INTERPOLATION_MODE d2d1_1_interp_mode_from_d2d1(D2D1_BITMAP_INTERPOLATION_MODE mode)
939 return (D2D1_INTERPOLATION_MODE)mode;
942 static inline const char *debug_d2d_color_f(const D2D1_COLOR_F *colour)
944 if (!colour)
945 return "(null)";
946 return wine_dbg_sprintf("{%.8e, %.8e, %.8e, %.8e}", colour->r, colour->g, colour->b, colour->a);
949 static inline const char *debug_d2d_point_2f(const D2D1_POINT_2F *point)
951 if (!point)
952 return "(null)";
953 return wine_dbg_sprintf("{%.8e, %.8e}", point->x, point->y);
956 static inline const char *debug_d2d_point_2l(const D2D1_POINT_2L *point)
958 if (!point)
959 return "(null)";
960 return wine_dbg_sprintf("{%ld, %ld}", point->x, point->y);
963 static inline const char *debug_d2d_rect_f(const D2D1_RECT_F *rect)
965 if (!rect)
966 return "(null)";
967 return wine_dbg_sprintf("(%.8e, %.8e)-(%.8e, %.8e)", rect->left, rect->top, rect->right, rect->bottom);
970 static inline const char *debug_d2d_rect_l(const D2D1_RECT_L *rect)
972 if (!rect)
973 return "(null)";
974 return wine_dbg_sprintf("(%ld, %ld)-(%ld, %ld)", rect->left, rect->top, rect->right, rect->bottom);
977 static inline const char *debug_d2d_rounded_rect(const D2D1_ROUNDED_RECT *rounded_rect)
979 if (!rounded_rect)
980 return "(null)";
981 return wine_dbg_sprintf("(%.8e, %.8e)-(%.8e, %.8e)[%.8e, %.8e]", rounded_rect->rect.left, rounded_rect->rect.top,
982 rounded_rect->rect.right, rounded_rect->rect.bottom, rounded_rect->radiusX, rounded_rect->radiusY);
985 static inline const char *debug_d2d_ellipse(const D2D1_ELLIPSE *ellipse)
987 if (!ellipse)
988 return "(null)";
989 return wine_dbg_sprintf("(%.8e, %.8e)[%.8e, %.8e]",
990 ellipse->point.x, ellipse->point.y, ellipse->radiusX, ellipse->radiusY);
993 #endif /* __WINE_D2D1_PRIVATE_H */