OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 | 8 |
9 #include "SkGr.h" | 9 #include "SkGr.h" |
10 #include "SkGrPriv.h" | 10 #include "SkGrPriv.h" |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 if (texture) { | 338 if (texture) { |
339 return texture; | 339 return texture; |
340 } | 340 } |
341 } | 341 } |
342 | 342 |
343 sk_sp<GrTexture> texture(create_texture_from_yuv(ctx, bitmap, desc)); | 343 sk_sp<GrTexture> texture(create_texture_from_yuv(ctx, bitmap, desc)); |
344 if (texture) { | 344 if (texture) { |
345 return texture.release(); | 345 return texture.release(); |
346 } | 346 } |
347 | 347 |
348 // SkMipMap::Build doesn't handle sRGB data correctly (yet). | 348 /* |
349 // Failover to the GL code-path for now. | 349 * TODO: determine when we want respect -vs- (compatible) ignore |
Brian Osman
2016/06/07 16:10:30
gammaTreatment is now passed into this function, s
reed1
2016/06/07 19:43:37
Doh!
| |
350 if (kLinear_SkColorProfileType != bitmap.profileType()) { | 350 */ |
351 return nullptr; | 351 SkSourceGammaTreatment treatment = SkSourceGammaTreatment::kIgnore; |
352 } | |
353 | 352 |
354 SkASSERT(sizeof(int) <= sizeof(uint32_t)); | 353 SkASSERT(sizeof(int) <= sizeof(uint32_t)); |
355 if (bitmap.width() < 0 || bitmap.height() < 0) { | 354 if (bitmap.width() < 0 || bitmap.height() < 0) { |
356 return nullptr; | 355 return nullptr; |
357 } | 356 } |
358 | 357 |
359 SkAutoPixmapUnlock srcUnlocker; | 358 SkAutoPixmapUnlock srcUnlocker; |
360 if (!bitmap.requestLock(&srcUnlocker)) { | 359 if (!bitmap.requestLock(&srcUnlocker)) { |
361 return nullptr; | 360 return nullptr; |
362 } | 361 } |
363 const SkPixmap& pixmap = srcUnlocker.pixmap(); | 362 const SkPixmap& pixmap = srcUnlocker.pixmap(); |
364 // Try to catch where we might have returned nullptr for src crbug.com/49281 8 | 363 // Try to catch where we might have returned nullptr for src crbug.com/49281 8 |
365 if (nullptr == pixmap.addr()) { | 364 if (nullptr == pixmap.addr()) { |
366 sk_throw(); | 365 sk_throw(); |
367 } | 366 } |
368 | 367 |
369 SkAutoTDelete<SkMipMap> mipmaps(SkMipMap::Build(pixmap, nullptr)); | 368 SkAutoTDelete<SkMipMap> mipmaps(SkMipMap::Build(pixmap, treatment, nullptr)) ; |
370 if (!mipmaps) { | 369 if (!mipmaps) { |
371 return nullptr; | 370 return nullptr; |
372 } | 371 } |
373 | 372 |
374 const int mipLevelCount = mipmaps->countLevels() + 1; | 373 const int mipLevelCount = mipmaps->countLevels() + 1; |
375 if (mipLevelCount < 1) { | 374 if (mipLevelCount < 1) { |
376 return nullptr; | 375 return nullptr; |
377 } | 376 } |
378 | 377 |
379 const bool isMipMapped = mipLevelCount > 1; | 378 const bool isMipMapped = mipLevelCount > 1; |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
775 SkErrorInternals::SetError( kInvalidPaint_SkError, | 774 SkErrorInternals::SetError( kInvalidPaint_SkError, |
776 "Sorry, I don't understand the filtering " | 775 "Sorry, I don't understand the filtering " |
777 "mode you asked for. Falling back to " | 776 "mode you asked for. Falling back to " |
778 "MIPMaps."); | 777 "MIPMaps."); |
779 textureFilterMode = GrTextureParams::kMipMap_FilterMode; | 778 textureFilterMode = GrTextureParams::kMipMap_FilterMode; |
780 break; | 779 break; |
781 | 780 |
782 } | 781 } |
783 return textureFilterMode; | 782 return textureFilterMode; |
784 } | 783 } |
OLD | NEW |