2 * Copyright 2014 Henri Verbeet for CodeWeavers
3 * Copyright 2016 Nikolay Sivov for CodeWeavers
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "d2d1_private.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(d2d
);
24 static inline struct d2d_bitmap_render_target
*impl_from_ID2D1BitmapRenderTarget(ID2D1BitmapRenderTarget
*iface
)
26 return CONTAINING_RECORD(iface
, struct d2d_bitmap_render_target
, ID2D1BitmapRenderTarget_iface
);
29 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_QueryInterface(ID2D1BitmapRenderTarget
*iface
,
30 REFIID iid
, void **out
)
32 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
34 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
36 if (IsEqualGUID(iid
, &IID_ID2D1BitmapRenderTarget
)
37 || IsEqualGUID(iid
, &IID_ID2D1RenderTarget
)
38 || IsEqualGUID(iid
, &IID_ID2D1Resource
)
39 || IsEqualGUID(iid
, &IID_IUnknown
))
41 ID2D1BitmapRenderTarget_AddRef(iface
);
46 return IUnknown_QueryInterface(render_target
->dxgi_inner
, iid
, out
);
49 static ULONG STDMETHODCALLTYPE
d2d_bitmap_render_target_AddRef(ID2D1BitmapRenderTarget
*iface
)
51 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
52 ULONG refcount
= InterlockedIncrement(&render_target
->refcount
);
54 TRACE("%p increasing refcount to %u.\n", iface
, refcount
);
59 static ULONG STDMETHODCALLTYPE
d2d_bitmap_render_target_Release(ID2D1BitmapRenderTarget
*iface
)
61 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
62 ULONG refcount
= InterlockedDecrement(&render_target
->refcount
);
64 TRACE("%p decreasing refcount to %u.\n", iface
, refcount
);
68 IUnknown_Release(render_target
->dxgi_inner
);
69 if (render_target
->bitmap
)
70 ID2D1Bitmap_Release(render_target
->bitmap
);
71 heap_free(render_target
);
77 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_GetFactory(ID2D1BitmapRenderTarget
*iface
,
78 ID2D1Factory
**factory
)
80 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
82 TRACE("iface %p, factory %p.\n", iface
, factory
);
84 ID2D1RenderTarget_GetFactory(render_target
->dxgi_target
, factory
);
87 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateBitmap(ID2D1BitmapRenderTarget
*iface
,
88 D2D1_SIZE_U size
, const void *src_data
, UINT32 pitch
, const D2D1_BITMAP_PROPERTIES
*desc
, ID2D1Bitmap
**bitmap
)
90 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
92 TRACE("iface %p, size {%u, %u}, src_data %p, pitch %u, desc %p, bitmap %p.\n",
93 iface
, size
.width
, size
.height
, src_data
, pitch
, desc
, bitmap
);
95 return ID2D1RenderTarget_CreateBitmap(render_target
->dxgi_target
, size
, src_data
, pitch
, desc
, bitmap
);
98 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateBitmapFromWicBitmap(ID2D1BitmapRenderTarget
*iface
,
99 IWICBitmapSource
*bitmap_source
, const D2D1_BITMAP_PROPERTIES
*desc
, ID2D1Bitmap
**bitmap
)
101 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
103 TRACE("iface %p, bitmap_source %p, desc %p, bitmap %p.\n",
104 iface
, bitmap_source
, desc
, bitmap
);
106 return ID2D1RenderTarget_CreateBitmapFromWicBitmap(render_target
->dxgi_target
, bitmap_source
, desc
, bitmap
);
109 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateSharedBitmap(ID2D1BitmapRenderTarget
*iface
,
110 REFIID iid
, void *data
, const D2D1_BITMAP_PROPERTIES
*desc
, ID2D1Bitmap
**bitmap
)
112 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
114 TRACE("iface %p, iid %s, data %p, desc %p, bitmap %p.\n",
115 iface
, debugstr_guid(iid
), data
, desc
, bitmap
);
117 return ID2D1RenderTarget_CreateSharedBitmap(render_target
->dxgi_target
, iid
, data
, desc
, bitmap
);
120 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateBitmapBrush(ID2D1BitmapRenderTarget
*iface
,
121 ID2D1Bitmap
*bitmap
, const D2D1_BITMAP_BRUSH_PROPERTIES
*bitmap_brush_desc
,
122 const D2D1_BRUSH_PROPERTIES
*brush_desc
, ID2D1BitmapBrush
**brush
)
124 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
126 TRACE("iface %p, bitmap %p, bitmap_brush_desc %p, brush_desc %p, brush %p.\n",
127 iface
, bitmap
, bitmap_brush_desc
, brush_desc
, brush
);
129 return ID2D1RenderTarget_CreateBitmapBrush(render_target
->dxgi_target
,
130 bitmap
, bitmap_brush_desc
, brush_desc
, brush
);
133 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateSolidColorBrush(ID2D1BitmapRenderTarget
*iface
,
134 const D2D1_COLOR_F
*color
, const D2D1_BRUSH_PROPERTIES
*desc
, ID2D1SolidColorBrush
**brush
)
136 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
138 TRACE("iface %p, color %p, desc %p, brush %p.\n", iface
, color
, desc
, brush
);
140 return ID2D1RenderTarget_CreateSolidColorBrush(render_target
->dxgi_target
, color
, desc
, brush
);
143 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateGradientStopCollection(ID2D1BitmapRenderTarget
*iface
,
144 const D2D1_GRADIENT_STOP
*stops
, UINT32 stop_count
, D2D1_GAMMA gamma
, D2D1_EXTEND_MODE extend_mode
,
145 ID2D1GradientStopCollection
**gradient
)
147 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
149 TRACE("iface %p, stops %p, stop_count %u, gamma %#x, extend_mode %#x, gradient %p.\n",
150 iface
, stops
, stop_count
, gamma
, extend_mode
, gradient
);
152 return ID2D1RenderTarget_CreateGradientStopCollection(render_target
->dxgi_target
,
153 stops
, stop_count
, gamma
, extend_mode
, gradient
);
156 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateLinearGradientBrush(ID2D1BitmapRenderTarget
*iface
,
157 const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES
*gradient_brush_desc
, const D2D1_BRUSH_PROPERTIES
*brush_desc
,
158 ID2D1GradientStopCollection
*gradient
, ID2D1LinearGradientBrush
**brush
)
160 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
162 TRACE("iface %p, gradient_brush_desc %p, brush_desc %p, gradient %p, brush %p.\n",
163 iface
, gradient_brush_desc
, brush_desc
, gradient
, brush
);
165 return ID2D1RenderTarget_CreateLinearGradientBrush(render_target
->dxgi_target
,
166 gradient_brush_desc
, brush_desc
, gradient
, brush
);
169 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateRadialGradientBrush(ID2D1BitmapRenderTarget
*iface
,
170 const D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES
*gradient_brush_desc
, const D2D1_BRUSH_PROPERTIES
*brush_desc
,
171 ID2D1GradientStopCollection
*gradient
, ID2D1RadialGradientBrush
**brush
)
173 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
175 TRACE("iface %p, gradient_brush_desc %p, brush_desc %p, gradient %p, brush %p.\n",
176 iface
, gradient_brush_desc
, brush_desc
, gradient
, brush
);
178 return ID2D1RenderTarget_CreateRadialGradientBrush(render_target
->dxgi_target
,
179 gradient_brush_desc
, brush_desc
, gradient
, brush
);
182 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateCompatibleRenderTarget(ID2D1BitmapRenderTarget
*iface
,
183 const D2D1_SIZE_F
*size
, const D2D1_SIZE_U
*pixel_size
, const D2D1_PIXEL_FORMAT
*format
,
184 D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS options
, ID2D1BitmapRenderTarget
**render_target
)
186 struct d2d_bitmap_render_target
*rt
= impl_from_ID2D1BitmapRenderTarget(iface
);
188 TRACE("iface %p, size %p, pixel_size %p, format %p, options %#x, render_target %p,\n",
189 iface
, size
, pixel_size
, format
, options
, render_target
);
191 return ID2D1RenderTarget_CreateCompatibleRenderTarget(rt
->dxgi_target
,
192 size
, pixel_size
, format
, options
, render_target
);
195 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateLayer(ID2D1BitmapRenderTarget
*iface
,
196 const D2D1_SIZE_F
*size
, ID2D1Layer
**layer
)
198 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
200 TRACE("iface %p, size %p, layer %p.\n", iface
, size
, layer
);
202 return ID2D1RenderTarget_CreateLayer(render_target
->dxgi_target
, size
, layer
);
205 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateMesh(ID2D1BitmapRenderTarget
*iface
, ID2D1Mesh
**mesh
)
207 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
209 TRACE("iface %p, mesh %p.\n", iface
, mesh
);
211 return ID2D1RenderTarget_CreateMesh(render_target
->dxgi_target
, mesh
);
214 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_DrawLine(ID2D1BitmapRenderTarget
*iface
,
215 D2D1_POINT_2F p0
, D2D1_POINT_2F p1
, ID2D1Brush
*brush
, float stroke_width
, ID2D1StrokeStyle
*stroke_style
)
217 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
219 TRACE("iface %p, p0 %s, p1 %s, brush %p, stroke_width %.8e, stroke_style %p.\n",
220 iface
, debug_d2d_point_2f(&p0
), debug_d2d_point_2f(&p1
), brush
, stroke_width
, stroke_style
);
222 ID2D1RenderTarget_DrawLine(render_target
->dxgi_target
, p0
, p1
, brush
, stroke_width
, stroke_style
);
225 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_DrawRectangle(ID2D1BitmapRenderTarget
*iface
,
226 const D2D1_RECT_F
*rect
, ID2D1Brush
*brush
, float stroke_width
, ID2D1StrokeStyle
*stroke_style
)
228 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
230 TRACE("iface %p, rect %s, brush %p, stroke_width %.8e, stroke_style %p.\n",
231 iface
, debug_d2d_rect_f(rect
), brush
, stroke_width
, stroke_style
);
233 ID2D1RenderTarget_DrawRectangle(render_target
->dxgi_target
, rect
, brush
, stroke_width
, stroke_style
);
236 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_FillRectangle(ID2D1BitmapRenderTarget
*iface
,
237 const D2D1_RECT_F
*rect
, ID2D1Brush
*brush
)
239 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
241 TRACE("iface %p, rect %s, brush %p.\n", iface
, debug_d2d_rect_f(rect
), brush
);
243 ID2D1RenderTarget_FillRectangle(render_target
->dxgi_target
, rect
, brush
);
246 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_DrawRoundedRectangle(ID2D1BitmapRenderTarget
*iface
,
247 const D2D1_ROUNDED_RECT
*rect
, ID2D1Brush
*brush
, float stroke_width
, ID2D1StrokeStyle
*stroke_style
)
249 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
251 TRACE("iface %p, rect %p, brush %p, stroke_width %.8e, stroke_style %p.\n",
252 iface
, rect
, brush
, stroke_width
, stroke_style
);
254 ID2D1RenderTarget_DrawRoundedRectangle(render_target
->dxgi_target
, rect
, brush
, stroke_width
, stroke_style
);
257 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_FillRoundedRectangle(ID2D1BitmapRenderTarget
*iface
,
258 const D2D1_ROUNDED_RECT
*rect
, ID2D1Brush
*brush
)
260 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
262 TRACE("iface %p, rect %p, brush %p.\n", iface
, rect
, brush
);
264 ID2D1RenderTarget_FillRoundedRectangle(render_target
->dxgi_target
, rect
, brush
);
267 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_DrawEllipse(ID2D1BitmapRenderTarget
*iface
,
268 const D2D1_ELLIPSE
*ellipse
, ID2D1Brush
*brush
, float stroke_width
, ID2D1StrokeStyle
*stroke_style
)
270 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
272 TRACE("iface %p, ellipse %p, brush %p, stroke_width %.8e, stroke_style %p.\n",
273 iface
, ellipse
, brush
, stroke_width
, stroke_style
);
275 ID2D1RenderTarget_DrawEllipse(render_target
->dxgi_target
, ellipse
, brush
, stroke_width
, stroke_style
);
278 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_FillEllipse(ID2D1BitmapRenderTarget
*iface
,
279 const D2D1_ELLIPSE
*ellipse
, ID2D1Brush
*brush
)
281 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
283 TRACE("iface %p, ellipse %p, brush %p.\n", iface
, ellipse
, brush
);
285 ID2D1RenderTarget_FillEllipse(render_target
->dxgi_target
, ellipse
, brush
);
288 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_DrawGeometry(ID2D1BitmapRenderTarget
*iface
,
289 ID2D1Geometry
*geometry
, ID2D1Brush
*brush
, float stroke_width
, ID2D1StrokeStyle
*stroke_style
)
291 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
293 TRACE("iface %p, geometry %p, brush %p, stroke_width %.8e, stroke_style %p.\n",
294 iface
, geometry
, brush
, stroke_width
, stroke_style
);
296 ID2D1RenderTarget_DrawGeometry(render_target
->dxgi_target
, geometry
, brush
, stroke_width
, stroke_style
);
299 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_FillGeometry(ID2D1BitmapRenderTarget
*iface
,
300 ID2D1Geometry
*geometry
, ID2D1Brush
*brush
, ID2D1Brush
*opacity_brush
)
302 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
304 TRACE("iface %p, geometry %p, brush %p, opacity_brush %p.\n", iface
, geometry
, brush
, opacity_brush
);
306 ID2D1RenderTarget_FillGeometry(render_target
->dxgi_target
, geometry
, brush
, opacity_brush
);
309 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_FillMesh(ID2D1BitmapRenderTarget
*iface
,
310 ID2D1Mesh
*mesh
, ID2D1Brush
*brush
)
312 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
314 TRACE("iface %p, mesh %p, brush %p.\n", iface
, mesh
, brush
);
316 ID2D1RenderTarget_FillMesh(render_target
->dxgi_target
, mesh
, brush
);
319 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_FillOpacityMask(ID2D1BitmapRenderTarget
*iface
,
320 ID2D1Bitmap
*mask
, ID2D1Brush
*brush
, D2D1_OPACITY_MASK_CONTENT content
,
321 const D2D1_RECT_F
*dst_rect
, const D2D1_RECT_F
*src_rect
)
323 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
325 TRACE("iface %p, mask %p, brush %p, content %#x, dst_rect %s, src_rect %s.\n",
326 iface
, mask
, brush
, content
, debug_d2d_rect_f(dst_rect
), debug_d2d_rect_f(src_rect
));
328 ID2D1RenderTarget_FillOpacityMask(render_target
->dxgi_target
,
329 mask
, brush
, content
, dst_rect
, src_rect
);
332 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_DrawBitmap(ID2D1BitmapRenderTarget
*iface
,
333 ID2D1Bitmap
*bitmap
, const D2D1_RECT_F
*dst_rect
, float opacity
,
334 D2D1_BITMAP_INTERPOLATION_MODE interpolation_mode
, const D2D1_RECT_F
*src_rect
)
336 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
338 TRACE("iface %p, bitmap %p, dst_rect %s, opacity %.8e, interpolation_mode %#x, src_rect %s.\n",
339 iface
, bitmap
, debug_d2d_rect_f(dst_rect
), opacity
, interpolation_mode
, debug_d2d_rect_f(src_rect
));
341 ID2D1RenderTarget_DrawBitmap(render_target
->dxgi_target
,
342 bitmap
, dst_rect
, opacity
, interpolation_mode
, src_rect
);
345 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_DrawText(ID2D1BitmapRenderTarget
*iface
,
346 const WCHAR
*string
, UINT32 string_len
, IDWriteTextFormat
*text_format
, const D2D1_RECT_F
*layout_rect
,
347 ID2D1Brush
*brush
, D2D1_DRAW_TEXT_OPTIONS options
, DWRITE_MEASURING_MODE measuring_mode
)
349 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
351 TRACE("iface %p, string %s, string_len %u, text_format %p, layout_rect %s, "
352 "brush %p, options %#x, measuring_mode %#x.\n",
353 iface
, debugstr_wn(string
, string_len
), string_len
, text_format
, debug_d2d_rect_f(layout_rect
),
354 brush
, options
, measuring_mode
);
356 ID2D1RenderTarget_DrawText(render_target
->dxgi_target
, string
, string_len
,
357 text_format
, layout_rect
, brush
, options
, measuring_mode
);
360 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_DrawTextLayout(ID2D1BitmapRenderTarget
*iface
,
361 D2D1_POINT_2F origin
, IDWriteTextLayout
*layout
, ID2D1Brush
*brush
, D2D1_DRAW_TEXT_OPTIONS options
)
363 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
365 TRACE("iface %p, origin %s, layout %p, brush %p, options %#x.\n",
366 iface
, debug_d2d_point_2f(&origin
), layout
, brush
, options
);
368 ID2D1RenderTarget_DrawTextLayout(render_target
->dxgi_target
, origin
, layout
, brush
, options
);
371 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_DrawGlyphRun(ID2D1BitmapRenderTarget
*iface
,
372 D2D1_POINT_2F baseline_origin
, const DWRITE_GLYPH_RUN
*glyph_run
, ID2D1Brush
*brush
,
373 DWRITE_MEASURING_MODE measuring_mode
)
375 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
377 TRACE("iface %p, baseline_origin %s, glyph_run %p, brush %p, measuring_mode %#x.\n",
378 iface
, debug_d2d_point_2f(&baseline_origin
), glyph_run
, brush
, measuring_mode
);
380 ID2D1RenderTarget_DrawGlyphRun(render_target
->dxgi_target
,
381 baseline_origin
, glyph_run
, brush
, measuring_mode
);
384 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_SetTransform(ID2D1BitmapRenderTarget
*iface
,
385 const D2D1_MATRIX_3X2_F
*transform
)
387 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
389 TRACE("iface %p, transform %p.\n", iface
, transform
);
391 ID2D1RenderTarget_SetTransform(render_target
->dxgi_target
, transform
);
394 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_GetTransform(ID2D1BitmapRenderTarget
*iface
,
395 D2D1_MATRIX_3X2_F
*transform
)
397 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
399 TRACE("iface %p, transform %p.\n", iface
, transform
);
401 ID2D1RenderTarget_GetTransform(render_target
->dxgi_target
, transform
);
404 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_SetAntialiasMode(ID2D1BitmapRenderTarget
*iface
,
405 D2D1_ANTIALIAS_MODE antialias_mode
)
407 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
409 TRACE("iface %p, antialias_mode %#x.\n", iface
, antialias_mode
);
411 ID2D1RenderTarget_SetAntialiasMode(render_target
->dxgi_target
, antialias_mode
);
414 static D2D1_ANTIALIAS_MODE STDMETHODCALLTYPE
d2d_bitmap_render_target_GetAntialiasMode(ID2D1BitmapRenderTarget
*iface
)
416 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
418 TRACE("iface %p.\n", iface
);
420 return ID2D1RenderTarget_GetAntialiasMode(render_target
->dxgi_target
);
423 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_SetTextAntialiasMode(ID2D1BitmapRenderTarget
*iface
,
424 D2D1_TEXT_ANTIALIAS_MODE antialias_mode
)
426 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
428 TRACE("iface %p, antialias_mode %#x.\n", iface
, antialias_mode
);
430 ID2D1RenderTarget_SetTextAntialiasMode(render_target
->dxgi_target
, antialias_mode
);
433 static D2D1_TEXT_ANTIALIAS_MODE STDMETHODCALLTYPE
d2d_bitmap_render_target_GetTextAntialiasMode(
434 ID2D1BitmapRenderTarget
*iface
)
436 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
438 TRACE("iface %p.\n", iface
);
440 return ID2D1RenderTarget_GetTextAntialiasMode(render_target
->dxgi_target
);
443 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_SetTextRenderingParams(ID2D1BitmapRenderTarget
*iface
,
444 IDWriteRenderingParams
*text_rendering_params
)
446 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
448 TRACE("iface %p, text_rendering_params %p.\n", iface
, text_rendering_params
);
450 ID2D1RenderTarget_SetTextRenderingParams(render_target
->dxgi_target
, text_rendering_params
);
453 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_GetTextRenderingParams(ID2D1BitmapRenderTarget
*iface
,
454 IDWriteRenderingParams
**text_rendering_params
)
456 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
458 TRACE("iface %p, text_rendering_params %p.\n", iface
, text_rendering_params
);
460 ID2D1RenderTarget_GetTextRenderingParams(render_target
->dxgi_target
, text_rendering_params
);
463 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_SetTags(ID2D1BitmapRenderTarget
*iface
, D2D1_TAG tag1
,
466 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
468 TRACE("iface %p, tag1 %s, tag2 %s.\n", iface
, wine_dbgstr_longlong(tag1
), wine_dbgstr_longlong(tag2
));
470 ID2D1RenderTarget_SetTags(render_target
->dxgi_target
, tag1
, tag2
);
473 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_GetTags(ID2D1BitmapRenderTarget
*iface
, D2D1_TAG
*tag1
,
476 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
478 TRACE("iface %p, tag1 %p, tag2 %p.\n", iface
, tag1
, tag2
);
480 ID2D1RenderTarget_GetTags(render_target
->dxgi_target
, tag1
, tag2
);
483 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_PushLayer(ID2D1BitmapRenderTarget
*iface
,
484 const D2D1_LAYER_PARAMETERS
*layer_parameters
, ID2D1Layer
*layer
)
486 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
488 TRACE("iface %p, layer_parameters %p, layer %p.\n", iface
, layer_parameters
, layer
);
490 ID2D1RenderTarget_PushLayer(render_target
->dxgi_target
, layer_parameters
, layer
);
493 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_PopLayer(ID2D1BitmapRenderTarget
*iface
)
495 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
497 TRACE("iface %p.\n", iface
);
499 ID2D1RenderTarget_PopLayer(render_target
->dxgi_target
);
502 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_Flush(ID2D1BitmapRenderTarget
*iface
, D2D1_TAG
*tag1
,
505 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
507 TRACE("iface %p, tag1 %p, tag2 %p.\n", iface
, tag1
, tag2
);
509 return ID2D1RenderTarget_Flush(render_target
->dxgi_target
, tag1
, tag2
);
512 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_SaveDrawingState(ID2D1BitmapRenderTarget
*iface
,
513 ID2D1DrawingStateBlock
*state_block
)
515 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
517 TRACE("iface %p, state_block %p.\n", iface
, state_block
);
519 ID2D1RenderTarget_SaveDrawingState(render_target
->dxgi_target
, state_block
);
522 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_RestoreDrawingState(ID2D1BitmapRenderTarget
*iface
,
523 ID2D1DrawingStateBlock
*state_block
)
525 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
527 TRACE("iface %p, state_block %p.\n", iface
, state_block
);
529 ID2D1RenderTarget_RestoreDrawingState(render_target
->dxgi_target
, state_block
);
532 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_PushAxisAlignedClip(ID2D1BitmapRenderTarget
*iface
,
533 const D2D1_RECT_F
*clip_rect
, D2D1_ANTIALIAS_MODE antialias_mode
)
535 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
537 TRACE("iface %p, clip_rect %s, antialias_mode %#x.\n", iface
, debug_d2d_rect_f(clip_rect
), antialias_mode
);
539 ID2D1RenderTarget_PushAxisAlignedClip(render_target
->dxgi_target
, clip_rect
, antialias_mode
);
542 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_PopAxisAlignedClip(ID2D1BitmapRenderTarget
*iface
)
544 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
546 TRACE("iface %p.\n", iface
);
548 ID2D1RenderTarget_PopAxisAlignedClip(render_target
->dxgi_target
);
551 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_Clear(ID2D1BitmapRenderTarget
*iface
, const D2D1_COLOR_F
*color
)
553 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
555 TRACE("iface %p, color %p.\n", iface
, color
);
557 ID2D1RenderTarget_Clear(render_target
->dxgi_target
, color
);
560 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_BeginDraw(ID2D1BitmapRenderTarget
*iface
)
562 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
564 TRACE("iface %p.\n", iface
);
566 ID2D1RenderTarget_BeginDraw(render_target
->dxgi_target
);
569 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_EndDraw(ID2D1BitmapRenderTarget
*iface
,
570 D2D1_TAG
*tag1
, D2D1_TAG
*tag2
)
572 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
574 TRACE("iface %p, tag1 %p, tag2 %p.\n", iface
, tag1
, tag2
);
576 return ID2D1RenderTarget_EndDraw(render_target
->dxgi_target
, tag1
, tag2
);
579 static D2D1_PIXEL_FORMAT
* STDMETHODCALLTYPE
d2d_bitmap_render_target_GetPixelFormat(ID2D1BitmapRenderTarget
*iface
,
580 D2D1_PIXEL_FORMAT
*format
)
582 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
584 TRACE("iface %p, format %p.\n", iface
, format
);
586 *format
= ID2D1RenderTarget_GetPixelFormat(render_target
->dxgi_target
);
590 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_SetDpi(ID2D1BitmapRenderTarget
*iface
, float dpi_x
, float dpi_y
)
592 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
594 TRACE("iface %p, dpi_x %.8e, dpi_y %.8e.\n", iface
, dpi_x
, dpi_y
);
596 ID2D1RenderTarget_SetDpi(render_target
->dxgi_target
, dpi_x
, dpi_y
);
599 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_GetDpi(ID2D1BitmapRenderTarget
*iface
,
600 float *dpi_x
, float *dpi_y
)
602 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
604 TRACE("iface %p, dpi_x %p, dpi_y %p.\n", iface
, dpi_x
, dpi_y
);
606 ID2D1RenderTarget_GetDpi(render_target
->dxgi_target
, dpi_x
, dpi_y
);
609 static D2D1_SIZE_F
* STDMETHODCALLTYPE
d2d_bitmap_render_target_GetSize(ID2D1BitmapRenderTarget
*iface
,
612 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
614 TRACE("iface %p, size %p.\n", iface
, size
);
616 *size
= ID2D1RenderTarget_GetSize(render_target
->dxgi_target
);
620 static D2D1_SIZE_U
* STDMETHODCALLTYPE
d2d_bitmap_render_target_GetPixelSize(ID2D1BitmapRenderTarget
*iface
,
621 D2D1_SIZE_U
*pixel_size
)
623 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
625 TRACE("iface %p, pixel_size %p.\n", iface
, pixel_size
);
627 *pixel_size
= ID2D1RenderTarget_GetPixelSize(render_target
->dxgi_target
);
631 static UINT32 STDMETHODCALLTYPE
d2d_bitmap_render_target_GetMaximumBitmapSize(ID2D1BitmapRenderTarget
*iface
)
633 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
635 TRACE("iface %p.\n", iface
);
637 return ID2D1RenderTarget_GetMaximumBitmapSize(render_target
->dxgi_target
);
640 static BOOL STDMETHODCALLTYPE
d2d_bitmap_render_target_IsSupported(ID2D1BitmapRenderTarget
*iface
,
641 const D2D1_RENDER_TARGET_PROPERTIES
*desc
)
643 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
645 TRACE("iface %p, desc %p.\n", iface
, desc
);
647 return ID2D1RenderTarget_IsSupported(render_target
->dxgi_target
, desc
);
650 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_GetBitmap(ID2D1BitmapRenderTarget
*iface
,
651 ID2D1Bitmap
**bitmap
)
653 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
655 TRACE("iface %p, bitmap %p.\n", iface
, bitmap
);
657 ID2D1Bitmap_AddRef(*bitmap
= render_target
->bitmap
);
661 static const struct ID2D1BitmapRenderTargetVtbl d2d_bitmap_render_target_vtbl
=
663 d2d_bitmap_render_target_QueryInterface
,
664 d2d_bitmap_render_target_AddRef
,
665 d2d_bitmap_render_target_Release
,
666 d2d_bitmap_render_target_GetFactory
,
667 d2d_bitmap_render_target_CreateBitmap
,
668 d2d_bitmap_render_target_CreateBitmapFromWicBitmap
,
669 d2d_bitmap_render_target_CreateSharedBitmap
,
670 d2d_bitmap_render_target_CreateBitmapBrush
,
671 d2d_bitmap_render_target_CreateSolidColorBrush
,
672 d2d_bitmap_render_target_CreateGradientStopCollection
,
673 d2d_bitmap_render_target_CreateLinearGradientBrush
,
674 d2d_bitmap_render_target_CreateRadialGradientBrush
,
675 d2d_bitmap_render_target_CreateCompatibleRenderTarget
,
676 d2d_bitmap_render_target_CreateLayer
,
677 d2d_bitmap_render_target_CreateMesh
,
678 d2d_bitmap_render_target_DrawLine
,
679 d2d_bitmap_render_target_DrawRectangle
,
680 d2d_bitmap_render_target_FillRectangle
,
681 d2d_bitmap_render_target_DrawRoundedRectangle
,
682 d2d_bitmap_render_target_FillRoundedRectangle
,
683 d2d_bitmap_render_target_DrawEllipse
,
684 d2d_bitmap_render_target_FillEllipse
,
685 d2d_bitmap_render_target_DrawGeometry
,
686 d2d_bitmap_render_target_FillGeometry
,
687 d2d_bitmap_render_target_FillMesh
,
688 d2d_bitmap_render_target_FillOpacityMask
,
689 d2d_bitmap_render_target_DrawBitmap
,
690 d2d_bitmap_render_target_DrawText
,
691 d2d_bitmap_render_target_DrawTextLayout
,
692 d2d_bitmap_render_target_DrawGlyphRun
,
693 d2d_bitmap_render_target_SetTransform
,
694 d2d_bitmap_render_target_GetTransform
,
695 d2d_bitmap_render_target_SetAntialiasMode
,
696 d2d_bitmap_render_target_GetAntialiasMode
,
697 d2d_bitmap_render_target_SetTextAntialiasMode
,
698 d2d_bitmap_render_target_GetTextAntialiasMode
,
699 d2d_bitmap_render_target_SetTextRenderingParams
,
700 d2d_bitmap_render_target_GetTextRenderingParams
,
701 d2d_bitmap_render_target_SetTags
,
702 d2d_bitmap_render_target_GetTags
,
703 d2d_bitmap_render_target_PushLayer
,
704 d2d_bitmap_render_target_PopLayer
,
705 d2d_bitmap_render_target_Flush
,
706 d2d_bitmap_render_target_SaveDrawingState
,
707 d2d_bitmap_render_target_RestoreDrawingState
,
708 d2d_bitmap_render_target_PushAxisAlignedClip
,
709 d2d_bitmap_render_target_PopAxisAlignedClip
,
710 d2d_bitmap_render_target_Clear
,
711 d2d_bitmap_render_target_BeginDraw
,
712 d2d_bitmap_render_target_EndDraw
,
713 d2d_bitmap_render_target_GetPixelFormat
,
714 d2d_bitmap_render_target_SetDpi
,
715 d2d_bitmap_render_target_GetDpi
,
716 d2d_bitmap_render_target_GetSize
,
717 d2d_bitmap_render_target_GetPixelSize
,
718 d2d_bitmap_render_target_GetMaximumBitmapSize
,
719 d2d_bitmap_render_target_IsSupported
,
720 d2d_bitmap_render_target_GetBitmap
723 static const struct d2d_device_context_ops d2d_bitmap_render_target_ops
=
728 HRESULT
d2d_bitmap_render_target_init(struct d2d_bitmap_render_target
*render_target
,
729 const struct d2d_device_context
*parent_target
, const D2D1_SIZE_F
*size
,
730 const D2D1_SIZE_U
*pixel_size
, const D2D1_PIXEL_FORMAT
*pixel_format
,
731 D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS options
)
733 D2D1_RENDER_TARGET_PROPERTIES dxgi_rt_desc
;
734 D2D1_BITMAP_PROPERTIES1 bitmap_desc
;
735 ID2D1DeviceContext
*context
;
736 D2D1_SIZE_U bitmap_size
;
740 FIXME("Compatible target options are ignored, %#x.\n", options
);
742 render_target
->ID2D1BitmapRenderTarget_iface
.lpVtbl
= &d2d_bitmap_render_target_vtbl
;
744 dxgi_rt_desc
.type
= parent_target
->desc
.type
;
745 dxgi_rt_desc
.usage
= parent_target
->desc
.usage
;
746 dxgi_rt_desc
.minLevel
= parent_target
->desc
.minLevel
;
750 bitmap_size
.width
= pixel_size
->width
;
751 bitmap_size
.height
= pixel_size
->height
;
755 bitmap_size
.width
= ceilf((size
->width
* parent_target
->desc
.dpiX
) / 96.0f
);
756 bitmap_size
.height
= ceilf((size
->height
* parent_target
->desc
.dpiY
) / 96.0f
);
760 bitmap_size
.width
= parent_target
->pixel_size
.width
;
761 bitmap_size
.height
= parent_target
->pixel_size
.height
;
764 if (size
&& size
->width
!= 0.0f
&& size
->height
!= 0.0f
)
766 dxgi_rt_desc
.dpiX
= (bitmap_size
.width
* 96.0f
) / size
->width
;
767 dxgi_rt_desc
.dpiY
= (bitmap_size
.height
* 96.0f
) / size
->height
;
771 dxgi_rt_desc
.dpiX
= parent_target
->desc
.dpiX
;
772 dxgi_rt_desc
.dpiY
= parent_target
->desc
.dpiY
;
775 if (!pixel_format
|| pixel_format
->format
== DXGI_FORMAT_UNKNOWN
)
776 dxgi_rt_desc
.pixelFormat
.format
= parent_target
->desc
.pixelFormat
.format
;
778 dxgi_rt_desc
.pixelFormat
.format
= pixel_format
->format
;
780 if (!pixel_format
|| pixel_format
->alphaMode
== D2D1_ALPHA_MODE_UNKNOWN
)
781 dxgi_rt_desc
.pixelFormat
.alphaMode
= D2D1_ALPHA_MODE_PREMULTIPLIED
;
783 dxgi_rt_desc
.pixelFormat
.alphaMode
= pixel_format
->alphaMode
;
785 if (FAILED(hr
= d2d_d3d_create_render_target(parent_target
->device
, NULL
,
786 (IUnknown
*)&render_target
->ID2D1BitmapRenderTarget_iface
,
787 parent_target
->ops
? &d2d_bitmap_render_target_ops
: NULL
,
788 &dxgi_rt_desc
, (void **)&render_target
->dxgi_inner
)))
790 WARN("Failed to create DXGI surface render target, hr %#x.\n", hr
);
794 /* Note that we should be a little careful with the "dxgi_target"
795 * reference we get here. Because the object is aggregated, releasing the
796 * interface in any error paths below would end up calling
797 * d2d_bitmap_render_target_Release(). */
798 if (FAILED(hr
= IUnknown_QueryInterface(render_target
->dxgi_inner
,
799 &IID_ID2D1RenderTarget
, (void **)&render_target
->dxgi_target
)))
801 WARN("Failed to retrieve ID2D1RenderTarget interface, hr %#x.\n", hr
);
802 IUnknown_Release(render_target
->dxgi_inner
);
806 bitmap_desc
.pixelFormat
= dxgi_rt_desc
.pixelFormat
;
807 bitmap_desc
.dpiX
= dxgi_rt_desc
.dpiX
;
808 bitmap_desc
.dpiY
= dxgi_rt_desc
.dpiY
;
809 bitmap_desc
.bitmapOptions
= D2D1_BITMAP_OPTIONS_TARGET
;
810 bitmap_desc
.colorContext
= NULL
;
812 ID2D1RenderTarget_QueryInterface(render_target
->dxgi_target
, &IID_ID2D1DeviceContext
, (void **)&context
);
813 hr
= ID2D1DeviceContext_CreateBitmap(context
, bitmap_size
, NULL
, 0, &bitmap_desc
,
814 (ID2D1Bitmap1
**)&render_target
->bitmap
);
815 ID2D1DeviceContext_SetTarget(context
, (ID2D1Image
*)render_target
->bitmap
);
816 ID2D1DeviceContext_Release(context
);
819 WARN("Failed to create target bitmap, hr %#x.\n", hr
);
820 IUnknown_Release(render_target
->dxgi_inner
);