1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/patches/archive/0013-Bug-761890-fonts.patch Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,162 @@ 1.4 +# HG changeset patch 1.5 +# User Nicholas Cameron <ncameron@mozilla.com> 1.6 +# Date 1337146927 -43200 1.7 +# Node ID 310209abef2c2667e5de41dd2a1f071e8cd42821 1.8 +# Parent 93f3ca4d5707b2aae9c6ae52d5d29c2c802e7ef8 1.9 +Bug 746883; changes to the Skia library. r=gw280 1.10 + 1.11 +diff --git a/gfx/skia/include/core/SkDraw.h b/gfx/skia/include/core/SkDraw.h 1.12 +--- a/gfx/skia/include/core/SkDraw.h 1.13 ++++ b/gfx/skia/include/core/SkDraw.h 1.14 +@@ -125,23 +125,24 @@ public: 1.15 + #endif 1.16 + }; 1.17 + 1.18 + class SkGlyphCache; 1.19 + 1.20 + class SkTextToPathIter { 1.21 + public: 1.22 + SkTextToPathIter(const char text[], size_t length, const SkPaint& paint, 1.23 +- bool applyStrokeAndPathEffects); 1.24 ++ bool applyStrokeAndPathEffects, bool useCanonicalTextSize = true); 1.25 + ~SkTextToPathIter(); 1.26 + 1.27 + const SkPaint& getPaint() const { return fPaint; } 1.28 + SkScalar getPathScale() const { return fScale; } 1.29 + 1.30 + const SkPath* next(SkScalar* xpos); //!< returns nil when there are no more paths 1.31 ++ bool nextWithWhitespace(const SkPath** path, SkScalar* xpos); //!< returns false when there are no more paths 1.32 + 1.33 + private: 1.34 + SkGlyphCache* fCache; 1.35 + SkPaint fPaint; 1.36 + SkScalar fScale; 1.37 + SkFixed fPrevAdvance; 1.38 + const char* fText; 1.39 + const char* fStop; 1.40 +diff --git a/gfx/skia/src/core/SkPaint.cpp b/gfx/skia/src/core/SkPaint.cpp 1.41 +--- a/gfx/skia/src/core/SkPaint.cpp 1.42 ++++ b/gfx/skia/src/core/SkPaint.cpp 1.43 +@@ -1359,30 +1359,32 @@ void SkPaint::getPosTextPath(const void* 1.44 + const SkPoint pos[], SkPath* path) const { 1.45 + SkASSERT(length == 0 || textData != NULL); 1.46 + 1.47 + const char* text = (const char*)textData; 1.48 + if (text == NULL || length == 0 || path == NULL) { 1.49 + return; 1.50 + } 1.51 + 1.52 +- SkTextToPathIter iter(text, length, *this, false); 1.53 ++ SkTextToPathIter iter(text, length, *this, false, false); 1.54 + SkMatrix matrix; 1.55 + SkPoint prevPos; 1.56 + prevPos.set(0, 0); 1.57 + 1.58 + matrix.setScale(iter.getPathScale(), iter.getPathScale()); 1.59 + path->reset(); 1.60 + 1.61 + unsigned int i = 0; 1.62 + const SkPath* iterPath; 1.63 +- while ((iterPath = iter.next(NULL)) != NULL) { 1.64 +- matrix.postTranslate(pos[i].fX - prevPos.fX, pos[i].fY - prevPos.fY); 1.65 +- path->addPath(*iterPath, matrix); 1.66 +- prevPos = pos[i]; 1.67 ++ while (iter.nextWithWhitespace(&iterPath, NULL)) { 1.68 ++ if (iterPath) { 1.69 ++ matrix.postTranslate(pos[i].fX - prevPos.fX, pos[i].fY - prevPos.fY); 1.70 ++ path->addPath(*iterPath, matrix); 1.71 ++ prevPos = pos[i]; 1.72 ++ } 1.73 + i++; 1.74 + } 1.75 + } 1.76 + 1.77 + static void add_flattenable(SkDescriptor* desc, uint32_t tag, 1.78 + SkFlattenableWriteBuffer* buffer) { 1.79 + buffer->flatten(desc->addEntry(tag, buffer->size(), NULL)); 1.80 + } 1.81 +@@ -2118,30 +2120,31 @@ const SkRect& SkPaint::doComputeFastBoun 1.82 + 1.83 + static bool has_thick_frame(const SkPaint& paint) { 1.84 + return paint.getStrokeWidth() > 0 && 1.85 + paint.getStyle() != SkPaint::kFill_Style; 1.86 + } 1.87 + 1.88 + SkTextToPathIter::SkTextToPathIter( const char text[], size_t length, 1.89 + const SkPaint& paint, 1.90 +- bool applyStrokeAndPathEffects) 1.91 ++ bool applyStrokeAndPathEffects, 1.92 ++ bool useCanonicalTextSize) 1.93 + : fPaint(paint) { 1.94 + fGlyphCacheProc = paint.getMeasureCacheProc(SkPaint::kForward_TextBufferDirection, 1.95 + true); 1.96 + 1.97 + fPaint.setLinearText(true); 1.98 + fPaint.setMaskFilter(NULL); // don't want this affecting our path-cache lookup 1.99 + 1.100 + if (fPaint.getPathEffect() == NULL && !has_thick_frame(fPaint)) { 1.101 + applyStrokeAndPathEffects = false; 1.102 + } 1.103 + 1.104 + // can't use our canonical size if we need to apply patheffects 1.105 +- if (fPaint.getPathEffect() == NULL) { 1.106 ++ if (useCanonicalTextSize && fPaint.getPathEffect() == NULL) { 1.107 + fPaint.setTextSize(SkIntToScalar(SkPaint::kCanonicalTextSizeForPaths)); 1.108 + fScale = paint.getTextSize() / SkPaint::kCanonicalTextSizeForPaths; 1.109 + if (has_thick_frame(fPaint)) { 1.110 + fPaint.setStrokeWidth(SkScalarDiv(fPaint.getStrokeWidth(), fScale)); 1.111 + } 1.112 + } else { 1.113 + fScale = SK_Scalar1; 1.114 + } 1.115 +@@ -2185,30 +2188,47 @@ SkTextToPathIter::SkTextToPathIter( cons 1.116 + fXYIndex = paint.isVerticalText() ? 1 : 0; 1.117 + } 1.118 + 1.119 + SkTextToPathIter::~SkTextToPathIter() { 1.120 + SkGlyphCache::AttachCache(fCache); 1.121 + } 1.122 + 1.123 + const SkPath* SkTextToPathIter::next(SkScalar* xpos) { 1.124 +- while (fText < fStop) { 1.125 ++ const SkPath* result; 1.126 ++ while (nextWithWhitespace(&result, xpos)) { 1.127 ++ if (result) { 1.128 ++ if (xpos) { 1.129 ++ *xpos = fXPos; 1.130 ++ } 1.131 ++ return result; 1.132 ++ } 1.133 ++ } 1.134 ++ return NULL; 1.135 ++} 1.136 ++ 1.137 ++bool SkTextToPathIter::nextWithWhitespace(const SkPath** path, SkScalar* xpos) { 1.138 ++ if (fText < fStop) { 1.139 + const SkGlyph& glyph = fGlyphCacheProc(fCache, &fText); 1.140 + 1.141 + fXPos += SkScalarMul(SkFixedToScalar(fPrevAdvance + fAutoKern.adjust(glyph)), fScale); 1.142 + fPrevAdvance = advance(glyph, fXYIndex); // + fPaint.getTextTracking(); 1.143 + 1.144 + if (glyph.fWidth) { 1.145 + if (xpos) { 1.146 + *xpos = fXPos; 1.147 + } 1.148 +- return fCache->findPath(glyph); 1.149 ++ *path = fCache->findPath(glyph); 1.150 ++ return true; 1.151 ++ } else { 1.152 ++ *path = NULL; 1.153 ++ return true; 1.154 + } 1.155 + } 1.156 +- return NULL; 1.157 ++ return false; 1.158 + } 1.159 + 1.160 + /////////////////////////////////////////////////////////////////////////////// 1.161 + 1.162 + bool SkPaint::nothingToDraw() const { 1.163 + if (fLooper) { 1.164 + return false; 1.165 + }