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"
32 #include "d2d1effectauthor.h"
42 D2D_BRUSH_TYPE_LINEAR
,
43 D2D_BRUSH_TYPE_RADIAL
,
44 D2D_BRUSH_TYPE_BITMAP
,
51 D2D_SHAPE_TYPE_OUTLINE
,
52 D2D_SHAPE_TYPE_BEZIER_OUTLINE
,
53 D2D_SHAPE_TYPE_ARC_OUTLINE
,
54 D2D_SHAPE_TYPE_TRIANGLE
,
61 unsigned int max_version_factory
;
63 extern struct d2d_settings d2d_settings
;
72 struct d2d_error_state
78 struct d2d_shape_resources
80 ID3D11InputLayout
*il
;
81 ID3D11VertexShader
*vs
;
86 enum d2d_brush_type type
;
99 unsigned int stop_count
;
103 D2D1_POINT_2F centre
;
104 D2D1_POINT_2F offset
;
107 unsigned int stop_count
;
112 float _11
, _21
, _31
, pad
;
124 struct d2d_brush_cb colour_brush
;
125 struct d2d_brush_cb opacity_brush
;
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,
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
;
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
;
181 enum d2d_device_context_target_type type
;
184 struct d2d_bitmap
*bitmap
;
185 struct d2d_command_list
*command_list
;
189 struct d2d_shape_resources shape_resources
[D2D_SHAPE_TYPE_COUNT
];
191 ID3D11PixelShader
*ps
;
194 unsigned int vb_stride
;
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
;
227 IDXGISurface
*dxgi_surface
;
228 ID2D1RenderTarget
*dxgi_target
;
229 IUnknown
*dxgi_inner
;
230 ID3D10Texture2D
*readback_texture
;
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
;
246 IDXGISurface1
*dxgi_surface
;
247 ID3D10Device1
*d3d_device
;
248 ID2D1RenderTarget
*dxgi_target
;
249 IUnknown
*dxgi_inner
;
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
;
265 ID2D1RenderTarget
*dxgi_target
;
266 IUnknown
*dxgi_inner
;
267 IDXGISwapChain
*swapchain
;
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
;
283 ID2D1RenderTarget
*dxgi_target
;
284 IUnknown
*dxgi_inner
;
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
);
295 ID2D1GradientStopCollection ID2D1GradientStopCollection_iface
;
298 ID2D1Factory
*factory
;
299 ID3D11ShaderResourceView
*view
;
300 D2D1_GRADIENT_STOP
*stops
;
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
);
310 ID2D1Brush ID2D1Brush_iface
;
313 ID2D1Factory
*factory
;
315 D2D1_MATRIX_3X2_F transform
;
317 enum d2d_brush_type type
;
326 struct d2d_gradient
*gradient
;
332 struct d2d_gradient
*gradient
;
333 D2D1_POINT_2F centre
;
334 D2D1_POINT_2F offset
;
335 D2D1_POINT_2F radius
;
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
;
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
;
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
;
379 ID2D1Factory
*factory
;
380 D2D1_STROKE_STYLE_PROPERTIES1 desc
;
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
);
391 ID2D1Layer ID2D1Layer_iface
;
394 ID2D1Factory
*factory
;
398 HRESULT
d2d_layer_create(ID2D1Factory
*factory
, const D2D1_SIZE_F
*size
, struct d2d_layer
**layer
);
402 ID2D1Mesh ID2D1Mesh_iface
;
405 ID2D1Factory
*factory
;
408 HRESULT
d2d_mesh_create(ID2D1Factory
*factory
, struct d2d_mesh
**mesh
);
412 ID2D1Bitmap1 ID2D1Bitmap1_iface
;
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
;
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
;
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
;
474 struct d2d_outline_vertex
476 D2D1_POINT_2F position
;
481 struct d2d_curve_outline_vertex
483 D2D1_POINT_2F position
;
484 D2D1_POINT_2F p0
, p1
, p2
;
485 D2D1_POINT_2F prev
, next
;
490 ID2D1Geometry ID2D1Geometry_iface
;
493 ID2D1Factory
*factory
;
495 D2D_MATRIX_3X2_F transform
;
499 D2D1_POINT_2F
*vertices
;
502 struct d2d_face
*faces
;
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
;
517 struct d2d_outline_vertex
*vertices
;
518 size_t vertices_size
;
521 struct d2d_face
*faces
;
525 struct d2d_curve_outline_vertex
*beziers
;
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
;
537 struct d2d_face
*arc_faces
;
538 size_t arc_faces_size
;
539 size_t arc_face_count
;
546 D2D1_ELLIPSE ellipse
;
550 ID2D1GeometrySink ID2D1GeometrySink_iface
;
552 struct d2d_figure
*figures
;
556 enum d2d_geometry_state state
;
557 D2D1_FILL_MODE fill_mode
;
558 UINT32 segment_count
;
568 D2D1_ROUNDED_RECT rounded_rect
;
572 ID2D1Geometry
*src_geometry
;
573 D2D_MATRIX_3X2_F transform
;
577 ID2D1Geometry
**src_geometries
;
578 UINT32 geometry_count
;
579 D2D1_FILL_MODE fill_mode
;
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
);
605 ID2D1Device1 ID2D1Device1_iface
;
607 ID2D1Factory1
*factory
;
608 IDXGIDevice
*dxgi_device
;
612 struct d2d_shader
*objects
;
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
;
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
637 D2D1_PROPERTY_TYPE type
;
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
;
669 struct d2d_effect_registration
672 PD2D1_EFFECT_FACTORY factory
;
673 UINT32 registration_count
;
677 struct d2d_effect_properties properties
;
682 ID2D1Factory3 ID2D1Factory3_iface
;
683 ID2D1Multithread ID2D1Multithread_iface
;
686 ID3D10Device1
*device
;
692 INIT_ONCE init_builtins
;
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
);
713 ID2D1TransformNode ID2D1TransformNode_iface
;
718 D2D1_POINT_2L offset
;
719 D2D1_BLEND_DESCRIPTION blend_desc
;
725 struct d2d_transform_node
728 ID2D1TransformNode
*object
;
731 struct d2d_transform_node_connection
733 struct d2d_transform_node
*node
;
737 struct d2d_transform_graph
739 ID2D1TransformGraph ID2D1TransformGraph_iface
;
742 struct d2d_transform_node_connection
*inputs
;
743 unsigned int input_count
;
745 struct d2d_transform_node
*output
;
752 ID2D1Effect ID2D1Effect_iface
;
753 ID2D1Image ID2D1Image_iface
;
756 ID2D1EffectImpl
*impl
;
757 struct d2d_effect_properties properties
;
758 struct d2d_effect_context
*effect_context
;
759 struct d2d_transform_graph
*graph
;
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
;
791 ID2D1Factory
*factory
;
792 enum d2d_command_list_state state
;
799 size_t objects_count
;
800 size_t objects_capacity
;
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
;
858 if (count
<= *capacity
)
861 max_capacity
= ~(SIZE_T
)0 / size
;
862 if (count
> max_capacity
)
865 new_capacity
= max(4, *capacity
);
866 while (new_capacity
< count
&& new_capacity
<= max_capacity
/ 2)
868 if (new_capacity
< count
)
869 new_capacity
= max_capacity
;
871 if (!(new_elements
= realloc(*elements
, new_capacity
* size
)))
874 *elements
= new_elements
;
875 *capacity
= new_capacity
;
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
;
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
;
908 static inline void d2d_point_set(D2D1_POINT_2F
*dst
, float x
, float 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
)
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
)
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
)
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
)
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
)
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
)
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
)
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
)
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 */