| 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 "SkAutoKern.h" | 9 #include "SkAutoKern.h" |
| 10 #include "SkChecksum.h" | 10 #include "SkChecksum.h" |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 this->setFlags(flags); | 704 this->setFlags(flags); |
| 705 this->setHinting(SkPaint::kNo_Hinting); | 705 this->setHinting(SkPaint::kNo_Hinting); |
| 706 | 706 |
| 707 SkScalar textSize = fTextSize; | 707 SkScalar textSize = fTextSize; |
| 708 this->setTextSize(kCanonicalTextSizeForPaths); | 708 this->setTextSize(kCanonicalTextSizeForPaths); |
| 709 return textSize / kCanonicalTextSizeForPaths; | 709 return textSize / kCanonicalTextSizeForPaths; |
| 710 } | 710 } |
| 711 | 711 |
| 712 class SkCanonicalizePaint { | 712 class SkCanonicalizePaint { |
| 713 public: | 713 public: |
| 714 SkCanonicalizePaint(const SkPaint& paint) : fPaint(&paint), fScale(0) { | 714 SkCanonicalizePaint(const SkPaint& paint, bool forceLinearText = false) : fP
aint(&paint), fScale(0) { |
| 715 if (paint.isLinearText() || SkDraw::ShouldDrawTextAsPaths(paint, SkMatri
x::I())) { | 715 if (forceLinearText || paint.isLinearText() || SkDraw::ShouldDrawTextAsP
aths(paint, SkMatrix::I())) { |
| 716 SkPaint* p = fLazy.set(paint); | 716 SkPaint* p = fLazy.set(paint); |
| 717 if (forceLinearText) |
| 718 p->setLinearText(true); |
| 717 fScale = p->setupForAsPaths(); | 719 fScale = p->setupForAsPaths(); |
| 718 fPaint = p; | 720 fPaint = p; |
| 719 } | 721 } |
| 720 } | 722 } |
| 721 | 723 |
| 722 const SkPaint& getPaint() const { return *fPaint; } | 724 const SkPaint& getPaint() const { return *fPaint; } |
| 723 | 725 |
| 724 /** | 726 /** |
| 725 * Returns 0 if the paint was unmodified, or the scale factor need to | 727 * Returns 0 if the paint was unmodified, or the scale factor need to |
| 726 * the original textSize | 728 * the original textSize |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 if (0 == byteLength) { | 994 if (0 == byteLength) { |
| 993 return 0; | 995 return 0; |
| 994 } | 996 } |
| 995 | 997 |
| 996 SkASSERT(textData); | 998 SkASSERT(textData); |
| 997 | 999 |
| 998 if (nullptr == widths && nullptr == bounds) { | 1000 if (nullptr == widths && nullptr == bounds) { |
| 999 return this->countText(textData, byteLength); | 1001 return this->countText(textData, byteLength); |
| 1000 } | 1002 } |
| 1001 | 1003 |
| 1002 SkCanonicalizePaint canon(*this); | 1004 SkCanonicalizePaint canon(*this, true); |
| 1003 const SkPaint& paint = canon.getPaint(); | 1005 const SkPaint& paint = canon.getPaint(); |
| 1004 SkScalar scale = canon.getScale(); | 1006 SkScalar scale = canon.getScale(); |
| 1005 | 1007 |
| 1006 SkAutoGlyphCache autoCache(paint, nullptr, nullptr); | 1008 SkAutoGlyphCache autoCache(paint, nullptr, nullptr); |
| 1007 SkGlyphCache* cache = autoCache.getCache(); | 1009 SkGlyphCache* cache = autoCache.getCache(); |
| 1008 GlyphCacheProc glyphCacheProc = paint.getGlyphCacheProc(nullptr != boun
ds); | 1010 GlyphCacheProc glyphCacheProc = paint.getGlyphCacheProc(nullptr != boun
ds); |
| 1009 | 1011 |
| 1010 const char* text = (const char*)textData; | 1012 const char* text = (const char*)textData; |
| 1011 const char* stop = text + byteLength; | 1013 const char* stop = text + byteLength; |
| 1012 int count = 0; | 1014 int count = 0; |
| (...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2322 } | 2324 } |
| 2323 | 2325 |
| 2324 uint32_t SkPaint::getHash() const { | 2326 uint32_t SkPaint::getHash() const { |
| 2325 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, | 2327 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, |
| 2326 // so fBitfields should be 10 pointers and 6 32-bit values from the start. | 2328 // so fBitfields should be 10 pointers and 6 32-bit values from the start. |
| 2327 static_assert(offsetof(SkPaint, fBitfields) == 9 * sizeof(void*) + 6 * sizeo
f(uint32_t), | 2329 static_assert(offsetof(SkPaint, fBitfields) == 9 * sizeof(void*) + 6 * sizeo
f(uint32_t), |
| 2328 "SkPaint_notPackedTightly"); | 2330 "SkPaint_notPackedTightly"); |
| 2329 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), | 2331 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), |
| 2330 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); | 2332 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); |
| 2331 } | 2333 } |
| OLD | NEW |