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
21 #include "wine/port.h"
23 #include "d2d1_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d2d
);
27 static inline struct d2d_bitmap_render_target
*impl_from_ID2D1BitmapRenderTarget(ID2D1BitmapRenderTarget
*iface
)
29 return CONTAINING_RECORD(iface
, struct d2d_bitmap_render_target
, ID2D1BitmapRenderTarget_iface
);
32 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_QueryInterface(ID2D1BitmapRenderTarget
*iface
,
33 REFIID iid
, void **out
)
35 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
37 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
39 if (IsEqualGUID(iid
, &IID_ID2D1BitmapRenderTarget
)
40 || IsEqualGUID(iid
, &IID_ID2D1RenderTarget
)
41 || IsEqualGUID(iid
, &IID_ID2D1Resource
)
42 || IsEqualGUID(iid
, &IID_IUnknown
))
44 ID2D1BitmapRenderTarget_AddRef(iface
);
48 else if (IsEqualGUID(iid
, &IID_ID2D1GdiInteropRenderTarget
))
49 return ID2D1RenderTarget_QueryInterface(render_target
->dxgi_target
, iid
, out
);
51 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
57 static ULONG STDMETHODCALLTYPE
d2d_bitmap_render_target_AddRef(ID2D1BitmapRenderTarget
*iface
)
59 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
60 ULONG refcount
= InterlockedIncrement(&render_target
->refcount
);
62 TRACE("%p increasing refcount to %u.\n", iface
, refcount
);
67 static ULONG STDMETHODCALLTYPE
d2d_bitmap_render_target_Release(ID2D1BitmapRenderTarget
*iface
)
69 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
70 ULONG refcount
= InterlockedDecrement(&render_target
->refcount
);
72 TRACE("%p decreasing refcount to %u.\n", iface
, refcount
);
76 ID2D1RenderTarget_Release(render_target
->dxgi_target
);
77 ID2D1Bitmap_Release(render_target
->bitmap
);
78 HeapFree(GetProcessHeap(), 0, render_target
);
84 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_GetFactory(ID2D1BitmapRenderTarget
*iface
,
85 ID2D1Factory
**factory
)
87 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
89 TRACE("iface %p, factory %p.\n", iface
, factory
);
91 ID2D1RenderTarget_GetFactory(render_target
->dxgi_target
, factory
);
94 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateBitmap(ID2D1BitmapRenderTarget
*iface
,
95 D2D1_SIZE_U size
, const void *src_data
, UINT32 pitch
, const D2D1_BITMAP_PROPERTIES
*desc
, ID2D1Bitmap
**bitmap
)
97 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
99 TRACE("iface %p, size {%u, %u}, src_data %p, pitch %u, desc %p, bitmap %p.\n",
100 iface
, size
.width
, size
.height
, src_data
, pitch
, desc
, bitmap
);
102 return ID2D1RenderTarget_CreateBitmap(render_target
->dxgi_target
, size
, src_data
, pitch
, desc
, bitmap
);
105 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateBitmapFromWicBitmap(ID2D1BitmapRenderTarget
*iface
,
106 IWICBitmapSource
*bitmap_source
, const D2D1_BITMAP_PROPERTIES
*desc
, ID2D1Bitmap
**bitmap
)
108 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
110 TRACE("iface %p, bitmap_source %p, desc %p, bitmap %p.\n",
111 iface
, bitmap_source
, desc
, bitmap
);
113 return ID2D1RenderTarget_CreateBitmapFromWicBitmap(render_target
->dxgi_target
, bitmap_source
, desc
, bitmap
);
116 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateSharedBitmap(ID2D1BitmapRenderTarget
*iface
,
117 REFIID iid
, void *data
, const D2D1_BITMAP_PROPERTIES
*desc
, ID2D1Bitmap
**bitmap
)
119 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
121 TRACE("iface %p, iid %s, data %p, desc %p, bitmap %p.\n",
122 iface
, debugstr_guid(iid
), data
, desc
, bitmap
);
124 return ID2D1RenderTarget_CreateSharedBitmap(render_target
->dxgi_target
, iid
, data
, desc
, bitmap
);
127 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateBitmapBrush(ID2D1BitmapRenderTarget
*iface
,
128 ID2D1Bitmap
*bitmap
, const D2D1_BITMAP_BRUSH_PROPERTIES
*bitmap_brush_desc
,
129 const D2D1_BRUSH_PROPERTIES
*brush_desc
, ID2D1BitmapBrush
**brush
)
131 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
133 TRACE("iface %p, bitmap %p, bitmap_brush_desc %p, brush_desc %p, brush %p.\n",
134 iface
, bitmap
, bitmap_brush_desc
, brush_desc
, brush
);
136 return ID2D1RenderTarget_CreateBitmapBrush(render_target
->dxgi_target
,
137 bitmap
, bitmap_brush_desc
, brush_desc
, brush
);
140 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateSolidColorBrush(ID2D1BitmapRenderTarget
*iface
,
141 const D2D1_COLOR_F
*color
, const D2D1_BRUSH_PROPERTIES
*desc
, ID2D1SolidColorBrush
**brush
)
143 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
145 TRACE("iface %p, color %p, desc %p, brush %p.\n", iface
, color
, desc
, brush
);
147 return ID2D1RenderTarget_CreateSolidColorBrush(render_target
->dxgi_target
, color
, desc
, brush
);
150 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateGradientStopCollection(ID2D1BitmapRenderTarget
*iface
,
151 const D2D1_GRADIENT_STOP
*stops
, UINT32 stop_count
, D2D1_GAMMA gamma
, D2D1_EXTEND_MODE extend_mode
,
152 ID2D1GradientStopCollection
**gradient
)
154 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
156 TRACE("iface %p, stops %p, stop_count %u, gamma %#x, extend_mode %#x, gradient %p.\n",
157 iface
, stops
, stop_count
, gamma
, extend_mode
, gradient
);
159 return ID2D1RenderTarget_CreateGradientStopCollection(render_target
->dxgi_target
,
160 stops
, stop_count
, gamma
, extend_mode
, gradient
);
163 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateLinearGradientBrush(ID2D1BitmapRenderTarget
*iface
,
164 const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES
*gradient_brush_desc
, const D2D1_BRUSH_PROPERTIES
*brush_desc
,
165 ID2D1GradientStopCollection
*gradient
, ID2D1LinearGradientBrush
**brush
)
167 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
169 TRACE("iface %p, gradient_brush_desc %p, brush_desc %p, gradient %p, brush %p.\n",
170 iface
, gradient_brush_desc
, brush_desc
, gradient
, brush
);
172 return ID2D1RenderTarget_CreateLinearGradientBrush(render_target
->dxgi_target
,
173 gradient_brush_desc
, brush_desc
, gradient
, brush
);
176 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateRadialGradientBrush(ID2D1BitmapRenderTarget
*iface
,
177 const D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES
*gradient_brush_desc
, const D2D1_BRUSH_PROPERTIES
*brush_desc
,
178 ID2D1GradientStopCollection
*gradient
, ID2D1RadialGradientBrush
**brush
)
180 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
182 TRACE("iface %p, gradient_brush_desc %p, brush_desc %p, gradient %p, brush %p.\n",
183 iface
, gradient_brush_desc
, brush_desc
, gradient
, brush
);
185 return ID2D1RenderTarget_CreateRadialGradientBrush(render_target
->dxgi_target
,
186 gradient_brush_desc
, brush_desc
, gradient
, brush
);
189 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateCompatibleRenderTarget(ID2D1BitmapRenderTarget
*iface
,
190 const D2D1_SIZE_F
*size
, const D2D1_SIZE_U
*pixel_size
, const D2D1_PIXEL_FORMAT
*format
,
191 D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS options
, ID2D1BitmapRenderTarget
**render_target
)
193 struct d2d_bitmap_render_target
*rt
= impl_from_ID2D1BitmapRenderTarget(iface
);
195 TRACE("iface %p, size %p, pixel_size %p, format %p, options %#x, render_target %p,\n",
196 iface
, size
, pixel_size
, format
, options
, render_target
);
198 return ID2D1RenderTarget_CreateCompatibleRenderTarget(rt
->dxgi_target
,
199 size
, pixel_size
, format
, options
, render_target
);
202 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateLayer(ID2D1BitmapRenderTarget
*iface
,
203 const D2D1_SIZE_F
*size
, ID2D1Layer
**layer
)
205 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
207 TRACE("iface %p, size %p, layer %p.\n", iface
, size
, layer
);
209 return ID2D1RenderTarget_CreateLayer(render_target
->dxgi_target
, size
, layer
);
212 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_CreateMesh(ID2D1BitmapRenderTarget
*iface
, ID2D1Mesh
**mesh
)
214 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
216 TRACE("iface %p, mesh %p.\n", iface
, mesh
);
218 return ID2D1RenderTarget_CreateMesh(render_target
->dxgi_target
, mesh
);
221 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_DrawLine(ID2D1BitmapRenderTarget
*iface
,
222 D2D1_POINT_2F p0
, D2D1_POINT_2F p1
, ID2D1Brush
*brush
, float stroke_width
, ID2D1StrokeStyle
*stroke_style
)
224 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
226 TRACE("iface %p, p0 {%.8e, %.8e}, p1 {%.8e, %.8e}, brush %p, stroke_width %.8e, stroke_style %p.\n",
227 iface
, p0
.x
, p0
.y
, p1
.x
, p1
.y
, brush
, stroke_width
, stroke_style
);
229 ID2D1RenderTarget_DrawLine(render_target
->dxgi_target
, p0
, p1
, brush
, stroke_width
, stroke_style
);
232 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_DrawRectangle(ID2D1BitmapRenderTarget
*iface
,
233 const D2D1_RECT_F
*rect
, ID2D1Brush
*brush
, float stroke_width
, ID2D1StrokeStyle
*stroke_style
)
235 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
237 TRACE("iface %p, rect %s, brush %p, stroke_width %.8e, stroke_style %p.\n",
238 iface
, debug_d2d_rect_f(rect
), brush
, stroke_width
, stroke_style
);
240 ID2D1RenderTarget_DrawRectangle(render_target
->dxgi_target
, rect
, brush
, stroke_width
, stroke_style
);
243 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_FillRectangle(ID2D1BitmapRenderTarget
*iface
,
244 const D2D1_RECT_F
*rect
, ID2D1Brush
*brush
)
246 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
248 TRACE("iface %p, rect %s, brush %p.\n", iface
, debug_d2d_rect_f(rect
), brush
);
250 ID2D1RenderTarget_FillRectangle(render_target
->dxgi_target
, rect
, brush
);
253 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_DrawRoundedRectangle(ID2D1BitmapRenderTarget
*iface
,
254 const D2D1_ROUNDED_RECT
*rect
, ID2D1Brush
*brush
, float stroke_width
, ID2D1StrokeStyle
*stroke_style
)
256 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
258 TRACE("iface %p, rect %p, brush %p, stroke_width %.8e, stroke_style %p.\n",
259 iface
, rect
, brush
, stroke_width
, stroke_style
);
261 ID2D1RenderTarget_DrawRoundedRectangle(render_target
->dxgi_target
, rect
, brush
, stroke_width
, stroke_style
);
264 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_FillRoundedRectangle(ID2D1BitmapRenderTarget
*iface
,
265 const D2D1_ROUNDED_RECT
*rect
, ID2D1Brush
*brush
)
267 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
269 TRACE("iface %p, rect %p, brush %p.\n", iface
, rect
, brush
);
271 ID2D1RenderTarget_FillRoundedRectangle(render_target
->dxgi_target
, rect
, brush
);
274 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_DrawEllipse(ID2D1BitmapRenderTarget
*iface
,
275 const D2D1_ELLIPSE
*ellipse
, ID2D1Brush
*brush
, float stroke_width
, ID2D1StrokeStyle
*stroke_style
)
277 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
279 TRACE("iface %p, ellipse %p, brush %p, stroke_width %.8e, stroke_style %p.\n",
280 iface
, ellipse
, brush
, stroke_width
, stroke_style
);
282 ID2D1RenderTarget_DrawEllipse(render_target
->dxgi_target
, ellipse
, brush
, stroke_width
, stroke_style
);
285 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_FillEllipse(ID2D1BitmapRenderTarget
*iface
,
286 const D2D1_ELLIPSE
*ellipse
, ID2D1Brush
*brush
)
288 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
290 TRACE("iface %p, ellipse %p, brush %p.\n", iface
, ellipse
, brush
);
292 ID2D1RenderTarget_FillEllipse(render_target
->dxgi_target
, ellipse
, brush
);
295 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_DrawGeometry(ID2D1BitmapRenderTarget
*iface
,
296 ID2D1Geometry
*geometry
, ID2D1Brush
*brush
, float stroke_width
, ID2D1StrokeStyle
*stroke_style
)
298 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
300 TRACE("iface %p, geometry %p, brush %p, stroke_width %.8e, stroke_style %p.\n",
301 iface
, geometry
, brush
, stroke_width
, stroke_style
);
303 ID2D1RenderTarget_DrawGeometry(render_target
->dxgi_target
, geometry
, brush
, stroke_width
, stroke_style
);
306 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_FillGeometry(ID2D1BitmapRenderTarget
*iface
,
307 ID2D1Geometry
*geometry
, ID2D1Brush
*brush
, ID2D1Brush
*opacity_brush
)
309 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
311 TRACE("iface %p, geometry %p, brush %p, opacity_brush %p.\n", iface
, geometry
, brush
, opacity_brush
);
313 ID2D1RenderTarget_FillGeometry(render_target
->dxgi_target
, geometry
, brush
, opacity_brush
);
316 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_FillMesh(ID2D1BitmapRenderTarget
*iface
,
317 ID2D1Mesh
*mesh
, ID2D1Brush
*brush
)
319 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
321 TRACE("iface %p, mesh %p, brush %p.\n", iface
, mesh
, brush
);
323 ID2D1RenderTarget_FillMesh(render_target
->dxgi_target
, mesh
, brush
);
326 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_FillOpacityMask(ID2D1BitmapRenderTarget
*iface
,
327 ID2D1Bitmap
*mask
, ID2D1Brush
*brush
, D2D1_OPACITY_MASK_CONTENT content
,
328 const D2D1_RECT_F
*dst_rect
, const D2D1_RECT_F
*src_rect
)
330 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
332 TRACE("iface %p, mask %p, brush %p, content %#x, dst_rect %s, src_rect %s.\n",
333 iface
, mask
, brush
, content
, debug_d2d_rect_f(dst_rect
), debug_d2d_rect_f(src_rect
));
335 ID2D1RenderTarget_FillOpacityMask(render_target
->dxgi_target
,
336 mask
, brush
, content
, dst_rect
, src_rect
);
339 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_DrawBitmap(ID2D1BitmapRenderTarget
*iface
,
340 ID2D1Bitmap
*bitmap
, const D2D1_RECT_F
*dst_rect
, float opacity
,
341 D2D1_BITMAP_INTERPOLATION_MODE interpolation_mode
, const D2D1_RECT_F
*src_rect
)
343 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
345 TRACE("iface %p, bitmap %p, dst_rect %s, opacity %.8e, interpolation_mode %#x, src_rect %s.\n",
346 iface
, bitmap
, debug_d2d_rect_f(dst_rect
), opacity
, interpolation_mode
, debug_d2d_rect_f(src_rect
));
348 ID2D1RenderTarget_DrawBitmap(render_target
->dxgi_target
,
349 bitmap
, dst_rect
, opacity
, interpolation_mode
, src_rect
);
352 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_DrawText(ID2D1BitmapRenderTarget
*iface
,
353 const WCHAR
*string
, UINT32 string_len
, IDWriteTextFormat
*text_format
, const D2D1_RECT_F
*layout_rect
,
354 ID2D1Brush
*brush
, D2D1_DRAW_TEXT_OPTIONS options
, DWRITE_MEASURING_MODE measuring_mode
)
356 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
358 TRACE("iface %p, string %s, string_len %u, text_format %p, layout_rect %s, "
359 "brush %p, options %#x, measuring_mode %#x.\n",
360 iface
, debugstr_wn(string
, string_len
), string_len
, text_format
, debug_d2d_rect_f(layout_rect
),
361 brush
, options
, measuring_mode
);
363 ID2D1RenderTarget_DrawText(render_target
->dxgi_target
, string
, string_len
,
364 text_format
, layout_rect
, brush
, options
, measuring_mode
);
367 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_DrawTextLayout(ID2D1BitmapRenderTarget
*iface
,
368 D2D1_POINT_2F origin
, IDWriteTextLayout
*layout
, ID2D1Brush
*brush
, D2D1_DRAW_TEXT_OPTIONS options
)
370 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
372 TRACE("iface %p, origin {%.8e, %.8e}, layout %p, brush %p, options %#x.\n",
373 iface
, origin
.x
, origin
.y
, layout
, brush
, options
);
375 ID2D1RenderTarget_DrawTextLayout(render_target
->dxgi_target
, origin
, layout
, brush
, options
);
378 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_DrawGlyphRun(ID2D1BitmapRenderTarget
*iface
,
379 D2D1_POINT_2F baseline_origin
, const DWRITE_GLYPH_RUN
*glyph_run
, ID2D1Brush
*brush
,
380 DWRITE_MEASURING_MODE measuring_mode
)
382 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
384 TRACE("iface %p, baseline_origin {%.8e, %.8e}, glyph_run %p, brush %p, measuring_mode %#x.\n",
385 iface
, baseline_origin
.x
, baseline_origin
.y
, glyph_run
, brush
, measuring_mode
);
387 ID2D1RenderTarget_DrawGlyphRun(render_target
->dxgi_target
,
388 baseline_origin
, glyph_run
, brush
, measuring_mode
);
391 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_SetTransform(ID2D1BitmapRenderTarget
*iface
,
392 const D2D1_MATRIX_3X2_F
*transform
)
394 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
396 TRACE("iface %p, transform %p.\n", iface
, transform
);
398 ID2D1RenderTarget_SetTransform(render_target
->dxgi_target
, transform
);
401 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_GetTransform(ID2D1BitmapRenderTarget
*iface
,
402 D2D1_MATRIX_3X2_F
*transform
)
404 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
406 TRACE("iface %p, transform %p.\n", iface
, transform
);
408 ID2D1RenderTarget_GetTransform(render_target
->dxgi_target
, transform
);
411 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_SetAntialiasMode(ID2D1BitmapRenderTarget
*iface
,
412 D2D1_ANTIALIAS_MODE antialias_mode
)
414 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
416 TRACE("iface %p, antialias_mode %#x.\n", iface
, antialias_mode
);
418 ID2D1RenderTarget_SetAntialiasMode(render_target
->dxgi_target
, antialias_mode
);
421 static D2D1_ANTIALIAS_MODE STDMETHODCALLTYPE
d2d_bitmap_render_target_GetAntialiasMode(ID2D1BitmapRenderTarget
*iface
)
423 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
425 TRACE("iface %p.\n", iface
);
427 return ID2D1RenderTarget_GetAntialiasMode(render_target
->dxgi_target
);
430 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_SetTextAntialiasMode(ID2D1BitmapRenderTarget
*iface
,
431 D2D1_TEXT_ANTIALIAS_MODE antialias_mode
)
433 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
435 TRACE("iface %p, antialias_mode %#x.\n", iface
, antialias_mode
);
437 ID2D1RenderTarget_SetTextAntialiasMode(render_target
->dxgi_target
, antialias_mode
);
440 static D2D1_TEXT_ANTIALIAS_MODE STDMETHODCALLTYPE
d2d_bitmap_render_target_GetTextAntialiasMode(
441 ID2D1BitmapRenderTarget
*iface
)
443 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
445 TRACE("iface %p.\n", iface
);
447 return ID2D1RenderTarget_GetTextAntialiasMode(render_target
->dxgi_target
);
450 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_SetTextRenderingParams(ID2D1BitmapRenderTarget
*iface
,
451 IDWriteRenderingParams
*text_rendering_params
)
453 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
455 TRACE("iface %p, text_rendering_params %p.\n", iface
, text_rendering_params
);
457 ID2D1RenderTarget_SetTextRenderingParams(render_target
->dxgi_target
, text_rendering_params
);
460 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_GetTextRenderingParams(ID2D1BitmapRenderTarget
*iface
,
461 IDWriteRenderingParams
**text_rendering_params
)
463 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
465 TRACE("iface %p, text_rendering_params %p.\n", iface
, text_rendering_params
);
467 ID2D1RenderTarget_GetTextRenderingParams(render_target
->dxgi_target
, text_rendering_params
);
470 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_SetTags(ID2D1BitmapRenderTarget
*iface
, D2D1_TAG tag1
,
473 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
475 TRACE("iface %p, tag1 %s, tag2 %s.\n", iface
, wine_dbgstr_longlong(tag1
), wine_dbgstr_longlong(tag2
));
477 ID2D1RenderTarget_SetTags(render_target
->dxgi_target
, tag1
, tag2
);
480 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_GetTags(ID2D1BitmapRenderTarget
*iface
, D2D1_TAG
*tag1
,
483 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
485 TRACE("iface %p, tag1 %p, tag2 %p.\n", iface
, tag1
, tag2
);
487 ID2D1RenderTarget_GetTags(render_target
->dxgi_target
, tag1
, tag2
);
490 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_PushLayer(ID2D1BitmapRenderTarget
*iface
,
491 const D2D1_LAYER_PARAMETERS
*layer_parameters
, ID2D1Layer
*layer
)
493 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
495 TRACE("iface %p, layer_parameters %p, layer %p.\n", iface
, layer_parameters
, layer
);
497 ID2D1RenderTarget_PushLayer(render_target
->dxgi_target
, layer_parameters
, layer
);
500 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_PopLayer(ID2D1BitmapRenderTarget
*iface
)
502 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
504 TRACE("iface %p.\n", iface
);
506 ID2D1RenderTarget_PopLayer(render_target
->dxgi_target
);
509 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_Flush(ID2D1BitmapRenderTarget
*iface
, D2D1_TAG
*tag1
,
512 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
514 TRACE("iface %p, tag1 %p, tag2 %p.\n", iface
, tag1
, tag2
);
516 return ID2D1RenderTarget_Flush(render_target
->dxgi_target
, tag1
, tag2
);
519 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_SaveDrawingState(ID2D1BitmapRenderTarget
*iface
,
520 ID2D1DrawingStateBlock
*state_block
)
522 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
524 TRACE("iface %p, state_block %p.\n", iface
, state_block
);
526 ID2D1RenderTarget_SaveDrawingState(render_target
->dxgi_target
, state_block
);
529 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_RestoreDrawingState(ID2D1BitmapRenderTarget
*iface
,
530 ID2D1DrawingStateBlock
*state_block
)
532 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
534 TRACE("iface %p, state_block %p.\n", iface
, state_block
);
536 ID2D1RenderTarget_RestoreDrawingState(render_target
->dxgi_target
, state_block
);
539 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_PushAxisAlignedClip(ID2D1BitmapRenderTarget
*iface
,
540 const D2D1_RECT_F
*clip_rect
, D2D1_ANTIALIAS_MODE antialias_mode
)
542 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
544 TRACE("iface %p, clip_rect %s, antialias_mode %#x.\n", iface
, debug_d2d_rect_f(clip_rect
), antialias_mode
);
546 ID2D1RenderTarget_PushAxisAlignedClip(render_target
->dxgi_target
, clip_rect
, antialias_mode
);
549 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_PopAxisAlignedClip(ID2D1BitmapRenderTarget
*iface
)
551 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
553 TRACE("iface %p.\n", iface
);
555 ID2D1RenderTarget_PopAxisAlignedClip(render_target
->dxgi_target
);
558 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_Clear(ID2D1BitmapRenderTarget
*iface
, const D2D1_COLOR_F
*color
)
560 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
562 TRACE("iface %p, color %p.\n", iface
, color
);
564 ID2D1RenderTarget_Clear(render_target
->dxgi_target
, color
);
567 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_BeginDraw(ID2D1BitmapRenderTarget
*iface
)
569 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
571 TRACE("iface %p.\n", iface
);
573 ID2D1RenderTarget_BeginDraw(render_target
->dxgi_target
);
576 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_EndDraw(ID2D1BitmapRenderTarget
*iface
,
577 D2D1_TAG
*tag1
, D2D1_TAG
*tag2
)
579 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
581 TRACE("iface %p, tag1 %p, tag2 %p.\n", iface
, tag1
, tag2
);
583 return ID2D1RenderTarget_EndDraw(render_target
->dxgi_target
, tag1
, tag2
);
586 static D2D1_PIXEL_FORMAT
* STDMETHODCALLTYPE
d2d_bitmap_render_target_GetPixelFormat(ID2D1BitmapRenderTarget
*iface
,
587 D2D1_PIXEL_FORMAT
*format
)
589 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
591 TRACE("iface %p, format %p.\n", iface
, format
);
593 *format
= ID2D1RenderTarget_GetPixelFormat(render_target
->dxgi_target
);
597 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_SetDpi(ID2D1BitmapRenderTarget
*iface
, float dpi_x
, float dpi_y
)
599 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
601 TRACE("iface %p, dpi_x %.8e, dpi_y %.8e.\n", iface
, dpi_x
, dpi_y
);
603 ID2D1RenderTarget_SetDpi(render_target
->dxgi_target
, dpi_x
, dpi_y
);
606 static void STDMETHODCALLTYPE
d2d_bitmap_render_target_GetDpi(ID2D1BitmapRenderTarget
*iface
,
607 float *dpi_x
, float *dpi_y
)
609 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
611 TRACE("iface %p, dpi_x %p, dpi_y %p.\n", iface
, dpi_x
, dpi_y
);
613 ID2D1RenderTarget_GetDpi(render_target
->dxgi_target
, dpi_x
, dpi_y
);
616 static D2D1_SIZE_F
* STDMETHODCALLTYPE
d2d_bitmap_render_target_GetSize(ID2D1BitmapRenderTarget
*iface
,
619 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
621 TRACE("iface %p, size %p.\n", iface
, size
);
623 *size
= ID2D1RenderTarget_GetSize(render_target
->dxgi_target
);
627 static D2D1_SIZE_U
* STDMETHODCALLTYPE
d2d_bitmap_render_target_GetPixelSize(ID2D1BitmapRenderTarget
*iface
,
628 D2D1_SIZE_U
*pixel_size
)
630 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
632 TRACE("iface %p, pixel_size %p.\n", iface
, pixel_size
);
634 *pixel_size
= ID2D1RenderTarget_GetPixelSize(render_target
->dxgi_target
);
638 static UINT32 STDMETHODCALLTYPE
d2d_bitmap_render_target_GetMaximumBitmapSize(ID2D1BitmapRenderTarget
*iface
)
640 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
642 TRACE("iface %p.\n", iface
);
644 return ID2D1RenderTarget_GetMaximumBitmapSize(render_target
->dxgi_target
);
647 static BOOL STDMETHODCALLTYPE
d2d_bitmap_render_target_IsSupported(ID2D1BitmapRenderTarget
*iface
,
648 const D2D1_RENDER_TARGET_PROPERTIES
*desc
)
650 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
652 TRACE("iface %p, desc %p.\n", iface
, desc
);
654 return ID2D1RenderTarget_IsSupported(render_target
->dxgi_target
, desc
);
657 static HRESULT STDMETHODCALLTYPE
d2d_bitmap_render_target_GetBitmap(ID2D1BitmapRenderTarget
*iface
,
658 ID2D1Bitmap
**bitmap
)
660 struct d2d_bitmap_render_target
*render_target
= impl_from_ID2D1BitmapRenderTarget(iface
);
662 TRACE("iface %p, bitmap %p.\n", iface
, bitmap
);
664 ID2D1Bitmap_AddRef(*bitmap
= render_target
->bitmap
);
668 static const struct ID2D1BitmapRenderTargetVtbl d2d_bitmap_render_target_vtbl
=
670 d2d_bitmap_render_target_QueryInterface
,
671 d2d_bitmap_render_target_AddRef
,
672 d2d_bitmap_render_target_Release
,
673 d2d_bitmap_render_target_GetFactory
,
674 d2d_bitmap_render_target_CreateBitmap
,
675 d2d_bitmap_render_target_CreateBitmapFromWicBitmap
,
676 d2d_bitmap_render_target_CreateSharedBitmap
,
677 d2d_bitmap_render_target_CreateBitmapBrush
,
678 d2d_bitmap_render_target_CreateSolidColorBrush
,
679 d2d_bitmap_render_target_CreateGradientStopCollection
,
680 d2d_bitmap_render_target_CreateLinearGradientBrush
,
681 d2d_bitmap_render_target_CreateRadialGradientBrush
,
682 d2d_bitmap_render_target_CreateCompatibleRenderTarget
,
683 d2d_bitmap_render_target_CreateLayer
,
684 d2d_bitmap_render_target_CreateMesh
,
685 d2d_bitmap_render_target_DrawLine
,
686 d2d_bitmap_render_target_DrawRectangle
,
687 d2d_bitmap_render_target_FillRectangle
,
688 d2d_bitmap_render_target_DrawRoundedRectangle
,
689 d2d_bitmap_render_target_FillRoundedRectangle
,
690 d2d_bitmap_render_target_DrawEllipse
,
691 d2d_bitmap_render_target_FillEllipse
,
692 d2d_bitmap_render_target_DrawGeometry
,
693 d2d_bitmap_render_target_FillGeometry
,
694 d2d_bitmap_render_target_FillMesh
,
695 d2d_bitmap_render_target_FillOpacityMask
,
696 d2d_bitmap_render_target_DrawBitmap
,
697 d2d_bitmap_render_target_DrawText
,
698 d2d_bitmap_render_target_DrawTextLayout
,
699 d2d_bitmap_render_target_DrawGlyphRun
,
700 d2d_bitmap_render_target_SetTransform
,
701 d2d_bitmap_render_target_GetTransform
,
702 d2d_bitmap_render_target_SetAntialiasMode
,
703 d2d_bitmap_render_target_GetAntialiasMode
,
704 d2d_bitmap_render_target_SetTextAntialiasMode
,
705 d2d_bitmap_render_target_GetTextAntialiasMode
,
706 d2d_bitmap_render_target_SetTextRenderingParams
,
707 d2d_bitmap_render_target_GetTextRenderingParams
,
708 d2d_bitmap_render_target_SetTags
,
709 d2d_bitmap_render_target_GetTags
,
710 d2d_bitmap_render_target_PushLayer
,
711 d2d_bitmap_render_target_PopLayer
,
712 d2d_bitmap_render_target_Flush
,
713 d2d_bitmap_render_target_SaveDrawingState
,
714 d2d_bitmap_render_target_RestoreDrawingState
,
715 d2d_bitmap_render_target_PushAxisAlignedClip
,
716 d2d_bitmap_render_target_PopAxisAlignedClip
,
717 d2d_bitmap_render_target_Clear
,
718 d2d_bitmap_render_target_BeginDraw
,
719 d2d_bitmap_render_target_EndDraw
,
720 d2d_bitmap_render_target_GetPixelFormat
,
721 d2d_bitmap_render_target_SetDpi
,
722 d2d_bitmap_render_target_GetDpi
,
723 d2d_bitmap_render_target_GetSize
,
724 d2d_bitmap_render_target_GetPixelSize
,
725 d2d_bitmap_render_target_GetMaximumBitmapSize
,
726 d2d_bitmap_render_target_IsSupported
,
727 d2d_bitmap_render_target_GetBitmap
730 HRESULT
d2d_bitmap_render_target_init(struct d2d_bitmap_render_target
*render_target
,
731 const struct d2d_d3d_render_target
*parent_target
, const D2D1_SIZE_F
*size
,
732 const D2D1_SIZE_U
*pixel_size
, const D2D1_PIXEL_FORMAT
*pixel_format
,
733 D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS options
)
735 D2D1_RENDER_TARGET_PROPERTIES dxgi_rt_desc
;
736 D2D1_BITMAP_PROPERTIES bitmap_desc
;
737 D3D10_TEXTURE2D_DESC texture_desc
;
738 IDXGISurface
*dxgi_surface
;
739 ID3D10Texture2D
*texture
;
743 FIXME("Compatible target options are ignored, %#x.\n", options
);
745 render_target
->ID2D1BitmapRenderTarget_iface
.lpVtbl
= &d2d_bitmap_render_target_vtbl
;
746 render_target
->refcount
= 1;
748 dxgi_rt_desc
.type
= parent_target
->desc
.type
;
749 dxgi_rt_desc
.usage
= parent_target
->desc
.usage
;
750 dxgi_rt_desc
.minLevel
= parent_target
->desc
.minLevel
;
754 texture_desc
.Width
= pixel_size
->width
;
755 texture_desc
.Height
= pixel_size
->height
;
759 texture_desc
.Width
= ceilf((size
->width
* parent_target
->desc
.dpiX
) / 96.0f
);
760 texture_desc
.Height
= ceilf((size
->height
* parent_target
->desc
.dpiY
) / 96.0f
);
764 texture_desc
.Width
= parent_target
->pixel_size
.width
;
765 texture_desc
.Height
= parent_target
->pixel_size
.height
;
770 dxgi_rt_desc
.dpiX
= (texture_desc
.Width
* 96.0f
) / size
->width
;
771 dxgi_rt_desc
.dpiY
= (texture_desc
.Height
* 96.0f
) / size
->height
;
775 dxgi_rt_desc
.dpiX
= parent_target
->desc
.dpiX
;
776 dxgi_rt_desc
.dpiY
= parent_target
->desc
.dpiY
;
779 if (!pixel_format
|| pixel_format
->format
== DXGI_FORMAT_UNKNOWN
)
780 texture_desc
.Format
= parent_target
->desc
.pixelFormat
.format
;
782 texture_desc
.Format
= pixel_format
->format
;
783 dxgi_rt_desc
.pixelFormat
.format
= texture_desc
.Format
;
785 if (!pixel_format
|| pixel_format
->alphaMode
== D2D1_ALPHA_MODE_UNKNOWN
)
786 dxgi_rt_desc
.pixelFormat
.alphaMode
= D2D1_ALPHA_MODE_PREMULTIPLIED
;
788 dxgi_rt_desc
.pixelFormat
.alphaMode
= pixel_format
->alphaMode
;
790 texture_desc
.MipLevels
= 1;
791 texture_desc
.ArraySize
= 1;
792 texture_desc
.SampleDesc
.Count
= 1;
793 texture_desc
.SampleDesc
.Quality
= 0;
794 texture_desc
.Usage
= D3D10_USAGE_DEFAULT
;
795 texture_desc
.BindFlags
= D3D10_BIND_RENDER_TARGET
| D3D10_BIND_SHADER_RESOURCE
;
796 texture_desc
.CPUAccessFlags
= 0;
797 texture_desc
.MiscFlags
= 0;
799 if (FAILED(hr
= ID3D10Device_CreateTexture2D(parent_target
->device
, &texture_desc
, NULL
, &texture
)))
801 WARN("Failed to create texture, hr %#x.\n", hr
);
805 hr
= ID3D10Texture2D_QueryInterface(texture
, &IID_IDXGISurface
, (void **)&dxgi_surface
);
806 ID3D10Texture2D_Release(texture
);
809 WARN("Failed to get DXGI surface interface, hr %#x.\n", hr
);
813 if (FAILED(hr
= d2d_d3d_create_render_target(parent_target
->factory
, dxgi_surface
,
814 (IUnknown
*)&render_target
->ID2D1BitmapRenderTarget_iface
, &dxgi_rt_desc
, &render_target
->dxgi_target
)))
816 WARN("Failed to create DXGI surface render target, hr %#x.\n", hr
);
817 IDXGISurface_Release(dxgi_surface
);
821 bitmap_desc
.pixelFormat
= dxgi_rt_desc
.pixelFormat
;
822 bitmap_desc
.dpiX
= dxgi_rt_desc
.dpiX
;
823 bitmap_desc
.dpiY
= dxgi_rt_desc
.dpiY
;
825 hr
= ID2D1RenderTarget_CreateSharedBitmap(render_target
->dxgi_target
, &IID_IDXGISurface
, dxgi_surface
,
826 &bitmap_desc
, &render_target
->bitmap
);
827 IDXGISurface_Release(dxgi_surface
);
830 WARN("Failed to create shared bitmap, hr %#x.\n", hr
);
831 ID2D1RenderTarget_Release(render_target
->dxgi_target
);