Chromium Code Reviews| 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; |
| 380 desc.fIsMipMapped = isMipMapped; | 374 desc.fIsMipMapped = isMipMapped; |
| 381 | 375 |
| 382 SkAutoTDeleteArray<GrMipLevel> texels(new GrMipLevel[mipLevelCount]); | 376 SkAutoTDeleteArray<GrMipLevel> texels(new GrMipLevel[mipLevelCount]); |
| 383 | 377 |
| 384 texels[0].fPixels = pixmap.addr(); | 378 texels[0].fPixels = pixmap.addr(); |
| 385 texels[0].fRowBytes = pixmap.rowBytes(); | 379 texels[0].fRowBytes = pixmap.rowBytes(); |
| 386 | 380 |
| 387 for (int i = 1; i < mipLevelCount; ++i) { | 381 for (int i = 1; i < mipLevelCount; ++i) { |
| 388 SkMipMap::Level generatedMipLevel; | 382 SkMipMap::Level generatedMipLevel; |
| 389 mipmaps->getLevel(i - 1, &generatedMipLevel); | 383 mipmaps->getLevel(i - 1, &generatedMipLevel); |
| 390 texels[i].fPixels = generatedMipLevel.fPixmap.addr(); | 384 texels[i].fPixels = generatedMipLevel.fPixmap.addr(); |
| 391 texels[i].fRowBytes = generatedMipLevel.fPixmap.rowBytes(); | 385 texels[i].fRowBytes = generatedMipLevel.fPixmap.rowBytes(); |
| 392 } | 386 } |
| 393 | 387 |
| 394 return ctx->textureProvider()->createMipMappedTexture(desc, SkBudgeted::kYes , texels.get(), | 388 return ctx->textureProvider()->createMipMappedTexture(desc, SkBudgeted::kYes , texels.get(), |
|
Brian Osman
2016/06/10 13:37:14
Ganesh is going to think the mips are not gamma-co
reed1
2016/06/10 14:26:04
Acknowledged.
| |
| 395 mipLevelCount); | 389 mipLevelCount); |
| 396 } | 390 } |
| 397 | 391 |
| 398 GrTexture* GrUploadMipMapToTexture(GrContext* ctx, const SkImageInfo& info, | 392 GrTexture* GrUploadMipMapToTexture(GrContext* ctx, const SkImageInfo& info, |
| 399 const GrMipLevel* texels, int mipLevelCount) { | 393 const GrMipLevel* texels, int mipLevelCount) { |
| 400 const GrCaps* caps = ctx->caps(); | 394 const GrCaps* caps = ctx->caps(); |
| 401 return ctx->textureProvider()->createMipMappedTexture(GrImageInfoToSurfaceDe sc(info, *caps), | 395 return ctx->textureProvider()->createMipMappedTexture(GrImageInfoToSurfaceDe sc(info, *caps), |
| 402 SkBudgeted::kYes, texe ls, | 396 SkBudgeted::kYes, texe ls, |
| 403 mipLevelCount); | 397 mipLevelCount); |
| 404 } | 398 } |
| (...skipping 362 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 |