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

Side by Side Diff: src/gpu/effects/GrTextureStripAtlas.cpp

Issue 929243004: adding preabandon flag to DM (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: feedback incorporated Created 5 years, 9 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/SkGr.cpp ('k') | tools/flags/SkCommonFlags.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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 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 #include "GrTextureStripAtlas.h" 9 #include "GrTextureStripAtlas.h"
10 #include "SkPixelRef.h" 10 #include "SkPixelRef.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 85 }
86 86
87 GrTextureStripAtlas::~GrTextureStripAtlas() { 87 GrTextureStripAtlas::~GrTextureStripAtlas() {
88 SkDELETE_ARRAY(fRows); 88 SkDELETE_ARRAY(fRows);
89 } 89 }
90 90
91 int GrTextureStripAtlas::lockRow(const SkBitmap& data) { 91 int GrTextureStripAtlas::lockRow(const SkBitmap& data) {
92 VALIDATE; 92 VALIDATE;
93 if (0 == fLockedRows) { 93 if (0 == fLockedRows) {
94 this->lockTexture(); 94 this->lockTexture();
95 if (!fTexture) {
96 return -1;
97 }
95 } 98 }
96 99
97 int key = data.getGenerationID(); 100 int key = data.getGenerationID();
98 int rowNumber = -1; 101 int rowNumber = -1;
99 int index = this->searchByKey(key); 102 int index = this->searchByKey(key);
100 103
101 if (index >= 0) { 104 if (index >= 0) {
102 // We already have the data in a row, so we can just return that row 105 // We already have the data in a row, so we can just return that row
103 AtlasRow* row = fKeyTable[index]; 106 AtlasRow* row = fKeyTable[index];
104 if (0 == row->fLocks) { 107 if (0 == row->fLocks) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 200
198 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); 201 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
199 GrUniqueKey key; 202 GrUniqueKey key;
200 GrUniqueKey::Builder builder(&key, kDomain, 1); 203 GrUniqueKey::Builder builder(&key, kDomain, 1);
201 builder[0] = static_cast<uint32_t>(fCacheKey); 204 builder[0] = static_cast<uint32_t>(fCacheKey);
202 builder.finish(); 205 builder.finish();
203 206
204 fTexture = fDesc.fContext->findAndRefCachedTexture(key); 207 fTexture = fDesc.fContext->findAndRefCachedTexture(key);
205 if (NULL == fTexture) { 208 if (NULL == fTexture) {
206 fTexture = fDesc.fContext->createTexture(texDesc, true, NULL, 0); 209 fTexture = fDesc.fContext->createTexture(texDesc, true, NULL, 0);
210 if (!fTexture) {
211 return;
212 }
207 fDesc.fContext->addResourceToCache(key, fTexture); 213 fDesc.fContext->addResourceToCache(key, fTexture);
208 // This is a new texture, so all of our cache info is now invalid 214 // This is a new texture, so all of our cache info is now invalid
209 this->initLRU(); 215 this->initLRU();
210 fKeyTable.rewind(); 216 fKeyTable.rewind();
211 } 217 }
212 SkASSERT(fTexture); 218 SkASSERT(fTexture);
213 } 219 }
214 220
215 void GrTextureStripAtlas::unlockTexture() { 221 void GrTextureStripAtlas::unlockTexture() {
216 SkASSERT(fTexture && 0 == fLockedRows); 222 SkASSERT(fTexture && 0 == fLockedRows);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 344
339 // If we have locked rows, we should have a locked texture, otherwise 345 // If we have locked rows, we should have a locked texture, otherwise
340 // it should be unlocked 346 // it should be unlocked
341 if (fLockedRows == 0) { 347 if (fLockedRows == 0) {
342 SkASSERT(NULL == fTexture); 348 SkASSERT(NULL == fTexture);
343 } else { 349 } else {
344 SkASSERT(fTexture); 350 SkASSERT(fTexture);
345 } 351 }
346 } 352 }
347 #endif 353 #endif
OLDNEW
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | tools/flags/SkCommonFlags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698