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

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

Issue 1075853002: Valgrind sez: new[] wants delete[]. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 | « no previous file | no next file » | 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698