Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: src/core/SkPaint.cpp

Issue 1872253004: Revert of Pass effects directly to fontcache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkGlyphCache.cpp ('k') | src/core/SkScalerContext.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 matrix.setConcat(ctm, textM); 423 matrix.setConcat(ctm, textM);
424 return tooBig(matrix, MaxCacheSize2()); 424 return tooBig(matrix, MaxCacheSize2());
425 } 425 }
426 426
427 427
428 /////////////////////////////////////////////////////////////////////////////// 428 ///////////////////////////////////////////////////////////////////////////////
429 429
430 #include "SkGlyphCache.h" 430 #include "SkGlyphCache.h"
431 #include "SkUtils.h" 431 #include "SkUtils.h"
432 432
433 static void DetachDescProc(SkTypeface* typeface, const SkScalerContextEffects& e ffects, 433 static void DetachDescProc(SkTypeface* typeface, const SkDescriptor* desc,
434 const SkDescriptor* desc, void* context) { 434 void* context) {
435 *((SkGlyphCache**)context) = SkGlyphCache::DetachCache(typeface, effects, de sc); 435 *((SkGlyphCache**)context) = SkGlyphCache::DetachCache(typeface, desc);
436 } 436 }
437 437
438 int SkPaint::textToGlyphs(const void* textData, size_t byteLength, uint16_t glyp hs[]) const { 438 int SkPaint::textToGlyphs(const void* textData, size_t byteLength,
439 uint16_t glyphs[]) const {
439 if (byteLength == 0) { 440 if (byteLength == 0) {
440 return 0; 441 return 0;
441 } 442 }
442 443
443 SkASSERT(textData != nullptr); 444 SkASSERT(textData != nullptr);
444 445
445 if (nullptr == glyphs) { 446 if (nullptr == glyphs) {
446 switch (this->getTextEncoding()) { 447 switch (this->getTextEncoding()) {
447 case kUTF8_TextEncoding: 448 case kUTF8_TextEncoding:
448 return SkUTF8_CountUnichars((const char*)textData, byteLength); 449 return SkUTF8_CountUnichars((const char*)textData, byteLength);
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 return text - stop + length; 931 return text - stop + length;
931 } 932 }
932 933
933 /////////////////////////////////////////////////////////////////////////////// 934 ///////////////////////////////////////////////////////////////////////////////
934 935
935 static bool FontMetricsCacheProc(const SkGlyphCache* cache, void* context) { 936 static bool FontMetricsCacheProc(const SkGlyphCache* cache, void* context) {
936 *(SkPaint::FontMetrics*)context = cache->getFontMetrics(); 937 *(SkPaint::FontMetrics*)context = cache->getFontMetrics();
937 return false; // don't detach the cache 938 return false; // don't detach the cache
938 } 939 }
939 940
940 static void FontMetricsDescProc(SkTypeface* typeface, const SkScalerContextEffec ts& effects, 941 static void FontMetricsDescProc(SkTypeface* typeface, const SkDescriptor* desc,
941 const SkDescriptor* desc, void* context) { 942 void* context) {
942 SkGlyphCache::VisitCache(typeface, effects, desc, FontMetricsCacheProc, cont ext); 943 SkGlyphCache::VisitCache(typeface, desc, FontMetricsCacheProc, context);
943 } 944 }
944 945
945 SkScalar SkPaint::getFontMetrics(FontMetrics* metrics, SkScalar zoom) const { 946 SkScalar SkPaint::getFontMetrics(FontMetrics* metrics, SkScalar zoom) const {
946 SkCanonicalizePaint canon(*this); 947 SkCanonicalizePaint canon(*this);
947 const SkPaint& paint = canon.getPaint(); 948 const SkPaint& paint = canon.getPaint();
948 SkScalar scale = canon.getScale(); 949 SkScalar scale = canon.getScale();
949 950
950 SkMatrix zoomMatrix, *zoomPtr = nullptr; 951 SkMatrix zoomMatrix, *zoomPtr = nullptr;
951 if (zoom) { 952 if (zoom) {
952 zoomMatrix.setScale(zoom, zoom); 953 zoomMatrix.setScale(zoom, zoom);
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 SkASSERT(descSize == desc1->getLength()); 1641 SkASSERT(descSize == desc1->getLength());
1641 SkASSERT(descSize == desc2->getLength()); 1642 SkASSERT(descSize == desc2->getLength());
1642 desc1->computeChecksum(); 1643 desc1->computeChecksum();
1643 desc2->computeChecksum(); 1644 desc2->computeChecksum();
1644 SkASSERT(!memcmp(desc, desc1, descSize)); 1645 SkASSERT(!memcmp(desc, desc1, descSize));
1645 SkASSERT(!memcmp(desc, desc2, descSize)); 1646 SkASSERT(!memcmp(desc, desc2, descSize));
1646 } 1647 }
1647 #endif 1648 #endif
1648 1649
1649 /* see the note on ignoreGamma on descriptorProc */ 1650 /* see the note on ignoreGamma on descriptorProc */
1650 void SkPaint::getScalerContextDescriptor(SkScalerContextEffects* effects, 1651 void SkPaint::getScalerContextDescriptor(SkAutoDescriptor* ad,
1651 SkAutoDescriptor* ad,
1652 const SkSurfaceProps& surfaceProps, 1652 const SkSurfaceProps& surfaceProps,
1653 uint32_t scalerContextFlags, 1653 uint32_t scalerContextFlags,
1654 const SkMatrix* deviceMatrix) const { 1654 const SkMatrix* deviceMatrix) const {
1655 SkScalerContext::Rec rec; 1655 SkScalerContext::Rec rec;
1656 1656
1657 SkPathEffect* pe = this->getPathEffect(); 1657 SkPathEffect* pe = this->getPathEffect();
1658 SkMaskFilter* mf = this->getMaskFilter(); 1658 SkMaskFilter* mf = this->getMaskFilter();
1659 SkRasterizer* ra = this->getRasterizer(); 1659 SkRasterizer* ra = this->getRasterizer();
1660 1660
1661 SkWriteBuffer peBuffer, mfBuffer, raBuffer; 1661 SkWriteBuffer peBuffer, mfBuffer, raBuffer;
1662 size_t descSize = fill_out_rec(*this, &rec, &surfaceProps, 1662 size_t descSize = fill_out_rec(*this, &rec, &surfaceProps,
1663 SkToBool(scalerContextFlags & kFakeGamma_Scal erContextFlag), 1663 SkToBool(scalerContextFlags & kFakeGamma_Scal erContextFlag),
1664 SkToBool(scalerContextFlags & kBoostContrast_ ScalerContextFlag), 1664 SkToBool(scalerContextFlags & kBoostContrast_ ScalerContextFlag),
1665 deviceMatrix, pe, &peBuffer, mf, &mfBuffer, r a, &raBuffer); 1665 deviceMatrix, pe, &peBuffer, mf, &mfBuffer, r a, &raBuffer);
1666 1666
1667 ad->reset(descSize); 1667 ad->reset(descSize);
1668 SkDescriptor* desc = ad->getDesc(); 1668 SkDescriptor* desc = ad->getDesc();
1669 1669
1670 write_out_descriptor(desc, rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer, descSize); 1670 write_out_descriptor(desc, rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer, descSize);
1671 1671
1672 SkASSERT(descSize == desc->getLength()); 1672 SkASSERT(descSize == desc->getLength());
1673 1673
1674 #ifdef TEST_DESC 1674 #ifdef TEST_DESC
1675 test_desc(rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer, desc, descSize); 1675 test_desc(rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer, desc, descSize);
1676 #endif 1676 #endif
1677
1678 effects->fPathEffect = pe;
1679 effects->fMaskFilter = mf;
1680 effects->fRasterizer = ra;
1681 } 1677 }
1682 1678
1683 /* 1679 /*
1684 * ignoreGamma tells us that the caller just wants metrics that are unaffected 1680 * ignoreGamma tells us that the caller just wants metrics that are unaffected
1685 * by gamma correction, so we set the rec to ignore preblend: i.e. gamma = 1, 1681 * by gamma correction, so we set the rec to ignore preblend: i.e. gamma = 1,
1686 * contrast = 0, luminanceColor = transparent black. 1682 * contrast = 0, luminanceColor = transparent black.
1687 */ 1683 */
1688 void SkPaint::descriptorProc(const SkSurfaceProps* surfaceProps, 1684 void SkPaint::descriptorProc(const SkSurfaceProps* surfaceProps,
1689 uint32_t scalerContextFlags, 1685 uint32_t scalerContextFlags,
1690 const SkMatrix* deviceMatrix, 1686 const SkMatrix* deviceMatrix,
1691 void (*proc)(SkTypeface*, const SkScalerContextEffe cts&, 1687 void (*proc)(SkTypeface*, const SkDescriptor*, void *),
1692 const SkDescriptor*, void*),
1693 void* context) const { 1688 void* context) const {
1694 SkScalerContext::Rec rec; 1689 SkScalerContext::Rec rec;
1695 1690
1696 SkPathEffect* pe = this->getPathEffect(); 1691 SkPathEffect* pe = this->getPathEffect();
1697 SkMaskFilter* mf = this->getMaskFilter(); 1692 SkMaskFilter* mf = this->getMaskFilter();
1698 SkRasterizer* ra = this->getRasterizer(); 1693 SkRasterizer* ra = this->getRasterizer();
1699 1694
1700 SkWriteBuffer peBuffer, mfBuffer, raBuffer; 1695 SkWriteBuffer peBuffer, mfBuffer, raBuffer;
1701 size_t descSize = fill_out_rec(*this, &rec, surfaceProps, 1696 size_t descSize = fill_out_rec(*this, &rec, surfaceProps,
1702 SkToBool(scalerContextFlags & kFakeGamma_Scal erContextFlag), 1697 SkToBool(scalerContextFlags & kFakeGamma_Scal erContextFlag),
1703 SkToBool(scalerContextFlags & kBoostContrast_ ScalerContextFlag), 1698 SkToBool(scalerContextFlags & kBoostContrast_ ScalerContextFlag),
1704 deviceMatrix, pe, &peBuffer, mf, &mfBuffer, r a, &raBuffer); 1699 deviceMatrix, pe, &peBuffer, mf, &mfBuffer, r a, &raBuffer);
1705 1700
1706 SkAutoDescriptor ad(descSize); 1701 SkAutoDescriptor ad(descSize);
1707 SkDescriptor* desc = ad.getDesc(); 1702 SkDescriptor* desc = ad.getDesc();
1708 1703
1709 write_out_descriptor(desc, rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer, descSize); 1704 write_out_descriptor(desc, rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer, descSize);
1710 1705
1711 SkASSERT(descSize == desc->getLength()); 1706 SkASSERT(descSize == desc->getLength());
1712 1707
1713 #ifdef TEST_DESC 1708 #ifdef TEST_DESC
1714 test_desc(rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer, desc, descSize); 1709 test_desc(rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer, desc, descSize);
1715 #endif 1710 #endif
1716 1711
1717 proc(fTypeface.get(), { pe, mf, ra }, desc, context); 1712 proc(fTypeface.get(), desc, context);
1718 } 1713 }
1719 1714
1720 SkGlyphCache* SkPaint::detachCache(const SkSurfaceProps* surfaceProps, 1715 SkGlyphCache* SkPaint::detachCache(const SkSurfaceProps* surfaceProps,
1721 uint32_t scalerContextFlags, 1716 uint32_t scalerContextFlags,
1722 const SkMatrix* deviceMatrix) const { 1717 const SkMatrix* deviceMatrix) const {
1723 SkGlyphCache* cache; 1718 SkGlyphCache* cache;
1724 this->descriptorProc(surfaceProps, scalerContextFlags, deviceMatrix, DetachD escProc, &cache); 1719 this->descriptorProc(surfaceProps, scalerContextFlags, deviceMatrix, DetachD escProc, &cache);
1725 return cache; 1720 return cache;
1726 } 1721 }
1727 1722
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
2371 } 2366 }
2372 2367
2373 uint32_t SkPaint::getHash() const { 2368 uint32_t SkPaint::getHash() const {
2374 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB itfields, 2369 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB itfields,
2375 // so fBitfields should be 10 pointers and 6 32-bit values from the start. 2370 // so fBitfields should be 10 pointers and 6 32-bit values from the start.
2376 static_assert(offsetof(SkPaint, fBitfields) == 9 * sizeof(void*) + 6 * sizeo f(uint32_t), 2371 static_assert(offsetof(SkPaint, fBitfields) == 9 * sizeof(void*) + 6 * sizeo f(uint32_t),
2377 "SkPaint_notPackedTightly"); 2372 "SkPaint_notPackedTightly");
2378 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), 2373 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this),
2379 offsetof(SkPaint, fBitfields) + sizeof(fBitfields )); 2374 offsetof(SkPaint, fBitfields) + sizeof(fBitfields ));
2380 } 2375 }
OLDNEW
« no previous file with comments | « src/core/SkGlyphCache.cpp ('k') | src/core/SkScalerContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698