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

Side by Side Diff: src/gpu/GrResourceCache.cpp

Issue 1445523003: Revert of Switch uses of SkChecksum::Compute to Murmur3. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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/gpu/GrProgramDesc.h ('k') | tests/ChecksumTest.cpp » ('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 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "GrResourceCache.h" 10 #include "GrResourceCache.h"
(...skipping 24 matching lines...) Expand all
35 35
36 int32_t domain = sk_atomic_inc(&gDomain); 36 int32_t domain = sk_atomic_inc(&gDomain);
37 if (domain > SK_MaxU16) { 37 if (domain > SK_MaxU16) {
38 SkFAIL("Too many GrUniqueKey Domains"); 38 SkFAIL("Too many GrUniqueKey Domains");
39 } 39 }
40 40
41 return static_cast<Domain>(domain); 41 return static_cast<Domain>(domain);
42 } 42 }
43 43
44 uint32_t GrResourceKeyHash(const uint32_t* data, size_t size) { 44 uint32_t GrResourceKeyHash(const uint32_t* data, size_t size) {
45 return SkChecksum::Murmur3(data, size); 45 return SkChecksum::Compute(data, size);
46 } 46 }
47 47
48 ////////////////////////////////////////////////////////////////////////////// 48 //////////////////////////////////////////////////////////////////////////////
49 49
50 class GrResourceCache::AutoValidate : ::SkNoncopyable { 50 class GrResourceCache::AutoValidate : ::SkNoncopyable {
51 public: 51 public:
52 AutoValidate(GrResourceCache* cache) : fCache(cache) { cache->validate(); } 52 AutoValidate(GrResourceCache* cache) : fCache(cache) { cache->validate(); }
53 ~AutoValidate() { fCache->validate(); } 53 ~AutoValidate() { fCache->validate(); }
54 private: 54 private:
55 GrResourceCache* fCache; 55 GrResourceCache* fCache;
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 } 557 }
558 }; 558 };
559 Less less; 559 Less less;
560 SkTQSort(fNonpurgeableResources.begin(), fNonpurgeableResources.end( ) - 1, less); 560 SkTQSort(fNonpurgeableResources.begin(), fNonpurgeableResources.end( ) - 1, less);
561 561
562 // Pick resources out of the purgeable and non-purgeable arrays base d on lowest 562 // Pick resources out of the purgeable and non-purgeable arrays base d on lowest
563 // timestamp and assign new timestamps. 563 // timestamp and assign new timestamps.
564 int currP = 0; 564 int currP = 0;
565 int currNP = 0; 565 int currNP = 0;
566 while (currP < sortedPurgeableResources.count() && 566 while (currP < sortedPurgeableResources.count() &&
567 currNP < fNonpurgeableResources.count()) { 567 currNP < fNonpurgeableResources.count()) {
568 uint32_t tsP = sortedPurgeableResources[currP]->cacheAccess().ti mestamp(); 568 uint32_t tsP = sortedPurgeableResources[currP]->cacheAccess().ti mestamp();
569 uint32_t tsNP = fNonpurgeableResources[currNP]->cacheAccess().ti mestamp(); 569 uint32_t tsNP = fNonpurgeableResources[currNP]->cacheAccess().ti mestamp();
570 SkASSERT(tsP != tsNP); 570 SkASSERT(tsP != tsNP);
571 if (tsP < tsNP) { 571 if (tsP < tsNP) {
572 sortedPurgeableResources[currP++]->cacheAccess().setTimestam p(fTimestamp++); 572 sortedPurgeableResources[currP++]->cacheAccess().setTimestam p(fTimestamp++);
573 } else { 573 } else {
574 // Correct the index in the nonpurgeable array stored on the resource post-sort. 574 // Correct the index in the nonpurgeable array stored on the resource post-sort.
575 *fNonpurgeableResources[currNP]->cacheAccess().accessCacheIn dex() = currNP; 575 *fNonpurgeableResources[currNP]->cacheAccess().accessCacheIn dex() = currNP;
576 fNonpurgeableResources[currNP++]->cacheAccess().setTimestamp (fTimestamp++); 576 fNonpurgeableResources[currNP++]->cacheAccess().setTimestamp (fTimestamp++);
577 } 577 }
(...skipping 11 matching lines...) Expand all
589 // Rebuild the queue. 589 // Rebuild the queue.
590 for (int i = 0; i < sortedPurgeableResources.count(); ++i) { 590 for (int i = 0; i < sortedPurgeableResources.count(); ++i) {
591 fPurgeableQueue.insert(sortedPurgeableResources[i]); 591 fPurgeableQueue.insert(sortedPurgeableResources[i]);
592 } 592 }
593 593
594 this->validate(); 594 this->validate();
595 SkASSERT(count == this->getResourceCount()); 595 SkASSERT(count == this->getResourceCount());
596 596
597 // count should be the next timestamp we return. 597 // count should be the next timestamp we return.
598 SkASSERT(fTimestamp == SkToU32(count)); 598 SkASSERT(fTimestamp == SkToU32(count));
599 599
600 // The historical timestamps of flushes are now invalid. 600 // The historical timestamps of flushes are now invalid.
601 this->resetFlushTimestamps(); 601 this->resetFlushTimestamps();
602 } 602 }
603 } 603 }
604 return fTimestamp++; 604 return fTimestamp++;
605 } 605 }
606 606
607 void GrResourceCache::notifyFlushOccurred() { 607 void GrResourceCache::notifyFlushOccurred() {
608 if (fFlushTimestamps) { 608 if (fFlushTimestamps) {
609 SkASSERT(SkIsPow2(fMaxUnusedFlushes)); 609 SkASSERT(SkIsPow2(fMaxUnusedFlushes));
610 fLastFlushTimestampIndex = (fLastFlushTimestampIndex + 1) & (fMaxUnusedF lushes - 1); 610 fLastFlushTimestampIndex = (fLastFlushTimestampIndex + 1) & (fMaxUnusedF lushes - 1);
611 // get the timestamp before accessing fFlushTimestamps because getNextTi mestamp will 611 // get the timestamp before accessing fFlushTimestamps because getNextTi mestamp will
612 // reallocate fFlushTimestamps on timestamp overflow. 612 // reallocate fFlushTimestamps on timestamp overflow.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 return true; 733 return true;
734 } 734 }
735 if (index < fNonpurgeableResources.count() && fNonpurgeableResources[index] == resource) { 735 if (index < fNonpurgeableResources.count() && fNonpurgeableResources[index] == resource) {
736 return true; 736 return true;
737 } 737 }
738 SkDEBUGFAIL("Resource index should be -1 or the resource should be in the ca che."); 738 SkDEBUGFAIL("Resource index should be -1 or the resource should be in the ca che.");
739 return false; 739 return false;
740 } 740 }
741 741
742 #endif 742 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrProgramDesc.h ('k') | tests/ChecksumTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698