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/core/SkImageCacherator.cpp

Issue 1351453004: use allocator (if present) when we allocate our cache bitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fission out test change to separate CL 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 | « include/core/SkImageGenerator.h ('k') | src/core/SkImageGenerator.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 * 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"
11 #include "SkMallocPixelRef.h" 11 #include "SkMallocPixelRef.h"
12 #include "SkNextID.h" 12 #include "SkNextID.h"
13 #include "SkPixelRef.h" 13 #include "SkPixelRef.h"
14 #include "SkResourceCache.h"
14 15
15 #if SK_SUPPORT_GPU 16 #if SK_SUPPORT_GPU
16 #include "GrContext.h" 17 #include "GrContext.h"
17 #include "GrGpuResourcePriv.h" 18 #include "GrGpuResourcePriv.h"
18 #include "GrResourceKey.h" 19 #include "GrResourceKey.h"
19 #include "GrTextureAccess.h" 20 #include "GrTextureAccess.h"
20 #include "GrYUVProvider.h" 21 #include "GrYUVProvider.h"
21 #include "SkGr.h" 22 #include "SkGr.h"
22 #include "SkGrPriv.h" 23 #include "SkGrPriv.h"
23 #endif 24 #endif
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 SkASSERT(bitmap.getGenerationID() == expectedID); 76 SkASSERT(bitmap.getGenerationID() == expectedID);
76 SkASSERT(bitmap.isImmutable()); 77 SkASSERT(bitmap.isImmutable());
77 SkASSERT(bitmap.getPixels()); 78 SkASSERT(bitmap.getPixels());
78 return true; 79 return true;
79 } 80 }
80 81
81 // Note, this returns a new, mutable, bitmap, with a new genID. 82 // Note, this returns a new, mutable, bitmap, with a new genID.
82 // If you want the immutable bitmap with the same ID as our cacherator, call try LockAsBitmap() 83 // If you want the immutable bitmap with the same ID as our cacherator, call try LockAsBitmap()
83 // 84 //
84 bool SkImageCacherator::generateBitmap(SkBitmap* bitmap) { 85 bool SkImageCacherator::generateBitmap(SkBitmap* bitmap) {
86 SkBitmap::Allocator* allocator = SkResourceCache::GetAllocator();
87
85 ScopedGenerator generator(this); 88 ScopedGenerator generator(this);
86 const SkImageInfo& genInfo = generator->getInfo(); 89 const SkImageInfo& genInfo = generator->getInfo();
87 if (fInfo.dimensions() == genInfo.dimensions()) { 90 if (fInfo.dimensions() == genInfo.dimensions()) {
88 SkASSERT(fOrigin.x() == 0 && fOrigin.y() == 0); 91 SkASSERT(fOrigin.x() == 0 && fOrigin.y() == 0);
89 // fast-case, no copy needed 92 // fast-case, no copy needed
90 return generator->tryGenerateBitmap(bitmap, fInfo); 93 return generator->tryGenerateBitmap(bitmap, fInfo, allocator);
91 } else { 94 } else {
92 // need to handle subsetting, so we first generate the full size version , and then 95 // need to handle subsetting, so we first generate the full size version , and then
93 // "read" from it to get our subset. See skbug.com/4213 96 // "read" from it to get our subset. See skbug.com/4213
94 97
95 SkBitmap full; 98 SkBitmap full;
96 if (!generator->tryGenerateBitmap(&full, genInfo)) { 99 if (!generator->tryGenerateBitmap(&full, genInfo, allocator)) {
97 return false; 100 return false;
98 } 101 }
99 if (!bitmap->tryAllocPixels(fInfo, nullptr, full.getColorTable())) { 102 if (!bitmap->tryAllocPixels(fInfo, nullptr, full.getColorTable())) {
100 return false; 103 return false;
101 } 104 }
102 return full.readPixels(bitmap->info(), bitmap->getPixels(), bitmap->rowB ytes(), 105 return full.readPixels(bitmap->info(), bitmap->getPixels(), bitmap->rowB ytes(),
103 fOrigin.x(), fOrigin.y()); 106 fOrigin.x(), fOrigin.y());
104 } 107 }
105 } 108 }
106 109
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // 5. Ask the generator to return RGB(A) data, which the GPU can convert 263 // 5. Ask the generator to return RGB(A) data, which the GPU can convert
261 SkBitmap bitmap; 264 SkBitmap bitmap;
262 if (this->tryLockAsBitmap(&bitmap)) { 265 if (this->tryLockAsBitmap(&bitmap)) {
263 return GrRefCachedBitmapTexture(ctx, bitmap, usage); 266 return GrRefCachedBitmapTexture(ctx, bitmap, usage);
264 } 267 }
265 #endif 268 #endif
266 269
267 return nullptr; 270 return nullptr;
268 } 271 }
269 272
OLDNEW
« no previous file with comments | « include/core/SkImageGenerator.h ('k') | src/core/SkImageGenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698