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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |