widl: Renamed --rt option to --winrt for midl compatibility.
[wine.git] / dlls / d2d1 / d2d1_private.h
blobcf98ff846c4dda9ea3144572145f06c731828780
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"
24 #include <assert.h>
25 #include <limits.h>
26 #define COBJMACROS
27 #include "d2d1.h"
28 #ifdef D2D1_INIT_GUID
29 #include "initguid.h"
30 #endif
31 #include "dwrite.h"
33 enum d2d_brush_type
35 D2D_BRUSH_TYPE_SOLID,
36 D2D_BRUSH_TYPE_LINEAR,
37 D2D_BRUSH_TYPE_BITMAP,
38 D2D_BRUSH_TYPE_COUNT,
41 enum d2d_shape_type
43 D2D_SHAPE_TYPE_TRIANGLE,
44 D2D_SHAPE_TYPE_BEZIER,
45 D2D_SHAPE_TYPE_COUNT,
48 struct d2d_clip_stack
50 D2D1_RECT_F *stack;
51 unsigned int size;
52 unsigned int count;
55 struct d2d_shape_resources
57 ID3D10InputLayout *il;
58 ID3D10VertexShader *vs;
59 ID3D10PixelShader *ps[D2D_BRUSH_TYPE_COUNT];
62 struct d2d_d3d_render_target
64 ID2D1RenderTarget ID2D1RenderTarget_iface;
65 IDWriteTextRenderer IDWriteTextRenderer_iface;
66 LONG refcount;
68 ID2D1Factory *factory;
69 ID3D10Device *device;
70 ID3D10RenderTargetView *view;
71 ID3D10StateBlock *stateblock;
72 struct d2d_shape_resources shape_resources[D2D_SHAPE_TYPE_COUNT];
73 ID3D10Buffer *ib;
74 unsigned int vb_stride;
75 ID3D10Buffer *vb;
76 ID3D10RasterizerState *rs;
77 ID3D10BlendState *bs;
79 D2D1_DRAWING_STATE_DESCRIPTION drawing_state;
80 IDWriteRenderingParams *text_rendering_params;
82 D2D1_PIXEL_FORMAT format;
83 D2D1_SIZE_U pixel_size;
84 struct d2d_clip_stack clip_stack;
85 float dpi_x;
86 float dpi_y;
89 HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_target, ID2D1Factory *factory,
90 IDXGISurface *surface, const D2D1_RENDER_TARGET_PROPERTIES *desc) DECLSPEC_HIDDEN;
92 struct d2d_wic_render_target
94 ID2D1RenderTarget ID2D1RenderTarget_iface;
95 LONG refcount;
97 IDXGISurface *dxgi_surface;
98 ID2D1RenderTarget *dxgi_target;
99 ID3D10Texture2D *readback_texture;
100 IWICBitmap *bitmap;
102 unsigned int width;
103 unsigned int height;
104 unsigned int bpp;
107 HRESULT d2d_wic_render_target_init(struct d2d_wic_render_target *render_target, ID2D1Factory *factory,
108 IWICBitmap *bitmap, const D2D1_RENDER_TARGET_PROPERTIES *desc) DECLSPEC_HIDDEN;
110 struct d2d_gradient
112 ID2D1GradientStopCollection ID2D1GradientStopCollection_iface;
113 LONG refcount;
115 D2D1_GRADIENT_STOP *stops;
116 UINT32 stop_count;
119 HRESULT d2d_gradient_init(struct d2d_gradient *gradient, ID2D1RenderTarget *render_target,
120 const D2D1_GRADIENT_STOP *stops, UINT32 stop_count, D2D1_GAMMA gamma,
121 D2D1_EXTEND_MODE extend_mode) DECLSPEC_HIDDEN;
123 struct d2d_brush
125 ID2D1Brush ID2D1Brush_iface;
126 LONG refcount;
128 float opacity;
129 D2D1_MATRIX_3X2_F transform;
131 enum d2d_brush_type type;
132 union
134 struct
136 D2D1_COLOR_F color;
137 } solid;
138 struct
140 struct d2d_bitmap *bitmap;
141 D2D1_EXTEND_MODE extend_mode_x;
142 D2D1_EXTEND_MODE extend_mode_y;
143 D2D1_BITMAP_INTERPOLATION_MODE interpolation_mode;
144 ID3D10SamplerState *sampler_state;
145 } bitmap;
146 } u;
149 void d2d_solid_color_brush_init(struct d2d_brush *brush, ID2D1RenderTarget *render_target,
150 const D2D1_COLOR_F *color, const D2D1_BRUSH_PROPERTIES *desc) DECLSPEC_HIDDEN;
151 void d2d_linear_gradient_brush_init(struct d2d_brush *brush, ID2D1RenderTarget *render_target,
152 const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES *gradient_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
153 ID2D1GradientStopCollection *gradient) DECLSPEC_HIDDEN;
154 HRESULT d2d_bitmap_brush_init(struct d2d_brush *brush, struct d2d_d3d_render_target *render_target,
155 ID2D1Bitmap *bitmap, const D2D1_BITMAP_BRUSH_PROPERTIES *bitmap_brush_desc,
156 const D2D1_BRUSH_PROPERTIES *brush_desc) DECLSPEC_HIDDEN;
157 void d2d_brush_bind_resources(struct d2d_brush *brush, struct d2d_d3d_render_target *render_target,
158 enum d2d_shape_type shape_type) DECLSPEC_HIDDEN;
159 HRESULT d2d_brush_get_ps_cb(struct d2d_brush *brush, struct d2d_d3d_render_target *render_target,
160 ID3D10Buffer **ps_cb) DECLSPEC_HIDDEN;
161 struct d2d_brush *unsafe_impl_from_ID2D1Brush(ID2D1Brush *iface) DECLSPEC_HIDDEN;
163 struct d2d_stroke_style
165 ID2D1StrokeStyle ID2D1StrokeStyle_iface;
166 LONG refcount;
168 ID2D1Factory *factory;
171 void d2d_stroke_style_init(struct d2d_stroke_style *style, ID2D1Factory *factory,
172 const D2D1_STROKE_STYLE_PROPERTIES *desc, const float *dashes, UINT32 dash_count) DECLSPEC_HIDDEN;
174 struct d2d_mesh
176 ID2D1Mesh ID2D1Mesh_iface;
177 LONG refcount;
180 void d2d_mesh_init(struct d2d_mesh *mesh) DECLSPEC_HIDDEN;
182 struct d2d_bitmap
184 ID2D1Bitmap ID2D1Bitmap_iface;
185 LONG refcount;
187 ID3D10ShaderResourceView *view;
188 D2D1_SIZE_U pixel_size;
189 D2D1_PIXEL_FORMAT format;
190 float dpi_x;
191 float dpi_y;
194 HRESULT d2d_bitmap_init(struct d2d_bitmap *bitmap, struct d2d_d3d_render_target *render_target,
195 D2D1_SIZE_U size, const void *src_data, UINT32 pitch, const D2D1_BITMAP_PROPERTIES *desc) DECLSPEC_HIDDEN;
196 struct d2d_bitmap *unsafe_impl_from_ID2D1Bitmap(ID2D1Bitmap *iface) DECLSPEC_HIDDEN;
198 struct d2d_state_block
200 ID2D1DrawingStateBlock ID2D1DrawingStateBlock_iface;
201 LONG refcount;
203 D2D1_DRAWING_STATE_DESCRIPTION drawing_state;
204 IDWriteRenderingParams *text_rendering_params;
207 void d2d_state_block_init(struct d2d_state_block *state_block, const D2D1_DRAWING_STATE_DESCRIPTION *desc,
208 IDWriteRenderingParams *text_rendering_params) DECLSPEC_HIDDEN;
209 struct d2d_state_block *unsafe_impl_from_ID2D1DrawingStateBlock(ID2D1DrawingStateBlock *iface) DECLSPEC_HIDDEN;
211 enum d2d_geometry_state
213 D2D_GEOMETRY_STATE_INITIAL = 0,
214 D2D_GEOMETRY_STATE_ERROR,
215 D2D_GEOMETRY_STATE_OPEN,
216 D2D_GEOMETRY_STATE_CLOSED,
217 D2D_GEOMETRY_STATE_FIGURE,
220 struct d2d_bezier
222 struct
224 D2D1_POINT_2F position;
225 struct
227 float u, v, sign;
228 } texcoord;
229 } v[3];
232 struct d2d_face
234 UINT16 v[3];
237 struct d2d_geometry
239 ID2D1Geometry ID2D1Geometry_iface;
240 LONG refcount;
242 D2D1_POINT_2F *vertices;
243 size_t vertex_count;
245 struct d2d_face *faces;
246 size_t faces_size;
247 size_t face_count;
249 struct d2d_bezier *beziers;
250 size_t bezier_count;
252 union
254 struct
256 ID2D1GeometrySink ID2D1GeometrySink_iface;
258 struct d2d_figure *figures;
259 size_t figures_size;
260 size_t figure_count;
262 enum d2d_geometry_state state;
263 D2D1_FILL_MODE fill_mode;
264 UINT32 segment_count;
265 } path;
266 struct
268 D2D1_RECT_F rect;
269 } rectangle;
270 } u;
273 void d2d_path_geometry_init(struct d2d_geometry *geometry) DECLSPEC_HIDDEN;
274 HRESULT d2d_rectangle_geometry_init(struct d2d_geometry *geometry, const D2D1_RECT_F *rect) DECLSPEC_HIDDEN;
275 struct d2d_geometry *unsafe_impl_from_ID2D1Geometry(ID2D1Geometry *iface) DECLSPEC_HIDDEN;
277 static inline void d2d_matrix_multiply(D2D_MATRIX_3X2_F *a, const D2D_MATRIX_3X2_F *b)
279 D2D_MATRIX_3X2_F tmp = *a;
281 a->_11 = tmp._11 * b->_11 + tmp._12 * b->_21;
282 a->_12 = tmp._11 * b->_12 + tmp._12 * b->_22;
283 a->_21 = tmp._21 * b->_11 + tmp._22 * b->_21;
284 a->_22 = tmp._21 * b->_12 + tmp._22 * b->_22;
285 a->_31 = tmp._31 * b->_11 + tmp._32 * b->_21 + b->_31;
286 a->_32 = tmp._31 * b->_12 + tmp._32 * b->_22 + b->_32;
289 #endif /* __WINE_D2D1_PRIVATE_H */