Bug 1397458 - part 3 - add ScaledFont::GetWRFontInstanceOptions for querying WebRender font instance options draft
authorLee Salzman <lsalzman@mozilla.com>
Tue, 19 Sep 2017 23:11:02 -0400
changeset 669052 a9848b7af85cc389e1750b408d4f0b36902a95e1
parent 669051 80a0b7ebfaed96d54530a4170c8b37e42e242372
child 669053 052691f4f93ee5e8a655e590ce7ad44053b14c10
push id81203
push userkgupta@mozilla.com
push dateFri, 22 Sep 2017 13:01:28 +0000
bugs1397458
milestone58.0a1
Bug 1397458 - part 3 - add ScaledFont::GetWRFontInstanceOptions for querying WebRender font instance options MozReview-Commit-ID: BRDfmwkbOY2
gfx/2d/2D.h
gfx/2d/ScaledFontMac.cpp
gfx/2d/ScaledFontMac.h
--- 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;