d2d1: Initial implementation of bitmap render target.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2016-10-19 20:00:21 +03:00 committed by Alexandre Julliard
parent 82a590403f
commit e9da184bbd
6 changed files with 895 additions and 41 deletions

View File

@ -5,6 +5,7 @@ DELAYIMPORTS = dwrite
C_SRCS = \ C_SRCS = \
bitmap.c \ bitmap.c \
bitmap_render_target.c \
brush.c \ brush.c \
dc_render_target.c \ dc_render_target.c \
factory.c \ factory.c \

View File

@ -0,0 +1,832 @@
/*
* Copyright 2014 Henri Verbeet for CodeWeavers
* Copyright 2016 Nikolay Sivov for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include "d2d1_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d2d);
static inline struct d2d_bitmap_render_target *impl_from_ID2D1BitmapRenderTarget(ID2D1BitmapRenderTarget *iface)
{
return CONTAINING_RECORD(iface, struct d2d_bitmap_render_target, ID2D1BitmapRenderTarget_iface);
}
static HRESULT STDMETHODCALLTYPE d2d_bitmap_render_target_QueryInterface(ID2D1BitmapRenderTarget *iface,
REFIID iid, void **out)
{
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
if (IsEqualGUID(iid, &IID_ID2D1BitmapRenderTarget)
|| IsEqualGUID(iid, &IID_ID2D1RenderTarget)
|| IsEqualGUID(iid, &IID_ID2D1Resource)
|| IsEqualGUID(iid, &IID_IUnknown))
{
ID2D1BitmapRenderTarget_AddRef(iface);
*out = iface;
return S_OK;
}
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
*out = NULL;
return E_NOINTERFACE;
}
static ULONG STDMETHODCALLTYPE d2d_bitmap_render_target_AddRef(ID2D1BitmapRenderTarget *iface)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
ULONG refcount = InterlockedIncrement(&render_target->refcount);
TRACE("%p increasing refcount to %u.\n", iface, refcount);
return refcount;
}
static ULONG STDMETHODCALLTYPE d2d_bitmap_render_target_Release(ID2D1BitmapRenderTarget *iface)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
ULONG refcount = InterlockedDecrement(&render_target->refcount);
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
if (!refcount)
{
ID2D1RenderTarget_Release(render_target->dxgi_target);
ID2D1Bitmap_Release(render_target->bitmap);
HeapFree(GetProcessHeap(), 0, render_target);
}
return refcount;
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_GetFactory(ID2D1BitmapRenderTarget *iface,
ID2D1Factory **factory)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, factory %p.\n", iface, factory);
ID2D1RenderTarget_GetFactory(render_target->dxgi_target, factory);
}
static HRESULT STDMETHODCALLTYPE d2d_bitmap_render_target_CreateBitmap(ID2D1BitmapRenderTarget *iface,
D2D1_SIZE_U size, const void *src_data, UINT32 pitch, const D2D1_BITMAP_PROPERTIES *desc, ID2D1Bitmap **bitmap)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, size {%u, %u}, src_data %p, pitch %u, desc %p, bitmap %p.\n",
iface, size.width, size.height, src_data, pitch, desc, bitmap);
return ID2D1RenderTarget_CreateBitmap(render_target->dxgi_target, size, src_data, pitch, desc, bitmap);
}
static HRESULT STDMETHODCALLTYPE d2d_bitmap_render_target_CreateBitmapFromWicBitmap(ID2D1BitmapRenderTarget *iface,
IWICBitmapSource *bitmap_source, const D2D1_BITMAP_PROPERTIES *desc, ID2D1Bitmap **bitmap)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, bitmap_source %p, desc %p, bitmap %p.\n",
iface, bitmap_source, desc, bitmap);
return ID2D1RenderTarget_CreateBitmapFromWicBitmap(render_target->dxgi_target, bitmap_source, desc, bitmap);
}
static HRESULT STDMETHODCALLTYPE d2d_bitmap_render_target_CreateSharedBitmap(ID2D1BitmapRenderTarget *iface,
REFIID iid, void *data, const D2D1_BITMAP_PROPERTIES *desc, ID2D1Bitmap **bitmap)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, iid %s, data %p, desc %p, bitmap %p.\n",
iface, debugstr_guid(iid), data, desc, bitmap);
return ID2D1RenderTarget_CreateSharedBitmap(render_target->dxgi_target, iid, data, desc, bitmap);
}
static HRESULT STDMETHODCALLTYPE d2d_bitmap_render_target_CreateBitmapBrush(ID2D1BitmapRenderTarget *iface,
ID2D1Bitmap *bitmap, const D2D1_BITMAP_BRUSH_PROPERTIES *bitmap_brush_desc,
const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1BitmapBrush **brush)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, bitmap %p, bitmap_brush_desc %p, brush_desc %p, brush %p.\n",
iface, bitmap, bitmap_brush_desc, brush_desc, brush);
return ID2D1RenderTarget_CreateBitmapBrush(render_target->dxgi_target,
bitmap, bitmap_brush_desc, brush_desc, brush);
}
static HRESULT STDMETHODCALLTYPE d2d_bitmap_render_target_CreateSolidColorBrush(ID2D1BitmapRenderTarget *iface,
const D2D1_COLOR_F *color, const D2D1_BRUSH_PROPERTIES *desc, ID2D1SolidColorBrush **brush)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, color %p, desc %p, brush %p.\n", iface, color, desc, brush);
return ID2D1RenderTarget_CreateSolidColorBrush(render_target->dxgi_target, color, desc, brush);
}
static HRESULT STDMETHODCALLTYPE d2d_bitmap_render_target_CreateGradientStopCollection(ID2D1BitmapRenderTarget *iface,
const D2D1_GRADIENT_STOP *stops, UINT32 stop_count, D2D1_GAMMA gamma, D2D1_EXTEND_MODE extend_mode,
ID2D1GradientStopCollection **gradient)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, stops %p, stop_count %u, gamma %#x, extend_mode %#x, gradient %p.\n",
iface, stops, stop_count, gamma, extend_mode, gradient);
return ID2D1RenderTarget_CreateGradientStopCollection(render_target->dxgi_target,
stops, stop_count, gamma, extend_mode, gradient);
}
static HRESULT STDMETHODCALLTYPE d2d_bitmap_render_target_CreateLinearGradientBrush(ID2D1BitmapRenderTarget *iface,
const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES *gradient_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
ID2D1GradientStopCollection *gradient, ID2D1LinearGradientBrush **brush)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, gradient_brush_desc %p, brush_desc %p, gradient %p, brush %p.\n",
iface, gradient_brush_desc, brush_desc, gradient, brush);
return ID2D1RenderTarget_CreateLinearGradientBrush(render_target->dxgi_target,
gradient_brush_desc, brush_desc, gradient, brush);
}
static HRESULT STDMETHODCALLTYPE d2d_bitmap_render_target_CreateRadialGradientBrush(ID2D1BitmapRenderTarget *iface,
const D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES *gradient_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
ID2D1GradientStopCollection *gradient, ID2D1RadialGradientBrush **brush)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, gradient_brush_desc %p, brush_desc %p, gradient %p, brush %p.\n",
iface, gradient_brush_desc, brush_desc, gradient, brush);
return ID2D1RenderTarget_CreateRadialGradientBrush(render_target->dxgi_target,
gradient_brush_desc, brush_desc, gradient, brush);
}
static HRESULT STDMETHODCALLTYPE d2d_bitmap_render_target_CreateCompatibleRenderTarget(ID2D1BitmapRenderTarget *iface,
const D2D1_SIZE_F *size, const D2D1_SIZE_U *pixel_size, const D2D1_PIXEL_FORMAT *format,
D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS options, ID2D1BitmapRenderTarget **render_target)
{
struct d2d_bitmap_render_target *rt = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, size %p, pixel_size %p, format %p, options %#x, render_target %p,\n",
iface, size, pixel_size, format, options, render_target);
return ID2D1RenderTarget_CreateCompatibleRenderTarget(rt->dxgi_target,
size, pixel_size, format, options, render_target);
}
static HRESULT STDMETHODCALLTYPE d2d_bitmap_render_target_CreateLayer(ID2D1BitmapRenderTarget *iface,
const D2D1_SIZE_F *size, ID2D1Layer **layer)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, size %p, layer %p.\n", iface, size, layer);
return ID2D1RenderTarget_CreateLayer(render_target->dxgi_target, size, layer);
}
static HRESULT STDMETHODCALLTYPE d2d_bitmap_render_target_CreateMesh(ID2D1BitmapRenderTarget *iface, ID2D1Mesh **mesh)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, mesh %p.\n", iface, mesh);
return ID2D1RenderTarget_CreateMesh(render_target->dxgi_target, mesh);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_DrawLine(ID2D1BitmapRenderTarget *iface,
D2D1_POINT_2F p0, D2D1_POINT_2F p1, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, p0 {%.8e, %.8e}, p1 {%.8e, %.8e}, brush %p, stroke_width %.8e, stroke_style %p.\n",
iface, p0.x, p0.y, p1.x, p1.y, brush, stroke_width, stroke_style);
ID2D1RenderTarget_DrawLine(render_target->dxgi_target, p0, p1, brush, stroke_width, stroke_style);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_DrawRectangle(ID2D1BitmapRenderTarget *iface,
const D2D1_RECT_F *rect, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, rect %p, brush %p, stroke_width %.8e, stroke_style %p.\n",
iface, rect, brush, stroke_width, stroke_style);
ID2D1RenderTarget_DrawRectangle(render_target->dxgi_target, rect, brush, stroke_width, stroke_style);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_FillRectangle(ID2D1BitmapRenderTarget *iface,
const D2D1_RECT_F *rect, ID2D1Brush *brush)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, rect %p, brush %p.\n", iface, rect, brush);
ID2D1RenderTarget_FillRectangle(render_target->dxgi_target, rect, brush);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_DrawRoundedRectangle(ID2D1BitmapRenderTarget *iface,
const D2D1_ROUNDED_RECT *rect, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, rect %p, brush %p, stroke_width %.8e, stroke_style %p.\n",
iface, rect, brush, stroke_width, stroke_style);
ID2D1RenderTarget_DrawRoundedRectangle(render_target->dxgi_target, rect, brush, stroke_width, stroke_style);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_FillRoundedRectangle(ID2D1BitmapRenderTarget *iface,
const D2D1_ROUNDED_RECT *rect, ID2D1Brush *brush)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, rect %p, brush %p.\n", iface, rect, brush);
ID2D1RenderTarget_FillRoundedRectangle(render_target->dxgi_target, rect, brush);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_DrawEllipse(ID2D1BitmapRenderTarget *iface,
const D2D1_ELLIPSE *ellipse, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, ellipse %p, brush %p, stroke_width %.8e, stroke_style %p.\n",
iface, ellipse, brush, stroke_width, stroke_style);
ID2D1RenderTarget_DrawEllipse(render_target->dxgi_target, ellipse, brush, stroke_width, stroke_style);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_FillEllipse(ID2D1BitmapRenderTarget *iface,
const D2D1_ELLIPSE *ellipse, ID2D1Brush *brush)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, ellipse %p, brush %p.\n", iface, ellipse, brush);
ID2D1RenderTarget_FillEllipse(render_target->dxgi_target, ellipse, brush);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_DrawGeometry(ID2D1BitmapRenderTarget *iface,
ID2D1Geometry *geometry, ID2D1Brush *brush, float stroke_width, ID2D1StrokeStyle *stroke_style)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, geometry %p, brush %p, stroke_width %.8e, stroke_style %p.\n",
iface, geometry, brush, stroke_width, stroke_style);
ID2D1RenderTarget_DrawGeometry(render_target->dxgi_target, geometry, brush, stroke_width, stroke_style);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_FillGeometry(ID2D1BitmapRenderTarget *iface,
ID2D1Geometry *geometry, ID2D1Brush *brush, ID2D1Brush *opacity_brush)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, geometry %p, brush %p, opacity_brush %p.\n", iface, geometry, brush, opacity_brush);
ID2D1RenderTarget_FillGeometry(render_target->dxgi_target, geometry, brush, opacity_brush);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_FillMesh(ID2D1BitmapRenderTarget *iface,
ID2D1Mesh *mesh, ID2D1Brush *brush)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, mesh %p, brush %p.\n", iface, mesh, brush);
ID2D1RenderTarget_FillMesh(render_target->dxgi_target, mesh, brush);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_FillOpacityMask(ID2D1BitmapRenderTarget *iface,
ID2D1Bitmap *mask, ID2D1Brush *brush, D2D1_OPACITY_MASK_CONTENT content,
const D2D1_RECT_F *dst_rect, const D2D1_RECT_F *src_rect)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, mask %p, brush %p, content %#x, dst_rect %p, src_rect %p.\n",
iface, mask, brush, content, dst_rect, src_rect);
ID2D1RenderTarget_FillOpacityMask(render_target->dxgi_target,
mask, brush, content, dst_rect, src_rect);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_DrawBitmap(ID2D1BitmapRenderTarget *iface,
ID2D1Bitmap *bitmap, const D2D1_RECT_F *dst_rect, float opacity,
D2D1_BITMAP_INTERPOLATION_MODE interpolation_mode, const D2D1_RECT_F *src_rect)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, bitmap %p, dst_rect %p, opacity %.8e, interpolation_mode %#x, src_rect %p.\n",
iface, bitmap, dst_rect, opacity, interpolation_mode, src_rect);
ID2D1RenderTarget_DrawBitmap(render_target->dxgi_target,
bitmap, dst_rect, opacity, interpolation_mode, src_rect);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_DrawText(ID2D1BitmapRenderTarget *iface,
const WCHAR *string, UINT32 string_len, IDWriteTextFormat *text_format, const D2D1_RECT_F *layout_rect,
ID2D1Brush *brush, D2D1_DRAW_TEXT_OPTIONS options, DWRITE_MEASURING_MODE measuring_mode)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, string %s, string_len %u, text_format %p, layout_rect %p, "
"brush %p, options %#x, measuring_mode %#x.\n",
iface, debugstr_wn(string, string_len), string_len, text_format, layout_rect,
brush, options, measuring_mode);
ID2D1RenderTarget_DrawText(render_target->dxgi_target, string, string_len,
text_format, layout_rect, brush, options, measuring_mode);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_DrawTextLayout(ID2D1BitmapRenderTarget *iface,
D2D1_POINT_2F origin, IDWriteTextLayout *layout, ID2D1Brush *brush, D2D1_DRAW_TEXT_OPTIONS options)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, origin {%.8e, %.8e}, layout %p, brush %p, options %#x.\n",
iface, origin.x, origin.y, layout, brush, options);
ID2D1RenderTarget_DrawTextLayout(render_target->dxgi_target, origin, layout, brush, options);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_DrawGlyphRun(ID2D1BitmapRenderTarget *iface,
D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *glyph_run, ID2D1Brush *brush,
DWRITE_MEASURING_MODE measuring_mode)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, baseline_origin {%.8e, %.8e}, glyph_run %p, brush %p, measuring_mode %#x.\n",
iface, baseline_origin.x, baseline_origin.y, glyph_run, brush, measuring_mode);
ID2D1RenderTarget_DrawGlyphRun(render_target->dxgi_target,
baseline_origin, glyph_run, brush, measuring_mode);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_SetTransform(ID2D1BitmapRenderTarget *iface,
const D2D1_MATRIX_3X2_F *transform)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, transform %p.\n", iface, transform);
ID2D1RenderTarget_SetTransform(render_target->dxgi_target, transform);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_GetTransform(ID2D1BitmapRenderTarget *iface,
D2D1_MATRIX_3X2_F *transform)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, transform %p.\n", iface, transform);
ID2D1RenderTarget_GetTransform(render_target->dxgi_target, transform);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_SetAntialiasMode(ID2D1BitmapRenderTarget *iface,
D2D1_ANTIALIAS_MODE antialias_mode)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, antialias_mode %#x.\n", iface, antialias_mode);
ID2D1RenderTarget_SetAntialiasMode(render_target->dxgi_target, antialias_mode);
}
static D2D1_ANTIALIAS_MODE STDMETHODCALLTYPE d2d_bitmap_render_target_GetAntialiasMode(ID2D1BitmapRenderTarget *iface)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p.\n", iface);
return ID2D1RenderTarget_GetAntialiasMode(render_target->dxgi_target);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_SetTextAntialiasMode(ID2D1BitmapRenderTarget *iface,
D2D1_TEXT_ANTIALIAS_MODE antialias_mode)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, antialias_mode %#x.\n", iface, antialias_mode);
ID2D1RenderTarget_SetTextAntialiasMode(render_target->dxgi_target, antialias_mode);
}
static D2D1_TEXT_ANTIALIAS_MODE STDMETHODCALLTYPE d2d_bitmap_render_target_GetTextAntialiasMode(
ID2D1BitmapRenderTarget *iface)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p.\n", iface);
return ID2D1RenderTarget_GetTextAntialiasMode(render_target->dxgi_target);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_SetTextRenderingParams(ID2D1BitmapRenderTarget *iface,
IDWriteRenderingParams *text_rendering_params)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, text_rendering_params %p.\n", iface, text_rendering_params);
ID2D1RenderTarget_SetTextRenderingParams(render_target->dxgi_target, text_rendering_params);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_GetTextRenderingParams(ID2D1BitmapRenderTarget *iface,
IDWriteRenderingParams **text_rendering_params)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, text_rendering_params %p.\n", iface, text_rendering_params);
ID2D1RenderTarget_GetTextRenderingParams(render_target->dxgi_target, text_rendering_params);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_SetTags(ID2D1BitmapRenderTarget *iface, D2D1_TAG tag1,
D2D1_TAG tag2)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, tag1 %s, tag2 %s.\n", iface, wine_dbgstr_longlong(tag1), wine_dbgstr_longlong(tag2));
ID2D1RenderTarget_SetTags(render_target->dxgi_target, tag1, tag2);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_GetTags(ID2D1BitmapRenderTarget *iface, D2D1_TAG *tag1,
D2D1_TAG *tag2)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, tag1 %p, tag2 %p.\n", iface, tag1, tag2);
ID2D1RenderTarget_GetTags(render_target->dxgi_target, tag1, tag2);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_PushLayer(ID2D1BitmapRenderTarget *iface,
const D2D1_LAYER_PARAMETERS *layer_parameters, ID2D1Layer *layer)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, layer_parameters %p, layer %p.\n", iface, layer_parameters, layer);
ID2D1RenderTarget_PushLayer(render_target->dxgi_target, layer_parameters, layer);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_PopLayer(ID2D1BitmapRenderTarget *iface)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p.\n", iface);
ID2D1RenderTarget_PopLayer(render_target->dxgi_target);
}
static HRESULT STDMETHODCALLTYPE d2d_bitmap_render_target_Flush(ID2D1BitmapRenderTarget *iface, D2D1_TAG *tag1,
D2D1_TAG *tag2)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, tag1 %p, tag2 %p.\n", iface, tag1, tag2);
return ID2D1RenderTarget_Flush(render_target->dxgi_target, tag1, tag2);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_SaveDrawingState(ID2D1BitmapRenderTarget *iface,
ID2D1DrawingStateBlock *state_block)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, state_block %p.\n", iface, state_block);
ID2D1RenderTarget_SaveDrawingState(render_target->dxgi_target, state_block);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_RestoreDrawingState(ID2D1BitmapRenderTarget *iface,
ID2D1DrawingStateBlock *state_block)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, state_block %p.\n", iface, state_block);
ID2D1RenderTarget_RestoreDrawingState(render_target->dxgi_target, state_block);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_PushAxisAlignedClip(ID2D1BitmapRenderTarget *iface,
const D2D1_RECT_F *clip_rect, D2D1_ANTIALIAS_MODE antialias_mode)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, clip_rect %p, antialias_mode %#x.\n", iface, clip_rect, antialias_mode);
ID2D1RenderTarget_PushAxisAlignedClip(render_target->dxgi_target, clip_rect, antialias_mode);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_PopAxisAlignedClip(ID2D1BitmapRenderTarget *iface)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p.\n", iface);
ID2D1RenderTarget_PopAxisAlignedClip(render_target->dxgi_target);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_Clear(ID2D1BitmapRenderTarget *iface, const D2D1_COLOR_F *color)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, color %p.\n", iface, color);
ID2D1RenderTarget_Clear(render_target->dxgi_target, color);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_BeginDraw(ID2D1BitmapRenderTarget *iface)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p.\n", iface);
ID2D1RenderTarget_BeginDraw(render_target->dxgi_target);
}
static HRESULT STDMETHODCALLTYPE d2d_bitmap_render_target_EndDraw(ID2D1BitmapRenderTarget *iface,
D2D1_TAG *tag1, D2D1_TAG *tag2)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, tag1 %p, tag2 %p.\n", iface, tag1, tag2);
return ID2D1RenderTarget_EndDraw(render_target->dxgi_target, tag1, tag2);
}
static D2D1_PIXEL_FORMAT * STDMETHODCALLTYPE d2d_bitmap_render_target_GetPixelFormat(ID2D1BitmapRenderTarget *iface,
D2D1_PIXEL_FORMAT *format)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, format %p.\n", iface, format);
*format = ID2D1RenderTarget_GetPixelFormat(render_target->dxgi_target);
return format;
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_SetDpi(ID2D1BitmapRenderTarget *iface, float dpi_x, float dpi_y)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, dpi_x %.8e, dpi_y %.8e.\n", iface, dpi_x, dpi_y);
ID2D1RenderTarget_SetDpi(render_target->dxgi_target, dpi_x, dpi_y);
}
static void STDMETHODCALLTYPE d2d_bitmap_render_target_GetDpi(ID2D1BitmapRenderTarget *iface,
float *dpi_x, float *dpi_y)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, dpi_x %p, dpi_y %p.\n", iface, dpi_x, dpi_y);
ID2D1RenderTarget_GetDpi(render_target->dxgi_target, dpi_x, dpi_y);
}
static D2D1_SIZE_F * STDMETHODCALLTYPE d2d_bitmap_render_target_GetSize(ID2D1BitmapRenderTarget *iface,
D2D1_SIZE_F *size)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, size %p.\n", iface, size);
*size = ID2D1RenderTarget_GetSize(render_target->dxgi_target);
return size;
}
static D2D1_SIZE_U * STDMETHODCALLTYPE d2d_bitmap_render_target_GetPixelSize(ID2D1BitmapRenderTarget *iface,
D2D1_SIZE_U *pixel_size)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, pixel_size %p.\n", iface, pixel_size);
*pixel_size = ID2D1RenderTarget_GetPixelSize(render_target->dxgi_target);
return pixel_size;
}
static UINT32 STDMETHODCALLTYPE d2d_bitmap_render_target_GetMaximumBitmapSize(ID2D1BitmapRenderTarget *iface)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p.\n", iface);
return ID2D1RenderTarget_GetMaximumBitmapSize(render_target->dxgi_target);
}
static BOOL STDMETHODCALLTYPE d2d_bitmap_render_target_IsSupported(ID2D1BitmapRenderTarget *iface,
const D2D1_RENDER_TARGET_PROPERTIES *desc)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, desc %p.\n", iface, desc);
return ID2D1RenderTarget_IsSupported(render_target->dxgi_target, desc);
}
static HRESULT STDMETHODCALLTYPE d2d_bitmap_render_target_GetBitmap(ID2D1BitmapRenderTarget *iface,
ID2D1Bitmap **bitmap)
{
struct d2d_bitmap_render_target *render_target = impl_from_ID2D1BitmapRenderTarget(iface);
TRACE("iface %p, bitmap %p.\n", iface, bitmap);
ID2D1Bitmap_AddRef(*bitmap = render_target->bitmap);
return S_OK;
}
static const struct ID2D1BitmapRenderTargetVtbl d2d_bitmap_render_target_vtbl =
{
d2d_bitmap_render_target_QueryInterface,
d2d_bitmap_render_target_AddRef,
d2d_bitmap_render_target_Release,
d2d_bitmap_render_target_GetFactory,
d2d_bitmap_render_target_CreateBitmap,
d2d_bitmap_render_target_CreateBitmapFromWicBitmap,
d2d_bitmap_render_target_CreateSharedBitmap,
d2d_bitmap_render_target_CreateBitmapBrush,
d2d_bitmap_render_target_CreateSolidColorBrush,
d2d_bitmap_render_target_CreateGradientStopCollection,
d2d_bitmap_render_target_CreateLinearGradientBrush,
d2d_bitmap_render_target_CreateRadialGradientBrush,
d2d_bitmap_render_target_CreateCompatibleRenderTarget,
d2d_bitmap_render_target_CreateLayer,
d2d_bitmap_render_target_CreateMesh,
d2d_bitmap_render_target_DrawLine,
d2d_bitmap_render_target_DrawRectangle,
d2d_bitmap_render_target_FillRectangle,
d2d_bitmap_render_target_DrawRoundedRectangle,
d2d_bitmap_render_target_FillRoundedRectangle,
d2d_bitmap_render_target_DrawEllipse,
d2d_bitmap_render_target_FillEllipse,
d2d_bitmap_render_target_DrawGeometry,
d2d_bitmap_render_target_FillGeometry,
d2d_bitmap_render_target_FillMesh,
d2d_bitmap_render_target_FillOpacityMask,
d2d_bitmap_render_target_DrawBitmap,
d2d_bitmap_render_target_DrawText,
d2d_bitmap_render_target_DrawTextLayout,
d2d_bitmap_render_target_DrawGlyphRun,
d2d_bitmap_render_target_SetTransform,
d2d_bitmap_render_target_GetTransform,
d2d_bitmap_render_target_SetAntialiasMode,
d2d_bitmap_render_target_GetAntialiasMode,
d2d_bitmap_render_target_SetTextAntialiasMode,
d2d_bitmap_render_target_GetTextAntialiasMode,
d2d_bitmap_render_target_SetTextRenderingParams,
d2d_bitmap_render_target_GetTextRenderingParams,
d2d_bitmap_render_target_SetTags,
d2d_bitmap_render_target_GetTags,
d2d_bitmap_render_target_PushLayer,
d2d_bitmap_render_target_PopLayer,
d2d_bitmap_render_target_Flush,
d2d_bitmap_render_target_SaveDrawingState,
d2d_bitmap_render_target_RestoreDrawingState,
d2d_bitmap_render_target_PushAxisAlignedClip,
d2d_bitmap_render_target_PopAxisAlignedClip,
d2d_bitmap_render_target_Clear,
d2d_bitmap_render_target_BeginDraw,
d2d_bitmap_render_target_EndDraw,
d2d_bitmap_render_target_GetPixelFormat,
d2d_bitmap_render_target_SetDpi,
d2d_bitmap_render_target_GetDpi,
d2d_bitmap_render_target_GetSize,
d2d_bitmap_render_target_GetPixelSize,
d2d_bitmap_render_target_GetMaximumBitmapSize,
d2d_bitmap_render_target_IsSupported,
d2d_bitmap_render_target_GetBitmap
};
HRESULT d2d_bitmap_render_target_init(struct d2d_bitmap_render_target *render_target,
const struct d2d_d3d_render_target *parent_target, const D2D1_SIZE_F *size,
const D2D1_SIZE_U *pixel_size, const D2D1_PIXEL_FORMAT *pixel_format,
D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS options)
{
D2D1_RENDER_TARGET_PROPERTIES dxgi_rt_desc;
D2D1_BITMAP_PROPERTIES bitmap_desc;
D3D10_TEXTURE2D_DESC texture_desc;
IDXGISurface *dxgi_surface;
ID3D10Texture2D *texture;
HRESULT hr;
if (options)
FIXME("Compatible target options are ignored, %#x.\n", options);
render_target->ID2D1BitmapRenderTarget_iface.lpVtbl = &d2d_bitmap_render_target_vtbl;
render_target->refcount = 1;
dxgi_rt_desc.type = parent_target->desc.type;
dxgi_rt_desc.usage = parent_target->desc.usage;
dxgi_rt_desc.minLevel = parent_target->desc.minLevel;
if (pixel_size)
{
texture_desc.Width = pixel_size->width;
texture_desc.Height = pixel_size->height;
}
else if (size)
{
texture_desc.Width = ceilf((size->width * parent_target->desc.dpiX) / 96.0f);
texture_desc.Height = ceilf((size->height * parent_target->desc.dpiY) / 96.0f);
}
else
{
texture_desc.Width = parent_target->pixel_size.width;
texture_desc.Height = parent_target->pixel_size.height;
}
if (size)
{
dxgi_rt_desc.dpiX = (texture_desc.Width * 96.0f) / size->width;
dxgi_rt_desc.dpiY = (texture_desc.Height * 96.0f) / size->height;
}
else
{
dxgi_rt_desc.dpiX = parent_target->desc.dpiX;
dxgi_rt_desc.dpiY = parent_target->desc.dpiY;
}
if (!pixel_format || pixel_format->format == DXGI_FORMAT_UNKNOWN)
texture_desc.Format = parent_target->desc.pixelFormat.format;
else
texture_desc.Format = pixel_format->format;
dxgi_rt_desc.pixelFormat.format = texture_desc.Format;
if (!pixel_format || pixel_format->alphaMode == D2D1_ALPHA_MODE_UNKNOWN)
dxgi_rt_desc.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED;
else
dxgi_rt_desc.pixelFormat.alphaMode = pixel_format->alphaMode;
texture_desc.MipLevels = 1;
texture_desc.ArraySize = 1;
texture_desc.SampleDesc.Count = 1;
texture_desc.SampleDesc.Quality = 0;
texture_desc.Usage = D3D10_USAGE_DEFAULT;
texture_desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
texture_desc.CPUAccessFlags = 0;
texture_desc.MiscFlags = 0;
if (FAILED(hr = ID3D10Device_CreateTexture2D(parent_target->device, &texture_desc, NULL, &texture)))
{
WARN("Failed to create texture, hr %#x.\n", hr);
return hr;
}
hr = ID3D10Texture2D_QueryInterface(texture, &IID_IDXGISurface, (void **)&dxgi_surface);
ID3D10Texture2D_Release(texture);
if (FAILED(hr))
{
WARN("Failed to get DXGI surface interface, hr %#x.\n", hr);
return hr;
}
if (FAILED(hr = ID2D1Factory_CreateDxgiSurfaceRenderTarget(parent_target->factory, dxgi_surface, &dxgi_rt_desc,
&render_target->dxgi_target)))
{
WARN("Failed to create DXGI surface render target, hr %#x.\n", hr);
IDXGISurface_Release(dxgi_surface);
return hr;
}
bitmap_desc.pixelFormat = dxgi_rt_desc.pixelFormat;
bitmap_desc.dpiX = dxgi_rt_desc.dpiX;
bitmap_desc.dpiY = dxgi_rt_desc.dpiY;
hr = ID2D1RenderTarget_CreateSharedBitmap(render_target->dxgi_target, &IID_IDXGISurface, dxgi_surface,
&bitmap_desc, &render_target->bitmap);
IDXGISurface_Release(dxgi_surface);
if (FAILED(hr))
{
WARN("Failed to create shared bitmap, hr %#x.\n", hr);
ID2D1RenderTarget_Release(render_target->dxgi_target);
return hr;
}
return S_OK;
}

View File

@ -789,11 +789,11 @@ static BOOL d2d_brush_fill_cb(struct d2d_brush *brush, struct d2d_d3d_render_tar
/* Scale for dpi. */ /* Scale for dpi. */
w = render_target->drawing_state.transform; w = render_target->drawing_state.transform;
dpi_scale = render_target->dpi_x / 96.0f; dpi_scale = render_target->desc.dpiX / 96.0f;
w._11 *= dpi_scale; w._11 *= dpi_scale;
w._21 *= dpi_scale; w._21 *= dpi_scale;
w._31 *= dpi_scale; w._31 *= dpi_scale;
dpi_scale = render_target->dpi_y / 96.0f; dpi_scale = render_target->desc.dpiY / 96.0f;
w._12 *= dpi_scale; w._12 *= dpi_scale;
w._22 *= dpi_scale; w._22 *= dpi_scale;
w._32 *= dpi_scale; w._32 *= dpi_scale;

View File

@ -87,11 +87,9 @@ struct d2d_d3d_render_target
IDWriteRenderingParams *text_rendering_params; IDWriteRenderingParams *text_rendering_params;
IDWriteRenderingParams *default_text_rendering_params; IDWriteRenderingParams *default_text_rendering_params;
D2D1_PIXEL_FORMAT format; D2D1_RENDER_TARGET_PROPERTIES desc;
D2D1_SIZE_U pixel_size; D2D1_SIZE_U pixel_size;
struct d2d_clip_stack clip_stack; struct d2d_clip_stack clip_stack;
float dpi_x;
float dpi_y;
}; };
HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_target, ID2D1Factory *factory, HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_target, ID2D1Factory *factory,
@ -146,6 +144,20 @@ HRESULT d2d_hwnd_render_target_init(struct d2d_hwnd_render_target *render_target
ID3D10Device1 *device, const D2D1_RENDER_TARGET_PROPERTIES *desc, ID3D10Device1 *device, const D2D1_RENDER_TARGET_PROPERTIES *desc,
const D2D1_HWND_RENDER_TARGET_PROPERTIES *hwnd_desc) DECLSPEC_HIDDEN; const D2D1_HWND_RENDER_TARGET_PROPERTIES *hwnd_desc) DECLSPEC_HIDDEN;
struct d2d_bitmap_render_target
{
ID2D1BitmapRenderTarget ID2D1BitmapRenderTarget_iface;
LONG refcount;
ID2D1RenderTarget *dxgi_target;
ID2D1Bitmap *bitmap;
};
HRESULT d2d_bitmap_render_target_init(struct d2d_bitmap_render_target *render_target,
const struct d2d_d3d_render_target *parent_target, const D2D1_SIZE_F *size,
const D2D1_SIZE_U *pixel_size, const D2D1_PIXEL_FORMAT *format,
D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS options) DECLSPEC_HIDDEN;
struct d2d_gradient struct d2d_gradient
{ {
ID2D1GradientStopCollection ID2D1GradientStopCollection_iface; ID2D1GradientStopCollection ID2D1GradientStopCollection_iface;

View File

@ -426,12 +426,30 @@ static HRESULT STDMETHODCALLTYPE d2d_d3d_render_target_CreateRadialGradientBrush
static HRESULT STDMETHODCALLTYPE d2d_d3d_render_target_CreateCompatibleRenderTarget(ID2D1RenderTarget *iface, static HRESULT STDMETHODCALLTYPE d2d_d3d_render_target_CreateCompatibleRenderTarget(ID2D1RenderTarget *iface,
const D2D1_SIZE_F *size, const D2D1_SIZE_U *pixel_size, const D2D1_PIXEL_FORMAT *format, const D2D1_SIZE_F *size, const D2D1_SIZE_U *pixel_size, const D2D1_PIXEL_FORMAT *format,
D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS options, ID2D1BitmapRenderTarget **render_target) D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS options, ID2D1BitmapRenderTarget **rt)
{ {
FIXME("iface %p, size %p, pixel_size %p, format %p, options %#x, render_target %p stub!\n", struct d2d_d3d_render_target *render_target = impl_from_ID2D1RenderTarget(iface);
iface, size, pixel_size, format, options, render_target); struct d2d_bitmap_render_target *object;
HRESULT hr;
return E_NOTIMPL; TRACE("iface %p, size %p, pixel_size %p, format %p, options %#x, render_target %p.\n",
iface, size, pixel_size, format, options, rt);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d2d_bitmap_render_target_init(object, render_target, size, pixel_size,
format, options)))
{
WARN("Failed to initialize render target, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created render target %p.\n", object);
*rt = &object->ID2D1BitmapRenderTarget_iface;
return S_OK;
} }
static HRESULT STDMETHODCALLTYPE d2d_d3d_render_target_CreateLayer(ID2D1RenderTarget *iface, static HRESULT STDMETHODCALLTYPE d2d_d3d_render_target_CreateLayer(ID2D1RenderTarget *iface,
@ -602,8 +620,8 @@ static void d2d_rt_fill_geometry(struct d2d_d3d_render_target *render_target,
float _12, _22, _32, pad1; float _12, _22, _32, pad1;
} transform; } transform;
tmp_x = (2.0f * render_target->dpi_x) / (96.0f * render_target->pixel_size.width); tmp_x = (2.0f * render_target->desc.dpiX) / (96.0f * render_target->pixel_size.width);
tmp_y = -(2.0f * render_target->dpi_y) / (96.0f * render_target->pixel_size.height); tmp_y = -(2.0f * render_target->desc.dpiY) / (96.0f * render_target->pixel_size.height);
w = render_target->drawing_state.transform; w = render_target->drawing_state.transform;
w._11 *= tmp_x; w._11 *= tmp_x;
w._21 *= tmp_x; w._21 *= tmp_x;
@ -826,7 +844,7 @@ static void STDMETHODCALLTYPE d2d_d3d_render_target_DrawText(ID2D1RenderTarget *
layout_rect->right - layout_rect->left, layout_rect->bottom - layout_rect->top, &text_layout); layout_rect->right - layout_rect->left, layout_rect->bottom - layout_rect->top, &text_layout);
else else
hr = IDWriteFactory_CreateGdiCompatibleTextLayout(dwrite_factory, string, string_len, text_format, hr = IDWriteFactory_CreateGdiCompatibleTextLayout(dwrite_factory, string, string_len, text_format,
layout_rect->right - layout_rect->left, layout_rect->bottom - layout_rect->top, render_target->dpi_x / 96.0f, layout_rect->right - layout_rect->left, layout_rect->bottom - layout_rect->top, render_target->desc.dpiX / 96.0f,
(DWRITE_MATRIX*)&render_target->drawing_state.transform, measuring_mode == DWRITE_MEASURING_MODE_GDI_NATURAL, &text_layout); (DWRITE_MATRIX*)&render_target->drawing_state.transform, measuring_mode == DWRITE_MEASURING_MODE_GDI_NATURAL, &text_layout);
IDWriteFactory_Release(dwrite_factory); IDWriteFactory_Release(dwrite_factory);
if (FAILED(hr)) if (FAILED(hr))
@ -975,10 +993,10 @@ static void d2d_rt_draw_glyph_run_bitmap(struct d2d_d3d_render_target *render_ta
bitmap_desc.pixelFormat.format = DXGI_FORMAT_A8_UNORM; bitmap_desc.pixelFormat.format = DXGI_FORMAT_A8_UNORM;
bitmap_desc.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED; bitmap_desc.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED;
bitmap_desc.dpiX = render_target->dpi_x; bitmap_desc.dpiX = render_target->desc.dpiX;
if (texture_type == DWRITE_TEXTURE_CLEARTYPE_3x1) if (texture_type == DWRITE_TEXTURE_CLEARTYPE_3x1)
bitmap_desc.dpiX *= 3.0f; bitmap_desc.dpiX *= 3.0f;
bitmap_desc.dpiY = render_target->dpi_y; bitmap_desc.dpiY = render_target->desc.dpiY;
if (FAILED(hr = d2d_d3d_render_target_CreateBitmap(&render_target->ID2D1RenderTarget_iface, if (FAILED(hr = d2d_d3d_render_target_CreateBitmap(&render_target->ID2D1RenderTarget_iface,
bitmap_size, opacity_values, bitmap_size.width, &bitmap_desc, &opacity_bitmap))) bitmap_size, opacity_values, bitmap_size.width, &bitmap_desc, &opacity_bitmap)))
{ {
@ -1040,7 +1058,7 @@ static void STDMETHODCALLTYPE d2d_d3d_render_target_DrawGlyphRun(ID2D1RenderTarg
if (render_target->drawing_state.textAntialiasMode != D2D1_TEXT_ANTIALIAS_MODE_DEFAULT) if (render_target->drawing_state.textAntialiasMode != D2D1_TEXT_ANTIALIAS_MODE_DEFAULT)
FIXME("Ignoring text antialiasing mode %#x.\n", render_target->drawing_state.textAntialiasMode); FIXME("Ignoring text antialiasing mode %#x.\n", render_target->drawing_state.textAntialiasMode);
ppd = max(render_target->dpi_x, render_target->dpi_y) / 96.0f; ppd = max(render_target->desc.dpiX, render_target->desc.dpiY) / 96.0f;
rendering_params = render_target->text_rendering_params ? render_target->text_rendering_params rendering_params = render_target->text_rendering_params ? render_target->text_rendering_params
: render_target->default_text_rendering_params; : render_target->default_text_rendering_params;
if (FAILED(hr = IDWriteFontFace_GetRecommendedRenderingMode(glyph_run->fontFace, glyph_run->fontEmSize, if (FAILED(hr = IDWriteFontFace_GetRecommendedRenderingMode(glyph_run->fontFace, glyph_run->fontEmSize,
@ -1223,8 +1241,8 @@ static void STDMETHODCALLTYPE d2d_d3d_render_target_PushAxisAlignedClip(ID2D1Ren
if (antialias_mode != D2D1_ANTIALIAS_MODE_ALIASED) if (antialias_mode != D2D1_ANTIALIAS_MODE_ALIASED)
FIXME("Ignoring antialias_mode %#x.\n", antialias_mode); FIXME("Ignoring antialias_mode %#x.\n", antialias_mode);
x_scale = render_target->dpi_x / 96.0f; x_scale = render_target->desc.dpiX / 96.0f;
y_scale = render_target->dpi_y / 96.0f; y_scale = render_target->desc.dpiY / 96.0f;
d2d_point_transform(&point, &render_target->drawing_state.transform, d2d_point_transform(&point, &render_target->drawing_state.transform,
clip_rect->left * x_scale, clip_rect->top * y_scale); clip_rect->left * x_scale, clip_rect->top * y_scale);
d2d_rect_set(&transformed_rect, point.x, point.y, point.x, point.y); d2d_rect_set(&transformed_rect, point.x, point.y, point.x, point.y);
@ -1286,7 +1304,7 @@ static void STDMETHODCALLTYPE d2d_d3d_render_target_Clear(ID2D1RenderTarget *ifa
if (color) if (color)
c = *color; c = *color;
if (render_target->format.alphaMode == D2D1_ALPHA_MODE_IGNORE) if (render_target->desc.pixelFormat.alphaMode == D2D1_ALPHA_MODE_IGNORE)
c.a = 1.0f; c.a = 1.0f;
c.r *= c.a; c.r *= c.a;
c.g *= c.a; c.g *= c.a;
@ -1339,7 +1357,7 @@ static D2D1_PIXEL_FORMAT * STDMETHODCALLTYPE d2d_d3d_render_target_GetPixelForma
TRACE("iface %p, format %p.\n", iface, format); TRACE("iface %p, format %p.\n", iface, format);
*format = render_target->format; *format = render_target->desc.pixelFormat;
return format; return format;
} }
@ -1357,8 +1375,8 @@ static void STDMETHODCALLTYPE d2d_d3d_render_target_SetDpi(ID2D1RenderTarget *if
else if (dpi_x <= 0.0f || dpi_y <= 0.0f) else if (dpi_x <= 0.0f || dpi_y <= 0.0f)
return; return;
render_target->dpi_x = dpi_x; render_target->desc.dpiX = dpi_x;
render_target->dpi_y = dpi_y; render_target->desc.dpiY = dpi_y;
} }
static void STDMETHODCALLTYPE d2d_d3d_render_target_GetDpi(ID2D1RenderTarget *iface, float *dpi_x, float *dpi_y) static void STDMETHODCALLTYPE d2d_d3d_render_target_GetDpi(ID2D1RenderTarget *iface, float *dpi_x, float *dpi_y)
@ -1367,8 +1385,8 @@ static void STDMETHODCALLTYPE d2d_d3d_render_target_GetDpi(ID2D1RenderTarget *if
TRACE("iface %p, dpi_x %p, dpi_y %p.\n", iface, dpi_x, dpi_y); TRACE("iface %p, dpi_x %p, dpi_y %p.\n", iface, dpi_x, dpi_y);
*dpi_x = render_target->dpi_x; *dpi_x = render_target->desc.dpiX;
*dpi_y = render_target->dpi_y; *dpi_y = render_target->desc.dpiY;
} }
static D2D1_SIZE_F * STDMETHODCALLTYPE d2d_d3d_render_target_GetSize(ID2D1RenderTarget *iface, D2D1_SIZE_F *size) static D2D1_SIZE_F * STDMETHODCALLTYPE d2d_d3d_render_target_GetSize(ID2D1RenderTarget *iface, D2D1_SIZE_F *size)
@ -1377,8 +1395,8 @@ static D2D1_SIZE_F * STDMETHODCALLTYPE d2d_d3d_render_target_GetSize(ID2D1Render
TRACE("iface %p, size %p.\n", iface, size); TRACE("iface %p, size %p.\n", iface, size);
size->width = render_target->pixel_size.width / (render_target->dpi_x / 96.0f); size->width = render_target->pixel_size.width / (render_target->desc.dpiX / 96.0f);
size->height = render_target->pixel_size.height / (render_target->dpi_y / 96.0f); size->height = render_target->pixel_size.height / (render_target->desc.dpiY / 96.0f);
return size; return size;
} }
@ -1541,7 +1559,7 @@ static HRESULT STDMETHODCALLTYPE d2d_text_renderer_GetPixelsPerDip(IDWriteTextRe
TRACE("iface %p, ctx %p, ppd %p.\n", iface, ctx, ppd); TRACE("iface %p, ctx %p, ppd %p.\n", iface, ctx, ppd);
*ppd = render_target->dpi_y / 96.0f; *ppd = render_target->desc.dpiY / 96.0f;
return S_OK; return S_OK;
} }
@ -1590,7 +1608,7 @@ static HRESULT STDMETHODCALLTYPE d2d_text_renderer_DrawUnderline(IDWriteTextRend
iface, ctx, baseline_origin_x, baseline_origin_y, underline, effect); iface, ctx, baseline_origin_x, baseline_origin_y, underline, effect);
/* minimal thickness in DIPs that will result in at least 1 pixel thick line */ /* minimal thickness in DIPs that will result in at least 1 pixel thick line */
min_thickness = 96.0f / (render_target->dpi_y * sqrtf(m->_21 * m->_21 + m->_22 * m->_22)); min_thickness = 96.0f / (render_target->desc.dpiY * sqrtf(m->_21 * m->_21 + m->_22 * m->_22));
rect.left = baseline_origin_x; rect.left = baseline_origin_x;
rect.top = baseline_origin_y + underline->offset; rect.top = baseline_origin_y + underline->offset;
@ -2167,7 +2185,7 @@ HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_target,
goto err; goto err;
} }
render_target->format = desc->pixelFormat; render_target->desc.pixelFormat = desc->pixelFormat;
render_target->pixel_size.width = surface_desc.Width; render_target->pixel_size.width = surface_desc.Width;
render_target->pixel_size.height = surface_desc.Height; render_target->pixel_size.height = surface_desc.Height;
render_target->drawing_state.transform = identity; render_target->drawing_state.transform = identity;
@ -2179,8 +2197,8 @@ HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_target,
goto err; goto err;
} }
render_target->dpi_x = dpi_x; render_target->desc.dpiX = dpi_x;
render_target->dpi_y = dpi_y; render_target->desc.dpiY = dpi_y;
return S_OK; return S_OK;

View File

@ -2993,17 +2993,8 @@ static void test_bitmap_target(void)
hr = ID2D1HwndRenderTarget_CreateCompatibleRenderTarget(hwnd_rt, NULL, NULL, NULL, hr = ID2D1HwndRenderTarget_CreateCompatibleRenderTarget(hwnd_rt, NULL, NULL, NULL,
D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_NONE, &rt); D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_NONE, &rt);
todo_wine
ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
if (FAILED(hr))
{
ID2D1HwndRenderTarget_Release(hwnd_rt);
DestroyWindow(hwnd_rt_desc.hwnd);
ID2D1Factory_Release(factory);
return;
}
/* See if parent target is referenced. */ /* See if parent target is referenced. */
ID2D1HwndRenderTarget_AddRef(hwnd_rt); ID2D1HwndRenderTarget_AddRef(hwnd_rt);
refcount = ID2D1HwndRenderTarget_Release(hwnd_rt); refcount = ID2D1HwndRenderTarget_Release(hwnd_rt);
@ -3059,8 +3050,8 @@ todo_wine
ID2D1BitmapRenderTarget_GetDpi(rt, dpi2, dpi2 + 1); ID2D1BitmapRenderTarget_GetDpi(rt, dpi2, dpi2 + 1);
pixel_size = ID2D1BitmapRenderTarget_GetPixelSize(rt); pixel_size = ID2D1BitmapRenderTarget_GetPixelSize(rt);
ok(pixel_size.width == ceilf(size.width * dpi2[0] / 96.0f) ok(pixel_size.width == ceilf(size.width * dpi[0] / 96.0f)
&& pixel_size.height == ceilf(size.height * dpi2[1] / 96.0f), "Wrong pixel size %ux%u\n", && pixel_size.height == ceilf(size.height * dpi[1] / 96.0f), "Wrong pixel size %ux%u\n",
pixel_size.width, pixel_size.height); pixel_size.width, pixel_size.height);
dpi[0] *= (pixel_size.width / size.width) * (96.0f / dpi[0]); dpi[0] *= (pixel_size.width / size.width) * (96.0f / dpi[0]);