dwrite: Initial implementation of Draw() for trimming sign.
This commit is contained in:
parent
6304a0f50a
commit
6fd4f963f6
|
@ -103,7 +103,7 @@ extern HRESULT create_textformat(const WCHAR*,IDWriteFontCollection*,DWRITE_FONT
|
||||||
FLOAT,const WCHAR*,IDWriteTextFormat**) DECLSPEC_HIDDEN;
|
FLOAT,const WCHAR*,IDWriteTextFormat**) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT create_textlayout(const WCHAR*,UINT32,IDWriteTextFormat*,FLOAT,FLOAT,IDWriteTextLayout**) DECLSPEC_HIDDEN;
|
extern HRESULT create_textlayout(const WCHAR*,UINT32,IDWriteTextFormat*,FLOAT,FLOAT,IDWriteTextLayout**) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT create_gdicompat_textlayout(const WCHAR*,UINT32,IDWriteTextFormat*,FLOAT,FLOAT,FLOAT,const DWRITE_MATRIX*,BOOL,IDWriteTextLayout**) DECLSPEC_HIDDEN;
|
extern HRESULT create_gdicompat_textlayout(const WCHAR*,UINT32,IDWriteTextFormat*,FLOAT,FLOAT,FLOAT,const DWRITE_MATRIX*,BOOL,IDWriteTextLayout**) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT create_trimmingsign(IDWriteTextFormat*,IDWriteInlineObject**) DECLSPEC_HIDDEN;
|
extern HRESULT create_trimmingsign(IDWriteFactory2*,IDWriteTextFormat*,IDWriteInlineObject**) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT create_typography(IDWriteTypography**) DECLSPEC_HIDDEN;
|
extern HRESULT create_typography(IDWriteTypography**) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT create_gdiinterop(IDWriteFactory2*,IDWriteGdiInterop**) DECLSPEC_HIDDEN;
|
extern HRESULT create_gdiinterop(IDWriteFactory2*,IDWriteGdiInterop**) DECLSPEC_HIDDEN;
|
||||||
extern void release_gdiinterop(IDWriteGdiInterop*) DECLSPEC_HIDDEN;
|
extern void release_gdiinterop(IDWriteGdiInterop*) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -243,6 +243,8 @@ struct dwrite_textformat {
|
||||||
struct dwrite_trimmingsign {
|
struct dwrite_trimmingsign {
|
||||||
IDWriteInlineObject IDWriteInlineObject_iface;
|
IDWriteInlineObject IDWriteInlineObject_iface;
|
||||||
LONG ref;
|
LONG ref;
|
||||||
|
|
||||||
|
IDWriteTextLayout *layout;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct dwrite_typography {
|
struct dwrite_typography {
|
||||||
|
@ -3371,7 +3373,6 @@ static HRESULT WINAPI dwritetrimmingsign_QueryInterface(IDWriteInlineObject *ifa
|
||||||
|
|
||||||
*obj = NULL;
|
*obj = NULL;
|
||||||
return E_NOINTERFACE;
|
return E_NOINTERFACE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI dwritetrimmingsign_AddRef(IDWriteInlineObject *iface)
|
static ULONG WINAPI dwritetrimmingsign_AddRef(IDWriteInlineObject *iface)
|
||||||
|
@ -3389,18 +3390,24 @@ static ULONG WINAPI dwritetrimmingsign_Release(IDWriteInlineObject *iface)
|
||||||
|
|
||||||
TRACE("(%p)->(%d)\n", This, ref);
|
TRACE("(%p)->(%d)\n", This, ref);
|
||||||
|
|
||||||
if (!ref)
|
if (!ref) {
|
||||||
|
IDWriteTextLayout_Release(This->layout);
|
||||||
heap_free(This);
|
heap_free(This);
|
||||||
|
}
|
||||||
|
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI dwritetrimmingsign_Draw(IDWriteInlineObject *iface, void *context, IDWriteTextRenderer *renderer,
|
static HRESULT WINAPI dwritetrimmingsign_Draw(IDWriteInlineObject *iface, void *context, IDWriteTextRenderer *renderer,
|
||||||
FLOAT originX, FLOAT originY, BOOL is_sideways, BOOL is_rtl, IUnknown *drawing_effect)
|
FLOAT originX, FLOAT originY, BOOL is_sideways, BOOL is_rtl, IUnknown *effect)
|
||||||
{
|
{
|
||||||
struct dwrite_trimmingsign *This = impl_from_IDWriteInlineObject(iface);
|
struct dwrite_trimmingsign *This = impl_from_IDWriteInlineObject(iface);
|
||||||
FIXME("(%p)->(%p %p %f %f %d %d %p): stub\n", This, context, renderer, originX, originY, is_sideways, is_rtl, drawing_effect);
|
DWRITE_TEXT_RANGE range = { 0, ~0u };
|
||||||
return E_NOTIMPL;
|
|
||||||
|
TRACE("(%p)->(%p %p %.2f %.2f %d %d %p)\n", This, context, renderer, originX, originY, is_sideways, is_rtl, effect);
|
||||||
|
|
||||||
|
IDWriteTextLayout_SetDrawingEffect(This->layout, effect, range);
|
||||||
|
return IDWriteTextLayout_Draw(This->layout, context, renderer, originX, originY);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI dwritetrimmingsign_GetMetrics(IDWriteInlineObject *iface, DWRITE_INLINE_OBJECT_METRICS *metrics)
|
static HRESULT WINAPI dwritetrimmingsign_GetMetrics(IDWriteInlineObject *iface, DWRITE_INLINE_OBJECT_METRICS *metrics)
|
||||||
|
@ -3463,11 +3470,13 @@ static inline BOOL is_flow_direction_vert(DWRITE_FLOW_DIRECTION direction)
|
||||||
(direction == DWRITE_FLOW_DIRECTION_BOTTOM_TO_TOP);
|
(direction == DWRITE_FLOW_DIRECTION_BOTTOM_TO_TOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT create_trimmingsign(IDWriteTextFormat *format, IDWriteInlineObject **sign)
|
HRESULT create_trimmingsign(IDWriteFactory2 *factory, IDWriteTextFormat *format, IDWriteInlineObject **sign)
|
||||||
{
|
{
|
||||||
|
static const WCHAR ellipsisW = 0x2026;
|
||||||
struct dwrite_trimmingsign *This;
|
struct dwrite_trimmingsign *This;
|
||||||
DWRITE_READING_DIRECTION reading;
|
DWRITE_READING_DIRECTION reading;
|
||||||
DWRITE_FLOW_DIRECTION flow;
|
DWRITE_FLOW_DIRECTION flow;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
*sign = NULL;
|
*sign = NULL;
|
||||||
|
|
||||||
|
@ -3480,12 +3489,20 @@ HRESULT create_trimmingsign(IDWriteTextFormat *format, IDWriteInlineObject **sig
|
||||||
(is_reading_direction_vert(reading) && is_flow_direction_vert(flow)))
|
(is_reading_direction_vert(reading) && is_flow_direction_vert(flow)))
|
||||||
return DWRITE_E_FLOWDIRECTIONCONFLICTS;
|
return DWRITE_E_FLOWDIRECTIONCONFLICTS;
|
||||||
|
|
||||||
This = heap_alloc(sizeof(struct dwrite_trimmingsign));
|
This = heap_alloc(sizeof(*This));
|
||||||
if (!This) return E_OUTOFMEMORY;
|
if (!This)
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
This->IDWriteInlineObject_iface.lpVtbl = &dwritetrimmingsignvtbl;
|
This->IDWriteInlineObject_iface.lpVtbl = &dwritetrimmingsignvtbl;
|
||||||
This->ref = 1;
|
This->ref = 1;
|
||||||
|
|
||||||
|
hr = IDWriteFactory2_CreateTextLayout(factory, &ellipsisW, 1, format, 0.0, 0.0, &This->layout);
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
heap_free(This);
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
IDWriteTextLayout_SetWordWrapping(This->layout, DWRITE_WORD_WRAPPING_NO_WRAP);
|
||||||
*sign = &This->IDWriteInlineObject_iface;
|
*sign = &This->IDWriteInlineObject_iface;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
|
@ -1052,7 +1052,7 @@ static HRESULT WINAPI dwritefactory_CreateEllipsisTrimmingSign(IDWriteFactory2 *
|
||||||
{
|
{
|
||||||
struct dwritefactory *This = impl_from_IDWriteFactory2(iface);
|
struct dwritefactory *This = impl_from_IDWriteFactory2(iface);
|
||||||
TRACE("(%p)->(%p %p)\n", This, format, trimming_sign);
|
TRACE("(%p)->(%p %p)\n", This, format, trimming_sign);
|
||||||
return create_trimmingsign(format, trimming_sign);
|
return create_trimmingsign(iface, format, trimming_sign);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI dwritefactory_CreateTextAnalyzer(IDWriteFactory2 *iface, IDWriteTextAnalyzer **analyzer)
|
static HRESULT WINAPI dwritefactory_CreateTextAnalyzer(IDWriteFactory2 *iface, IDWriteTextAnalyzer **analyzer)
|
||||||
|
|
|
@ -856,12 +856,18 @@ static void test_GetLocaleName(void)
|
||||||
IDWriteFactory_Release(factory);
|
IDWriteFactory_Release(factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct drawcall_entry drawellipsis_seq[] = {
|
||||||
|
{ DRAW_GLYPHRUN, {0x2026, 0} },
|
||||||
|
{ DRAW_LAST_KIND }
|
||||||
|
};
|
||||||
|
|
||||||
static void test_CreateEllipsisTrimmingSign(void)
|
static void test_CreateEllipsisTrimmingSign(void)
|
||||||
{
|
{
|
||||||
DWRITE_BREAK_CONDITION before, after;
|
DWRITE_BREAK_CONDITION before, after;
|
||||||
IDWriteTextFormat *format;
|
IDWriteTextFormat *format;
|
||||||
IDWriteInlineObject *sign;
|
IDWriteInlineObject *sign;
|
||||||
IDWriteFactory *factory;
|
IDWriteFactory *factory;
|
||||||
|
IUnknown *unk;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
factory = create_factory();
|
factory = create_factory();
|
||||||
|
@ -875,6 +881,9 @@ static void test_CreateEllipsisTrimmingSign(void)
|
||||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
EXPECT_REF(format, 1);
|
EXPECT_REF(format, 1);
|
||||||
|
|
||||||
|
hr = IDWriteInlineObject_QueryInterface(sign, &IID_IDWriteTextLayout, (void**)&unk);
|
||||||
|
ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
|
||||||
|
|
||||||
if (0) /* crashes on native */
|
if (0) /* crashes on native */
|
||||||
hr = IDWriteInlineObject_GetBreakConditions(sign, NULL, NULL);
|
hr = IDWriteInlineObject_GetBreakConditions(sign, NULL, NULL);
|
||||||
|
|
||||||
|
@ -883,6 +892,12 @@ if (0) /* crashes on native */
|
||||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
ok(before == DWRITE_BREAK_CONDITION_NEUTRAL, "got %d\n", before);
|
ok(before == DWRITE_BREAK_CONDITION_NEUTRAL, "got %d\n", before);
|
||||||
ok(after == DWRITE_BREAK_CONDITION_NEUTRAL, "got %d\n", after);
|
ok(after == DWRITE_BREAK_CONDITION_NEUTRAL, "got %d\n", after);
|
||||||
|
|
||||||
|
/* Draw tests */
|
||||||
|
flush_sequence(sequences, RENDERER_ID);
|
||||||
|
hr = IDWriteInlineObject_Draw(sign, NULL, &testrenderer, 0.0, 0.0, FALSE, FALSE, NULL);
|
||||||
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
ok_sequence(sequences, RENDERER_ID, drawellipsis_seq, "ellipsis sign draw test", FALSE);
|
||||||
IDWriteInlineObject_Release(sign);
|
IDWriteInlineObject_Release(sign);
|
||||||
|
|
||||||
/* non-orthogonal flow/reading combination */
|
/* non-orthogonal flow/reading combination */
|
||||||
|
|
Loading…
Reference in New Issue