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

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

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 EDT Created 5 years, 3 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/gpu/GrRectanizer_skyline.cpp ('k') | src/gpu/GrResourceProvider.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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 , fFlushTimestamps(NULL) 77 , fFlushTimestamps(NULL)
78 , fLastFlushTimestampIndex(0) 78 , fLastFlushTimestampIndex(0)
79 , fPreferVRAMUseOverFlushes(caps->preferVRAMUseOverFlushes()) { 79 , fPreferVRAMUseOverFlushes(caps->preferVRAMUseOverFlushes()) {
80 SkDEBUGCODE(fCount = 0;) 80 SkDEBUGCODE(fCount = 0;)
81 SkDEBUGCODE(fNewlyPurgeableResourceForValidation = NULL;) 81 SkDEBUGCODE(fNewlyPurgeableResourceForValidation = NULL;)
82 this->resetFlushTimestamps(); 82 this->resetFlushTimestamps();
83 } 83 }
84 84
85 GrResourceCache::~GrResourceCache() { 85 GrResourceCache::~GrResourceCache() {
86 this->releaseAll(); 86 this->releaseAll();
87 SkDELETE_ARRAY(fFlushTimestamps); 87 delete[] fFlushTimestamps;
88 } 88 }
89 89
90 void GrResourceCache::setLimits(int count, size_t bytes, int maxUnusedFlushes) { 90 void GrResourceCache::setLimits(int count, size_t bytes, int maxUnusedFlushes) {
91 fMaxCount = count; 91 fMaxCount = count;
92 fMaxBytes = bytes; 92 fMaxBytes = bytes;
93 fMaxUnusedFlushes = maxUnusedFlushes; 93 fMaxUnusedFlushes = maxUnusedFlushes;
94 this->resetFlushTimestamps(); 94 this->resetFlushTimestamps();
95 this->purgeAsNeeded(); 95 this->purgeAsNeeded();
96 } 96 }
97 97
98 void GrResourceCache::resetFlushTimestamps() { 98 void GrResourceCache::resetFlushTimestamps() {
99 SkDELETE_ARRAY(fFlushTimestamps); 99 delete[] fFlushTimestamps;
100 100
101 // We assume this number is a power of two when wrapping indices into the ti mestamp array. 101 // We assume this number is a power of two when wrapping indices into the ti mestamp array.
102 fMaxUnusedFlushes = SkNextPow2(fMaxUnusedFlushes); 102 fMaxUnusedFlushes = SkNextPow2(fMaxUnusedFlushes);
103 103
104 // Since our implementation is to store the timestamps of the last fMaxUnuse dFlushes flush calls 104 // Since our implementation is to store the timestamps of the last fMaxUnuse dFlushes flush calls
105 // we just turn the feature off if that array would be large. 105 // we just turn the feature off if that array would be large.
106 static const int kMaxSupportedTimestampHistory = 128; 106 static const int kMaxSupportedTimestampHistory = 128;
107 107
108 if (fMaxUnusedFlushes > kMaxSupportedTimestampHistory) { 108 if (fMaxUnusedFlushes > kMaxSupportedTimestampHistory) {
109 fFlushTimestamps = NULL; 109 fFlushTimestamps = NULL;
110 return; 110 return;
111 } 111 }
112 112
113 fFlushTimestamps = SkNEW_ARRAY(uint32_t, fMaxUnusedFlushes); 113 fFlushTimestamps = new uint32_t[fMaxUnusedFlushes];
114 fLastFlushTimestampIndex = 0; 114 fLastFlushTimestampIndex = 0;
115 // Set all the historical flush timestamps to initially be at the beginning of time (timestamp 115 // Set all the historical flush timestamps to initially be at the beginning of time (timestamp
116 // 0). 116 // 0).
117 sk_bzero(fFlushTimestamps, fMaxUnusedFlushes * sizeof(uint32_t)); 117 sk_bzero(fFlushTimestamps, fMaxUnusedFlushes * sizeof(uint32_t));
118 } 118 }
119 119
120 void GrResourceCache::insertResource(GrGpuResource* resource) { 120 void GrResourceCache::insertResource(GrGpuResource* resource) {
121 SkASSERT(resource); 121 SkASSERT(resource);
122 SkASSERT(!this->isInCache(resource)); 122 SkASSERT(!this->isInCache(resource));
123 SkASSERT(!resource->wasDestroyed()); 123 SkASSERT(!resource->wasDestroyed());
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 return true; 724 return true;
725 } 725 }
726 if (index < fNonpurgeableResources.count() && fNonpurgeableResources[index] == resource) { 726 if (index < fNonpurgeableResources.count() && fNonpurgeableResources[index] == resource) {
727 return true; 727 return true;
728 } 728 }
729 SkDEBUGFAIL("Resource index should be -1 or the resource should be in the ca che."); 729 SkDEBUGFAIL("Resource index should be -1 or the resource should be in the ca che.");
730 return false; 730 return false;
731 } 731 }
732 732
733 #endif 733 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrRectanizer_skyline.cpp ('k') | src/gpu/GrResourceProvider.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698