d2d1: Allow setting command list as a target.
[wine.git] / dlls / d2d1 / d2d1_private.h
blob5b61b58f09b51d419e67079b878192f542e224e9
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 DECLSPEC_HIDDEN;
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 ID2D1Device *device;
175 ID3D11Device1 *d3d_device;
176 ID3DDeviceContextState *d3d_state;
177 struct
179 ID2D1Image *object;
180 enum d2d_device_context_target_type type;
181 union
183 struct d2d_bitmap *bitmap;
184 struct d2d_command_list *command_list;
186 } target;
187 struct d2d_shape_resources shape_resources[D2D_SHAPE_TYPE_COUNT];
188 ID3D11Buffer *vs_cb;
189 ID3D11PixelShader *ps;
190 ID3D11Buffer *ps_cb;
191 ID3D11Buffer *ib;
192 unsigned int vb_stride;
193 ID3D11Buffer *vb;
194 ID3D11RasterizerState *rs;
195 ID3D11BlendState *bs;
196 ID3D11SamplerState *sampler_states
197 [D2D_SAMPLER_INTERPOLATION_MODE_COUNT]
198 [D2D_SAMPLER_EXTEND_MODE_COUNT]
199 [D2D_SAMPLER_EXTEND_MODE_COUNT];
201 struct d2d_error_state error;
202 D2D1_DRAWING_STATE_DESCRIPTION1 drawing_state;
203 IDWriteRenderingParams *text_rendering_params;
204 IDWriteRenderingParams *default_text_rendering_params;
206 D2D1_RENDER_TARGET_PROPERTIES desc;
207 D2D1_SIZE_U pixel_size;
208 struct d2d_clip_stack clip_stack;
211 HRESULT d2d_d3d_create_render_target(ID2D1Device *device, IDXGISurface *surface, IUnknown *outer_unknown,
212 const struct d2d_device_context_ops *ops, const D2D1_RENDER_TARGET_PROPERTIES *desc,
213 void **render_target) DECLSPEC_HIDDEN;
215 static inline BOOL d2d_device_context_is_dxgi_target(const struct d2d_device_context *context)
217 return !context->ops;
220 struct d2d_wic_render_target
222 IUnknown IUnknown_iface;
223 LONG refcount;
225 IDXGISurface *dxgi_surface;
226 ID2D1RenderTarget *dxgi_target;
227 IUnknown *dxgi_inner;
228 ID3D10Texture2D *readback_texture;
229 IWICBitmap *bitmap;
231 unsigned int width;
232 unsigned int height;
233 unsigned int bpp;
236 HRESULT d2d_wic_render_target_init(struct d2d_wic_render_target *render_target, ID2D1Factory1 *factory,
237 ID3D10Device1 *d3d_device, IWICBitmap *bitmap, const D2D1_RENDER_TARGET_PROPERTIES *desc) DECLSPEC_HIDDEN;
239 struct d2d_dc_render_target
241 ID2D1DCRenderTarget ID2D1DCRenderTarget_iface;
242 LONG refcount;
244 IDXGISurface1 *dxgi_surface;
245 D2D1_PIXEL_FORMAT pixel_format;
246 ID3D10Device1 *d3d_device;
247 ID2D1RenderTarget *dxgi_target;
248 IUnknown *dxgi_inner;
250 RECT dst_rect;
251 HDC hdc;
254 HRESULT d2d_dc_render_target_init(struct d2d_dc_render_target *render_target, ID2D1Factory1 *factory,
255 ID3D10Device1 *d3d_device, const D2D1_RENDER_TARGET_PROPERTIES *desc) DECLSPEC_HIDDEN;
257 struct d2d_hwnd_render_target
259 ID2D1HwndRenderTarget ID2D1HwndRenderTarget_iface;
260 LONG refcount;
262 ID2D1RenderTarget *dxgi_target;
263 IUnknown *dxgi_inner;
264 IDXGISwapChain *swapchain;
265 UINT sync_interval;
266 HWND hwnd;
269 HRESULT d2d_hwnd_render_target_init(struct d2d_hwnd_render_target *render_target, ID2D1Factory1 *factory,
270 ID3D10Device1 *d3d_device, const D2D1_RENDER_TARGET_PROPERTIES *desc,
271 const D2D1_HWND_RENDER_TARGET_PROPERTIES *hwnd_desc) DECLSPEC_HIDDEN;
273 struct d2d_bitmap_render_target
275 ID2D1BitmapRenderTarget ID2D1BitmapRenderTarget_iface;
276 LONG refcount;
278 ID2D1RenderTarget *dxgi_target;
279 IUnknown *dxgi_inner;
280 ID2D1Bitmap *bitmap;
283 HRESULT d2d_bitmap_render_target_init(struct d2d_bitmap_render_target *render_target,
284 const struct d2d_device_context *parent_target, const D2D1_SIZE_F *size,
285 const D2D1_SIZE_U *pixel_size, const D2D1_PIXEL_FORMAT *format,
286 D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS options) DECLSPEC_HIDDEN;
288 struct d2d_gradient
290 ID2D1GradientStopCollection ID2D1GradientStopCollection_iface;
291 LONG refcount;
293 ID2D1Factory *factory;
294 ID3D11ShaderResourceView *view;
295 D2D1_GRADIENT_STOP *stops;
296 UINT32 stop_count;
299 HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D11Device1 *device, const D2D1_GRADIENT_STOP *stops,
300 UINT32 stop_count, D2D1_GAMMA gamma, D2D1_EXTEND_MODE extend_mode,
301 struct d2d_gradient **gradient) DECLSPEC_HIDDEN;
303 struct d2d_brush
305 ID2D1Brush ID2D1Brush_iface;
306 LONG refcount;
308 ID2D1Factory *factory;
309 float opacity;
310 D2D1_MATRIX_3X2_F transform;
312 enum d2d_brush_type type;
313 union
315 struct
317 D2D1_COLOR_F color;
318 } solid;
319 struct
321 struct d2d_gradient *gradient;
322 D2D1_POINT_2F start;
323 D2D1_POINT_2F end;
324 } linear;
325 struct
327 struct d2d_gradient *gradient;
328 D2D1_POINT_2F centre;
329 D2D1_POINT_2F offset;
330 D2D1_POINT_2F radius;
331 } radial;
332 struct
334 struct d2d_bitmap *bitmap;
335 D2D1_EXTEND_MODE extend_mode_x;
336 D2D1_EXTEND_MODE extend_mode_y;
337 D2D1_INTERPOLATION_MODE interpolation_mode;
338 } bitmap;
339 struct
341 ID2D1Image *image;
342 D2D1_EXTEND_MODE extend_mode_x;
343 D2D1_EXTEND_MODE extend_mode_y;
344 D2D1_INTERPOLATION_MODE interpolation_mode;
345 D2D1_RECT_F source_rect;
346 } image;
347 } u;
350 HRESULT d2d_solid_color_brush_create(ID2D1Factory *factory, const D2D1_COLOR_F *color,
351 const D2D1_BRUSH_PROPERTIES *desc, struct d2d_brush **brush) DECLSPEC_HIDDEN;
352 HRESULT d2d_linear_gradient_brush_create(ID2D1Factory *factory,
353 const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES *gradient_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
354 ID2D1GradientStopCollection *gradient, struct d2d_brush **brush) DECLSPEC_HIDDEN;
355 HRESULT d2d_radial_gradient_brush_create(ID2D1Factory *factory,
356 const D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES *gradient_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
357 ID2D1GradientStopCollection *gradient, struct d2d_brush **brush) DECLSPEC_HIDDEN;
358 HRESULT d2d_bitmap_brush_create(ID2D1Factory *factory, ID2D1Bitmap *bitmap,
359 const D2D1_BITMAP_BRUSH_PROPERTIES1 *bitmap_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
360 struct d2d_brush **brush) DECLSPEC_HIDDEN;
361 HRESULT d2d_image_brush_create(ID2D1Factory *factory, ID2D1Image *image,
362 const D2D1_IMAGE_BRUSH_PROPERTIES *image_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
363 struct d2d_brush **brush) DECLSPEC_HIDDEN;
364 void d2d_brush_bind_resources(struct d2d_brush *brush, struct d2d_device_context *context,
365 unsigned int brush_idx) DECLSPEC_HIDDEN;
366 BOOL d2d_brush_fill_cb(const struct d2d_brush *brush, struct d2d_brush_cb *cb) DECLSPEC_HIDDEN;
367 struct d2d_brush *unsafe_impl_from_ID2D1Brush(ID2D1Brush *iface) DECLSPEC_HIDDEN;
369 struct d2d_stroke_style
371 ID2D1StrokeStyle1 ID2D1StrokeStyle1_iface;
372 LONG refcount;
374 ID2D1Factory *factory;
375 D2D1_STROKE_STYLE_PROPERTIES1 desc;
376 float *dashes;
377 UINT32 dash_count;
380 HRESULT d2d_stroke_style_init(struct d2d_stroke_style *style, ID2D1Factory *factory,
381 const D2D1_STROKE_STYLE_PROPERTIES1 *desc, const float *dashes, UINT32 dash_count) DECLSPEC_HIDDEN;
383 struct d2d_layer
385 ID2D1Layer ID2D1Layer_iface;
386 LONG refcount;
388 ID2D1Factory *factory;
389 D2D1_SIZE_F size;
392 HRESULT d2d_layer_create(ID2D1Factory *factory, const D2D1_SIZE_F *size, struct d2d_layer **layer) DECLSPEC_HIDDEN;
394 struct d2d_mesh
396 ID2D1Mesh ID2D1Mesh_iface;
397 LONG refcount;
399 ID2D1Factory *factory;
402 HRESULT d2d_mesh_create(ID2D1Factory *factory, struct d2d_mesh **mesh) DECLSPEC_HIDDEN;
404 struct d2d_bitmap
406 ID2D1Bitmap1 ID2D1Bitmap1_iface;
407 LONG refcount;
409 ID2D1Factory *factory;
410 ID3D11ShaderResourceView *srv;
411 ID3D11RenderTargetView *rtv;
412 IDXGISurface *surface;
413 ID3D11Resource *resource;
414 D3D11_MAPPED_SUBRESOURCE mapped_resource;
415 D2D1_SIZE_U pixel_size;
416 D2D1_PIXEL_FORMAT format;
417 float dpi_x;
418 float dpi_y;
419 D2D1_BITMAP_OPTIONS options;
422 HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size, const void *src_data,
423 UINT32 pitch, const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap) DECLSPEC_HIDDEN;
424 HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid, void *data,
425 const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap) DECLSPEC_HIDDEN;
426 HRESULT d2d_bitmap_create_from_wic_bitmap(struct d2d_device_context *context, IWICBitmapSource *bitmap_source,
427 const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap) DECLSPEC_HIDDEN;
428 unsigned int d2d_get_bitmap_options_for_surface(IDXGISurface *surface) DECLSPEC_HIDDEN;
429 struct d2d_bitmap *unsafe_impl_from_ID2D1Bitmap(ID2D1Bitmap *iface) DECLSPEC_HIDDEN;
431 struct d2d_state_block
433 ID2D1DrawingStateBlock1 ID2D1DrawingStateBlock1_iface;
434 LONG refcount;
436 ID2D1Factory *factory;
437 D2D1_DRAWING_STATE_DESCRIPTION1 drawing_state;
438 IDWriteRenderingParams *text_rendering_params;
441 void d2d_state_block_init(struct d2d_state_block *state_block, ID2D1Factory *factory,
442 const D2D1_DRAWING_STATE_DESCRIPTION1 *desc, IDWriteRenderingParams *text_rendering_params) DECLSPEC_HIDDEN;
443 struct d2d_state_block *unsafe_impl_from_ID2D1DrawingStateBlock(ID2D1DrawingStateBlock *iface) DECLSPEC_HIDDEN;
445 enum d2d_geometry_state
447 D2D_GEOMETRY_STATE_INITIAL = 0,
448 D2D_GEOMETRY_STATE_ERROR,
449 D2D_GEOMETRY_STATE_OPEN,
450 D2D_GEOMETRY_STATE_CLOSED,
451 D2D_GEOMETRY_STATE_FIGURE,
454 struct d2d_curve_vertex
456 D2D1_POINT_2F position;
457 struct
459 float u, v, sign;
460 } texcoord;
463 struct d2d_face
465 UINT16 v[3];
468 struct d2d_outline_vertex
470 D2D1_POINT_2F position;
471 D2D1_POINT_2F prev;
472 D2D1_POINT_2F next;
475 struct d2d_curve_outline_vertex
477 D2D1_POINT_2F position;
478 D2D1_POINT_2F p0, p1, p2;
479 D2D1_POINT_2F prev, next;
482 struct d2d_geometry
484 ID2D1Geometry ID2D1Geometry_iface;
485 LONG refcount;
487 ID2D1Factory *factory;
489 D2D_MATRIX_3X2_F transform;
491 struct
493 D2D1_POINT_2F *vertices;
494 size_t vertex_count;
496 struct d2d_face *faces;
497 size_t faces_size;
498 size_t face_count;
500 struct d2d_curve_vertex *bezier_vertices;
501 size_t bezier_vertices_size;
502 size_t bezier_vertex_count;
504 struct d2d_curve_vertex *arc_vertices;
505 size_t arc_vertices_size;
506 size_t arc_vertex_count;
507 } fill;
509 struct
511 struct d2d_outline_vertex *vertices;
512 size_t vertices_size;
513 size_t vertex_count;
515 struct d2d_face *faces;
516 size_t faces_size;
517 size_t face_count;
519 struct d2d_curve_outline_vertex *beziers;
520 size_t beziers_size;
521 size_t bezier_count;
523 struct d2d_face *bezier_faces;
524 size_t bezier_faces_size;
525 size_t bezier_face_count;
527 struct d2d_curve_outline_vertex *arcs;
528 size_t arcs_size;
529 size_t arc_count;
531 struct d2d_face *arc_faces;
532 size_t arc_faces_size;
533 size_t arc_face_count;
534 } outline;
536 union
538 struct
540 D2D1_ELLIPSE ellipse;
541 } ellipse;
542 struct
544 ID2D1GeometrySink ID2D1GeometrySink_iface;
546 struct d2d_figure *figures;
547 size_t figures_size;
548 size_t figure_count;
550 enum d2d_geometry_state state;
551 D2D1_FILL_MODE fill_mode;
552 UINT32 segment_count;
554 D2D1_RECT_F bounds;
555 } path;
556 struct
558 D2D1_RECT_F rect;
559 } rectangle;
560 struct
562 D2D1_ROUNDED_RECT rounded_rect;
563 } rounded_rectangle;
564 struct
566 ID2D1Geometry *src_geometry;
567 D2D_MATRIX_3X2_F transform;
568 } transformed;
569 struct
571 ID2D1Geometry **src_geometries;
572 UINT32 geometry_count;
573 D2D1_FILL_MODE fill_mode;
574 } group;
575 } u;
578 HRESULT d2d_ellipse_geometry_init(struct d2d_geometry *geometry,
579 ID2D1Factory *factory, const D2D1_ELLIPSE *ellipse) DECLSPEC_HIDDEN;
580 void d2d_path_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *factory) DECLSPEC_HIDDEN;
581 HRESULT d2d_rectangle_geometry_init(struct d2d_geometry *geometry,
582 ID2D1Factory *factory, const D2D1_RECT_F *rect) DECLSPEC_HIDDEN;
583 HRESULT d2d_rounded_rectangle_geometry_init(struct d2d_geometry *geometry,
584 ID2D1Factory *factory, const D2D1_ROUNDED_RECT *rounded_rect) DECLSPEC_HIDDEN;
585 void d2d_transformed_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *factory,
586 ID2D1Geometry *src_geometry, const D2D_MATRIX_3X2_F *transform) DECLSPEC_HIDDEN;
587 HRESULT d2d_geometry_group_init(struct d2d_geometry *geometry, ID2D1Factory *factory,
588 D2D1_FILL_MODE fill_mode, ID2D1Geometry **src_geometries, unsigned int geometry_count) DECLSPEC_HIDDEN;
589 struct d2d_geometry *unsafe_impl_from_ID2D1Geometry(ID2D1Geometry *iface) DECLSPEC_HIDDEN;
591 struct d2d_device
593 ID2D1Device ID2D1Device_iface;
594 LONG refcount;
595 ID2D1Factory1 *factory;
596 IDXGIDevice *dxgi_device;
599 void d2d_device_init(struct d2d_device *device, ID2D1Factory1 *factory, IDXGIDevice *dxgi_device) DECLSPEC_HIDDEN;
601 struct d2d_shader
603 GUID id;
604 IUnknown *shader;
607 struct d2d_effect_context
609 ID2D1EffectContext ID2D1EffectContext_iface;
610 LONG refcount;
612 struct d2d_device_context *device_context;
614 struct d2d_shader *shaders;
615 size_t shaders_size;
616 size_t shader_count;
619 void d2d_effect_context_init(struct d2d_effect_context *effect_context,
620 struct d2d_device_context *device_context) DECLSPEC_HIDDEN;
622 struct d2d_effect_property
624 WCHAR *name;
625 D2D1_PROPERTY_TYPE type;
626 UINT32 index;
627 BOOL readonly;
628 union
630 size_t offset;
631 void *ptr;
632 } data;
633 UINT32 size;
634 PD2D1_PROPERTY_SET_FUNCTION set_function;
635 PD2D1_PROPERTY_GET_FUNCTION get_function;
636 struct d2d_effect_properties *subproperties;
639 struct d2d_effect_properties
641 ID2D1Properties ID2D1Properties_iface;
642 struct d2d_effect *effect;
644 struct d2d_effect_property *properties;
645 size_t offset;
646 size_t size;
647 size_t count;
648 size_t custom_count;
649 struct
651 BYTE *ptr;
652 size_t size;
653 size_t count;
654 } data;
657 struct d2d_effect_registration
659 struct list entry;
660 PD2D1_EFFECT_FACTORY factory;
661 UINT32 registration_count;
662 BOOL builtin;
663 CLSID id;
665 UINT32 input_count;
666 UINT32 default_input_count;
667 struct d2d_effect_properties properties;
670 struct d2d_factory;
671 void d2d_effects_init_builtins(struct d2d_factory *factory) DECLSPEC_HIDDEN;
672 struct d2d_effect_registration * d2d_factory_get_registered_effect(ID2D1Factory *factory,
673 const GUID *effect_id) DECLSPEC_HIDDEN;
674 void d2d_factory_register_effect(struct d2d_factory *factory,
675 struct d2d_effect_registration *effect) DECLSPEC_HIDDEN;
677 struct d2d_transform_graph
679 ID2D1TransformGraph ID2D1TransformGraph_iface;
680 LONG refcount;
683 struct d2d_effect
685 ID2D1Effect ID2D1Effect_iface;
686 ID2D1Image ID2D1Image_iface;
687 LONG refcount;
689 ID2D1EffectImpl *impl;
690 struct d2d_effect_properties properties;
691 struct d2d_effect_context *effect_context;
692 struct d2d_transform_graph *graph;
693 ID2D1Image **inputs;
694 size_t inputs_size;
695 size_t input_count;
698 HRESULT d2d_effect_create(struct d2d_device_context *context, const CLSID *effect_id,
699 ID2D1Effect **effect) DECLSPEC_HIDDEN;
700 HRESULT d2d_effect_properties_add(struct d2d_effect_properties *props, const WCHAR *name,
701 UINT32 index, D2D1_PROPERTY_TYPE type, const WCHAR *value) DECLSPEC_HIDDEN;
702 HRESULT d2d_effect_subproperties_add(struct d2d_effect_properties *props, const WCHAR *name,
703 UINT32 index, D2D1_PROPERTY_TYPE type, const WCHAR *value) DECLSPEC_HIDDEN;
704 struct d2d_effect_property * d2d_effect_properties_get_property_by_name(
705 const struct d2d_effect_properties *properties, const WCHAR *name) DECLSPEC_HIDDEN;
706 void d2d_effect_properties_cleanup(struct d2d_effect_properties *props) DECLSPEC_HIDDEN;
708 struct d2d_command_list
710 ID2D1CommandList ID2D1CommandList_iface;
711 LONG refcount;
713 ID2D1Factory *factory;
716 HRESULT d2d_command_list_create(ID2D1Factory *factory, struct d2d_command_list **command_list) DECLSPEC_HIDDEN;
717 struct d2d_command_list *unsafe_impl_from_ID2D1CommandList(ID2D1CommandList *iface) DECLSPEC_HIDDEN;
719 static inline BOOL d2d_array_reserve(void **elements, size_t *capacity, size_t count, size_t size)
721 size_t new_capacity, max_capacity;
722 void *new_elements;
724 if (count <= *capacity)
725 return TRUE;
727 max_capacity = ~(SIZE_T)0 / size;
728 if (count > max_capacity)
729 return FALSE;
731 new_capacity = max(4, *capacity);
732 while (new_capacity < count && new_capacity <= max_capacity / 2)
733 new_capacity *= 2;
734 if (new_capacity < count)
735 new_capacity = max_capacity;
737 if (!(new_elements = realloc(*elements, new_capacity * size)))
738 return FALSE;
740 *elements = new_elements;
741 *capacity = new_capacity;
742 return TRUE;
745 static inline void d2d_matrix_multiply(D2D_MATRIX_3X2_F *a, const D2D_MATRIX_3X2_F *b)
747 D2D_MATRIX_3X2_F tmp = *a;
749 a->_11 = tmp._11 * b->_11 + tmp._12 * b->_21;
750 a->_12 = tmp._11 * b->_12 + tmp._12 * b->_22;
751 a->_21 = tmp._21 * b->_11 + tmp._22 * b->_21;
752 a->_22 = tmp._21 * b->_12 + tmp._22 * b->_22;
753 a->_31 = tmp._31 * b->_11 + tmp._32 * b->_21 + b->_31;
754 a->_32 = tmp._31 * b->_12 + tmp._32 * b->_22 + b->_32;
757 /* Dst must be different from src. */
758 static inline BOOL d2d_matrix_invert(D2D_MATRIX_3X2_F *dst, const D2D_MATRIX_3X2_F *src)
760 float d = src->_11 * src->_22 - src->_21 * src->_12;
762 if (d == 0.0f)
763 return FALSE;
764 dst->_11 = src->_22 / d;
765 dst->_21 = -src->_21 / d;
766 dst->_31 = (src->_21 * src->_32 - src->_31 * src->_22) / d;
767 dst->_12 = -src->_12 / d;
768 dst->_22 = src->_11 / d;
769 dst->_32 = -(src->_11 * src->_32 - src->_31 * src->_12) / d;
771 return TRUE;
774 static inline void d2d_point_set(D2D1_POINT_2F *dst, float x, float y)
776 dst->x = x;
777 dst->y = y;
780 static inline float d2d_point_dot(const D2D1_POINT_2F *p0, const D2D1_POINT_2F *p1)
782 return p0->x * p1->x + p0->y * p1->y;
785 static inline void d2d_point_transform(D2D1_POINT_2F *dst, const D2D1_MATRIX_3X2_F *matrix, float x, float y)
787 dst->x = x * matrix->_11 + y * matrix->_21 + matrix->_31;
788 dst->y = x * matrix->_12 + y * matrix->_22 + matrix->_32;
791 static inline void d2d_rect_expand(D2D1_RECT_F *dst, const D2D1_POINT_2F *point)
793 if (point->x < dst->left)
794 dst->left = point->x;
795 if (point->x > dst->right)
796 dst->right = point->x;
797 if (point->y < dst->top)
798 dst->top = point->y;
799 if (point->y > dst->bottom)
800 dst->bottom = point->y;
803 static inline D2D1_INTERPOLATION_MODE d2d1_1_interp_mode_from_d2d1(D2D1_BITMAP_INTERPOLATION_MODE mode)
805 return (D2D1_INTERPOLATION_MODE)mode;
808 static inline const char *debug_d2d_color_f(const D2D1_COLOR_F *colour)
810 if (!colour)
811 return "(null)";
812 return wine_dbg_sprintf("{%.8e, %.8e, %.8e, %.8e}", colour->r, colour->g, colour->b, colour->a);
815 static inline const char *debug_d2d_point_2f(const D2D1_POINT_2F *point)
817 if (!point)
818 return "(null)";
819 return wine_dbg_sprintf("{%.8e, %.8e}", point->x, point->y);
822 static inline const char *debug_d2d_point_2l(const D2D1_POINT_2L *point)
824 if (!point)
825 return "(null)";
826 return wine_dbg_sprintf("{%ld, %ld}", point->x, point->y);
829 static inline const char *debug_d2d_rect_f(const D2D1_RECT_F *rect)
831 if (!rect)
832 return "(null)";
833 return wine_dbg_sprintf("(%.8e, %.8e)-(%.8e, %.8e)", rect->left, rect->top, rect->right, rect->bottom);
836 static inline const char *debug_d2d_rect_l(const D2D1_RECT_L *rect)
838 if (!rect)
839 return "(null)";
840 return wine_dbg_sprintf("(%ld, %ld)-(%ld, %ld)", rect->left, rect->top, rect->right, rect->bottom);
843 static inline const char *debug_d2d_rounded_rect(const D2D1_ROUNDED_RECT *rounded_rect)
845 if (!rounded_rect)
846 return "(null)";
847 return wine_dbg_sprintf("(%.8e, %.8e)-(%.8e, %.8e)[%.8e, %.8e]", rounded_rect->rect.left, rounded_rect->rect.top,
848 rounded_rect->rect.right, rounded_rect->rect.bottom, rounded_rect->radiusX, rounded_rect->radiusY);
851 static inline const char *debug_d2d_ellipse(const D2D1_ELLIPSE *ellipse)
853 if (!ellipse)
854 return "(null)";
855 return wine_dbg_sprintf("(%.8e, %.8e)[%.8e, %.8e]",
856 ellipse->point.x, ellipse->point.y, ellipse->radiusX, ellipse->radiusY);
859 #endif /* __WINE_D2D1_PRIVATE_H */