| 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). | |
| 349 // Failover to the GL code-path for now. | |
| 350 if (kLinear_SkColorProfileType != bitmap.profileType()) { | |
| 351 return nullptr; | |
| 352 } | |
| 353 | |
| 354 SkASSERT(sizeof(int) <= sizeof(uint32_t)); | 348 SkASSERT(sizeof(int) <= sizeof(uint32_t)); |
| 355 if (bitmap.width() < 0 || bitmap.height() < 0) { | 349 if (bitmap.width() < 0 || bitmap.height() < 0) { |
| 356 return nullptr; | 350 return nullptr; |
| 357 } | 351 } |
| 358 | 352 |
| 359 SkAutoPixmapUnlock srcUnlocker; | 353 SkAutoPixmapUnlock srcUnlocker; |
| 360 if (!bitmap.requestLock(&srcUnlocker)) { | 354 if (!bitmap.requestLock(&srcUnlocker)) { |
| 361 return nullptr; | 355 return nullptr; |
| 362 } | 356 } |
| 363 const SkPixmap& pixmap = srcUnlocker.pixmap(); | 357 const SkPixmap& pixmap = srcUnlocker.pixmap(); |
| 364 // Try to catch where we might have returned nullptr for src crbug.com/49281
8 | 358 // Try to catch where we might have returned nullptr for src crbug.com/49281
8 |
| 365 if (nullptr == pixmap.addr()) { | 359 if (nullptr == pixmap.addr()) { |
| 366 sk_throw(); | 360 sk_throw(); |
| 367 } | 361 } |
| 368 | 362 |
| 369 SkAutoTDelete<SkMipMap> mipmaps(SkMipMap::Build(pixmap, nullptr)); | 363 SkAutoTDelete<SkMipMap> mipmaps(SkMipMap::Build(pixmap, gammaTreatment, null
ptr)); |
| 370 if (!mipmaps) { | 364 if (!mipmaps) { |
| 371 return nullptr; | 365 return nullptr; |
| 372 } | 366 } |
| 373 | 367 |
| 374 const int mipLevelCount = mipmaps->countLevels() + 1; | 368 const int mipLevelCount = mipmaps->countLevels() + 1; |
| 375 if (mipLevelCount < 1) { | 369 if (mipLevelCount < 1) { |
| 376 return nullptr; | 370 return nullptr; |
| 377 } | 371 } |
| 378 | 372 |
| 379 const bool isMipMapped = mipLevelCount > 1; | 373 const bool isMipMapped = mipLevelCount > 1; |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 SkErrorInternals::SetError( kInvalidPaint_SkError, | 761 SkErrorInternals::SetError( kInvalidPaint_SkError, |
| 768 "Sorry, I don't understand the filtering
" | 762 "Sorry, I don't understand the filtering
" |
| 769 "mode you asked for. Falling back to " | 763 "mode you asked for. Falling back to " |
| 770 "MIPMaps."); | 764 "MIPMaps."); |
| 771 textureFilterMode = GrTextureParams::kMipMap_FilterMode; | 765 textureFilterMode = GrTextureParams::kMipMap_FilterMode; |
| 772 break; | 766 break; |
| 773 | 767 |
| 774 } | 768 } |
| 775 return textureFilterMode; | 769 return textureFilterMode; |
| 776 } | 770 } |
| OLD | NEW |