winebus.sys: Add stub driver.
[wine.git] / dlls / d2d1 / d2d1_private.h
blobf0577ed7dbf8aeba6ad4ab9afa08e8cfb426ed60
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_error_state
57 HRESULT code;
58 D2D1_TAG tag1, tag2;
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;
72 LONG refcount;
74 ID2D1Factory *factory;
75 ID3D10Device *device;
76 ID3D10RenderTargetView *view;
77 ID3D10StateBlock *stateblock;
78 struct d2d_shape_resources shape_resources[D2D_SHAPE_TYPE_COUNT];
79 ID3D10Buffer *ib;
80 unsigned int vb_stride;
81 ID3D10Buffer *vb;
82 ID3D10RasterizerState *rs;
83 ID3D10BlendState *bs;
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;
93 float dpi_x;
94 float dpi_y;
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;
103 LONG refcount;
105 IDXGISurface *dxgi_surface;
106 ID2D1RenderTarget *dxgi_target;
107 ID3D10Texture2D *readback_texture;
108 IWICBitmap *bitmap;
110 unsigned int width;
111 unsigned int height;
112 unsigned int bpp;
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;
118 struct d2d_gradient
120 ID2D1GradientStopCollection ID2D1GradientStopCollection_iface;
121 LONG refcount;
123 ID2D1Factory *factory;
124 D2D1_GRADIENT_STOP *stops;
125 UINT32 stop_count;
128 HRESULT d2d_gradient_create(ID2D1Factory *factory, const D2D1_GRADIENT_STOP *stops,
129 UINT32 stop_count, D2D1_GAMMA gamma, D2D1_EXTEND_MODE extend_mode,
130 struct d2d_gradient **gradient) DECLSPEC_HIDDEN;
132 struct d2d_brush
134 ID2D1Brush ID2D1Brush_iface;
135 LONG refcount;
137 ID2D1Factory *factory;
138 float opacity;
139 D2D1_MATRIX_3X2_F transform;
141 enum d2d_brush_type type;
142 union
144 struct
146 D2D1_COLOR_F color;
147 } solid;
148 struct
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;
155 } bitmap;
156 } u;
159 HRESULT d2d_solid_color_brush_create(ID2D1Factory *factory, const D2D1_COLOR_F *color,
160 const D2D1_BRUSH_PROPERTIES *desc, struct d2d_brush **brush) DECLSPEC_HIDDEN;
161 HRESULT d2d_linear_gradient_brush_create(ID2D1Factory *factory, const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES *gradient_brush_desc,
162 const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1GradientStopCollection *gradient,
163 struct d2d_brush **brush) DECLSPEC_HIDDEN;
164 HRESULT d2d_bitmap_brush_create(ID2D1Factory *factory, ID2D1Bitmap *bitmap, const D2D1_BITMAP_BRUSH_PROPERTIES *bitmap_brush_desc,
165 const D2D1_BRUSH_PROPERTIES *brush_desc, struct d2d_brush **brush) DECLSPEC_HIDDEN;
166 void d2d_brush_bind_resources(struct d2d_brush *brush, struct d2d_brush *opacity_brush,
167 struct d2d_d3d_render_target *render_target, enum d2d_shape_type shape_type) DECLSPEC_HIDDEN;
168 HRESULT d2d_brush_get_ps_cb(struct d2d_brush *brush, struct d2d_brush *opacity_brush,
169 struct d2d_d3d_render_target *render_target, ID3D10Buffer **ps_cb) DECLSPEC_HIDDEN;
170 struct d2d_brush *unsafe_impl_from_ID2D1Brush(ID2D1Brush *iface) DECLSPEC_HIDDEN;
172 struct d2d_stroke_style
174 ID2D1StrokeStyle ID2D1StrokeStyle_iface;
175 LONG refcount;
177 ID2D1Factory *factory;
180 void d2d_stroke_style_init(struct d2d_stroke_style *style, ID2D1Factory *factory,
181 const D2D1_STROKE_STYLE_PROPERTIES *desc, const float *dashes, UINT32 dash_count) DECLSPEC_HIDDEN;
183 struct d2d_mesh
185 ID2D1Mesh ID2D1Mesh_iface;
186 LONG refcount;
188 ID2D1Factory *factory;
191 HRESULT d2d_mesh_create(ID2D1Factory *factory, struct d2d_mesh **mesh) DECLSPEC_HIDDEN;
193 struct d2d_bitmap
195 ID2D1Bitmap ID2D1Bitmap_iface;
196 LONG refcount;
198 ID2D1Factory *factory;
199 ID3D10ShaderResourceView *view;
200 D2D1_SIZE_U pixel_size;
201 D2D1_PIXEL_FORMAT format;
202 float dpi_x;
203 float dpi_y;
206 HRESULT d2d_bitmap_create(ID2D1Factory *factory, ID3D10Device *device, D2D1_SIZE_U size, const void *src_data,
207 UINT32 pitch, const D2D1_BITMAP_PROPERTIES *desc, struct d2d_bitmap **bitmap) DECLSPEC_HIDDEN;
208 HRESULT d2d_bitmap_create_shared(ID2D1Factory *factory, ID3D10Device *device, REFIID iid, void *data,
209 const D2D1_BITMAP_PROPERTIES *desc, struct d2d_bitmap **bitmap) DECLSPEC_HIDDEN;
210 HRESULT d2d_bitmap_create_from_wic_bitmap(ID2D1Factory *factory, ID3D10Device *device, IWICBitmapSource *bitmap_source,
211 const D2D1_BITMAP_PROPERTIES *desc, struct d2d_bitmap **bitmap) DECLSPEC_HIDDEN;
212 struct d2d_bitmap *unsafe_impl_from_ID2D1Bitmap(ID2D1Bitmap *iface) DECLSPEC_HIDDEN;
214 struct d2d_state_block
216 ID2D1DrawingStateBlock ID2D1DrawingStateBlock_iface;
217 LONG refcount;
219 ID2D1Factory *factory;
220 D2D1_DRAWING_STATE_DESCRIPTION drawing_state;
221 IDWriteRenderingParams *text_rendering_params;
224 void d2d_state_block_init(struct d2d_state_block *state_block, ID2D1Factory *factory,
225 const D2D1_DRAWING_STATE_DESCRIPTION *desc, IDWriteRenderingParams *text_rendering_params) DECLSPEC_HIDDEN;
226 struct d2d_state_block *unsafe_impl_from_ID2D1DrawingStateBlock(ID2D1DrawingStateBlock *iface) DECLSPEC_HIDDEN;
228 enum d2d_geometry_state
230 D2D_GEOMETRY_STATE_INITIAL = 0,
231 D2D_GEOMETRY_STATE_ERROR,
232 D2D_GEOMETRY_STATE_OPEN,
233 D2D_GEOMETRY_STATE_CLOSED,
234 D2D_GEOMETRY_STATE_FIGURE,
237 struct d2d_bezier
239 struct
241 D2D1_POINT_2F position;
242 struct
244 float u, v, sign;
245 } texcoord;
246 } v[3];
249 struct d2d_face
251 UINT16 v[3];
254 struct d2d_geometry
256 ID2D1Geometry ID2D1Geometry_iface;
257 LONG refcount;
259 ID2D1Factory *factory;
261 D2D_MATRIX_3X2_F transform;
263 D2D1_POINT_2F *vertices;
264 size_t vertex_count;
266 struct d2d_face *faces;
267 size_t faces_size;
268 size_t face_count;
270 struct d2d_bezier *beziers;
271 size_t bezier_count;
273 union
275 struct
277 ID2D1GeometrySink ID2D1GeometrySink_iface;
279 struct d2d_figure *figures;
280 size_t figures_size;
281 size_t figure_count;
283 enum d2d_geometry_state state;
284 D2D1_FILL_MODE fill_mode;
285 UINT32 segment_count;
286 } path;
287 struct
289 D2D1_RECT_F rect;
290 } rectangle;
291 struct
293 ID2D1Geometry *src_geometry;
294 } transformed;
295 } u;
298 void d2d_path_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *factory) DECLSPEC_HIDDEN;
299 HRESULT d2d_rectangle_geometry_init(struct d2d_geometry *geometry,
300 ID2D1Factory *factory, const D2D1_RECT_F *rect) DECLSPEC_HIDDEN;
301 void d2d_transformed_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *factory,
302 ID2D1Geometry *src_geometry, const D2D_MATRIX_3X2_F *transform) DECLSPEC_HIDDEN;
303 struct d2d_geometry *unsafe_impl_from_ID2D1Geometry(ID2D1Geometry *iface) DECLSPEC_HIDDEN;
305 static inline void d2d_matrix_multiply(D2D_MATRIX_3X2_F *a, const D2D_MATRIX_3X2_F *b)
307 D2D_MATRIX_3X2_F tmp = *a;
309 a->_11 = tmp._11 * b->_11 + tmp._12 * b->_21;
310 a->_12 = tmp._11 * b->_12 + tmp._12 * b->_22;
311 a->_21 = tmp._21 * b->_11 + tmp._22 * b->_21;
312 a->_22 = tmp._21 * b->_12 + tmp._22 * b->_22;
313 a->_31 = tmp._31 * b->_11 + tmp._32 * b->_21 + b->_31;
314 a->_32 = tmp._31 * b->_12 + tmp._32 * b->_22 + b->_32;
317 #endif /* __WINE_D2D1_PRIVATE_H */