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, |
| 253 SkSourceGammaTreatment gammaTreatment)
{ |
253 // Values representing the various texture lock paths we can take. Used for
logging the path | 254 // Values representing the various texture lock paths we can take. Used for
logging the path |
254 // taken to a histogram. | 255 // taken to a histogram. |
255 enum LockTexturePath { | 256 enum LockTexturePath { |
256 kFailure_LockTexturePath, | 257 kFailure_LockTexturePath, |
257 kPreExisting_LockTexturePath, | 258 kPreExisting_LockTexturePath, |
258 kNative_LockTexturePath, | 259 kNative_LockTexturePath, |
259 kCompressed_LockTexturePath, | 260 kCompressed_LockTexturePath, |
260 kYUV_LockTexturePath, | 261 kYUV_LockTexturePath, |
261 kRGBA_LockTexturePath, | 262 kRGBA_LockTexturePath, |
262 }; | 263 }; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 kLockTexturePathCount); | 309 kLockTexturePathCount); |
309 return set_key_and_return(tex.release(), key); | 310 return set_key_and_return(tex.release(), key); |
310 } | 311 } |
311 } | 312 } |
312 | 313 |
313 // 5. Ask the generator to return RGB(A) data, which the GPU can convert | 314 // 5. Ask the generator to return RGB(A) data, which the GPU can convert |
314 SkBitmap bitmap; | 315 SkBitmap bitmap; |
315 if (this->tryLockAsBitmap(&bitmap, client, chint)) { | 316 if (this->tryLockAsBitmap(&bitmap, client, chint)) { |
316 GrTexture* tex = nullptr; | 317 GrTexture* tex = nullptr; |
317 if (willBeMipped) { | 318 if (willBeMipped) { |
318 tex = GrGenerateMipMapsAndUploadToTexture(ctx, bitmap); | 319 tex = GrGenerateMipMapsAndUploadToTexture(ctx, bitmap, gammaTreatmen
t); |
319 } | 320 } |
320 if (!tex) { | 321 if (!tex) { |
321 tex = GrUploadBitmapToTexture(ctx, bitmap); | 322 tex = GrUploadBitmapToTexture(ctx, bitmap); |
322 } | 323 } |
323 if (tex) { | 324 if (tex) { |
324 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kRGBA_LockTexturePath, | 325 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kRGBA_LockTexturePath, |
325 kLockTexturePathCount); | 326 kLockTexturePathCount); |
326 return set_key_and_return(tex, key); | 327 return set_key_and_return(tex, key); |
327 } | 328 } |
328 } | 329 } |
329 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kFailure_LockTexturePath, | 330 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kFailure_LockTexturePath, |
330 kLockTexturePathCount); | 331 kLockTexturePathCount); |
331 return nullptr; | 332 return nullptr; |
332 } | 333 } |
333 | 334 |
334 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 335 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
335 | 336 |
336 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam
s& params, | 337 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam
s& params, |
| 338 SkSourceGammaTreatment gammaTreatmen
t, |
337 const SkImage* client, SkImage::Cach
ingHint chint) { | 339 const SkImage* client, SkImage::Cach
ingHint chint) { |
338 if (!ctx) { | 340 if (!ctx) { |
339 return nullptr; | 341 return nullptr; |
340 } | 342 } |
341 | 343 |
342 return GrImageTextureMaker(ctx, this, client, chint).refTextureForParams(par
ams); | 344 return GrImageTextureMaker(ctx, this, client, chint).refTextureForParams(par
ams, |
| 345 gam
maTreatment); |
343 } | 346 } |
344 | 347 |
345 #else | 348 #else |
346 | 349 |
347 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam
s&, | 350 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam
s&, |
| 351 SkSourceGammaTreatment gammaTreatmen
t, |
348 const SkImage* client, SkImage::Cach
ingHint) { | 352 const SkImage* client, SkImage::Cach
ingHint) { |
349 return nullptr; | 353 return nullptr; |
350 } | 354 } |
351 | 355 |
352 #endif | 356 #endif |
OLD | NEW |