Bug 1267180. Don't draw emojis as paths when they are too big. r=lsalzman
authorMason Chang <mchang@mozilla.com>
Fri, 29 Apr 2016 10:23:49 -0400
changeset 295437 57e54fef9cf2ebe21eb7d928ed6d5e1d2d180a79
parent 295436 a2df8487be0583ad13cbcb1b023dbb951c361f3f
child 295438 247e670772921fea3ebebd7dcf9ff04c8a105b4d
push id75922
push usermchang@mozilla.com
push dateFri, 29 Apr 2016 14:23:59 +0000
treeherdermozilla-inbound@57e54fef9cf2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman
bugs1267180
milestone49.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 1267180. Don't draw emojis as paths when they are too big. r=lsalzman
gfx/skia/skia/include/core/SkTypeface.h
gfx/skia/skia/src/core/SkDraw.cpp
gfx/skia/skia/src/ports/SkFontHost_mac.cpp
--- a/gfx/skia/skia/include/core/SkTypeface.h
+++ b/gfx/skia/skia/include/core/SkTypeface.h
@@ -300,16 +300,22 @@ public:
 
     /**
      *  Return a rectangle (scaled to 1-pt) that represents the union of the bounds of all
      *  of the glyphs, but each one positioned at (0,). This may be conservatively large, and
      *  will not take into account any hinting or other size-specific adjustments.
      */
     SkRect getBounds() const;
 
+    /***
+     * Returns whether this typeface has color glyphs and therefore cannot be
+     * rendered as a path. e.g. Emojis.
+     */
+    virtual bool hasColorGlyphs() const { return false; }
+
     // PRIVATE / EXPERIMENTAL -- do not call
     void filterRec(SkScalerContextRec* rec) const {
         this->onFilterRec(rec);
     }
     // PRIVATE / EXPERIMENTAL -- do not call
     void getFontDescriptor(SkFontDescriptor* desc, bool* isLocal) const {
         this->onGetFontDescriptor(desc, isLocal);
     }
--- a/gfx/skia/skia/src/core/SkDraw.cpp
+++ b/gfx/skia/skia/src/core/SkDraw.cpp
@@ -1398,16 +1398,21 @@ bool SkDraw::ShouldDrawTextAsPaths(const
         return true;
     }
 
     // we don't cache perspective
     if (ctm.hasPerspective()) {
         return true;
     }
 
+    // Glyphs like Emojis can't be rendered as a path.
+    if (paint.getTypeface()->hasColorGlyphs()) {
+      return false;
+    }
+
     SkMatrix textM;
     return SkPaint::TooBigToUseCache(ctm, *paint.setTextMatrix(&textM));
 }
 
 void SkDraw::drawText_asPaths(const char text[], size_t byteLength,
                               SkScalar x, SkScalar y,
                               const SkPaint& paint) const {
     SkDEBUGCODE(this->validate();)
--- a/gfx/skia/skia/src/ports/SkFontHost_mac.cpp
+++ b/gfx/skia/skia/src/ports/SkFontHost_mac.cpp
@@ -460,16 +460,17 @@ public:
     {
         SkASSERT(fontRef);
     }
 
     SkString fRequestedName;
     AutoCFRelease<CTFontRef> fFontRef;
     AutoCFRelease<CFTypeRef> fOriginatingCFTypeRef;
     const bool fHasColorGlyphs;
+    bool hasColorGlyphs() const override { return fHasColorGlyphs; }
 
 protected:
     int onGetUPEM() const override;
     SkStreamAsset* onOpenStream(int* ttcIndex) const override;
     SkFontData* onCreateFontData() const override;
     void onGetFamilyName(SkString* familyName) const override;
     SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override;
     int onGetTableTags(SkFontTableTag tags[]) const override;