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

Side by Side Diff: src/core/SkImageCacherator.cpp

Issue 1338373002: be sure to use cached bitmap when we need to upload something to make a texture (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/core/SkBitmapCache.cpp ('k') | 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 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkBitmapCache.h" 9 #include "SkBitmapCache.h"
10 #include "SkImageCacherator.h" 10 #include "SkImageCacherator.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return generator->refEncodedData(); 63 return generator->refEncodedData();
64 } 64 }
65 65
66 static bool check_output_bitmap(const SkBitmap& bitmap, uint32_t expectedID) { 66 static bool check_output_bitmap(const SkBitmap& bitmap, uint32_t expectedID) {
67 SkASSERT(bitmap.getGenerationID() == expectedID); 67 SkASSERT(bitmap.getGenerationID() == expectedID);
68 SkASSERT(bitmap.isImmutable()); 68 SkASSERT(bitmap.isImmutable());
69 SkASSERT(bitmap.getPixels()); 69 SkASSERT(bitmap.getPixels());
70 return true; 70 return true;
71 } 71 }
72 72
73 // Note, this returns a new, mutable, bitmap, with a new genID.
74 // If you want the immutable bitmap with the same ID as our cacherator, call try LockAsBitmap()
tomhudson 2015/09/14 17:31:45 Is there some way we could change the names of the
75 //
73 bool SkImageCacherator::generateBitmap(SkBitmap* bitmap) { 76 bool SkImageCacherator::generateBitmap(SkBitmap* bitmap) {
74 ScopedGenerator generator(this); 77 ScopedGenerator generator(this);
75 const SkImageInfo& genInfo = generator->getInfo(); 78 const SkImageInfo& genInfo = generator->getInfo();
76 if (fInfo.dimensions() == genInfo.dimensions()) { 79 if (fInfo.dimensions() == genInfo.dimensions()) {
77 SkASSERT(fOrigin.x() == 0 && fOrigin.y() == 0); 80 SkASSERT(fOrigin.x() == 0 && fOrigin.y() == 0);
78 // fast-case, no copy needed 81 // fast-case, no copy needed
79 return generator->tryGenerateBitmap(bitmap, fInfo); 82 return generator->tryGenerateBitmap(bitmap, fInfo);
80 } else { 83 } else {
81 // need to handle subsetting, so we first generate the full size version , and then 84 // need to handle subsetting, so we first generate the full size version , and then
82 // "read" from it to get our subset. See skbug.com/4213 85 // "read" from it to get our subset. See skbug.com/4213
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 ScopedGenerator generator(this); 252 ScopedGenerator generator(this);
250 Generator_GrYUVProvider provider(generator); 253 Generator_GrYUVProvider provider(generator);
251 GrTexture* tex = provider.refAsTexture(ctx, desc, true); 254 GrTexture* tex = provider.refAsTexture(ctx, desc, true);
252 if (tex) { 255 if (tex) {
253 return set_key_and_return(tex, key); 256 return set_key_and_return(tex, key);
254 } 257 }
255 } 258 }
256 259
257 // 5. Ask the generator to return RGB(A) data, which the GPU can convert 260 // 5. Ask the generator to return RGB(A) data, which the GPU can convert
258 SkBitmap bitmap; 261 SkBitmap bitmap;
259 if (this->generateBitmap(&bitmap)) { 262 if (this->tryLockAsBitmap(&bitmap)) {
260 return GrRefCachedBitmapTexture(ctx, bitmap, usage); 263 return GrRefCachedBitmapTexture(ctx, bitmap, usage);
261 } 264 }
262 #endif 265 #endif
263 266
264 return nullptr; 267 return nullptr;
265 } 268 }
266 269
OLDNEW
« no previous file with comments | « src/core/SkBitmapCache.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698