| OLD | NEW |
| 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 * We have a 5 ways to try to return a texture (in sorted order) | 242 * We have a 5 ways to try to return a texture (in sorted order) |
| 243 * | 243 * |
| 244 * 1. Check the cache for a pre-existing one | 244 * 1. Check the cache for a pre-existing one |
| 245 * 2. Ask the generator to natively create one | 245 * 2. Ask the generator to natively create one |
| 246 * 3. Ask the generator to return a compressed form that the GPU might support | 246 * 3. Ask the generator to return a compressed form that the GPU might support |
| 247 * 4. Ask the generator to return YUV planes, which the GPU can convert | 247 * 4. Ask the generator to return YUV planes, which the GPU can convert |
| 248 * 5. Ask the generator to return RGB(A) data, which the GPU can convert | 248 * 5. Ask the generator to return RGB(A) data, which the GPU can convert |
| 249 */ | 249 */ |
| 250 GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& key
, | 250 GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& key
, |
| 251 const SkImage* client, SkImage::Cachin
gHint chint, | 251 const SkImage* client, SkImage::Cachin
gHint chint, |
| 252 bool willBeMipped) { | 252 bool willBeMipped, bool gammaCorrect)
{ |
| 253 // Values representing the various texture lock paths we can take. Used for
logging the path | 253 // Values representing the various texture lock paths we can take. Used for
logging the path |
| 254 // taken to a histogram. | 254 // taken to a histogram. |
| 255 enum LockTexturePath { | 255 enum LockTexturePath { |
| 256 kFailure_LockTexturePath, | 256 kFailure_LockTexturePath, |
| 257 kPreExisting_LockTexturePath, | 257 kPreExisting_LockTexturePath, |
| 258 kNative_LockTexturePath, | 258 kNative_LockTexturePath, |
| 259 kCompressed_LockTexturePath, | 259 kCompressed_LockTexturePath, |
| 260 kYUV_LockTexturePath, | 260 kYUV_LockTexturePath, |
| 261 kRGBA_LockTexturePath, | 261 kRGBA_LockTexturePath, |
| 262 }; | 262 }; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 kLockTexturePathCount); | 308 kLockTexturePathCount); |
| 309 return set_key_and_return(tex.release(), key); | 309 return set_key_and_return(tex.release(), key); |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 | 312 |
| 313 // 5. Ask the generator to return RGB(A) data, which the GPU can convert | 313 // 5. Ask the generator to return RGB(A) data, which the GPU can convert |
| 314 SkBitmap bitmap; | 314 SkBitmap bitmap; |
| 315 if (this->tryLockAsBitmap(&bitmap, client, chint)) { | 315 if (this->tryLockAsBitmap(&bitmap, client, chint)) { |
| 316 GrTexture* tex = nullptr; | 316 GrTexture* tex = nullptr; |
| 317 if (willBeMipped) { | 317 if (willBeMipped) { |
| 318 tex = GrGenerateMipMapsAndUploadToTexture(ctx, bitmap); | 318 tex = GrGenerateMipMapsAndUploadToTexture(ctx, bitmap, gammaCorrect)
; |
| 319 } | 319 } |
| 320 if (!tex) { | 320 if (!tex) { |
| 321 tex = GrUploadBitmapToTexture(ctx, bitmap); | 321 tex = GrUploadBitmapToTexture(ctx, bitmap); |
| 322 } | 322 } |
| 323 if (tex) { | 323 if (tex) { |
| 324 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kRGBA_LockTexturePath, | 324 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kRGBA_LockTexturePath, |
| 325 kLockTexturePathCount); | 325 kLockTexturePathCount); |
| 326 return set_key_and_return(tex, key); | 326 return set_key_and_return(tex, key); |
| 327 } | 327 } |
| 328 } | 328 } |
| 329 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kFailure_LockTexturePath, | 329 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kFailure_LockTexturePath, |
| 330 kLockTexturePathCount); | 330 kLockTexturePathCount); |
| 331 return nullptr; | 331 return nullptr; |
| 332 } | 332 } |
| 333 | 333 |
| 334 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 334 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 335 | 335 |
| 336 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam
s& params, | 336 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam
s& params, |
| 337 const SkImage* client, SkImage::Cach
ingHint chint) { | 337 bool gammaCorrect, const SkImage* cl
ient, |
| 338 SkImage::CachingHint chint) { |
| 338 if (!ctx) { | 339 if (!ctx) { |
| 339 return nullptr; | 340 return nullptr; |
| 340 } | 341 } |
| 341 | 342 |
| 342 return GrImageTextureMaker(ctx, this, client, chint).refTextureForParams(par
ams); | 343 return GrImageTextureMaker(ctx, this, client, chint).refTextureForParams(par
ams, gammaCorrect); |
| 343 } | 344 } |
| 344 | 345 |
| 345 #else | 346 #else |
| 346 | 347 |
| 347 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam
s&, | 348 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam
s&, |
| 348 const SkImage* client, SkImage::Cach
ingHint) { | 349 bool gammaCorrect, const SkImage* cl
ient, |
| 350 SkImage::CachingHint) { |
| 349 return nullptr; | 351 return nullptr; |
| 350 } | 352 } |
| 351 | 353 |
| 352 #endif | 354 #endif |
| OLD | NEW |