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

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: Refactoring the mipmap level count out. Cleaning includes. Created 4 years, 11 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
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 // 1. Check the cache for a pre-existing one 244 // 1. Check the cache for a pre-existing one
244 if (key.isValid()) { 245 if (key.isValid()) {
245 if (GrTexture* tex = ctx->textureProvider()->findAndRefTextureByUniqueKe y(key)) { 246 if (GrTexture* tex = ctx->textureProvider()->findAndRefTextureByUniqueKe y(key)) {
246 return tex; 247 return tex;
247 } 248 }
248 } 249 }
249 250
250 // 2. Ask the generator to natively create one 251 // 2. Ask the generator to natively create one
251 { 252 {
252 ScopedGenerator generator(this); 253 ScopedGenerator generator(this);
(...skipping 20 matching lines...) Expand all
273 Generator_GrYUVProvider provider(generator); 274 Generator_GrYUVProvider provider(generator);
274 GrTexture* tex = provider.refAsTexture(ctx, desc, true); 275 GrTexture* tex = provider.refAsTexture(ctx, desc, true);
275 if (tex) { 276 if (tex) {
276 return set_key_and_return(tex, key); 277 return set_key_and_return(tex, key);
277 } 278 }
278 } 279 }
279 280
280 // 5. Ask the generator to return RGB(A) data, which the GPU can convert 281 // 5. Ask the generator to return RGB(A) data, which the GPU can convert
281 SkBitmap bitmap; 282 SkBitmap bitmap;
282 if (this->tryLockAsBitmap(&bitmap, client, chint)) { 283 if (this->tryLockAsBitmap(&bitmap, client, chint)) {
283 GrTexture* tex = GrUploadBitmapToTexture(ctx, bitmap); 284 GrTexture* tex = nullptr;
285 if (willBeMipped) {
286 tex = GrGenerateMipMapsAndUploadToTexture(ctx, bitmap);
287 } else {
288 tex = GrUploadBitmapToTexture(ctx, bitmap);
289 }
284 if (tex) { 290 if (tex) {
285 return set_key_and_return(tex, key); 291 return set_key_and_return(tex, key);
286 } 292 }
287 } 293 }
288 return nullptr; 294 return nullptr;
289 } 295 }
290 296
291 //////////////////////////////////////////////////////////////////////////////// /////////////////// 297 //////////////////////////////////////////////////////////////////////////////// ///////////////////
292 298
293 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam s& params, 299 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam s& params,
294 const SkImage* client, SkImage::Cach ingHint chint) { 300 const SkImage* client, SkImage::Cach ingHint chint) {
295 if (!ctx) { 301 if (!ctx) {
296 return nullptr; 302 return nullptr;
297 } 303 }
298 304
299 return GrImageTextureMaker(ctx, this, client, chint).refTextureForParams(par ams); 305 return GrImageTextureMaker(ctx, this, client, chint).refTextureForParams(par ams);
300 } 306 }
301 307
302 #else 308 #else
303 309
304 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam s&, 310 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam s&,
305 const SkImage* client, SkImage::Cach ingHint) { 311 const SkImage* client, SkImage::Cach ingHint) {
306 return nullptr; 312 return nullptr;
307 } 313 }
308 314
309 #endif 315 #endif
OLDNEW
« no previous file with comments | « src/core/SkImageCacherator.h ('k') | src/core/SkMipMap.h » ('j') | src/core/SkMipMap.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698