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