| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkPaint.h" | 8 #include "SkPaint.h" |
| 9 #include "SkAnnotation.h" | 9 #include "SkAnnotation.h" |
| 10 #include "SkAutoKern.h" | 10 #include "SkAutoKern.h" |
| 11 #include "SkColorFilter.h" | 11 #include "SkColorFilter.h" |
| 12 #include "SkData.h" | 12 #include "SkData.h" |
| 13 #include "SkDeviceProperties.h" | 13 #include "SkDeviceProperties.h" |
| 14 #include "SkDraw.h" | |
| 15 #include "SkFontDescriptor.h" | 14 #include "SkFontDescriptor.h" |
| 16 #include "SkFontHost.h" | 15 #include "SkFontHost.h" |
| 17 #include "SkGlyphCache.h" | 16 #include "SkGlyphCache.h" |
| 18 #include "SkImageFilter.h" | 17 #include "SkImageFilter.h" |
| 19 #include "SkMaskFilter.h" | 18 #include "SkMaskFilter.h" |
| 20 #include "SkMaskGamma.h" | 19 #include "SkMaskGamma.h" |
| 21 #include "SkReadBuffer.h" | 20 #include "SkReadBuffer.h" |
| 22 #include "SkWriteBuffer.h" | 21 #include "SkWriteBuffer.h" |
| 23 #include "SkPaintDefaults.h" | 22 #include "SkPaintDefaults.h" |
| 24 #include "SkPaintOptionsAndroid.h" | 23 #include "SkPaintOptionsAndroid.h" |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 | 499 |
| 501 bool SkPaint::TooBigToUseCache(const SkMatrix& ctm, const SkMatrix& textM) { | 500 bool SkPaint::TooBigToUseCache(const SkMatrix& ctm, const SkMatrix& textM) { |
| 502 SkASSERT(!ctm.hasPerspective()); | 501 SkASSERT(!ctm.hasPerspective()); |
| 503 SkASSERT(!textM.hasPerspective()); | 502 SkASSERT(!textM.hasPerspective()); |
| 504 | 503 |
| 505 SkMatrix matrix; | 504 SkMatrix matrix; |
| 506 matrix.setConcat(ctm, textM); | 505 matrix.setConcat(ctm, textM); |
| 507 return tooBig(matrix, MaxCacheSize2()); | 506 return tooBig(matrix, MaxCacheSize2()); |
| 508 } | 507 } |
| 509 | 508 |
| 509 bool SkPaint::tooBigToUseCache(const SkMatrix& ctm) const { |
| 510 SkMatrix textM; |
| 511 return TooBigToUseCache(ctm, *this->setTextMatrix(&textM)); |
| 512 } |
| 513 |
| 514 bool SkPaint::tooBigToUseCache() const { |
| 515 SkMatrix textM; |
| 516 return tooBig(*this->setTextMatrix(&textM), MaxCacheSize2()); |
| 517 } |
| 510 | 518 |
| 511 /////////////////////////////////////////////////////////////////////////////// | 519 /////////////////////////////////////////////////////////////////////////////// |
| 512 | 520 |
| 513 #include "SkGlyphCache.h" | 521 #include "SkGlyphCache.h" |
| 514 #include "SkUtils.h" | 522 #include "SkUtils.h" |
| 515 | 523 |
| 516 static void DetachDescProc(SkTypeface* typeface, const SkDescriptor* desc, | 524 static void DetachDescProc(SkTypeface* typeface, const SkDescriptor* desc, |
| 517 void* context) { | 525 void* context) { |
| 518 *((SkGlyphCache**)context) = SkGlyphCache::DetachCache(typeface, desc); | 526 *((SkGlyphCache**)context) = SkGlyphCache::DetachCache(typeface, desc); |
| 519 } | 527 } |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 this->setHinting(SkPaint::kNo_Hinting); | 990 this->setHinting(SkPaint::kNo_Hinting); |
| 983 | 991 |
| 984 SkScalar textSize = fTextSize; | 992 SkScalar textSize = fTextSize; |
| 985 this->setTextSize(kCanonicalTextSizeForPaths); | 993 this->setTextSize(kCanonicalTextSizeForPaths); |
| 986 return textSize / kCanonicalTextSizeForPaths; | 994 return textSize / kCanonicalTextSizeForPaths; |
| 987 } | 995 } |
| 988 | 996 |
| 989 class SkCanonicalizePaint { | 997 class SkCanonicalizePaint { |
| 990 public: | 998 public: |
| 991 SkCanonicalizePaint(const SkPaint& paint) : fPaint(&paint), fScale(0) { | 999 SkCanonicalizePaint(const SkPaint& paint) : fPaint(&paint), fScale(0) { |
| 992 if (paint.isLinearText() || SkDraw::ShouldDrawTextAsPaths(paint, SkMatri
x::I())) { | 1000 if (paint.isLinearText() || paint.tooBigToUseCache()) { |
| 993 SkPaint* p = fLazy.set(paint); | 1001 SkPaint* p = fLazy.set(paint); |
| 994 fScale = p->setupForAsPaths(); | 1002 fScale = p->setupForAsPaths(); |
| 995 fPaint = p; | 1003 fPaint = p; |
| 996 } | 1004 } |
| 997 } | 1005 } |
| 998 | 1006 |
| 999 const SkPaint& getPaint() const { return *fPaint; } | 1007 const SkPaint& getPaint() const { return *fPaint; } |
| 1000 | 1008 |
| 1001 /** | 1009 /** |
| 1002 * Returns 0 if the paint was unmodified, or the scale factor need to | 1010 * Returns 0 if the paint was unmodified, or the scale factor need to |
| (...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2748 } | 2756 } |
| 2749 #ifdef SK_BUILD_FOR_ANDROID | 2757 #ifdef SK_BUILD_FOR_ANDROID |
| 2750 if (dirty & kPaintOptionsAndroid_DirtyBit) { | 2758 if (dirty & kPaintOptionsAndroid_DirtyBit) { |
| 2751 SkPaintOptionsAndroid options; | 2759 SkPaintOptionsAndroid options; |
| 2752 options.unflatten(buffer); | 2760 options.unflatten(buffer); |
| 2753 paint->setPaintOptionsAndroid(options); | 2761 paint->setPaintOptionsAndroid(options); |
| 2754 } | 2762 } |
| 2755 #endif | 2763 #endif |
| 2756 SkASSERT(dirty == paint->fDirtyBits); | 2764 SkASSERT(dirty == paint->fDirtyBits); |
| 2757 } | 2765 } |
| OLD | NEW |