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 1249543003: Creating functions for uploading a mipmapped texture. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Rebasing. Created 4 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/core/SkImageCacherator.h ('k') | src/core/SkMipMap.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 "SkImage_Base.h" 10 #include "SkImage_Base.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 /* 232 /*
233 * We have a 5 ways to try to return a texture (in sorted order) 233 * We have a 5 ways to try to return a texture (in sorted order)
234 * 234 *
235 * 1. Check the cache for a pre-existing one 235 * 1. Check the cache for a pre-existing one
236 * 2. Ask the generator to natively create one 236 * 2. Ask the generator to natively create one
237 * 3. Ask the generator to return a compressed form that the GPU might support 237 * 3. Ask the generator to return a compressed form that the GPU might support
238 * 4. Ask the generator to return YUV planes, which the GPU can convert 238 * 4. Ask the generator to return YUV planes, which the GPU can convert
239 * 5. Ask the generator to return RGB(A) data, which the GPU can convert 239 * 5. Ask the generator to return RGB(A) data, which the GPU can convert
240 */ 240 */
241 GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& key , 241 GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& key ,
242 const SkImage* client, SkImage::Cachin gHint chint) { 242 const SkImage* client, SkImage::Cachin gHint chint,
243 bool willBeMipped) {
243 // Values representing the various texture lock paths we can take. Used for logging the path 244 // Values representing the various texture lock paths we can take. Used for logging the path
244 // taken to a histogram. 245 // taken to a histogram.
245 enum LockTexturePath { 246 enum LockTexturePath {
246 kFailure_LockTexturePath, 247 kFailure_LockTexturePath,
247 kPreExisting_LockTexturePath, 248 kPreExisting_LockTexturePath,
248 kNative_LockTexturePath, 249 kNative_LockTexturePath,
249 kCompressed_LockTexturePath, 250 kCompressed_LockTexturePath,
250 kYUV_LockTexturePath, 251 kYUV_LockTexturePath,
251 kRGBA_LockTexturePath, 252 kRGBA_LockTexturePath,
252 }; 253 };
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 if (tex) { 295 if (tex) {
295 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kYUV_LockTexturePath, 296 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kYUV_LockTexturePath,
296 kLockTexturePathCount); 297 kLockTexturePathCount);
297 return set_key_and_return(tex, key); 298 return set_key_and_return(tex, key);
298 } 299 }
299 } 300 }
300 301
301 // 5. Ask the generator to return RGB(A) data, which the GPU can convert 302 // 5. Ask the generator to return RGB(A) data, which the GPU can convert
302 SkBitmap bitmap; 303 SkBitmap bitmap;
303 if (this->tryLockAsBitmap(&bitmap, client, chint)) { 304 if (this->tryLockAsBitmap(&bitmap, client, chint)) {
304 GrTexture* tex = GrUploadBitmapToTexture(ctx, bitmap); 305 GrTexture* tex = nullptr;
306 if (willBeMipped) {
307 tex = GrGenerateMipMapsAndUploadToTexture(ctx, bitmap);
308 } else {
309 tex = GrUploadBitmapToTexture(ctx, bitmap);
310 }
305 if (tex) { 311 if (tex) {
306 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kRGBA_LockTexturePath, 312 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kRGBA_LockTexturePath,
307 kLockTexturePathCount); 313 kLockTexturePathCount);
308 return set_key_and_return(tex, key); 314 return set_key_and_return(tex, key);
309 } 315 }
310 } 316 }
311 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kFailure_LockTexturePath, 317 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kFailure_LockTexturePath,
312 kLockTexturePathCount); 318 kLockTexturePathCount);
313 return nullptr; 319 return nullptr;
314 } 320 }
(...skipping 10 matching lines...) Expand all
325 } 331 }
326 332
327 #else 333 #else
328 334
329 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam s&, 335 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam s&,
330 const SkImage* client, SkImage::Cach ingHint) { 336 const SkImage* client, SkImage::Cach ingHint) {
331 return nullptr; 337 return nullptr;
332 } 338 }
333 339
334 #endif 340 #endif
OLDNEW
« no previous file with comments | « src/core/SkImageCacherator.h ('k') | src/core/SkMipMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698