Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: src/gpu/SkGr.cpp

Issue 2029373004: respect srgb gamma when building mips (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Need to know when we're in L32 compatibility mode !!!? Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 if (texture) { 337 if (texture) {
338 return texture; 338 return texture;
339 } 339 }
340 } 340 }
341 341
342 sk_sp<GrTexture> texture(create_texture_from_yuv(ctx, bitmap, desc)); 342 sk_sp<GrTexture> texture(create_texture_from_yuv(ctx, bitmap, desc));
343 if (texture) { 343 if (texture) {
344 return texture.release(); 344 return texture.release();
345 } 345 }
346 346
347 // SkMipMap::Build doesn't handle sRGB data correctly (yet). 347 SkMipMap::SrcGammaMode mode = SkMipMap::kRespect_SrcGammaMode;
348 // Failover to the GL code-path for now. 348 if (/* we're in compatibility-mode-for-L32*/true) {
349 if (kLinear_SkColorProfileType != bitmap.profileType()) { 349 mode = SkMipMap::kIgnore_SrcGammaMode;
350 return nullptr;
351 } 350 }
352 351
353 SkASSERT(sizeof(int) <= sizeof(uint32_t)); 352 SkASSERT(sizeof(int) <= sizeof(uint32_t));
354 if (bitmap.width() < 0 || bitmap.height() < 0) { 353 if (bitmap.width() < 0 || bitmap.height() < 0) {
355 return nullptr; 354 return nullptr;
356 } 355 }
357 356
358 SkAutoPixmapUnlock srcUnlocker; 357 SkAutoPixmapUnlock srcUnlocker;
359 if (!bitmap.requestLock(&srcUnlocker)) { 358 if (!bitmap.requestLock(&srcUnlocker)) {
360 return nullptr; 359 return nullptr;
361 } 360 }
362 const SkPixmap& pixmap = srcUnlocker.pixmap(); 361 const SkPixmap& pixmap = srcUnlocker.pixmap();
363 // Try to catch where we might have returned nullptr for src crbug.com/49281 8 362 // Try to catch where we might have returned nullptr for src crbug.com/49281 8
364 if (nullptr == pixmap.addr()) { 363 if (nullptr == pixmap.addr()) {
365 sk_throw(); 364 sk_throw();
366 } 365 }
367 366
368 SkAutoTDelete<SkMipMap> mipmaps(SkMipMap::Build(pixmap, nullptr)); 367 SkAutoTDelete<SkMipMap> mipmaps(SkMipMap::Build(pixmap, mode, nullptr));
369 if (!mipmaps) { 368 if (!mipmaps) {
370 return nullptr; 369 return nullptr;
371 } 370 }
372 371
373 const int mipLevelCount = mipmaps->countLevels() + 1; 372 const int mipLevelCount = mipmaps->countLevels() + 1;
374 if (mipLevelCount < 1) { 373 if (mipLevelCount < 1) {
375 return nullptr; 374 return nullptr;
376 } 375 }
377 376
378 const bool isMipMapped = mipLevelCount > 1; 377 const bool isMipMapped = mipLevelCount > 1;
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 SkErrorInternals::SetError( kInvalidPaint_SkError, 758 SkErrorInternals::SetError( kInvalidPaint_SkError,
760 "Sorry, I don't understand the filtering " 759 "Sorry, I don't understand the filtering "
761 "mode you asked for. Falling back to " 760 "mode you asked for. Falling back to "
762 "MIPMaps."); 761 "MIPMaps.");
763 textureFilterMode = GrTextureParams::kMipMap_FilterMode; 762 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
764 break; 763 break;
765 764
766 } 765 }
767 return textureFilterMode; 766 return textureFilterMode;
768 } 767 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698