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
;
43 static inline struct rendertarget
*impl_from_IDWriteBitmapRenderTarget(IDWriteBitmapRenderTarget
*iface
)
45 return CONTAINING_RECORD(iface
, struct rendertarget
, IDWriteBitmapRenderTarget_iface
);
48 static HRESULT WINAPI
rendertarget_QueryInterface(IDWriteBitmapRenderTarget
*iface
, REFIID riid
, void **obj
)
50 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
52 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), obj
);
54 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IDWriteBitmapRenderTarget
))
57 IDWriteBitmapRenderTarget_AddRef(iface
);
66 static ULONG WINAPI
rendertarget_AddRef(IDWriteBitmapRenderTarget
*iface
)
68 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
69 ULONG ref
= InterlockedIncrement(&This
->ref
);
70 TRACE("(%p)->(%d)\n", This
, ref
);
74 static ULONG WINAPI
rendertarget_Release(IDWriteBitmapRenderTarget
*iface
)
76 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
77 ULONG ref
= InterlockedDecrement(&This
->ref
);
79 TRACE("(%p)->(%d)\n", This
, ref
);
90 static HRESULT WINAPI
rendertarget_DrawGlyphRun(IDWriteBitmapRenderTarget
*iface
,
91 FLOAT baselineOriginX
, FLOAT baselineOriginY
, DWRITE_MEASURING_MODE measuring_mode
,
92 DWRITE_GLYPH_RUN
const* glyph_run
, IDWriteRenderingParams
* params
, COLORREF textColor
,
95 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
96 FIXME("(%p)->(%f %f %d %p %p 0x%08x %p): stub\n", This
, baselineOriginX
, baselineOriginY
,
97 measuring_mode
, glyph_run
, params
, textColor
, blackbox_rect
);
101 static HDC WINAPI
rendertarget_GetMemoryDC(IDWriteBitmapRenderTarget
*iface
)
103 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
104 TRACE("(%p)\n", This
);
108 static FLOAT WINAPI
rendertarget_GetPixelsPerDip(IDWriteBitmapRenderTarget
*iface
)
110 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
111 FIXME("(%p): stub\n", This
);
115 static HRESULT WINAPI
rendertarget_SetPixelsPerDip(IDWriteBitmapRenderTarget
*iface
, FLOAT pixels_per_dip
)
117 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
118 FIXME("(%p)->(%f): stub\n", This
, pixels_per_dip
);
122 static HRESULT WINAPI
rendertarget_GetCurrentTransform(IDWriteBitmapRenderTarget
*iface
, DWRITE_MATRIX
*transform
)
124 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
125 FIXME("(%p)->(%p): stub\n", This
, transform
);
129 static HRESULT WINAPI
rendertarget_SetCurrentTransform(IDWriteBitmapRenderTarget
*iface
, DWRITE_MATRIX
const *transform
)
131 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
132 FIXME("(%p)->(%p): stub\n", This
, transform
);
136 static HRESULT WINAPI
rendertarget_GetSize(IDWriteBitmapRenderTarget
*iface
, SIZE
*size
)
138 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
140 TRACE("(%p)->(%p)\n", This
, size
);
145 static HRESULT WINAPI
rendertarget_Resize(IDWriteBitmapRenderTarget
*iface
, UINT32 width
, UINT32 height
)
147 struct rendertarget
*This
= impl_from_IDWriteBitmapRenderTarget(iface
);
148 FIXME("(%p)->(%u %u): stub\n", This
, width
, height
);
152 static const IDWriteBitmapRenderTargetVtbl rendertargetvtbl
= {
153 rendertarget_QueryInterface
,
155 rendertarget_Release
,
156 rendertarget_DrawGlyphRun
,
157 rendertarget_GetMemoryDC
,
158 rendertarget_GetPixelsPerDip
,
159 rendertarget_SetPixelsPerDip
,
160 rendertarget_GetCurrentTransform
,
161 rendertarget_SetCurrentTransform
,
162 rendertarget_GetSize
,
166 static HRESULT
create_rendertarget(HDC hdc
, UINT32 width
, UINT32 height
, IDWriteBitmapRenderTarget
**target
)
168 char bmibuf
[FIELD_OFFSET(BITMAPINFO
, bmiColors
[256])];
169 BITMAPINFO
*bmi
= (BITMAPINFO
*)bmibuf
;
170 struct rendertarget
*This
;
175 This
= heap_alloc(sizeof(struct rendertarget
));
176 if (!This
) return E_OUTOFMEMORY
;
178 This
->IDWriteBitmapRenderTarget_iface
.lpVtbl
= &rendertargetvtbl
;
181 This
->size
.cx
= width
;
182 This
->size
.cy
= height
;
184 This
->hdc
= CreateCompatibleDC(hdc
);
186 memset(bmi
, 0, sizeof(bmibuf
));
187 bmi
->bmiHeader
.biSize
= sizeof(bmi
->bmiHeader
);
188 bmi
->bmiHeader
.biHeight
= height
;
189 bmi
->bmiHeader
.biWidth
= width
;
190 bmi
->bmiHeader
.biBitCount
= 32;
191 bmi
->bmiHeader
.biPlanes
= 1;
192 bmi
->bmiHeader
.biCompression
= BI_RGB
;
194 dib
= CreateDIBSection(This
->hdc
, bmi
, DIB_RGB_COLORS
, NULL
, NULL
, 0);
195 SelectObject(This
->hdc
, dib
);
197 *target
= &This
->IDWriteBitmapRenderTarget_iface
;
202 static HRESULT WINAPI
gdiinterop_QueryInterface(IDWriteGdiInterop
*iface
, REFIID riid
, void **obj
)
204 TRACE("(%s %p)\n", debugstr_guid(riid
), obj
);
206 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IDWriteGdiInterop
))
214 return E_NOINTERFACE
;
217 static ULONG WINAPI
gdiinterop_AddRef(IDWriteGdiInterop
*iface
)
222 static ULONG WINAPI
gdiinterop_Release(IDWriteGdiInterop
*iface
)
227 static HRESULT WINAPI
gdiinterop_CreateFontFromLOGFONT(IDWriteGdiInterop
*iface
,
228 LOGFONTW
const *logfont
, IDWriteFont
**font
)
230 TRACE("(%p %p)\n", logfont
, font
);
232 if (!logfont
) return E_INVALIDARG
;
234 return create_font_from_logfont(logfont
, font
);
237 static HRESULT WINAPI
gdiinterop_ConvertFontToLOGFONT(IDWriteGdiInterop
*iface
,
238 IDWriteFont
*font
, LOGFONTW
*logfont
, BOOL
*is_systemfont
)
240 FIXME("(%p %p %p): stub\n", font
, logfont
, is_systemfont
);
244 static HRESULT WINAPI
gdiinterop_ConvertFontFaceToLOGFONT(IDWriteGdiInterop
*iface
,
245 IDWriteFontFace
*font
, LOGFONTW
*logfont
)
247 FIXME("(%p %p): stub\n", font
, logfont
);
251 static HRESULT WINAPI
gdiinterop_CreateFontFaceFromHdc(IDWriteGdiInterop
*iface
,
252 HDC hdc
, IDWriteFontFace
**fontface
)
254 FIXME("(%p %p): stub\n", hdc
, fontface
);
258 static HRESULT WINAPI
gdiinterop_CreateBitmapRenderTarget(IDWriteGdiInterop
*iface
,
259 HDC hdc
, UINT32 width
, UINT32 height
, IDWriteBitmapRenderTarget
**target
)
261 TRACE("(%p %u %u %p)\n", hdc
, width
, height
, target
);
262 return create_rendertarget(hdc
, width
, height
, target
);
265 static const struct IDWriteGdiInteropVtbl gdiinteropvtbl
= {
266 gdiinterop_QueryInterface
,
269 gdiinterop_CreateFontFromLOGFONT
,
270 gdiinterop_ConvertFontToLOGFONT
,
271 gdiinterop_ConvertFontFaceToLOGFONT
,
272 gdiinterop_CreateFontFaceFromHdc
,
273 gdiinterop_CreateBitmapRenderTarget
276 static IDWriteGdiInterop gdiinterop
= { &gdiinteropvtbl
};
278 HRESULT
get_gdiinterop(IDWriteGdiInterop
**ret
)