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_indexed_objects
173 struct d2d_device_context
175 ID2D1DeviceContext6 ID2D1DeviceContext6_iface
;
176 ID2D1GdiInteropRenderTarget ID2D1GdiInteropRenderTarget_iface
;
177 IDWriteTextRenderer IDWriteTextRenderer_iface
;
178 IUnknown IUnknown_iface
;
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
;
192 enum d2d_device_context_target_type type
;
195 struct d2d_bitmap
*bitmap
;
196 struct d2d_command_list
*command_list
;
200 struct d2d_shape_resources shape_resources
[D2D_SHAPE_TYPE_COUNT
];
202 ID3D11PixelShader
*ps
;
205 unsigned int vb_stride
;
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
;
240 IDXGISurface
*dxgi_surface
;
241 ID2D1RenderTarget
*dxgi_target
;
242 IUnknown
*dxgi_inner
;
243 ID3D10Texture2D
*readback_texture
;
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
;
259 IDXGISurface1
*dxgi_surface
;
260 ID3D10Device1
*d3d_device
;
261 ID2D1RenderTarget
*dxgi_target
;
262 IUnknown
*dxgi_inner
;
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
;
278 ID2D1RenderTarget
*dxgi_target
;
279 IUnknown
*dxgi_inner
;
280 IDXGISwapChain
*swapchain
;
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
;
296 ID2D1RenderTarget
*dxgi_target
;
297 IUnknown
*dxgi_inner
;
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
);
308 ID2D1GradientStopCollection ID2D1GradientStopCollection_iface
;
311 ID2D1Factory
*factory
;
312 ID3D11ShaderResourceView
*view
;
313 D2D1_GRADIENT_STOP
*stops
;
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
);
323 ID2D1Brush ID2D1Brush_iface
;
326 ID2D1Factory
*factory
;
328 D2D1_MATRIX_3X2_F transform
;
330 enum d2d_brush_type type
;
339 struct d2d_gradient
*gradient
;
345 struct d2d_gradient
*gradient
;
346 D2D1_POINT_2F centre
;
347 D2D1_POINT_2F offset
;
348 D2D1_POINT_2F radius
;
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
;
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
;
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
;
392 ID2D1Factory
*factory
;
393 D2D1_STROKE_STYLE_PROPERTIES1 desc
;
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
);
404 ID2D1Layer ID2D1Layer_iface
;
407 ID2D1Factory
*factory
;
411 HRESULT
d2d_layer_create(ID2D1Factory
*factory
, const D2D1_SIZE_F
*size
, struct d2d_layer
**layer
);
415 ID2D1Mesh ID2D1Mesh_iface
;
418 ID2D1Factory
*factory
;
421 HRESULT
d2d_mesh_create(ID2D1Factory
*factory
, struct d2d_mesh
**mesh
);
425 ID2D1Bitmap1 ID2D1Bitmap1_iface
;
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
;
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
;
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
;
487 struct d2d_outline_vertex
489 D2D1_POINT_2F position
;
494 struct d2d_curve_outline_vertex
496 D2D1_POINT_2F position
;
497 D2D1_POINT_2F p0
, p1
, p2
;
498 D2D1_POINT_2F prev
, next
;
503 ID2D1Geometry ID2D1Geometry_iface
;
506 ID2D1Factory
*factory
;
508 D2D_MATRIX_3X2_F transform
;
512 D2D1_POINT_2F
*vertices
;
515 struct d2d_face
*faces
;
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
;
530 struct d2d_outline_vertex
*vertices
;
531 size_t vertices_size
;
534 struct d2d_face
*faces
;
538 struct d2d_curve_outline_vertex
*beziers
;
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
;
550 struct d2d_face
*arc_faces
;
551 size_t arc_faces_size
;
552 size_t arc_face_count
;
559 D2D1_ELLIPSE ellipse
;
563 ID2D1GeometrySink ID2D1GeometrySink_iface
;
565 struct d2d_figure
*figures
;
569 enum d2d_geometry_state state
;
570 D2D1_FILL_MODE fill_mode
;
571 UINT32 segment_count
;
581 D2D1_ROUNDED_RECT rounded_rect
;
585 ID2D1Geometry
*src_geometry
;
586 D2D_MATRIX_3X2_F transform
;
590 ID2D1Geometry
**src_geometries
;
591 UINT32 geometry_count
;
592 D2D1_FILL_MODE fill_mode
;
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
);
612 ID2D1Device6 ID2D1Device6_iface
;
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
,
623 BOOL
d2d_device_get_indexed_object(struct d2d_indexed_objects
*objects
, const GUID
*id
,
625 void d2d_device_indexed_objects_clear(struct d2d_indexed_objects
*objects
);
627 struct d2d_effect_context
629 ID2D1EffectContext ID2D1EffectContext_iface
;
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
641 D2D1_PROPERTY_TYPE type
;
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
;
659 struct d2d_effect
*effect
;
661 struct d2d_effect_property
*properties
;
674 struct d2d_effect_registration
677 PD2D1_EFFECT_FACTORY factory
;
678 UINT32 registration_count
;
682 struct d2d_effect_properties
*properties
;
687 ID2D1Factory7 ID2D1Factory7_iface
;
688 ID2D1Multithread ID2D1Multithread_iface
;
691 ID3D10Device1
*device
;
697 INIT_ONCE init_builtins
;
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
);
719 ID2D1TransformNode ID2D1TransformNode_iface
;
724 D2D1_POINT_2L offset
;
725 D2D1_BLEND_DESCRIPTION blend_desc
;
728 D2D1_EXTEND_MODE mode_x
;
729 D2D1_EXTEND_MODE mode_y
;
737 enum d2d_render_info_mask
739 D2D_RENDER_INFO_PIXEL_SHADER
= 0x1,
742 struct d2d_render_info
744 ID2D1DrawInfo ID2D1DrawInfo_iface
;
751 struct d2d_transform_node
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
;
767 struct d2d_transform_graph
769 ID2D1TransformGraph ID2D1TransformGraph_iface
;
772 struct d2d_transform_node_connection
*inputs
;
773 unsigned int input_count
;
775 struct d2d_transform_node
*output
;
778 unsigned int passthrough_input
;
785 ID2D1Effect ID2D1Effect_iface
;
786 ID2D1Image ID2D1Image_iface
;
789 ID2D1EffectImpl
*impl
;
790 struct d2d_effect_properties properties
;
791 struct d2d_effect_context
*effect_context
;
792 struct d2d_transform_graph
*graph
;
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
;
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
;
831 ID2D1Factory
*factory
;
832 enum d2d_command_list_state state
;
839 size_t objects_count
;
840 size_t objects_capacity
;
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
;
898 if (count
<= *capacity
)
901 max_capacity
= ~(SIZE_T
)0 / size
;
902 if (count
> max_capacity
)
905 new_capacity
= max(4, *capacity
);
906 while (new_capacity
< count
&& new_capacity
<= max_capacity
/ 2)
908 if (new_capacity
< count
)
909 new_capacity
= max_capacity
;
911 if (!(new_elements
= realloc(*elements
, new_capacity
* size
)))
914 *elements
= new_elements
;
915 *capacity
= new_capacity
;
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
;
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
;
948 static inline void d2d_point_set(D2D1_POINT_2F
*dst
, float x
, float 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
)
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
)
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
)
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
)
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
)
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
)
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
)
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
)
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 */