Bug 1430632 - Copy declarations of new DirectWrite interfaces into our code so it will build against the current Windows SDK and WINVER settings. r=lsalzman,froydnj
authorJonathan Kew <jkew@mozilla.com>
Thu, 18 Jan 2018 17:45:25 +0000
changeset 400009 6d97ae42700e4086584d74cde222fa2f870780dd
parent 400008 794abd47aa0cbcc2608b7e5c38f14227d9c5dd8e
child 400091 85824602b47916f9b13a3ead5005fcb524ad0f4b
push id99078
push userjkew@mozilla.com
push dateSat, 20 Jan 2018 09:29:47 +0000
treeherdermozilla-inbound@6d97ae42700e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman, froydnj
bugs1430632
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1430632 - Copy declarations of new DirectWrite interfaces into our code so it will build against the current Windows SDK and WINVER settings. r=lsalzman,froydnj
gfx/thebes/dw-extra.h
gfx/thebes/gfxDWriteFontList.h
new file mode 100644
--- /dev/null
+++ b/gfx/thebes/dw-extra.h
@@ -0,0 +1,151 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+* This Source Code Form is subject to the terms of the Mozilla Public
+* License, v. 2.0. If a copy of the MPL was not distributed with this
+* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * New DirectWrite interfaces based on Win10 Fall Creators Update versions
+ * of dwrite_3.h and dcommon.h (from SDK 10.0.17061.0). This particular
+ * subset of declarations is intended to be just sufficient to compile the
+ * Gecko DirectWrite font code; it omits many other new interfaces, etc.
+ */
+
+#ifndef DWRITE_EXTRA_H
+#define DWRITE_EXTRA_H
+
+#pragma once
+
+interface IDWriteFontResource;
+interface IDWriteFontFaceReference1;
+
+enum DWRITE_GLYPH_IMAGE_FORMATS {
+    DWRITE_GLYPH_IMAGE_FORMATS_NONE                   = 0x00000000,
+    DWRITE_GLYPH_IMAGE_FORMATS_TRUETYPE               = 0x00000001,
+    DWRITE_GLYPH_IMAGE_FORMATS_CFF                    = 0x00000002,
+    DWRITE_GLYPH_IMAGE_FORMATS_COLR                   = 0x00000004,
+    DWRITE_GLYPH_IMAGE_FORMATS_SVG                    = 0x00000008,
+    DWRITE_GLYPH_IMAGE_FORMATS_PNG                    = 0x00000010,
+    DWRITE_GLYPH_IMAGE_FORMATS_JPEG                   = 0x00000020,
+    DWRITE_GLYPH_IMAGE_FORMATS_TIFF                   = 0x00000040,
+    DWRITE_GLYPH_IMAGE_FORMATS_PREMULTIPLIED_B8G8R8A8 = 0x00000080,
+};
+
+#ifdef DEFINE_ENUM_FLAG_OPERATORS
+DEFINE_ENUM_FLAG_OPERATORS(DWRITE_GLYPH_IMAGE_FORMATS);
+#endif
+
+#define DWRITE_MAKE_FONT_AXIS_TAG(a,b,c,d) \
+    (static_cast<DWRITE_FONT_AXIS_TAG>(DWRITE_MAKE_OPENTYPE_TAG(a,b,c,d)))
+
+enum DWRITE_FONT_AXIS_TAG : UINT32 {
+    DWRITE_FONT_AXIS_TAG_WEIGHT       = DWRITE_MAKE_FONT_AXIS_TAG('w', 'g', 'h', 't'),
+    DWRITE_FONT_AXIS_TAG_WIDTH        = DWRITE_MAKE_FONT_AXIS_TAG('w', 'd', 't', 'h'),
+    DWRITE_FONT_AXIS_TAG_SLANT        = DWRITE_MAKE_FONT_AXIS_TAG('s', 'l', 'n', 't'),
+    DWRITE_FONT_AXIS_TAG_OPTICAL_SIZE = DWRITE_MAKE_FONT_AXIS_TAG('o', 'p', 's', 'z'),
+    DWRITE_FONT_AXIS_TAG_ITALIC       = DWRITE_MAKE_FONT_AXIS_TAG('i', 't', 'a', 'l'),
+};
+
+enum DWRITE_FONT_AXIS_ATTRIBUTES {
+    DWRITE_FONT_AXIS_ATTRIBUTES_NONE     = 0x0000,
+    DWRITE_FONT_AXIS_ATTRIBUTES_VARIABLE = 0x0001,
+    DWRITE_FONT_AXIS_ATTRIBUTES_HIDDEN   = 0x0002,
+};
+
+struct DWRITE_FONT_AXIS_VALUE {
+    DWRITE_FONT_AXIS_TAG axisTag;
+    FLOAT value;
+};
+
+struct DWRITE_FONT_AXIS_RANGE {
+    DWRITE_FONT_AXIS_TAG axisTag;
+    FLOAT minValue;
+    FLOAT maxValue;
+};
+
+struct DWRITE_GLYPH_IMAGE_DATA;
+
+interface DWRITE_DECLARE_INTERFACE("27F2A904-4EB8-441D-9678-0563F53E3E2F") IDWriteFontFace4
+    : public IDWriteFontFace3
+{
+    STDMETHOD_(DWRITE_GLYPH_IMAGE_FORMATS, GetGlyphImageFormats)() PURE;
+    STDMETHOD(GetGlyphImageFormats)(
+        UINT16 glyphId,
+        UINT32 pixelsPerEmFirst,
+        UINT32 pixelsPerEmLast,
+        _Out_ DWRITE_GLYPH_IMAGE_FORMATS* glyphImageFormats
+        ) PURE;
+    STDMETHOD(GetGlyphImageData)(
+        _In_ UINT16 glyphId,
+        UINT32 pixelsPerEm,
+        DWRITE_GLYPH_IMAGE_FORMATS glyphImageFormat,
+        _Out_ DWRITE_GLYPH_IMAGE_DATA* glyphData,
+        _Outptr_result_maybenull_ void** glyphDataContext
+        ) PURE;
+    STDMETHOD_(void, ReleaseGlyphImageData)(
+        void* glyphDataContext
+        ) PURE;
+};
+
+interface DWRITE_DECLARE_INTERFACE("98EFF3A5-B667-479A-B145-E2FA5B9FDC29") IDWriteFontFace5
+    : public IDWriteFontFace4
+{
+    STDMETHOD_(UINT32, GetFontAxisValueCount)() PURE;
+    STDMETHOD(GetFontAxisValues)(
+        _Out_writes_(fontAxisValueCount) DWRITE_FONT_AXIS_VALUE* fontAxisValues,
+        UINT32 fontAxisValueCount
+        ) PURE;
+    STDMETHOD_(BOOL, HasVariations)() PURE;
+    STDMETHOD(GetFontResource)(
+        _COM_Outptr_ IDWriteFontResource** fontResource
+        ) PURE;
+    STDMETHOD_(BOOL, Equals)(IDWriteFontFace* fontFace) PURE;
+};
+
+interface DWRITE_DECLARE_INTERFACE("1F803A76-6871-48E8-987F-B975551C50F2") IDWriteFontResource
+    : public IUnknown
+{
+    STDMETHOD(GetFontFile)(
+        _COM_Outptr_ IDWriteFontFile** fontFile
+        ) PURE;
+    STDMETHOD_(UINT32, GetFontFaceIndex)() PURE;
+    STDMETHOD_(UINT32, GetFontAxisCount)() PURE;
+    STDMETHOD(GetDefaultFontAxisValues)(
+        _Out_writes_(fontAxisValueCount) DWRITE_FONT_AXIS_VALUE* fontAxisValues,
+        UINT32 fontAxisValueCount
+        ) PURE;
+    STDMETHOD(GetFontAxisRanges)(
+        _Out_writes_(fontAxisRangeCount) DWRITE_FONT_AXIS_RANGE* fontAxisRanges,
+        UINT32 fontAxisRangeCount
+        ) PURE;
+    STDMETHOD_(DWRITE_FONT_AXIS_ATTRIBUTES, GetFontAxisAttributes)(
+        UINT32 axisIndex
+        ) PURE;
+    STDMETHOD(GetAxisNames)(
+        UINT32 axisIndex,
+        _COM_Outptr_ IDWriteLocalizedStrings** names
+        ) PURE;
+    STDMETHOD_(UINT32, GetAxisValueNameCount)(
+        UINT32 axisIndex
+        ) PURE;
+    STDMETHOD(GetAxisValueNames)(
+        UINT32 axisIndex,
+        UINT32 axisValueIndex,
+        _Out_ DWRITE_FONT_AXIS_RANGE* fontAxisRange,
+        _COM_Outptr_ IDWriteLocalizedStrings** names
+        ) PURE;
+    STDMETHOD_(BOOL, HasVariations)() PURE;
+    STDMETHOD(CreateFontFace)(
+        DWRITE_FONT_SIMULATIONS fontSimulations,
+        _In_reads_(fontAxisValueCount) DWRITE_FONT_AXIS_VALUE const* fontAxisValues,
+        UINT32 fontAxisValueCount,
+        _COM_Outptr_ IDWriteFontFace5** fontFace
+        ) PURE;
+    STDMETHOD(CreateFontFaceReference)(
+        DWRITE_FONT_SIMULATIONS fontSimulations,
+        _In_reads_(fontAxisValueCount) DWRITE_FONT_AXIS_VALUE const* fontAxisValues,
+        UINT32 fontAxisValueCount,
+        _COM_Outptr_ IDWriteFontFaceReference1** fontFaceReference
+        ) PURE;
+};
+
+#endif /* DWRITE_EXTRA_H */
--- a/gfx/thebes/gfxDWriteFontList.h
+++ b/gfx/thebes/gfxDWriteFontList.h
@@ -5,16 +5,28 @@
 
 #ifndef GFX_DWRITEFONTLIST_H
 #define GFX_DWRITEFONTLIST_H
 
 #include "mozilla/MemoryReporting.h"
 #include "gfxDWriteCommon.h"
 #include "dwrite_3.h"
 
+ // Currently, we build with WINVER=0x601 (Win7), which means newer
+ // declarations in dwrite_3.h will not be visible. Also, we don't
+ // yet have the Fall Creators Update SDK available on build machines,
+ // so even with updated WINVER, some of the interfaces we need would
+ // not be present.
+ // To work around this, until the build environment is updated,
+ // we #include an extra header that contains copies of the relevant
+ // classes/interfaces we need.
+#if WINVER < 0x0A00
+#include "dw-extra.h"
+#endif
+
 #include "gfxFont.h"
 #include "gfxUserFontSet.h"
 #include "cairo-win32.h"
 
 #include "gfxPlatformFontList.h"
 #include "gfxPlatform.h"
 #include <algorithm>