Bug 1397458 - part 3 - add ScaledFont::GetWRFontInstanceOptions for querying WebRender font instance options
MozReview-Commit-ID: BRDfmwkbOY2
--- a/gfx/2d/2D.h
+++ b/gfx/2d/2D.h
@@ -67,16 +67,21 @@ struct gfxFontStyle;
struct CGContext;
typedef struct CGContext *CGContextRef;
namespace mozilla {
class Mutex;
+namespace wr {
+struct FontInstanceOptions;
+struct FontInstancePlatformOptions;
+}
+
namespace gfx {
class UnscaledFont;
class ScaledFont;
}
template<>
struct WeakPtrTraits<gfx::UnscaledFont>
{
@@ -823,16 +828,23 @@ public:
virtual void GetGlyphDesignMetrics(const uint16_t* aGlyphIndices, uint32_t aNumGlyphs, GlyphMetrics* aGlyphMetrics) = 0;
typedef void (*FontInstanceDataOutput)(const uint8_t* aData, uint32_t aLength,
const FontVariation* aVariations, uint32_t aNumVariations,
void* aBaton);
virtual bool GetFontInstanceData(FontInstanceDataOutput, void *) { return false; }
+ virtual bool GetWRFontInstanceOptions(Maybe<wr::FontInstanceOptions>* aOutOptions,
+ Maybe<wr::FontInstancePlatformOptions>* aOutPlatformOptions,
+ std::vector<FontVariation>* aOutVariations)
+ {
+ return false;
+ }
+
virtual bool CanSerialize() { return false; }
void AddUserData(UserDataKey *key, void *userData, void (*destroy)(void*)) {
mUserData.Add(key, userData, destroy);
}
void *GetUserData(UserDataKey *key) {
return mUserData.Get(key);
}
--- a/gfx/2d/ScaledFontMac.cpp
+++ b/gfx/2d/ScaledFontMac.cpp
@@ -353,16 +353,27 @@ ScaledFontMac::GetFontInstanceData(FontI
std::vector<FontVariation> variations;
if (!GetVariationsForCTFont(mCTFont, &variations)) {
return false;
}
aCb(nullptr, 0, variations.data(), variations.size(), aBaton);
return true;
}
+bool
+ScaledFontMac::GetWRFontInstanceOptions(Maybe<wr::FontInstanceOptions>* aOutOptions,
+ Maybe<wr::FontInstancePlatformOptions>* aOutPlatformOptions,
+ std::vector<FontVariation>* aOutVariations)
+{
+ if (!GetVariationsForCTFont(mCTFont, aOutVariations)) {
+ return false;
+ }
+ return true;
+}
+
static CFDictionaryRef
CreateVariationDictionaryOrNull(CGFontRef aCGFont, uint32_t aVariationCount,
const FontVariation* aVariations)
{
// Avoid calling potentially buggy variation APIs on pre-Sierra macOS
// versions (see bug 1331683)
if (!nsCocoaFeatures::OnSierraOrLater()) {
return nullptr;
--- a/gfx/2d/ScaledFontMac.h
+++ b/gfx/2d/ScaledFontMac.h
@@ -47,16 +47,20 @@ public:
FontType GetType() const override { return FontType::MAC; }
#ifdef USE_SKIA
SkTypeface* GetSkTypeface() override;
#endif
already_AddRefed<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget) override;
bool GetFontInstanceData(FontInstanceDataOutput aCb, void* aBaton) override;
+ bool GetWRFontInstanceOptions(Maybe<wr::FontInstanceOptions>* aOutOptions,
+ Maybe<wr::FontInstancePlatformOptions>* aOutPlatformOptions,
+ std::vector<FontVariation>* aOutVariations) override;
+
bool CanSerialize() override { return true; }
#ifdef USE_CAIRO_SCALED_FONT
cairo_font_face_t* GetCairoFontFace() override;
#endif
private:
friend class DrawTargetSkia;