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_TRIANGLE
,
44 D2D_SHAPE_TYPE_BEZIER
,
55 struct d2d_error_state
61 struct d2d_shape_resources
63 ID3D10InputLayout
*il
;
64 ID3D10VertexShader
*vs
;
65 ID3D10PixelShader
*ps
[D2D_BRUSH_TYPE_COUNT
][D2D_BRUSH_TYPE_COUNT
+ 1];
68 struct d2d_d3d_render_target
70 ID2D1RenderTarget ID2D1RenderTarget_iface
;
71 IDWriteTextRenderer IDWriteTextRenderer_iface
;
74 ID2D1Factory
*factory
;
76 ID3D10RenderTargetView
*view
;
77 ID3D10StateBlock
*stateblock
;
78 struct d2d_shape_resources shape_resources
[D2D_SHAPE_TYPE_COUNT
];
80 unsigned int vb_stride
;
82 ID3D10RasterizerState
*rs
;
85 struct d2d_error_state error
;
86 D2D1_DRAWING_STATE_DESCRIPTION drawing_state
;
87 IDWriteRenderingParams
*text_rendering_params
;
88 IDWriteRenderingParams
*default_text_rendering_params
;
90 D2D1_PIXEL_FORMAT format
;
91 D2D1_SIZE_U pixel_size
;
92 struct d2d_clip_stack clip_stack
;
97 HRESULT
d2d_d3d_render_target_init(struct d2d_d3d_render_target
*render_target
, ID2D1Factory
*factory
,
98 IDXGISurface
*surface
, const D2D1_RENDER_TARGET_PROPERTIES
*desc
) DECLSPEC_HIDDEN
;
100 struct d2d_wic_render_target
102 ID2D1RenderTarget ID2D1RenderTarget_iface
;
105 IDXGISurface
*dxgi_surface
;
106 ID2D1RenderTarget
*dxgi_target
;
107 ID3D10Texture2D
*readback_texture
;
115 HRESULT
d2d_wic_render_target_init(struct d2d_wic_render_target
*render_target
, ID2D1Factory
*factory
,
116 ID3D10Device1
*device
, IWICBitmap
*bitmap
, const D2D1_RENDER_TARGET_PROPERTIES
*desc
) DECLSPEC_HIDDEN
;
120 ID2D1GradientStopCollection ID2D1GradientStopCollection_iface
;
123 ID2D1Factory
*factory
;
124 D2D1_GRADIENT_STOP
*stops
;
128 HRESULT
d2d_gradient_init(struct d2d_gradient
*gradient
, ID2D1Factory
*factory
,
129 const D2D1_GRADIENT_STOP
*stops
, UINT32 stop_count
, D2D1_GAMMA gamma
,
130 D2D1_EXTEND_MODE extend_mode
) DECLSPEC_HIDDEN
;
134 ID2D1Brush ID2D1Brush_iface
;
137 ID2D1Factory
*factory
;
139 D2D1_MATRIX_3X2_F transform
;
141 enum d2d_brush_type type
;
150 struct d2d_bitmap
*bitmap
;
151 D2D1_EXTEND_MODE extend_mode_x
;
152 D2D1_EXTEND_MODE extend_mode_y
;
153 D2D1_BITMAP_INTERPOLATION_MODE interpolation_mode
;
154 ID3D10SamplerState
*sampler_state
;
159 void d2d_solid_color_brush_init(struct d2d_brush
*brush
, ID2D1Factory
*factory
,
160 const D2D1_COLOR_F
*color
, const D2D1_BRUSH_PROPERTIES
*desc
) DECLSPEC_HIDDEN
;
161 void d2d_linear_gradient_brush_init(struct d2d_brush
*brush
, ID2D1Factory
*factory
,
162 const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES
*gradient_brush_desc
, const D2D1_BRUSH_PROPERTIES
*brush_desc
,
163 ID2D1GradientStopCollection
*gradient
) DECLSPEC_HIDDEN
;
164 void d2d_bitmap_brush_init(struct d2d_brush
*brush
, ID2D1Factory
*factory
,
165 ID2D1Bitmap
*bitmap
, const D2D1_BITMAP_BRUSH_PROPERTIES
*bitmap_brush_desc
,
166 const D2D1_BRUSH_PROPERTIES
*brush_desc
) DECLSPEC_HIDDEN
;
167 void d2d_brush_bind_resources(struct d2d_brush
*brush
, struct d2d_brush
*opacity_brush
,
168 struct d2d_d3d_render_target
*render_target
, enum d2d_shape_type shape_type
) DECLSPEC_HIDDEN
;
169 HRESULT
d2d_brush_get_ps_cb(struct d2d_brush
*brush
, struct d2d_brush
*opacity_brush
,
170 struct d2d_d3d_render_target
*render_target
, ID3D10Buffer
**ps_cb
) DECLSPEC_HIDDEN
;
171 struct d2d_brush
*unsafe_impl_from_ID2D1Brush(ID2D1Brush
*iface
) DECLSPEC_HIDDEN
;
173 struct d2d_stroke_style
175 ID2D1StrokeStyle ID2D1StrokeStyle_iface
;
178 ID2D1Factory
*factory
;
181 void d2d_stroke_style_init(struct d2d_stroke_style
*style
, ID2D1Factory
*factory
,
182 const D2D1_STROKE_STYLE_PROPERTIES
*desc
, const float *dashes
, UINT32 dash_count
) DECLSPEC_HIDDEN
;
186 ID2D1Mesh ID2D1Mesh_iface
;
189 ID2D1Factory
*factory
;
192 void d2d_mesh_init(struct d2d_mesh
*mesh
, ID2D1Factory
*factory
) DECLSPEC_HIDDEN
;
196 ID2D1Bitmap ID2D1Bitmap_iface
;
199 ID2D1Factory
*factory
;
200 ID3D10ShaderResourceView
*view
;
201 D2D1_SIZE_U pixel_size
;
202 D2D1_PIXEL_FORMAT format
;
207 HRESULT
d2d_bitmap_init_memory(struct d2d_bitmap
*bitmap
, struct d2d_d3d_render_target
*render_target
,
208 D2D1_SIZE_U size
, const void *src_data
, UINT32 pitch
, const D2D1_BITMAP_PROPERTIES
*desc
) DECLSPEC_HIDDEN
;
209 HRESULT
d2d_bitmap_init_shared(struct d2d_bitmap
*bitmap
, struct d2d_d3d_render_target
*render_target
,
210 REFIID iid
, void *data
, const D2D1_BITMAP_PROPERTIES
*desc
) DECLSPEC_HIDDEN
;
211 struct d2d_bitmap
*unsafe_impl_from_ID2D1Bitmap(ID2D1Bitmap
*iface
) DECLSPEC_HIDDEN
;
213 struct d2d_state_block
215 ID2D1DrawingStateBlock ID2D1DrawingStateBlock_iface
;
218 ID2D1Factory
*factory
;
219 D2D1_DRAWING_STATE_DESCRIPTION drawing_state
;
220 IDWriteRenderingParams
*text_rendering_params
;
223 void d2d_state_block_init(struct d2d_state_block
*state_block
, ID2D1Factory
*factory
,
224 const D2D1_DRAWING_STATE_DESCRIPTION
*desc
, IDWriteRenderingParams
*text_rendering_params
) DECLSPEC_HIDDEN
;
225 struct d2d_state_block
*unsafe_impl_from_ID2D1DrawingStateBlock(ID2D1DrawingStateBlock
*iface
) DECLSPEC_HIDDEN
;
227 enum d2d_geometry_state
229 D2D_GEOMETRY_STATE_INITIAL
= 0,
230 D2D_GEOMETRY_STATE_ERROR
,
231 D2D_GEOMETRY_STATE_OPEN
,
232 D2D_GEOMETRY_STATE_CLOSED
,
233 D2D_GEOMETRY_STATE_FIGURE
,
240 D2D1_POINT_2F position
;
255 ID2D1Geometry ID2D1Geometry_iface
;
258 ID2D1Factory
*factory
;
260 D2D_MATRIX_3X2_F transform
;
262 D2D1_POINT_2F
*vertices
;
265 struct d2d_face
*faces
;
269 struct d2d_bezier
*beziers
;
276 ID2D1GeometrySink ID2D1GeometrySink_iface
;
278 struct d2d_figure
*figures
;
282 enum d2d_geometry_state state
;
283 D2D1_FILL_MODE fill_mode
;
284 UINT32 segment_count
;
292 ID2D1Geometry
*src_geometry
;
297 void d2d_path_geometry_init(struct d2d_geometry
*geometry
, ID2D1Factory
*factory
) DECLSPEC_HIDDEN
;
298 HRESULT
d2d_rectangle_geometry_init(struct d2d_geometry
*geometry
,
299 ID2D1Factory
*factory
, const D2D1_RECT_F
*rect
) DECLSPEC_HIDDEN
;
300 void d2d_transformed_geometry_init(struct d2d_geometry
*geometry
, ID2D1Factory
*factory
,
301 ID2D1Geometry
*src_geometry
, const D2D_MATRIX_3X2_F
*transform
) DECLSPEC_HIDDEN
;
302 struct d2d_geometry
*unsafe_impl_from_ID2D1Geometry(ID2D1Geometry
*iface
) DECLSPEC_HIDDEN
;
304 static inline void d2d_matrix_multiply(D2D_MATRIX_3X2_F
*a
, const D2D_MATRIX_3X2_F
*b
)
306 D2D_MATRIX_3X2_F tmp
= *a
;
308 a
->_11
= tmp
._11
* b
->_11
+ tmp
._12
* b
->_21
;
309 a
->_12
= tmp
._11
* b
->_12
+ tmp
._12
* b
->_22
;
310 a
->_21
= tmp
._21
* b
->_11
+ tmp
._22
* b
->_21
;
311 a
->_22
= tmp
._21
* b
->_12
+ tmp
._22
* b
->_22
;
312 a
->_31
= tmp
._31
* b
->_11
+ tmp
._32
* b
->_21
+ b
->_31
;
313 a
->_32
= tmp
._31
* b
->_12
+ tmp
._32
* b
->_22
+ b
->_32
;
316 #endif /* __WINE_D2D1_PRIVATE_H */