dwrite: Implement GetPaletteEntries().
This commit is contained in:
parent
4df29eb02f
commit
fd35a1af6a
|
@ -155,6 +155,7 @@ extern HRESULT opentype_get_typographic_features(IDWriteFontFace*,UINT32,UINT32,
|
||||||
extern BOOL opentype_get_vdmx_size(const void*,INT,UINT16*,UINT16*) DECLSPEC_HIDDEN;
|
extern BOOL opentype_get_vdmx_size(const void*,INT,UINT16*,UINT16*) DECLSPEC_HIDDEN;
|
||||||
extern UINT32 opentype_get_cpal_palettecount(const void*) DECLSPEC_HIDDEN;
|
extern UINT32 opentype_get_cpal_palettecount(const void*) DECLSPEC_HIDDEN;
|
||||||
extern UINT32 opentype_get_cpal_paletteentrycount(const void*) DECLSPEC_HIDDEN;
|
extern UINT32 opentype_get_cpal_paletteentrycount(const void*) DECLSPEC_HIDDEN;
|
||||||
|
extern HRESULT opentype_get_cpal_entries(const void*,UINT32,UINT32,UINT32,DWRITE_COLOR_F*) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
enum gasp_flags {
|
enum gasp_flags {
|
||||||
GASP_GRIDFIT = 0x0001,
|
GASP_GRIDFIT = 0x0001,
|
||||||
|
|
|
@ -972,8 +972,8 @@ static HRESULT WINAPI dwritefontface2_GetPaletteEntries(IDWriteFontFace2 *iface,
|
||||||
UINT32 first_entry_index, UINT32 entry_count, DWRITE_COLOR_F *entries)
|
UINT32 first_entry_index, UINT32 entry_count, DWRITE_COLOR_F *entries)
|
||||||
{
|
{
|
||||||
struct dwrite_fontface *This = impl_from_IDWriteFontFace2(iface);
|
struct dwrite_fontface *This = impl_from_IDWriteFontFace2(iface);
|
||||||
FIXME("(%p)->(%u %u %u %p): stub\n", This, palette_index, first_entry_index, entry_count, entries);
|
TRACE("(%p)->(%u %u %u %p)\n", This, palette_index, first_entry_index, entry_count, entries);
|
||||||
return E_NOTIMPL;
|
return opentype_get_cpal_entries(get_fontface_cpal(This), palette_index, first_entry_index, entry_count, entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI dwritefontface2_GetRecommendedRenderingMode(IDWriteFontFace2 *iface, FLOAT emSize,
|
static HRESULT WINAPI dwritefontface2_GetRecommendedRenderingMode(IDWriteFontFace2 *iface, FLOAT emSize,
|
||||||
|
|
|
@ -687,6 +687,14 @@ struct CPAL_SubHeader_1
|
||||||
ULONG offsetPaletteEntryLabelArray;
|
ULONG offsetPaletteEntryLabelArray;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct CPAL_ColorRecord
|
||||||
|
{
|
||||||
|
BYTE blue;
|
||||||
|
BYTE green;
|
||||||
|
BYTE red;
|
||||||
|
BYTE alpha;
|
||||||
|
};
|
||||||
|
|
||||||
BOOL is_face_type_supported(DWRITE_FONT_FACE_TYPE type)
|
BOOL is_face_type_supported(DWRITE_FONT_FACE_TYPE type)
|
||||||
{
|
{
|
||||||
return (type == DWRITE_FONT_FACE_TYPE_CFF) ||
|
return (type == DWRITE_FONT_FACE_TYPE_CFF) ||
|
||||||
|
@ -1434,3 +1442,33 @@ UINT32 opentype_get_cpal_paletteentrycount(const void *cpal)
|
||||||
const struct CPAL_Header_0 *header = (const struct CPAL_Header_0*)cpal;
|
const struct CPAL_Header_0 *header = (const struct CPAL_Header_0*)cpal;
|
||||||
return header ? GET_BE_WORD(header->numPaletteEntries) : 0;
|
return header ? GET_BE_WORD(header->numPaletteEntries) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HRESULT opentype_get_cpal_entries(const void *cpal, UINT32 palette, UINT32 first_entry_index, UINT32 entry_count,
|
||||||
|
DWRITE_COLOR_F *entries)
|
||||||
|
{
|
||||||
|
const struct CPAL_Header_0 *header = (const struct CPAL_Header_0*)cpal;
|
||||||
|
const struct CPAL_ColorRecord *records;
|
||||||
|
UINT32 palettecount, entrycount, i;
|
||||||
|
|
||||||
|
if (!header) return DWRITE_E_NOCOLOR;
|
||||||
|
|
||||||
|
palettecount = GET_BE_WORD(header->numPalette);
|
||||||
|
if (palette >= palettecount)
|
||||||
|
return DWRITE_E_NOCOLOR;
|
||||||
|
|
||||||
|
entrycount = GET_BE_WORD(header->numPaletteEntries);
|
||||||
|
if (first_entry_index + entry_count > entrycount)
|
||||||
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
records = (const struct CPAL_ColorRecord*)((BYTE*)cpal + GET_BE_DWORD(header->offsetFirstColorRecord));
|
||||||
|
first_entry_index += GET_BE_WORD(header->colorRecordIndices[palette]);
|
||||||
|
|
||||||
|
for (i = 0; i < entry_count; i++) {
|
||||||
|
entries[i].r = records[first_entry_index + i].red / 255.0f;
|
||||||
|
entries[i].g = records[first_entry_index + i].green / 255.0f;
|
||||||
|
entries[i].b = records[first_entry_index + i].blue / 255.0f;
|
||||||
|
entries[i].a = records[first_entry_index + i].alpha / 255.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
|
@ -4792,7 +4792,6 @@ static void test_GetPaletteEntries(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = IDWriteFontFace2_GetPaletteEntries(fontface2, 0, 0, 1, &color);
|
hr = IDWriteFontFace2_GetPaletteEntries(fontface2, 0, 0, 1, &color);
|
||||||
todo_wine
|
|
||||||
ok(hr == DWRITE_E_NOCOLOR, "got 0x%08x\n", hr);
|
ok(hr == DWRITE_E_NOCOLOR, "got 0x%08x\n", hr);
|
||||||
IDWriteFontFace2_Release(fontface2);
|
IDWriteFontFace2_Release(fontface2);
|
||||||
|
|
||||||
|
@ -4827,7 +4826,6 @@ todo_wine
|
||||||
/* invalid palette index */
|
/* invalid palette index */
|
||||||
color.r = color.g = color.b = color.a = 123.0;
|
color.r = color.g = color.b = color.a = 123.0;
|
||||||
hr = IDWriteFontFace2_GetPaletteEntries(fontface2, palettecount, 0, 1, &color);
|
hr = IDWriteFontFace2_GetPaletteEntries(fontface2, palettecount, 0, 1, &color);
|
||||||
todo_wine
|
|
||||||
ok(hr == DWRITE_E_NOCOLOR, "got 0x%08x\n", hr);
|
ok(hr == DWRITE_E_NOCOLOR, "got 0x%08x\n", hr);
|
||||||
ok(color.r == 123.0 && color.g == 123.0 && color.b == 123.0 && color.a == 123.0,
|
ok(color.r == 123.0 && color.g == 123.0 && color.b == 123.0 && color.a == 123.0,
|
||||||
"got wrong color %.2fx%.2fx%.2fx%.2f\n", color.r, color.g, color.b, color.a);
|
"got wrong color %.2fx%.2fx%.2fx%.2f\n", color.r, color.g, color.b, color.a);
|
||||||
|
@ -4835,23 +4833,19 @@ todo_wine
|
||||||
/* invalid entry index */
|
/* invalid entry index */
|
||||||
color.r = color.g = color.b = color.a = 123.0;
|
color.r = color.g = color.b = color.a = 123.0;
|
||||||
hr = IDWriteFontFace2_GetPaletteEntries(fontface2, 0, entrycount, 1, &color);
|
hr = IDWriteFontFace2_GetPaletteEntries(fontface2, 0, entrycount, 1, &color);
|
||||||
todo_wine
|
|
||||||
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
||||||
ok(color.r == 123.0 && color.g == 123.0 && color.b == 123.0 && color.a == 123.0,
|
ok(color.r == 123.0 && color.g == 123.0 && color.b == 123.0 && color.a == 123.0,
|
||||||
"got wrong color %.2fx%.2fx%.2fx%.2f\n", color.r, color.g, color.b, color.a);
|
"got wrong color %.2fx%.2fx%.2fx%.2f\n", color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
color.r = color.g = color.b = color.a = 123.0;
|
color.r = color.g = color.b = color.a = 123.0;
|
||||||
hr = IDWriteFontFace2_GetPaletteEntries(fontface2, 0, entrycount - 1, 1, &color);
|
hr = IDWriteFontFace2_GetPaletteEntries(fontface2, 0, entrycount - 1, 1, &color);
|
||||||
todo_wine {
|
|
||||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
ok(color.r != 123.0 && color.g != 123.0 && color.b != 123.0 && color.a != 123.0,
|
ok(color.r != 123.0 && color.g != 123.0 && color.b != 123.0 && color.a != 123.0,
|
||||||
"got wrong color %.2fx%.2fx%.2fx%.2f\n", color.r, color.g, color.b, color.a);
|
"got wrong color %.2fx%.2fx%.2fx%.2f\n", color.r, color.g, color.b, color.a);
|
||||||
}
|
|
||||||
|
|
||||||
/* zero return length */
|
/* zero return length */
|
||||||
color.r = color.g = color.b = color.a = 123.0;
|
color.r = color.g = color.b = color.a = 123.0;
|
||||||
hr = IDWriteFontFace2_GetPaletteEntries(fontface2, 0, 0, 0, &color);
|
hr = IDWriteFontFace2_GetPaletteEntries(fontface2, 0, 0, 0, &color);
|
||||||
todo_wine
|
|
||||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
ok(color.r == 123.0 && color.g == 123.0 && color.b == 123.0 && color.a == 123.0,
|
ok(color.r == 123.0 && color.g == 123.0 && color.b == 123.0 && color.a == 123.0,
|
||||||
"got wrong color %.2fx%.2fx%.2fx%.2f\n", color.r, color.g, color.b, color.a);
|
"got wrong color %.2fx%.2fx%.2fx%.2f\n", color.r, color.g, color.b, color.a);
|
||||||
|
|
Loading…
Reference in New Issue