4 * Copyright 2012 Nikolay Sivov for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "dwrite_private.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(dwrite
);
36 IDWriteBitmapRenderTarget IDWriteBitmapRenderTarget_iface
;
42 static inline struct rendertarget
*impl_from_IDWriteBitmapRenderTarget(IDWriteBitmapRenderTarget
*iface
)
44 return CONTAINING_RECORD(iface
, struct rendertarget
, IDWriteBitmapRenderTarget_iface
);
47 static HRESULT WINAPI
rendertarget_QueryInterface(IDWriteBitmapRenderTarget
*iface
, REFIID riid
, void **obj
)
49 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
51 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), obj
);
53 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IDWriteBitmapRenderTarget
))
56 IDWriteBitmapRenderTarget_AddRef(iface
);
65 static ULONG WINAPI
rendertarget_AddRef(IDWriteBitmapRenderTarget
*iface
)
67 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
68 ULONG ref
= InterlockedIncrement(&This
->ref
);
69 TRACE("(%p)->(%d)\n", This
, ref
);
73 static ULONG WINAPI
rendertarget_Release(IDWriteBitmapRenderTarget
*iface
)
75 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
76 ULONG ref
= InterlockedDecrement(&This
->ref
);
78 TRACE("(%p)->(%d)\n", This
, ref
);
89 static HRESULT WINAPI
rendertarget_DrawGlyphRun(IDWriteBitmapRenderTarget
*iface
,
90 FLOAT baselineOriginX
, FLOAT baselineOriginY
, DWRITE_MEASURING_MODE measuring_mode
,
91 DWRITE_GLYPH_RUN
const* glyph_run
, IDWriteRenderingParams
* params
, COLORREF textColor
,
94 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
95 FIXME("(%p)->(%f %f %d %p %p 0x%08x %p): stub\n", This
, baselineOriginX
, baselineOriginY
,
96 measuring_mode
, glyph_run
, params
, textColor
, blackbox_rect
);
100 static HDC WINAPI
rendertarget_GetMemoryDC(IDWriteBitmapRenderTarget
*iface
)
102 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
103 TRACE("(%p)\n", This
);
107 static FLOAT WINAPI
rendertarget_GetPixelsPerDip(IDWriteBitmapRenderTarget
*iface
)
109 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
110 FIXME("(%p): stub\n", This
);
114 static HRESULT WINAPI
rendertarget_SetPixelsPerDip(IDWriteBitmapRenderTarget
*iface
, FLOAT pixels_per_dip
)
116 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
117 FIXME("(%p)->(%f): stub\n", This
, pixels_per_dip
);
121 static HRESULT WINAPI
rendertarget_GetCurrentTransform(IDWriteBitmapRenderTarget
*iface
, DWRITE_MATRIX
*transform
)
123 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
124 FIXME("(%p)->(%p): stub\n", This
, transform
);
128 static HRESULT WINAPI
rendertarget_SetCurrentTransform(IDWriteBitmapRenderTarget
*iface
, DWRITE_MATRIX
const *transform
)
130 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
131 FIXME("(%p)->(%p): stub\n", This
, transform
);
135 static HRESULT WINAPI
rendertarget_GetSize(IDWriteBitmapRenderTarget
*iface
, SIZE
*size
)
137 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
138 FIXME("(%p)->(%p): stub\n", This
, size
);
142 static HRESULT WINAPI
rendertarget_Resize(IDWriteBitmapRenderTarget
*iface
, UINT32 width
, UINT32 height
)
144 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
145 FIXME("(%p)->(%u %u): stub\n", This
, width
, height
);
149 static const IDWriteBitmapRenderTargetVtbl rendertargetvtbl
= {
150 rendertarget_QueryInterface
,
152 rendertarget_Release
,
153 rendertarget_DrawGlyphRun
,
154 rendertarget_GetMemoryDC
,
155 rendertarget_GetPixelsPerDip
,
156 rendertarget_SetPixelsPerDip
,
157 rendertarget_GetCurrentTransform
,
158 rendertarget_SetCurrentTransform
,
159 rendertarget_GetSize
,
163 static HRESULT
create_rendertarget(HDC hdc
, UINT32 width
, UINT32 height
, IDWriteBitmapRenderTarget
**target
)
165 char bmibuf
[sizeof(BITMAPINFO
) + 256 * sizeof(RGBQUAD
)];
166 BITMAPINFO
*bmi
= (BITMAPINFO
*)bmibuf
;
167 struct rendertarget
*This
;
172 This
= heap_alloc(sizeof(struct rendertarget
));
173 if (!This
) return E_OUTOFMEMORY
;
175 This
->IDWriteBitmapRenderTarget_iface
.lpVtbl
= &rendertargetvtbl
;
178 This
->hdc
= CreateCompatibleDC(hdc
);
180 memset(bmi
, 0, sizeof(bmibuf
));
181 bmi
->bmiHeader
.biSize
= sizeof(bmi
->bmiHeader
);
182 bmi
->bmiHeader
.biHeight
= height
;
183 bmi
->bmiHeader
.biWidth
= width
;
184 bmi
->bmiHeader
.biBitCount
= 32;
185 bmi
->bmiHeader
.biPlanes
= 1;
186 bmi
->bmiHeader
.biCompression
= BI_RGB
;
188 dib
= CreateDIBSection(This
->hdc
, bmi
, DIB_RGB_COLORS
, NULL
, NULL
, 0);
189 SelectObject(This
->hdc
, dib
);
191 *target
= &This
->IDWriteBitmapRenderTarget_iface
;
196 static HRESULT WINAPI
gdiinterop_QueryInterface(IDWriteGdiInterop
*iface
, REFIID riid
, void **obj
)
198 TRACE("(%s %p)\n", debugstr_guid(riid
), obj
);
200 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IDWriteGdiInterop
))
208 return E_NOINTERFACE
;
211 static ULONG WINAPI
gdiinterop_AddRef(IDWriteGdiInterop
*iface
)
216 static ULONG WINAPI
gdiinterop_Release(IDWriteGdiInterop
*iface
)
221 static HRESULT WINAPI
gdiinterop_CreateFontFromLOGFONT(IDWriteGdiInterop
*iface
,
222 LOGFONTW
const *logfont
, IDWriteFont
**font
)
224 TRACE("(%p %p)\n", logfont
, font
);
226 if (!logfont
) return E_INVALIDARG
;
228 return create_font_from_logfont(logfont
, font
);
231 static HRESULT WINAPI
gdiinterop_ConvertFontToLOGFONT(IDWriteGdiInterop
*iface
,
232 IDWriteFont
*font
, LOGFONTW
*logfont
, BOOL
*is_systemfont
)
234 FIXME("(%p %p %p): stub\n", font
, logfont
, is_systemfont
);
238 static HRESULT WINAPI
gdiinterop_ConvertFontFaceToLOGFONT(IDWriteGdiInterop
*iface
,
239 IDWriteFontFace
*font
, LOGFONTW
*logfont
)
241 FIXME("(%p %p): stub\n", font
, logfont
);
245 static HRESULT WINAPI
gdiinterop_CreateFontFaceFromHdc(IDWriteGdiInterop
*iface
,
246 HDC hdc
, IDWriteFontFace
**fontface
)
248 FIXME("(%p %p): stub\n", hdc
, fontface
);
252 static HRESULT WINAPI
gdiinterop_CreateBitmapRenderTarget(IDWriteGdiInterop
*iface
,
253 HDC hdc
, UINT32 width
, UINT32 height
, IDWriteBitmapRenderTarget
**target
)
255 TRACE("(%p %u %u %p)\n", hdc
, width
, height
, target
);
256 return create_rendertarget(hdc
, width
, height
, target
);
259 static const struct IDWriteGdiInteropVtbl gdiinteropvtbl
= {
260 gdiinterop_QueryInterface
,
263 gdiinterop_CreateFontFromLOGFONT
,
264 gdiinterop_ConvertFontToLOGFONT
,
265 gdiinterop_ConvertFontFaceToLOGFONT
,
266 gdiinterop_CreateFontFaceFromHdc
,
267 gdiinterop_CreateBitmapRenderTarget
270 static IDWriteGdiInterop gdiinterop
= { &gdiinteropvtbl
};
272 HRESULT
create_gdiinterop(IDWriteGdiInterop
**ret
)