| Index: src/core/SkPaint.cpp
|
| diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
|
| index 9b6b88386339d24a41d3c2f2bd5a3db4115c0dc5..811cbeff9ba8adc15dc54f8ebcdf954db2c0ee18 100644
|
| --- a/src/core/SkPaint.cpp
|
| +++ b/src/core/SkPaint.cpp
|
| @@ -425,6 +425,37 @@ SkAnnotation* SkPaint::setAnnotation(SkAnnotation* annotation) {
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| +static SkScalar mag2(SkScalar x, SkScalar y) {
|
| + return x * x + y * y;
|
| +}
|
| +
|
| +static bool tooBig(const SkMatrix& m, SkScalar ma2max) {
|
| + return mag2(m[SkMatrix::kMScaleX], m[SkMatrix::kMSkewY]) > ma2max
|
| + ||
|
| + mag2(m[SkMatrix::kMSkewX], m[SkMatrix::kMScaleY]) > ma2max;
|
| +}
|
| +
|
| +bool SkPaint::TooBigToUseCache(const SkMatrix& ctm, const SkMatrix& textM) {
|
| + SkASSERT(!ctm.hasPerspective());
|
| + SkASSERT(!textM.hasPerspective());
|
| +
|
| + SkMatrix matrix;
|
| + matrix.setConcat(ctm, textM);
|
| + return tooBig(matrix, MaxCacheSize2());
|
| +}
|
| +
|
| +bool SkPaint::tooBigToUseCache(const SkMatrix& ctm) const {
|
| + SkMatrix textM;
|
| + return TooBigToUseCache(ctm, *this->setTextMatrix(&textM));
|
| +}
|
| +
|
| +bool SkPaint::tooBigToUseCache() const {
|
| + SkMatrix textM;
|
| + return tooBig(*this->setTextMatrix(&textM), MaxCacheSize2());
|
| +}
|
| +
|
| +///////////////////////////////////////////////////////////////////////////////
|
| +
|
| #include "SkGlyphCache.h"
|
| #include "SkUtils.h"
|
|
|
| @@ -1072,7 +1103,7 @@ SkScalar SkPaint::measureText(const void* textData, size_t length,
|
| SkScalar scale = 0;
|
| SkAutoRestorePaintTextSizeAndFrame restore(this);
|
|
|
| - if (this->isLinearText()) {
|
| + if (this->isLinearText() || this->tooBigToUseCache()) {
|
| scale = fTextSize / kCanonicalTextSizeForPaths;
|
| // this gets restored by restore
|
| ((SkPaint*)this)->setTextSize(SkIntToScalar(kCanonicalTextSizeForPaths));
|
| @@ -1287,7 +1318,7 @@ int SkPaint::getTextWidths(const void* textData, size_t byteLength,
|
| SkAutoRestorePaintTextSizeAndFrame restore(this);
|
| SkScalar scale = 0;
|
|
|
| - if (this->isLinearText()) {
|
| + if (this->isLinearText() || this->tooBigToUseCache()) {
|
| scale = fTextSize / kCanonicalTextSizeForPaths;
|
| // this gets restored by restore
|
| ((SkPaint*)this)->setTextSize(SkIntToScalar(kCanonicalTextSizeForPaths));
|
|
|