OLD | NEW |
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 , fOverBudgetData(NULL) | 76 , fOverBudgetData(NULL) |
77 , fFlushTimestamps(NULL) | 77 , fFlushTimestamps(NULL) |
78 , fLastFlushTimestampIndex(0){ | 78 , fLastFlushTimestampIndex(0){ |
79 SkDEBUGCODE(fCount = 0;) | 79 SkDEBUGCODE(fCount = 0;) |
80 SkDEBUGCODE(fNewlyPurgeableResourceForValidation = NULL;) | 80 SkDEBUGCODE(fNewlyPurgeableResourceForValidation = NULL;) |
81 this->resetFlushTimestamps(); | 81 this->resetFlushTimestamps(); |
82 } | 82 } |
83 | 83 |
84 GrResourceCache::~GrResourceCache() { | 84 GrResourceCache::~GrResourceCache() { |
85 this->releaseAll(); | 85 this->releaseAll(); |
86 SkDELETE(fFlushTimestamps); | 86 SkDELETE_ARRAY(fFlushTimestamps); |
87 } | 87 } |
88 | 88 |
89 void GrResourceCache::setLimits(int count, size_t bytes, int maxUnusedFlushes) { | 89 void GrResourceCache::setLimits(int count, size_t bytes, int maxUnusedFlushes) { |
90 fMaxCount = count; | 90 fMaxCount = count; |
91 fMaxBytes = bytes; | 91 fMaxBytes = bytes; |
92 fMaxUnusedFlushes = maxUnusedFlushes; | 92 fMaxUnusedFlushes = maxUnusedFlushes; |
93 this->resetFlushTimestamps(); | 93 this->resetFlushTimestamps(); |
94 this->purgeAsNeeded(); | 94 this->purgeAsNeeded(); |
95 } | 95 } |
96 | 96 |
97 void GrResourceCache::resetFlushTimestamps() { | 97 void GrResourceCache::resetFlushTimestamps() { |
98 SkDELETE(fFlushTimestamps); | 98 SkDELETE_ARRAY(fFlushTimestamps); |
99 | 99 |
100 // We assume this number is a power of two when wrapping indices into the ti
mestamp array. | 100 // We assume this number is a power of two when wrapping indices into the ti
mestamp array. |
101 fMaxUnusedFlushes = SkNextPow2(fMaxUnusedFlushes); | 101 fMaxUnusedFlushes = SkNextPow2(fMaxUnusedFlushes); |
102 | 102 |
103 // Since our implementation is to store the timestamps of the last fMaxUnuse
dFlushes flush calls | 103 // Since our implementation is to store the timestamps of the last fMaxUnuse
dFlushes flush calls |
104 // we just turn the feature off if that array would be large. | 104 // we just turn the feature off if that array would be large. |
105 static const int kMaxSupportedTimestampHistory = 128; | 105 static const int kMaxSupportedTimestampHistory = 128; |
106 | 106 |
107 if (fMaxUnusedFlushes > kMaxSupportedTimestampHistory) { | 107 if (fMaxUnusedFlushes > kMaxSupportedTimestampHistory) { |
108 fFlushTimestamps = NULL; | 108 fFlushTimestamps = NULL; |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 return true; | 716 return true; |
717 } | 717 } |
718 if (index < fNonpurgeableResources.count() && fNonpurgeableResources[index]
== resource) { | 718 if (index < fNonpurgeableResources.count() && fNonpurgeableResources[index]
== resource) { |
719 return true; | 719 return true; |
720 } | 720 } |
721 SkDEBUGFAIL("Resource index should be -1 or the resource should be in the ca
che."); | 721 SkDEBUGFAIL("Resource index should be -1 or the resource should be in the ca
che."); |
722 return false; | 722 return false; |
723 } | 723 } |
724 | 724 |
725 #endif | 725 #endif |
OLD | NEW |