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"
36 D2D_BRUSH_TYPE_LINEAR
,
37 D2D_BRUSH_TYPE_BITMAP
,
43 D2D_SHAPE_TYPE_OUTLINE
,
44 D2D_SHAPE_TYPE_TRIANGLE
,
45 D2D_SHAPE_TYPE_BEZIER
,
56 struct d2d_error_state
62 struct d2d_shape_resources
64 ID3D10InputLayout
*il
;
65 ID3D10VertexShader
*vs
;
66 ID3D10PixelShader
*ps
[D2D_BRUSH_TYPE_COUNT
][D2D_BRUSH_TYPE_COUNT
+ 1];
69 struct d2d_d3d_render_target
71 ID2D1RenderTarget ID2D1RenderTarget_iface
;
72 ID2D1GdiInteropRenderTarget ID2D1GdiInteropRenderTarget_iface
;
73 IDWriteTextRenderer IDWriteTextRenderer_iface
;
76 IUnknown
*outer_unknown
;
78 ID2D1Factory
*factory
;
80 ID3D10RenderTargetView
*view
;
81 ID3D10StateBlock
*stateblock
;
82 struct d2d_shape_resources shape_resources
[D2D_SHAPE_TYPE_COUNT
];
84 unsigned int vb_stride
;
86 ID3D10RasterizerState
*rs
;
89 struct d2d_error_state error
;
90 D2D1_DRAWING_STATE_DESCRIPTION drawing_state
;
91 IDWriteRenderingParams
*text_rendering_params
;
92 IDWriteRenderingParams
*default_text_rendering_params
;
94 D2D1_RENDER_TARGET_PROPERTIES desc
;
95 D2D1_SIZE_U pixel_size
;
96 struct d2d_clip_stack clip_stack
;
99 HRESULT
d2d_d3d_create_render_target(ID2D1Factory
*factory
, IDXGISurface
*surface
, IUnknown
*outer_unknown
,
100 const D2D1_RENDER_TARGET_PROPERTIES
*desc
, ID2D1RenderTarget
**render_target
) DECLSPEC_HIDDEN
;
101 HRESULT
d2d_d3d_render_target_create_rtv(ID2D1RenderTarget
*render_target
, IDXGISurface1
*surface
) DECLSPEC_HIDDEN
;
103 struct d2d_wic_render_target
105 ID2D1RenderTarget ID2D1RenderTarget_iface
;
108 IDXGISurface
*dxgi_surface
;
109 ID2D1RenderTarget
*dxgi_target
;
110 ID3D10Texture2D
*readback_texture
;
118 HRESULT
d2d_wic_render_target_init(struct d2d_wic_render_target
*render_target
, ID2D1Factory
*factory
,
119 ID3D10Device1
*device
, IWICBitmap
*bitmap
, const D2D1_RENDER_TARGET_PROPERTIES
*desc
) DECLSPEC_HIDDEN
;
121 struct d2d_dc_render_target
123 ID2D1DCRenderTarget ID2D1DCRenderTarget_iface
;
126 IDXGISurface1
*dxgi_surface
;
127 ID2D1RenderTarget
*dxgi_target
;
133 HRESULT
d2d_dc_render_target_init(struct d2d_dc_render_target
*render_target
, ID2D1Factory
*factory
,
134 ID3D10Device1
*device
, const D2D1_RENDER_TARGET_PROPERTIES
*desc
) DECLSPEC_HIDDEN
;
136 struct d2d_hwnd_render_target
138 ID2D1HwndRenderTarget ID2D1HwndRenderTarget_iface
;
141 ID2D1RenderTarget
*dxgi_target
;
142 IDXGISwapChain
*swapchain
;
147 HRESULT
d2d_hwnd_render_target_init(struct d2d_hwnd_render_target
*render_target
, ID2D1Factory
*factory
,
148 ID3D10Device1
*device
, const D2D1_RENDER_TARGET_PROPERTIES
*desc
,
149 const D2D1_HWND_RENDER_TARGET_PROPERTIES
*hwnd_desc
) DECLSPEC_HIDDEN
;
151 struct d2d_bitmap_render_target
153 ID2D1BitmapRenderTarget ID2D1BitmapRenderTarget_iface
;
156 ID2D1RenderTarget
*dxgi_target
;
160 HRESULT
d2d_bitmap_render_target_init(struct d2d_bitmap_render_target
*render_target
,
161 const struct d2d_d3d_render_target
*parent_target
, const D2D1_SIZE_F
*size
,
162 const D2D1_SIZE_U
*pixel_size
, const D2D1_PIXEL_FORMAT
*format
,
163 D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS options
) DECLSPEC_HIDDEN
;
167 ID2D1GradientStopCollection ID2D1GradientStopCollection_iface
;
170 ID2D1Factory
*factory
;
171 D2D1_GRADIENT_STOP
*stops
;
175 HRESULT
d2d_gradient_create(ID2D1Factory
*factory
, const D2D1_GRADIENT_STOP
*stops
,
176 UINT32 stop_count
, D2D1_GAMMA gamma
, D2D1_EXTEND_MODE extend_mode
,
177 struct d2d_gradient
**gradient
) DECLSPEC_HIDDEN
;
181 ID2D1Brush ID2D1Brush_iface
;
184 ID2D1Factory
*factory
;
186 D2D1_MATRIX_3X2_F transform
;
188 enum d2d_brush_type type
;
197 struct d2d_bitmap
*bitmap
;
198 D2D1_EXTEND_MODE extend_mode_x
;
199 D2D1_EXTEND_MODE extend_mode_y
;
200 D2D1_BITMAP_INTERPOLATION_MODE interpolation_mode
;
201 ID3D10SamplerState
*sampler_state
;
205 D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES desc
;
206 ID2D1GradientStopCollection
*gradient
;
211 HRESULT
d2d_solid_color_brush_create(ID2D1Factory
*factory
, const D2D1_COLOR_F
*color
,
212 const D2D1_BRUSH_PROPERTIES
*desc
, struct d2d_brush
**brush
) DECLSPEC_HIDDEN
;
213 HRESULT
d2d_linear_gradient_brush_create(ID2D1Factory
*factory
, const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES
*gradient_brush_desc
,
214 const D2D1_BRUSH_PROPERTIES
*brush_desc
, ID2D1GradientStopCollection
*gradient
,
215 struct d2d_brush
**brush
) DECLSPEC_HIDDEN
;
216 HRESULT
d2d_bitmap_brush_create(ID2D1Factory
*factory
, ID2D1Bitmap
*bitmap
, const D2D1_BITMAP_BRUSH_PROPERTIES
*bitmap_brush_desc
,
217 const D2D1_BRUSH_PROPERTIES
*brush_desc
, struct d2d_brush
**brush
) DECLSPEC_HIDDEN
;
218 void d2d_brush_bind_resources(struct d2d_brush
*brush
, struct d2d_brush
*opacity_brush
,
219 struct d2d_d3d_render_target
*render_target
, enum d2d_shape_type shape_type
) DECLSPEC_HIDDEN
;
220 HRESULT
d2d_brush_get_ps_cb(struct d2d_brush
*brush
, struct d2d_brush
*opacity_brush
,
221 struct d2d_d3d_render_target
*render_target
, ID3D10Buffer
**ps_cb
) DECLSPEC_HIDDEN
;
222 struct d2d_brush
*unsafe_impl_from_ID2D1Brush(ID2D1Brush
*iface
) DECLSPEC_HIDDEN
;
224 struct d2d_stroke_style
226 ID2D1StrokeStyle ID2D1StrokeStyle_iface
;
229 ID2D1Factory
*factory
;
230 D2D1_STROKE_STYLE_PROPERTIES desc
;
235 HRESULT
d2d_stroke_style_init(struct d2d_stroke_style
*style
, ID2D1Factory
*factory
,
236 const D2D1_STROKE_STYLE_PROPERTIES
*desc
, const float *dashes
, UINT32 dash_count
) DECLSPEC_HIDDEN
;
240 ID2D1Mesh ID2D1Mesh_iface
;
243 ID2D1Factory
*factory
;
246 HRESULT
d2d_mesh_create(ID2D1Factory
*factory
, struct d2d_mesh
**mesh
) DECLSPEC_HIDDEN
;
250 ID2D1Bitmap ID2D1Bitmap_iface
;
253 ID2D1Factory
*factory
;
254 ID3D10ShaderResourceView
*view
;
255 D2D1_SIZE_U pixel_size
;
256 D2D1_PIXEL_FORMAT format
;
261 HRESULT
d2d_bitmap_create(ID2D1Factory
*factory
, ID3D10Device
*device
, D2D1_SIZE_U size
, const void *src_data
,
262 UINT32 pitch
, const D2D1_BITMAP_PROPERTIES
*desc
, struct d2d_bitmap
**bitmap
) DECLSPEC_HIDDEN
;
263 HRESULT
d2d_bitmap_create_shared(ID2D1RenderTarget
*render_target
, ID3D10Device
*device
, REFIID iid
, void *data
,
264 const D2D1_BITMAP_PROPERTIES
*desc
, struct d2d_bitmap
**bitmap
) DECLSPEC_HIDDEN
;
265 HRESULT
d2d_bitmap_create_from_wic_bitmap(ID2D1Factory
*factory
, ID3D10Device
*device
, IWICBitmapSource
*bitmap_source
,
266 const D2D1_BITMAP_PROPERTIES
*desc
, struct d2d_bitmap
**bitmap
) DECLSPEC_HIDDEN
;
267 struct d2d_bitmap
*unsafe_impl_from_ID2D1Bitmap(ID2D1Bitmap
*iface
) DECLSPEC_HIDDEN
;
269 struct d2d_state_block
271 ID2D1DrawingStateBlock ID2D1DrawingStateBlock_iface
;
274 ID2D1Factory
*factory
;
275 D2D1_DRAWING_STATE_DESCRIPTION drawing_state
;
276 IDWriteRenderingParams
*text_rendering_params
;
279 void d2d_state_block_init(struct d2d_state_block
*state_block
, ID2D1Factory
*factory
,
280 const D2D1_DRAWING_STATE_DESCRIPTION
*desc
, IDWriteRenderingParams
*text_rendering_params
) DECLSPEC_HIDDEN
;
281 struct d2d_state_block
*unsafe_impl_from_ID2D1DrawingStateBlock(ID2D1DrawingStateBlock
*iface
) DECLSPEC_HIDDEN
;
283 enum d2d_geometry_state
285 D2D_GEOMETRY_STATE_INITIAL
= 0,
286 D2D_GEOMETRY_STATE_ERROR
,
287 D2D_GEOMETRY_STATE_OPEN
,
288 D2D_GEOMETRY_STATE_CLOSED
,
289 D2D_GEOMETRY_STATE_FIGURE
,
292 struct d2d_bezier_vertex
294 D2D1_POINT_2F position
;
311 struct d2d_outline_vertex
313 D2D1_POINT_2F position
;
320 ID2D1Geometry ID2D1Geometry_iface
;
323 ID2D1Factory
*factory
;
325 D2D_MATRIX_3X2_F transform
;
329 D2D1_POINT_2F
*vertices
;
332 struct d2d_face
*faces
;
336 struct d2d_bezier_vertex
*bezier_vertices
;
337 size_t bezier_vertex_count
;
342 struct d2d_outline_vertex
*vertices
;
343 size_t vertices_size
;
346 struct d2d_face
*faces
;
355 ID2D1GeometrySink ID2D1GeometrySink_iface
;
357 struct d2d_figure
*figures
;
361 enum d2d_geometry_state state
;
362 D2D1_FILL_MODE fill_mode
;
363 UINT32 segment_count
;
371 ID2D1Geometry
*src_geometry
;
372 D2D_MATRIX_3X2_F transform
;
377 void d2d_path_geometry_init(struct d2d_geometry
*geometry
, ID2D1Factory
*factory
) DECLSPEC_HIDDEN
;
378 HRESULT
d2d_rectangle_geometry_init(struct d2d_geometry
*geometry
,
379 ID2D1Factory
*factory
, const D2D1_RECT_F
*rect
) DECLSPEC_HIDDEN
;
380 void d2d_transformed_geometry_init(struct d2d_geometry
*geometry
, ID2D1Factory
*factory
,
381 ID2D1Geometry
*src_geometry
, const D2D_MATRIX_3X2_F
*transform
) DECLSPEC_HIDDEN
;
382 struct d2d_geometry
*unsafe_impl_from_ID2D1Geometry(ID2D1Geometry
*iface
) DECLSPEC_HIDDEN
;
384 static inline void d2d_matrix_multiply(D2D_MATRIX_3X2_F
*a
, const D2D_MATRIX_3X2_F
*b
)
386 D2D_MATRIX_3X2_F tmp
= *a
;
388 a
->_11
= tmp
._11
* b
->_11
+ tmp
._12
* b
->_21
;
389 a
->_12
= tmp
._11
* b
->_12
+ tmp
._12
* b
->_22
;
390 a
->_21
= tmp
._21
* b
->_11
+ tmp
._22
* b
->_21
;
391 a
->_22
= tmp
._21
* b
->_12
+ tmp
._22
* b
->_22
;
392 a
->_31
= tmp
._31
* b
->_11
+ tmp
._32
* b
->_21
+ b
->_31
;
393 a
->_32
= tmp
._31
* b
->_12
+ tmp
._32
* b
->_22
+ b
->_32
;
396 /* Dst must be different from src. */
397 static inline BOOL
d2d_matrix_invert(D2D_MATRIX_3X2_F
*dst
, const D2D_MATRIX_3X2_F
*src
)
399 float d
= src
->_11
* src
->_22
- src
->_21
* src
->_12
;
403 dst
->_11
= src
->_22
/ d
;
404 dst
->_21
= -src
->_21
/ d
;
405 dst
->_31
= (src
->_21
* src
->_32
- src
->_31
* src
->_22
) / d
;
406 dst
->_12
= -src
->_12
/ d
;
407 dst
->_22
= src
->_11
/ d
;
408 dst
->_32
= -(src
->_11
* src
->_32
- src
->_31
* src
->_12
) / d
;
413 static inline void d2d_point_set(D2D1_POINT_2F
*dst
, float x
, float y
)
419 static inline void d2d_point_transform(D2D1_POINT_2F
*dst
, const D2D1_MATRIX_3X2_F
*matrix
, float x
, float y
)
421 dst
->x
= x
* matrix
->_11
+ y
* matrix
->_21
+ matrix
->_31
;
422 dst
->y
= x
* matrix
->_12
+ y
* matrix
->_22
+ matrix
->_32
;
425 #endif /* __WINE_D2D1_PRIVATE_H */