From 2b23c4bf3186bf3fa71bb105afdcf3b8e5995b52 Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Fri, 1 Jun 2018 12:25:08 -0400 Subject: Dest color space no longer impacts mipmaps or texture sampling PS5: Removes SkDestinationSurfaceColorMode, tracking of mipmap mode on GrTexture, sRGB decode state per-texture. Because we were often choosing sRGB configs for RGB color types, legacy rendering would then be incorrect (too dark). So... PS7: Stops ever using sRGB pixel configs when translating image info or color type. Also removes a bunch of GrCaps bits and a GrContextOption that are no longer relevant. PS9: Adjusts surface creation unit test expectations, and changes the raster rules accordingly. At this point, sRGB configs are (obviously) going to be broken. Locally, I ran 8888, gl, and the gbr- versions of both. Across all GMs x configs, there are 13 diffs. 12 are GMs that create surfaces with a color-space attached (and thus, the offscreen is no longer getting sRGB pixel config). The only remainder constructs an SkPictureImageGenerator, (with an attached color space) and renders it to the gbr-gl canvas, which triggers a a tagged surface inside the generator. Bug: skia: Change-Id: Ie5edfa157dd799f3121e8173fc4f97f6c8ed6789 Reviewed-on: https://skia-review.googlesource.com/131282 Commit-Queue: Brian Osman Reviewed-by: Mike Klein Reviewed-by: Brian Salomon --- bench/MipMapBench.cpp | 43 +++---- bench/nanobench.cpp | 3 +- dm/DMSrcSink.cpp | 3 +- gm/showmiplevels.cpp | 6 +- gm/texturedomaineffect.cpp | 2 +- gm/yuvtorgbeffect.cpp | 6 +- gn/tests.gni | 1 - include/gpu/GrContextOptions.h | 8 -- include/gpu/GrTexture.h | 2 - include/gpu/vk/GrVkTypes.h | 4 - include/private/SkImageInfoPriv.h | 14 +-- src/core/SkBitmapCache.cpp | 23 ++-- src/core/SkBitmapCache.h | 5 +- src/core/SkBitmapController.cpp | 7 +- src/core/SkBitmapProvider.cpp | 2 +- src/core/SkBitmapProvider.h | 12 +- src/core/SkMipMap.cpp | 11 +- src/core/SkMipMap.h | 12 +- src/effects/SkTableColorFilter.cpp | 2 +- src/gpu/GrBitmapTextureMaker.cpp | 4 +- src/gpu/GrCaps.cpp | 2 - src/gpu/GrCaps.h | 2 - src/gpu/GrContext.cpp | 7 +- src/gpu/GrGpu.h | 3 +- src/gpu/GrPaint.cpp | 1 - src/gpu/GrPaint.h | 11 +- src/gpu/GrPipeline.h | 11 -- src/gpu/GrProxyProvider.cpp | 20 ++-- src/gpu/GrProxyProvider.h | 3 +- src/gpu/GrRenderTargetContext.cpp | 3 +- src/gpu/GrResourceProvider.cpp | 10 +- src/gpu/GrResourceProvider.h | 2 +- src/gpu/GrSurfaceProxy.cpp | 3 +- src/gpu/GrTexture.cpp | 4 +- src/gpu/GrTexturePriv.h | 5 - src/gpu/SkGpuDevice.cpp | 2 +- src/gpu/SkGr.cpp | 30 ++--- src/gpu/SkGr.h | 9 +- src/gpu/gl/GrGLCaps.cpp | 14 +-- src/gpu/gl/GrGLCaps.h | 3 - src/gpu/gl/GrGLGpu.cpp | 71 ++--------- src/gpu/gl/GrGLGpu.h | 8 +- src/gpu/gl/GrGLProgram.cpp | 19 ++- src/gpu/gl/GrGLProgram.h | 5 +- src/gpu/gl/GrGLTexture.h | 1 - src/gpu/ops/GrDashOp.cpp | 5 - src/gpu/ops/GrTextureOp.cpp | 24 ++-- src/gpu/ops/GrTextureOp.h | 2 +- src/gpu/text/GrAtlasManager.cpp | 6 +- src/gpu/vk/GrVkCaps.cpp | 5 +- src/gpu/vk/GrVkCopyManager.cpp | 4 +- src/gpu/vk/GrVkGpu.cpp | 6 +- src/gpu/vk/GrVkImage.cpp | 6 +- src/gpu/vk/GrVkPipelineState.cpp | 7 +- src/gpu/vk/GrVkPipelineState.h | 3 +- src/gpu/vk/GrVkTexture.cpp | 40 +------ src/gpu/vk/GrVkTexture.h | 3 +- src/gpu/vk/GrVkUtil.cpp | 99 --------------- src/gpu/vk/GrVkUtil.h | 6 - src/image/SkImage_Gpu.cpp | 8 +- src/image/SkImage_Lazy.cpp | 6 +- src/image/SkSurface_Gpu.cpp | 14 +-- src/image/SkSurface_Raster.cpp | 3 - src/shaders/SkImageShader.cpp | 5 +- src/shaders/gradients/SkGradientShader.cpp | 2 +- tests/GLProgramsTest.cpp | 3 - tests/GrContextFactoryTest.cpp | 22 ---- tests/ImageTest.cpp | 2 +- tests/MipMapTest.cpp | 6 +- tests/OnFlushCallbackTest.cpp | 2 +- tests/ProxyTest.cpp | 8 +- tests/SRGBMipMapTest.cpp | 186 ----------------------------- tests/SkResourceCacheTest.cpp | 19 ++- tests/SpecialImageTest.cpp | 5 +- tests/SurfaceTest.cpp | 14 +-- tools/DDLPromiseImageHelper.cpp | 1 - tools/fiddle/fiddle_main.cpp | 12 +- tools/flags/SkCommonFlagsConfig.cpp | 11 -- tools/gpu/GrContextFactory.cpp | 8 -- tools/gpu/GrContextFactory.h | 6 +- tools/gpu/GrTest.cpp | 5 +- tools/sk_app/VulkanWindowContext.cpp | 5 +- tools/skpbench/skpbench.cpp | 3 +- 83 files changed, 182 insertions(+), 809 deletions(-) delete mode 100644 tests/SRGBMipMapTest.cpp diff --git a/bench/MipMapBench.cpp b/bench/MipMapBench.cpp index 9b6fc27cfb..e41d39b928 100644 --- a/bench/MipMapBench.cpp +++ b/bench/MipMapBench.cpp @@ -13,14 +13,13 @@ class MipMapBench: public Benchmark { SkBitmap fBitmap; SkString fName; const int fW, fH; - SkDestinationSurfaceColorMode fColorMode; bool fHalfFoat; public: - MipMapBench(int w, int h, SkDestinationSurfaceColorMode colorMode, bool halfFloat = false) - : fW(w), fH(h), fColorMode(colorMode), fHalfFoat(halfFloat) + MipMapBench(int w, int h, bool halfFloat = false) + : fW(w), fH(h), fHalfFoat(halfFloat) { - fName.printf("mipmap_build_%dx%d_%d_gamma", w, h, static_cast(colorMode)); + fName.printf("mipmap_build_%dx%d", w, h); if (halfFloat) { fName.append("_f16"); } @@ -44,7 +43,7 @@ protected: void onDraw(int loops, SkCanvas*) override { for (int i = 0; i < loops * 4; i++) { - SkMipMap::Build(fBitmap, fColorMode, nullptr)->unref(); + SkMipMap::Build(fBitmap, nullptr)->unref(); } } @@ -55,25 +54,15 @@ private: // Build variants that exercise the width and heights being even or odd at each level, as the // impl specializes on each of these. // -DEF_BENCH( return new MipMapBench(511, 511, SkDestinationSurfaceColorMode::kLegacy); ) -DEF_BENCH( return new MipMapBench(512, 511, SkDestinationSurfaceColorMode::kLegacy); ) -DEF_BENCH( return new MipMapBench(511, 512, SkDestinationSurfaceColorMode::kLegacy); ) -DEF_BENCH( return new MipMapBench(512, 512, SkDestinationSurfaceColorMode::kLegacy); ) -DEF_BENCH( return new MipMapBench(512, 512, - SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware); ) -DEF_BENCH( return new MipMapBench(511, 511, - SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware); ) -DEF_BENCH( return new MipMapBench(512, 512, SkDestinationSurfaceColorMode::kLegacy, true); ) -DEF_BENCH( return new MipMapBench(511, 511, SkDestinationSurfaceColorMode::kLegacy, true); ) -DEF_BENCH( return new MipMapBench(2048, 2048, SkDestinationSurfaceColorMode::kLegacy); ) -DEF_BENCH( return new MipMapBench(2048, 2048, - SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware); ) -DEF_BENCH( return new MipMapBench(2047, 2047, SkDestinationSurfaceColorMode::kLegacy); ) -DEF_BENCH( return new MipMapBench(2047, 2047, - SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware); ) -DEF_BENCH( return new MipMapBench(2048, 2047, SkDestinationSurfaceColorMode::kLegacy); ) -DEF_BENCH( return new MipMapBench(2048, 2047, - SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware); ) -DEF_BENCH( return new MipMapBench(2047, 2048, SkDestinationSurfaceColorMode::kLegacy); ) -DEF_BENCH( return new MipMapBench(2047, 2048, - SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware); ) +DEF_BENCH( return new MipMapBench(511, 511); ) +DEF_BENCH( return new MipMapBench(512, 511); ) +DEF_BENCH( return new MipMapBench(511, 512); ) +DEF_BENCH( return new MipMapBench(512, 512); ) + +DEF_BENCH( return new MipMapBench(512, 512, true); ) +DEF_BENCH( return new MipMapBench(511, 511, true); ) + +DEF_BENCH( return new MipMapBench(2048, 2048); ) +DEF_BENCH( return new MipMapBench(2047, 2047); ) +DEF_BENCH( return new MipMapBench(2048, 2047); ) +DEF_BENCH( return new MipMapBench(2047, 2048); ) diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp index 0376bdbec3..4d2773e605 100644 --- a/bench/nanobench.cpp +++ b/bench/nanobench.cpp @@ -424,8 +424,7 @@ static void create_config(const SkCommandLineConfig* config, SkTArray* c GrContextFactory factory(grContextOpts); if (const GrContext* ctx = factory.get(ctxType, ctxOverrides)) { - GrPixelConfig grPixConfig = - SkImageInfo2GrPixelConfig(colorType, colorSpace, *ctx->contextPriv().caps()); + GrPixelConfig grPixConfig = SkColorType2GrPixelConfig(colorType); int supportedSampleCount = ctx->contextPriv().caps()->getRenderTargetSampleCount(sampleCount, grPixConfig); if (sampleCount != supportedSampleCount) { diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 5b93de3ed9..baa98a0784 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -1514,8 +1514,7 @@ Error GPUSink::onDraw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log, break; case SkCommandLineConfigGpu::SurfType::kBackendTexture: backendTexture = context->contextPriv().getGpu()->createTestingOnlyBackendTexture( - nullptr, info.width(), info.height(), info.colorType(), info.colorSpace(), - true, GrMipMapped::kNo); + nullptr, info.width(), info.height(), info.colorType(), true, GrMipMapped::kNo); surface = SkSurface::MakeFromBackendTexture(context, backendTexture, kTopLeft_GrSurfaceOrigin, fSampleCount, fColorType, info.refColorSpace(), &props); diff --git a/gm/showmiplevels.cpp b/gm/showmiplevels.cpp index 6f0975da7e..4a3a83615c 100644 --- a/gm/showmiplevels.cpp +++ b/gm/showmiplevels.cpp @@ -135,8 +135,7 @@ protected: SkPixmap prevPM; baseBM.peekPixels(&prevPM); - SkDestinationSurfaceColorMode colorMode = SkDestinationSurfaceColorMode::kLegacy; - sk_sp mm(SkMipMap::Build(baseBM, colorMode, nullptr)); + sk_sp mm(SkMipMap::Build(baseBM, nullptr)); int index = 0; SkMipMap::Level level; @@ -244,8 +243,7 @@ protected: SkScalar x = 4; SkScalar y = 4; - SkDestinationSurfaceColorMode colorMode = SkDestinationSurfaceColorMode::kLegacy; - sk_sp mm(SkMipMap::Build(baseBM, colorMode, nullptr)); + sk_sp mm(SkMipMap::Build(baseBM, nullptr)); int index = 0; SkMipMap::Level level; diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp index e314668d00..63e01111f4 100644 --- a/gm/texturedomaineffect.cpp +++ b/gm/texturedomaineffect.cpp @@ -89,7 +89,7 @@ protected: GrSurfaceDesc desc; desc.fWidth = fBmp.width(); desc.fHeight = fBmp.height(); - desc.fConfig = SkImageInfo2GrPixelConfig(fBmp.info(), *context->contextPriv().caps()); + desc.fConfig = SkColorType2GrPixelConfig(fBmp.colorType()); SkASSERT(kUnknown_GrPixelConfig != desc.fConfig); sk_sp proxy = proxyProvider->createTextureProxy( diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp index 5efbc3ad4f..7b7846d6eb 100644 --- a/gm/yuvtorgbeffect.cpp +++ b/gm/yuvtorgbeffect.cpp @@ -88,8 +88,7 @@ protected: GrSurfaceDesc desc; desc.fWidth = fBmp[i].width(); desc.fHeight = fBmp[i].height(); - desc.fConfig = - SkImageInfo2GrPixelConfig(fBmp[i].info(), *context->contextPriv().caps()); + desc.fConfig = SkColorType2GrPixelConfig(fBmp[i].colorType()); SkASSERT(kUnknown_GrPixelConfig != desc.fConfig); proxy[i] = proxyProvider->createTextureProxy(desc, SkBudgeted::kYes, @@ -215,8 +214,7 @@ protected: GrSurfaceDesc desc; desc.fWidth = fBmp[index].width(); desc.fHeight = fBmp[index].height(); - desc.fConfig = - SkImageInfo2GrPixelConfig(fBmp[index].info(), *context->contextPriv().caps()); + desc.fConfig = SkColorType2GrPixelConfig(fBmp[index].colorType()); SkASSERT(kUnknown_GrPixelConfig != desc.fConfig); proxy[i] = proxyProvider->createTextureProxy( diff --git a/gn/tests.gni b/gn/tests.gni index 5b4594099b..a67b4f4e34 100644 --- a/gn/tests.gni +++ b/gn/tests.gni @@ -236,7 +236,6 @@ tests_sources = [ "$_tests/SpecialImageTest.cpp", "$_tests/SpecialSurfaceTest.cpp", "$_tests/SrcOverTest.cpp", - "$_tests/SRGBMipMapTest.cpp", "$_tests/SRGBReadWritePixelsTest.cpp", "$_tests/SRGBTest.cpp", "$_tests/StreamBufferTest.cpp", diff --git a/include/gpu/GrContextOptions.h b/include/gpu/GrContextOptions.h index eea7771075..2d3151db67 100644 --- a/include/gpu/GrContextOptions.h +++ b/include/gpu/GrContextOptions.h @@ -89,14 +89,6 @@ struct GrContextOptions { */ bool fAllowPathMaskCaching = true; - /** - * If true, sRGB support will not be enabled unless sRGB decoding can be disabled (via an - * extension). If mixed use of "legacy" mode and sRGB/color-correct mode is not required, this - * can be set to false, which will significantly expand the number of devices that qualify for - * sRGB support. - */ - bool fRequireDecodeDisableForSRGB = true; - /** * If true, the GPU will not be used to perform YUV -> RGB conversion when generating * textures from codec-backed images. diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h index 1f75c1f9be..215cda1e94 100644 --- a/include/gpu/GrTexture.h +++ b/include/gpu/GrTexture.h @@ -18,7 +18,6 @@ #include "../private/GrTypesPriv.h" class GrTexturePriv; -enum class SkDestinationSurfaceColorMode; class GrTexture : virtual public GrSurface { public: @@ -81,7 +80,6 @@ private: GrSamplerState::Filter fHighestFilterMode; GrMipMapsStatus fMipMapsStatus; int fMaxMipMapLevel; - SkDestinationSurfaceColorMode fMipColorMode; friend class GrTexturePriv; typedef GrSurface INHERITED; diff --git a/include/gpu/vk/GrVkTypes.h b/include/gpu/vk/GrVkTypes.h index 9225e92778..d734c2bc23 100644 --- a/include/gpu/vk/GrVkTypes.h +++ b/include/gpu/vk/GrVkTypes.h @@ -71,10 +71,6 @@ private: bool fUsesSystemHeap; }; struct GrVkImageInfo { - /** - * If the image's format is sRGB (GrVkFormatIsSRGB returns true), then the image must have - * been created with VkImageCreateFlags containing VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT. - */ VkImage fImage; GrVkAlloc fAlloc; VkImageTiling fImageTiling; diff --git a/include/private/SkImageInfoPriv.h b/include/private/SkImageInfoPriv.h index aac1750708..56ed16fb9d 100644 --- a/include/private/SkImageInfoPriv.h +++ b/include/private/SkImageInfoPriv.h @@ -10,11 +10,6 @@ #include "SkImageInfo.h" -enum class SkDestinationSurfaceColorMode { - kLegacy, - kGammaAndColorSpaceAware, -}; - enum SkColorTypeComponentFlag { kRed_SkColorTypeComponentFlag = 0x1, kGreen_SkColorTypeComponentFlag = 0x2, @@ -154,14 +149,9 @@ static inline bool SkImageInfoIsValidRenderingCS(const SkImageInfo& info) { /** * Returns true if |info| contains a valid combination of width, height, colorType, alphaType, - * colorSpace. Uses |colorMode| to decide how to treat color spaces. + * colorSpace. */ -static inline bool SkImageInfoIsValid(const SkImageInfo& info, - SkDestinationSurfaceColorMode colorMode) { - if (SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware == colorMode) { - return SkImageInfoIsValidRenderingCS(info); - } - +static inline bool SkImageInfoIsValid(const SkImageInfo& info) { return SkImageInfoIsValidAllowNumericalCS(info); } diff --git a/src/core/SkBitmapCache.cpp b/src/core/SkBitmapCache.cpp index cb88070ba4..3b85657b1b 100644 --- a/src/core/SkBitmapCache.cpp +++ b/src/core/SkBitmapCache.cpp @@ -330,26 +330,23 @@ static unsigned gMipMapKeyNamespaceLabel; struct MipMapKey : public SkResourceCache::Key { public: - MipMapKey(uint32_t imageID, const SkIRect& subset, SkDestinationSurfaceColorMode colorMode) + MipMapKey(uint32_t imageID, const SkIRect& subset) : fImageID(imageID) - , fColorMode(static_cast(colorMode)) , fSubset(subset) { SkASSERT(fImageID); SkASSERT(!subset.isEmpty()); this->init(&gMipMapKeyNamespaceLabel, SkMakeResourceCacheSharedIDForBitmap(fImageID), - sizeof(fImageID) + sizeof(fColorMode) + sizeof(fSubset)); + sizeof(fImageID) + sizeof(fSubset)); } uint32_t fImageID; - uint32_t fColorMode; SkIRect fSubset; }; struct MipMapRec : public SkResourceCache::Rec { - MipMapRec(uint32_t imageID, const SkIRect& subset, SkDestinationSurfaceColorMode colorMode, - const SkMipMap* result) - : fKey(imageID, subset, colorMode) + MipMapRec(uint32_t imageID, const SkIRect& subset, const SkMipMap* result) + : fKey(imageID, subset) , fMipMap(result) { fMipMap->attachToCacheAndRef(); @@ -387,11 +384,10 @@ private: } const SkMipMap* SkMipMapCache::FindAndRef(const SkBitmapCacheDesc& desc, - SkDestinationSurfaceColorMode colorMode, SkResourceCache* localCache) { SkASSERT(desc.fScaledWidth == 0); SkASSERT(desc.fScaledHeight == 0); - MipMapKey key(desc.fImageID, desc.fSubset, colorMode); + MipMapKey key(desc.fImageID, desc.fSubset); const SkMipMap* result; if (!CHECK_LOCAL(localCache, find, Find, key, MipMapRec::Finder, &result)) { @@ -405,13 +401,10 @@ static SkResourceCache::DiscardableFactory get_fact(SkResourceCache* localCache) : SkResourceCache::GetDiscardableFactory(); } -const SkMipMap* SkMipMapCache::AddAndRef(const SkBitmap& src, - SkDestinationSurfaceColorMode colorMode, - SkResourceCache* localCache) { - SkMipMap* mipmap = SkMipMap::Build(src, colorMode, get_fact(localCache)); +const SkMipMap* SkMipMapCache::AddAndRef(const SkBitmap& src, SkResourceCache* localCache) { + SkMipMap* mipmap = SkMipMap::Build(src, get_fact(localCache)); if (mipmap) { - MipMapRec* rec = new MipMapRec(src.getGenerationID(), get_bounds_from_bitmap(src), - colorMode, mipmap); + MipMapRec* rec = new MipMapRec(src.getGenerationID(), get_bounds_from_bitmap(src), mipmap); CHECK_LOCAL(localCache, add, Add, rec); src.pixelRef()->notifyAddedToCache(); } diff --git a/src/core/SkBitmapCache.h b/src/core/SkBitmapCache.h index a59dcb5a12..86382614d3 100644 --- a/src/core/SkBitmapCache.h +++ b/src/core/SkBitmapCache.h @@ -64,10 +64,9 @@ private: class SkMipMapCache { public: // Note: the scaled width/height in desc must be 0, as any other value would not make sense. - static const SkMipMap* FindAndRef(const SkBitmapCacheDesc&, SkDestinationSurfaceColorMode, + static const SkMipMap* FindAndRef(const SkBitmapCacheDesc&, SkResourceCache* localCache = nullptr); - static const SkMipMap* AddAndRef(const SkBitmap& src, SkDestinationSurfaceColorMode, - SkResourceCache* localCache = nullptr); + static const SkMipMap* AddAndRef(const SkBitmap& src, SkResourceCache* localCache = nullptr); }; #endif diff --git a/src/core/SkBitmapController.cpp b/src/core/SkBitmapController.cpp index 91fdc6fa41..005c5a559f 100644 --- a/src/core/SkBitmapController.cpp +++ b/src/core/SkBitmapController.cpp @@ -93,17 +93,14 @@ bool SkDefaultBitmapControllerState::processMediumRequest(const SkBitmapProvider return false; } - SkDestinationSurfaceColorMode colorMode = provider.dstColorSpace() - ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware - : SkDestinationSurfaceColorMode::kLegacy; if (invScaleSize.width() > SK_Scalar1 || invScaleSize.height() > SK_Scalar1) { - fCurrMip.reset(SkMipMapCache::FindAndRef(provider.makeCacheDesc(), colorMode)); + fCurrMip.reset(SkMipMapCache::FindAndRef(provider.makeCacheDesc())); if (nullptr == fCurrMip.get()) { SkBitmap orig; if (!provider.asBitmap(&orig)) { return false; } - fCurrMip.reset(SkMipMapCache::AddAndRef(orig, colorMode)); + fCurrMip.reset(SkMipMapCache::AddAndRef(orig)); if (nullptr == fCurrMip.get()) { return false; } diff --git a/src/core/SkBitmapProvider.cpp b/src/core/SkBitmapProvider.cpp index 90c4e62a54..fa1e81544d 100644 --- a/src/core/SkBitmapProvider.cpp +++ b/src/core/SkBitmapProvider.cpp @@ -44,5 +44,5 @@ void SkBitmapProvider::notifyAddedToCache() const { } bool SkBitmapProvider::asBitmap(SkBitmap* bm) const { - return as_IB(fImage)->getROPixels(bm, fDstColorSpace, SkImage::kAllow_CachingHint); + return as_IB(fImage)->getROPixels(bm, nullptr, SkImage::kAllow_CachingHint); } diff --git a/src/core/SkBitmapProvider.h b/src/core/SkBitmapProvider.h index f4904d4aa4..186f155ee6 100644 --- a/src/core/SkBitmapProvider.h +++ b/src/core/SkBitmapProvider.h @@ -13,20 +13,17 @@ class SkBitmapProvider { public: - explicit SkBitmapProvider(const SkImage* img, SkColorSpace* dstColorSpace) - : fImage(img) - , fDstColorSpace(dstColorSpace) { + explicit SkBitmapProvider(const SkImage* img) + : fImage(img) { SkASSERT(img); } SkBitmapProvider(const SkBitmapProvider& other) : fImage(other.fImage) - , fDstColorSpace(other.fDstColorSpace) {} int width() const; int height() const; uint32_t getID() const; - SkColorSpace* dstColorSpace() const { return fDstColorSpace; } SkImageInfo info() const; bool isVolatile() const; @@ -44,10 +41,9 @@ private: void* operator new(size_t) = delete; void* operator new(size_t, void*) = delete; - // SkBitmapProvider is always short-lived/stack allocated, and the source image and destination - // color space are guaranteed to outlive its scope => we can store raw ptrs to avoid ref churn. + // SkBitmapProvider is always short-lived/stack allocated, and the source image is guaranteed + // to outlive its scope => we can store a raw ptr to avoid ref churn. const SkImage* fImage; - SkColorSpace* fDstColorSpace; }; #endif diff --git a/src/core/SkMipMap.cpp b/src/core/SkMipMap.cpp index 1b5d84bf39..51ff77f4bf 100644 --- a/src/core/SkMipMap.cpp +++ b/src/core/SkMipMap.cpp @@ -483,8 +483,7 @@ size_t SkMipMap::AllocLevelsSize(int levelCount, size_t pixelSize) { return SkTo(size); } -SkMipMap* SkMipMap::Build(const SkPixmap& src, SkDestinationSurfaceColorMode colorMode, - SkDiscardableFactoryProc fact) { +SkMipMap* SkMipMap::Build(const SkPixmap& src, SkDiscardableFactoryProc fact) { typedef void FilterProc(void*, const void* srcPtr, size_t srcRB, int count); FilterProc* proc_1_2 = nullptr; @@ -498,8 +497,7 @@ SkMipMap* SkMipMap::Build(const SkPixmap& src, SkDestinationSurfaceColorMode col const SkColorType ct = src.colorType(); const SkAlphaType at = src.alphaType(); - const bool srgbGamma = (SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware == colorMode) - && src.info().gammaCloseToSRGB(); + const bool srgbGamma = false; // TODO: sRGB_ColorType switch (ct) { case kRGBA_8888_SkColorType: @@ -778,13 +776,12 @@ bool SkMipMap::extractLevel(const SkSize& scaleSize, Level* levelPtr) const { // Helper which extracts a pixmap from the src bitmap // -SkMipMap* SkMipMap::Build(const SkBitmap& src, SkDestinationSurfaceColorMode colorMode, - SkDiscardableFactoryProc fact) { +SkMipMap* SkMipMap::Build(const SkBitmap& src, SkDiscardableFactoryProc fact) { SkPixmap srcPixmap; if (!src.peekPixels(&srcPixmap)) { return nullptr; } - return Build(srcPixmap, colorMode, fact); + return Build(srcPixmap, fact); } int SkMipMap::countLevels() const { diff --git a/src/core/SkMipMap.h b/src/core/SkMipMap.h index 7710002542..c6fc24dbf1 100644 --- a/src/core/SkMipMap.h +++ b/src/core/SkMipMap.h @@ -29,16 +29,8 @@ typedef SkDiscardableMemory* (*SkDiscardableFactoryProc)(size_t bytes); */ class SkMipMap : public SkCachedData { public: - static SkMipMap* Build(const SkPixmap& src, SkDestinationSurfaceColorMode, - SkDiscardableFactoryProc); - static SkMipMap* Build(const SkBitmap& src, SkDestinationSurfaceColorMode, - SkDiscardableFactoryProc); - - static SkDestinationSurfaceColorMode DeduceColorMode(const SkShaderBase::ContextRec& rec) { - return (SkShaderBase::ContextRec::kPMColor_DstType == rec.fPreferredDstType) - ? SkDestinationSurfaceColorMode::kLegacy - : SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware; - } + static SkMipMap* Build(const SkPixmap& src, SkDiscardableFactoryProc); + static SkMipMap* Build(const SkBitmap& src, SkDiscardableFactoryProc); // Determines how many levels a SkMipMap will have without creating that mipmap. // This does not include the base mipmap level that the user provided when diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp index 47d6ae2d8c..08b7b7ecac 100644 --- a/src/effects/SkTableColorFilter.cpp +++ b/src/effects/SkTableColorFilter.cpp @@ -443,7 +443,7 @@ std::unique_ptr ColorTableEffect::Make(GrContext* context, desc.fWidth = bitmap.width(); desc.fHeight = 128; desc.fRowHeight = bitmap.height(); - desc.fConfig = SkImageInfo2GrPixelConfig(bitmap.info(), *context->contextPriv().caps()); + desc.fConfig = SkColorType2GrPixelConfig(bitmap.colorType()); if (kUnknown_GrPixelConfig == desc.fConfig) { return nullptr; diff --git a/src/gpu/GrBitmapTextureMaker.cpp b/src/gpu/GrBitmapTextureMaker.cpp index 2fd8016818..d2a1fbe3e9 100644 --- a/src/gpu/GrBitmapTextureMaker.cpp +++ b/src/gpu/GrBitmapTextureMaker.cpp @@ -49,10 +49,10 @@ sk_sp GrBitmapTextureMaker::refOriginalTextureProxy(bool willBeM if (!proxy) { if (willBeMipped) { - proxy = proxyProvider->createMipMapProxyFromBitmap(fBitmap, dstColorSpace); + proxy = proxyProvider->createMipMapProxyFromBitmap(fBitmap); } if (!proxy) { - proxy = GrUploadBitmapToTextureProxy(proxyProvider, fBitmap, dstColorSpace); + proxy = GrUploadBitmapToTextureProxy(proxyProvider, fBitmap); } if (proxy) { if (fOriginalKey.isValid()) { diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp index 42d3d4c51a..db4681a3aa 100644 --- a/src/gpu/GrCaps.cpp +++ b/src/gpu/GrCaps.cpp @@ -44,7 +44,6 @@ GrCaps::GrCaps(const GrContextOptions& options) { fNPOTTextureTileSupport = false; fSRGBSupport = false; fSRGBWriteControl = false; - fSRGBDecodeDisableSupport = false; fDiscardRenderTargetSupport = false; fReuseScratchTextures = true; fReuseScratchBuffers = true; @@ -156,7 +155,6 @@ void GrCaps::dumpJSON(SkJSONWriter* writer) const { writer->appendBool("NPOT Texture Tile Support", fNPOTTextureTileSupport); writer->appendBool("sRGB Support", fSRGBSupport); writer->appendBool("sRGB Write Control", fSRGBWriteControl); - writer->appendBool("sRGB Decode Disable", fSRGBDecodeDisableSupport); writer->appendBool("Discard Render Target Support", fDiscardRenderTargetSupport); writer->appendBool("Reuse Scratch Textures", fReuseScratchTextures); writer->appendBool("Reuse Scratch Buffers", fReuseScratchBuffers); diff --git a/src/gpu/GrCaps.h b/src/gpu/GrCaps.h index b6758d1352..a04699f77e 100644 --- a/src/gpu/GrCaps.h +++ b/src/gpu/GrCaps.h @@ -51,7 +51,6 @@ public: * Is there support for enabling/disabling sRGB writes for sRGB-capable color buffers? */ bool srgbWriteControl() const { return fSRGBWriteControl; } - bool srgbDecodeDisableSupport() const { return fSRGBDecodeDisableSupport; } bool discardRenderTargetSupport() const { return fDiscardRenderTargetSupport; } bool gpuTracingSupport() const { return fGpuTracingSupport; } bool oversizedStencilSupport() const { return fOversizedStencilSupport; } @@ -287,7 +286,6 @@ protected: bool fMipMapSupport : 1; bool fSRGBSupport : 1; bool fSRGBWriteControl : 1; - bool fSRGBDecodeDisableSupport : 1; bool fDiscardRenderTargetSupport : 1; bool fReuseScratchTextures : 1; bool fReuseScratchBuffers : 1; diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index c9c476fb1a..b020729f67 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -329,12 +329,12 @@ int GrContext::maxTextureSize() const { return fCaps->maxTextureSize(); } int GrContext::maxRenderTargetSize() const { return fCaps->maxRenderTargetSize(); } bool GrContext::colorTypeSupportedAsImage(SkColorType colorType) const { - GrPixelConfig config = SkImageInfo2GrPixelConfig(colorType, nullptr, *fCaps); + GrPixelConfig config = SkColorType2GrPixelConfig(colorType); return fCaps->isConfigTexturable(config); } int GrContext::maxSurfaceSampleCountForColorType(SkColorType colorType) const { - GrPixelConfig config = SkImageInfo2GrPixelConfig(colorType, nullptr, *fCaps); + GrPixelConfig config = SkColorType2GrPixelConfig(colorType); return fCaps->maxRenderTargetSampleCount(config); } @@ -654,8 +654,6 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceContext* dst, int left, int top, GrPaint paint; paint.addColorFragmentProcessor(std::move(fp)); paint.setPorterDuffXPFactory(SkBlendMode::kSrc); - paint.setAllowSRGBInputs(dst->colorSpaceInfo().isGammaCorrect() || - GrPixelConfigIsSRGB(dst->colorSpaceInfo().config())); SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)); renderTargetContext->drawRect(GrNoClip(), std::move(paint), GrAA::kNo, matrix, rect, nullptr); @@ -814,7 +812,6 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceContext* src, int left, int top, GrPaint paint; paint.addColorFragmentProcessor(std::move(fp)); paint.setPorterDuffXPFactory(SkBlendMode::kSrc); - paint.setAllowSRGBInputs(true); SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)); tempRTC->drawRect(GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(), rect, nullptr); diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index eb969e4704..31870dc833 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -454,8 +454,7 @@ public: only to be used for testing (particularly for testing the methods that import an externally created texture into Skia. Must be matched with a call to deleteTestingOnlyTexture(). */ GrBackendTexture createTestingOnlyBackendTexture(const void* pixels, int w, int h, SkColorType, - SkColorSpace* cs, bool isRenderTarget, - GrMipMapped); + bool isRenderTarget, GrMipMapped); /** Older version based on GrPixelConfig. Currently the preferred one above devolves to this. */ virtual GrBackendTexture createTestingOnlyBackendTexture(const void* pixels, int w, int h, GrPixelConfig config, diff --git a/src/gpu/GrPaint.cpp b/src/gpu/GrPaint.cpp index e29c464bc0..bf198a8493 100644 --- a/src/gpu/GrPaint.cpp +++ b/src/gpu/GrPaint.cpp @@ -16,7 +16,6 @@ GrPaint::GrPaint(const GrPaint& that) , fColorFragmentProcessors(that.fColorFragmentProcessors.count()) , fCoverageFragmentProcessors(that.fCoverageFragmentProcessors.count()) , fDisableOutputConversionToSRGB(that.fDisableOutputConversionToSRGB) - , fAllowSRGBInputs(that.fAllowSRGBInputs) , fTrivial(that.fTrivial) , fColor(that.fColor) { for (int i = 0; i < that.fColorFragmentProcessors.count(); ++i) { diff --git a/src/gpu/GrPaint.h b/src/gpu/GrPaint.h index c5b45633a7..3a5fa11d03 100644 --- a/src/gpu/GrPaint.h +++ b/src/gpu/GrPaint.h @@ -62,20 +62,12 @@ public: void setDisableOutputConversionToSRGB(bool srgb) { fDisableOutputConversionToSRGB = srgb; } bool getDisableOutputConversionToSRGB() const { return fDisableOutputConversionToSRGB; } - /** - * Should sRGB inputs be allowed to perform sRGB to linear conversion. With this flag - * set to false, sRGB textures will be treated as linear (including filtering). - */ - void setAllowSRGBInputs(bool allowSRGBInputs) { fAllowSRGBInputs = allowSRGBInputs; } - bool getAllowSRGBInputs() const { return fAllowSRGBInputs; } - /** * Should rendering be gamma-correct, end-to-end. Causes sRGB render targets to behave - * as such (with linear blending), and sRGB inputs to be filtered and decoded correctly. + * as such (with linear blending). */ void setGammaCorrect(bool gammaCorrect) { this->setDisableOutputConversionToSRGB(!gammaCorrect); - this->setAllowSRGBInputs(gammaCorrect); } void setXPFactory(const GrXPFactory* xpFactory) { @@ -155,7 +147,6 @@ private: SkSTArray<4, std::unique_ptr> fColorFragmentProcessors; SkSTArray<2, std::unique_ptr> fCoverageFragmentProcessors; bool fDisableOutputConversionToSRGB = false; - bool fAllowSRGBInputs = false; bool fTrivial = true; GrColor4f fColor = GrColor4f::OpaqueWhite(); }; diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h index c4319958a4..3862ab49c2 100644 --- a/src/gpu/GrPipeline.h +++ b/src/gpu/GrPipeline.h @@ -54,15 +54,10 @@ public: kSnapVerticesToPixelCenters_Flag = 0x2, /** Disables conversion to sRGB from linear when writing to a sRGB destination. */ kDisableOutputConversionToSRGB_Flag = 0x4, - /** Allows conversion from sRGB to linear when reading from processor's sRGB texture. */ - kAllowSRGBInputs_Flag = 0x8, }; static uint32_t SRGBFlagsFromPaint(const GrPaint& paint) { uint32_t flags = 0; - if (paint.getAllowSRGBInputs()) { - flags |= kAllowSRGBInputs_Flag; - } if (paint.getDisableOutputConversionToSRGB()) { flags |= kDisableOutputConversionToSRGB_Flag; } @@ -185,9 +180,6 @@ public: bool getDisableOutputConversionToSRGB() const { return SkToBool(fFlags & kDisableOutputConversionToSRGB_Flag); } - bool getAllowSRGBInputs() const { - return SkToBool(fFlags & kAllowSRGBInputs_Flag); - } bool hasStencilClip() const { return SkToBool(fFlags & kHasStencilClip_Flag); } @@ -210,9 +202,6 @@ public: if (flags & GrPipeline::kDisableOutputConversionToSRGB_Flag) { result.append("Disable output conversion to sRGB.\n"); } - if (flags & GrPipeline::kAllowSRGBInputs_Flag) { - result.append("Allow sRGB Inputs.\n"); - } return result; } return SkString("No pipeline flags\n"); diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp index 49e57df35b..a2b97d173a 100644 --- a/src/gpu/GrProxyProvider.cpp +++ b/src/gpu/GrProxyProvider.cpp @@ -211,8 +211,7 @@ sk_sp GrProxyProvider::createTextureProxy(sk_sp srcImag return nullptr; } - GrPixelConfig config = SkImageInfo2GrPixelConfig(as_IB(srcImage)->onImageInfo(), - *this->caps()); + GrPixelConfig config = SkImageInfo2GrPixelConfig(as_IB(srcImage)->onImageInfo()); if (kUnknown_GrPixelConfig == config) { return nullptr; @@ -284,13 +283,8 @@ sk_sp GrProxyProvider::createMipMapProxy(const GrSurfaceDesc& de GrInternalSurfaceFlags::kNone); } -sk_sp GrProxyProvider::createMipMapProxyFromBitmap(const SkBitmap& bitmap, - SkColorSpace* dstColorSpace) { - SkDestinationSurfaceColorMode mipColorMode = dstColorSpace - ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware - : SkDestinationSurfaceColorMode::kLegacy; - - if (!SkImageInfoIsValid(bitmap.info(), mipColorMode)) { +sk_sp GrProxyProvider::createMipMapProxyFromBitmap(const SkBitmap& bitmap) { + if (!SkImageInfoIsValid(bitmap.info())) { return nullptr; } @@ -300,7 +294,7 @@ sk_sp GrProxyProvider::createMipMapProxyFromBitmap(const SkBitma } ATRACE_ANDROID_FRAMEWORK("Upload MipMap Texture [%ux%u]", pixmap.width(), pixmap.height()); - sk_sp mipmaps(SkMipMap::Build(pixmap, mipColorMode, nullptr)); + sk_sp mipmaps(SkMipMap::Build(pixmap, nullptr)); if (!mipmaps) { return nullptr; } @@ -320,7 +314,7 @@ sk_sp GrProxyProvider::createMipMapProxyFromBitmap(const SkBitma return nullptr; } - GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(pixmap.info(), *this->caps()); + GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(pixmap.info()); if (0 == mipmaps->countLevels()) { return this->createTextureProxy(baseLevel, kNone_GrSurfaceFlags, 1, SkBudgeted::kYes, @@ -328,7 +322,7 @@ sk_sp GrProxyProvider::createMipMapProxyFromBitmap(const SkBitma } sk_sp proxy = this->createLazyProxy( - [desc, baseLevel, mipmaps, mipColorMode](GrResourceProvider* resourceProvider) { + [desc, baseLevel, mipmaps](GrResourceProvider* resourceProvider) { if (!resourceProvider) { return sk_sp(); } @@ -353,7 +347,7 @@ sk_sp GrProxyProvider::createMipMapProxyFromBitmap(const SkBitma } return resourceProvider->createTexture(desc, SkBudgeted::kYes, texels.get(), - mipLevelCount, mipColorMode); + mipLevelCount); }, desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kYes, SkBackingFit::kExact, SkBudgeted::kYes); diff --git a/src/gpu/GrProxyProvider.h b/src/gpu/GrProxyProvider.h index 76f0ae963b..c466c98475 100644 --- a/src/gpu/GrProxyProvider.h +++ b/src/gpu/GrProxyProvider.h @@ -100,8 +100,7 @@ public: /* * Creates a new mipmapped texture proxy for the bitmap with mip levels generated by the cpu. */ - sk_sp createMipMapProxyFromBitmap(const SkBitmap& bitmap, - SkColorSpace* dstColorSpace); + sk_sp createMipMapProxyFromBitmap(const SkBitmap& bitmap); /* * Create a GrSurfaceProxy without any data. diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index 456d8e4a82..e5bda32354 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -792,10 +792,9 @@ void GrRenderTargetContext::drawTexture(const GrClip& clip, sk_spcolorSpaceInfo().colorSpace()); this->addDrawOp(clip, GrTextureOp::Make(std::move(proxy), filter, color, clippedSrcRect, clippedDstRect, aaType, constraint, viewMatrix, - std::move(colorSpaceXform), allowSRGB)); + std::move(colorSpaceXform))); } void GrRenderTargetContext::fillRectWithLocalMatrix(const GrClip& clip, diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp index 2145190ee2..b09506e3f4 100644 --- a/src/gpu/GrResourceProvider.cpp +++ b/src/gpu/GrResourceProvider.cpp @@ -62,8 +62,7 @@ GrResourceProvider::GrResourceProvider(GrGpu* gpu, GrResourceCache* cache, GrSin } sk_sp GrResourceProvider::createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, - const GrMipLevel texels[], int mipLevelCount, - SkDestinationSurfaceColorMode mipColorMode) { + const GrMipLevel texels[], int mipLevelCount) { ASSERT_SINGLE_OWNER SkASSERT(mipLevelCount > 0); @@ -77,12 +76,7 @@ sk_sp GrResourceProvider::createTexture(const GrSurfaceDesc& desc, Sk return nullptr; } - sk_sp tex(fGpu->createTexture(desc, budgeted, texels, mipLevelCount)); - if (tex) { - tex->texturePriv().setMipColorMode(mipColorMode); - } - - return tex; + return fGpu->createTexture(desc, budgeted, texels, mipLevelCount); } sk_sp GrResourceProvider::getExactScratch(const GrSurfaceDesc& desc, diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h index a853f08ca3..35c36826af 100644 --- a/src/gpu/GrResourceProvider.h +++ b/src/gpu/GrResourceProvider.h @@ -68,7 +68,7 @@ public: sk_sp createTexture(const GrSurfaceDesc&, SkBudgeted, uint32_t flags = 0); sk_sp createTexture(const GrSurfaceDesc&, SkBudgeted, const GrMipLevel texels[], - int mipLevelCount, SkDestinationSurfaceColorMode mipColorMode); + int mipLevelCount); // Create a potentially loose fit texture with the provided data sk_sp createTexture(const GrSurfaceDesc&, SkBudgeted, SkBackingFit, diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp index 4d44d1ecc6..dd15b18bd4 100644 --- a/src/gpu/GrSurfaceProxy.cpp +++ b/src/gpu/GrSurfaceProxy.cpp @@ -153,8 +153,7 @@ sk_sp GrSurfaceProxy::createSurfaceImpl( texels[i].fRowBytes = 0; } - surface = resourceProvider->createTexture(desc, fBudgeted, texels.get(), mipCount, - SkDestinationSurfaceColorMode::kLegacy); + surface = resourceProvider->createTexture(desc, fBudgeted, texels.get(), mipCount); if (surface) { SkASSERT(surface->asTexture()); SkASSERT(GrMipMapped::kYes == surface->asTexture()->texturePriv().mipMapped()); diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp index dd0631775f..cd3e7055ab 100644 --- a/src/gpu/GrTexture.cpp +++ b/src/gpu/GrTexture.cpp @@ -47,9 +47,7 @@ GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrSLType samplerType : INHERITED(gpu, desc) , fSamplerType(samplerType) , fHighestFilterMode(highestFilterMode) - , fMipMapsStatus(mipMapsStatus) - // Mip color mode is explicitly set after creation via GrTexturePriv - , fMipColorMode(SkDestinationSurfaceColorMode::kLegacy) { + , fMipMapsStatus(mipMapsStatus) { if (GrMipMapsStatus::kNotAllocated == fMipMapsStatus) { fMaxMipMapLevel = 0; } else { diff --git a/src/gpu/GrTexturePriv.h b/src/gpu/GrTexturePriv.h index 80ac75fdb8..4517e9e076 100644 --- a/src/gpu/GrTexturePriv.h +++ b/src/gpu/GrTexturePriv.h @@ -53,11 +53,6 @@ public: /** The filter used is clamped to this value in GrProcessor::TextureSampler. */ GrSamplerState::Filter highestFilterMode() const { return fTexture->fHighestFilterMode; } - void setMipColorMode(SkDestinationSurfaceColorMode colorMode) const { - fTexture->fMipColorMode = colorMode; - } - SkDestinationSurfaceColorMode mipColorMode() const { return fTexture->fMipColorMode; } - static void ComputeScratchKey(const GrSurfaceDesc&, GrScratchKey*); static void ComputeScratchKey(GrPixelConfig config, int width, int height, bool isRenderTarget, int sampleCnt, diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 883f32605a..06307a1af2 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -157,7 +157,7 @@ sk_sp SkGpuDevice::MakeRenderTargetContext( return nullptr; } - GrPixelConfig config = SkImageInfo2GrPixelConfig(origInfo, *context->contextPriv().caps()); + GrPixelConfig config = SkImageInfo2GrPixelConfig(origInfo); if (kUnknown_GrPixelConfig == config) { return nullptr; } diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 528d133e2d..6767a1b50f 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -41,12 +41,12 @@ #include "effects/GrPorterDuffXferProcessor.h" #include "effects/GrXfermodeFragmentProcessor.h" -GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo& info, const GrCaps& caps) { +GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo& info) { GrSurfaceDesc desc; desc.fFlags = kNone_GrSurfaceFlags; desc.fWidth = info.width(); desc.fHeight = info.height(); - desc.fConfig = SkImageInfo2GrPixelConfig(info, caps); + desc.fConfig = SkImageInfo2GrPixelConfig(info); desc.fSampleCnt = 1; return desc; } @@ -66,17 +66,12 @@ void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& ima ////////////////////////////////////////////////////////////////////////////// sk_sp GrUploadBitmapToTextureProxy(GrProxyProvider* proxyProvider, - const SkBitmap& bitmap, - SkColorSpace* dstColorSpace) { + const SkBitmap& bitmap) { if (!bitmap.peekPixels(nullptr)) { return nullptr; } - SkDestinationSurfaceColorMode colorMode = dstColorSpace - ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware - : SkDestinationSurfaceColorMode::kLegacy; - - if (!SkImageInfoIsValid(bitmap.info(), colorMode)) { + if (!SkImageInfoIsValid(bitmap.info())) { return nullptr; } @@ -246,8 +241,7 @@ GrColor4f SkColorToUnpremulGrColor4f(SkColor c, const GrColorSpaceInfo& colorSpa /////////////////////////////////////////////////////////////////////////////// -GrPixelConfig SkImageInfo2GrPixelConfig(const SkColorType type, SkColorSpace* cs, - const GrCaps& caps) { +GrPixelConfig SkColorType2GrPixelConfig(const SkColorType type) { switch (type) { case kUnknown_SkColorType: return kUnknown_GrPixelConfig; @@ -258,15 +252,11 @@ GrPixelConfig SkImageInfo2GrPixelConfig(const SkColorType type, SkColorSpace* cs case kARGB_4444_SkColorType: return kRGBA_4444_GrPixelConfig; case kRGBA_8888_SkColorType: - return (caps.srgbSupport() && cs && cs->gammaCloseToSRGB()) - ? kSRGBA_8888_GrPixelConfig : kRGBA_8888_GrPixelConfig; - // TODO: We're checking for srgbSupport, but we can then end up picking sBGRA as our pixel - // config (which may not be supported). We need a better test here. + return kRGBA_8888_GrPixelConfig; case kRGB_888x_SkColorType: return kRGB_888_GrPixelConfig; case kBGRA_8888_SkColorType: - return (caps.srgbSupport() && cs && cs->gammaCloseToSRGB()) - ? kSBGRA_8888_GrPixelConfig : kBGRA_8888_GrPixelConfig; + return kBGRA_8888_GrPixelConfig; case kRGBA_1010102_SkColorType: return kRGBA_1010102_GrPixelConfig; case kRGB_101010x_SkColorType: @@ -280,8 +270,8 @@ GrPixelConfig SkImageInfo2GrPixelConfig(const SkColorType type, SkColorSpace* cs return kUnknown_GrPixelConfig; } -GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info, const GrCaps& caps) { - return SkImageInfo2GrPixelConfig(info.colorType(), info.colorSpace(), caps); +GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info) { + return SkColorType2GrPixelConfig(info.colorType()); } bool GrPixelConfigToColorType(GrPixelConfig config, SkColorType* ctOut) { @@ -322,8 +312,6 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context, std::unique_ptr* shaderProcessor, SkBlendMode* primColorMode, GrPaint* grPaint) { - grPaint->setAllowSRGBInputs(colorSpaceInfo.isGammaCorrect()); - // Convert SkPaint color to 4f format, including optional linearizing and gamut conversion. GrColor4f origColor = SkColorToUnpremulGrColor4f(skPaint.getColor(), colorSpaceInfo); diff --git a/src/gpu/SkGr.h b/src/gpu/SkGr.h index d8d227f53f..b766105613 100644 --- a/src/gpu/SkGr.h +++ b/src/gpu/SkGr.h @@ -143,9 +143,9 @@ bool SkPaintToGrPaintWithTexture(GrContext* context, //////////////////////////////////////////////////////////////////////////////// // Misc Sk to Gr type conversions -GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&, const GrCaps&); -GrPixelConfig SkImageInfo2GrPixelConfig(const SkColorType, SkColorSpace*, const GrCaps& caps); -GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info, const GrCaps& caps); +GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&); +GrPixelConfig SkColorType2GrPixelConfig(const SkColorType); +GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info); bool GrPixelConfigToColorType(GrPixelConfig, SkColorType*); @@ -206,8 +206,7 @@ sk_sp GrRefCachedBitmapTextureProxy(GrContext*, * The bitmap must have CPU-accessible pixels. Attempts to take advantage of faster paths for * yuv planes. */ -sk_sp GrUploadBitmapToTextureProxy(GrProxyProvider*, const SkBitmap&, - SkColorSpace* dstColorSpace); +sk_sp GrUploadBitmapToTextureProxy(GrProxyProvider*, const SkBitmap&); /** * Creates a new texture with mipmap levels and copies the baseProxy into the base layer. diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 4660cdaf53..e20d0137e9 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -52,7 +52,6 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, fRGBAToBGRAReadbackConversionsAreSlow = false; fUseBufferDataNullHint = SkToBool(GR_GL_USE_BUFFER_DATA_NULL_HINT); fDoManualMipmapping = false; - fSRGBDecodeDisableAffectsMipmaps = false; fClearToBoundaryValuesIsBroken = false; fClearTextureSupport = false; fDrawArraysBaseVertexIsBroken = false; @@ -588,11 +587,6 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, // Safely moving textures between contexts requires fences. fCrossContextTextureSupport = fFenceSyncSupport; - fSRGBDecodeDisableSupport = ctxInfo.hasExtension("GL_EXT_texture_sRGB_decode"); - - fSRGBDecodeDisableAffectsMipmaps = fSRGBDecodeDisableSupport && - kChromium_GrGLDriver != ctxInfo.driver(); - if (kGL_GrGLStandard == standard) { if (version >= GR_GL_VER(4, 1)) { fProgramBinarySupport = true; @@ -1529,8 +1523,7 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions, } fConfigTable[kBGRA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); - // We only enable srgb support if both textures and FBOs support srgb, - // *and* we can disable sRGB decode-on-read, to support "legacy" mode. + // We only enable srgb support if both textures and FBOs support srgb. if (kGL_GrGLStandard == standard) { if (ctxInfo.version() >= GR_GL_VER(3,0)) { fSRGBSupport = true; @@ -1555,11 +1548,6 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions, fSRGBWriteControl = !disableSRGBWriteControlForAdreno4xx && ctxInfo.hasExtension("GL_EXT_sRGB_write_control"); } - if (contextOptions.fRequireDecodeDisableForSRGB && !fSRGBDecodeDisableSupport) { - // To support "legacy" L32 mode, we require the ability to turn off sRGB decode. Clients - // can opt-out of that requirement, if they intend to always do linear blending. - fSRGBSupport = false; - } // This is very conservative, if we're on a platform where N32 is BGRA, and using ES, disable // all sRGB support. Too much code relies on creating surfaces with N32 + sRGB colorspace, diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index 76eec3afb0..e258eaa57d 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -343,8 +343,6 @@ public: bool doManualMipmapping() const { return fDoManualMipmapping; } - bool srgbDecodeDisableAffectsMipmaps() const { return fSRGBDecodeDisableAffectsMipmaps; } - void onDumpJSON(SkJSONWriter*) const override; bool rgba8888PixelsOpsAreSlow() const { return fRGBA8888PixelsOpsAreSlow; } @@ -517,7 +515,6 @@ private: // Driver workarounds bool fDoManualMipmapping : 1; - bool fSRGBDecodeDisableAffectsMipmaps : 1; bool fClearToBoundaryValuesIsBroken : 1; bool fDrawArraysBaseVertexIsBroken : 1; bool fUseDrawToClearColor : 1; diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 5bfe2e557e..3c4b1e8bca 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -3004,8 +3004,8 @@ static GrGLenum filter_to_gl_min_filter(GrSamplerState::Filter filter) { return 0; } -void GrGLGpu::bindTexture(int unitIdx, const GrSamplerState& samplerState, bool allowSRGBInputs, - GrGLTexture* texture, GrSurfaceOrigin textureOrigin) { +void GrGLGpu::bindTexture(int unitIdx, const GrSamplerState& samplerState, GrGLTexture* texture, + GrSurfaceOrigin textureOrigin) { SkASSERT(texture); #ifdef SK_DEBUG @@ -3050,24 +3050,10 @@ void GrGLGpu::bindTexture(int unitIdx, const GrSamplerState& samplerState, bool newTexParams.fMinFilter = filter_to_gl_min_filter(filterMode); newTexParams.fMagFilter = filter_to_gl_mag_filter(filterMode); - if (this->glCaps().srgbDecodeDisableSupport() && GrPixelConfigIsSRGB(texture->config())) { - newTexParams.fSRGBDecode = allowSRGBInputs ? GR_GL_DECODE_EXT : GR_GL_SKIP_DECODE_EXT; - if (setAll || newTexParams.fSRGBDecode != oldTexParams.fSRGBDecode) { - this->setTextureUnit(unitIdx); - GL_CALL(TexParameteri(target, GR_GL_TEXTURE_SRGB_DECODE_EXT, newTexParams.fSRGBDecode)); - } - } - #ifdef SK_DEBUG - // We were supposed to ensure MipMaps were up-to-date and built correctly before getting here. + // We were supposed to ensure MipMaps were up-to-date before getting here. if (GrSamplerState::Filter::kMipMap == filterMode) { SkASSERT(!texture->texturePriv().mipMapsAreDirty()); - if (GrPixelConfigIsSRGB(texture->config())) { - SkDestinationSurfaceColorMode colorMode = allowSRGBInputs - ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware - : SkDestinationSurfaceColorMode::kLegacy; - SkASSERT(texture->texturePriv().mipColorMode() == colorMode); - } } #endif @@ -3159,8 +3145,8 @@ void GrGLGpu::bindTexelBuffer(int unitIdx, GrPixelConfig texelConfig, GrGLBuffer } } -void GrGLGpu::generateMipmaps(const GrSamplerState& params, bool allowSRGBInputs, - GrGLTexture* texture, GrSurfaceOrigin textureOrigin) { +void GrGLGpu::generateMipmaps(const GrSamplerState& params, GrGLTexture* texture, + GrSurfaceOrigin textureOrigin) { SkASSERT(texture); // First, figure out if we need mips for this texture at all: @@ -3176,17 +3162,6 @@ void GrGLGpu::generateMipmaps(const GrSamplerState& params, bool allowSRGBInputs return; } - // If this is an sRGB texture and the mips were previously built the "other" way - // (gamma-correct vs. not), then we need to rebuild them. We don't need to check for - // srgbSupport - we'll *never* get an sRGB pixel config if we don't support it. - SkDestinationSurfaceColorMode colorMode = allowSRGBInputs - ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware - : SkDestinationSurfaceColorMode::kLegacy; - if (GrPixelConfigIsSRGB(texture->config()) && - colorMode != texture->texturePriv().mipColorMode()) { - texture->texturePriv().markMipMapsDirty(); - } - // If the mips aren't dirty, we're done: if (!texture->texturePriv().mipMapsAreDirty()) { return; @@ -3203,30 +3178,14 @@ void GrGLGpu::generateMipmaps(const GrSamplerState& params, bool allowSRGBInputs this->setScratchTextureUnit(); GL_CALL(BindTexture(target, texture->textureID())); - // Configure sRGB decode, if necessary. This state is the only thing needed for the driver - // call (glGenerateMipmap) to work correctly. Our manual method dirties other state, too. - if (this->glCaps().srgbDecodeDisableSupport() && GrPixelConfigIsSRGB(texture->config())) { - GrGLenum srgbDecode = allowSRGBInputs ? GR_GL_DECODE_EXT : GR_GL_SKIP_DECODE_EXT; - // Command buffer's sRGB decode extension doesn't influence mipmap generation correctly. - // If we set this to skip_decode, it appears to suppress sRGB -> Linear for each downsample, - // but not the Linear -> sRGB when writing the next level. The result is that mip-chains - // get progressively brighter as you go down. Forcing this to 'decode' gives predictable - // (and only slightly incorrect) results. See crbug.com/655247 (~comment 28) - if (!this->glCaps().srgbDecodeDisableAffectsMipmaps()) { - srgbDecode = GR_GL_DECODE_EXT; - } - GL_CALL(TexParameteri(target, GR_GL_TEXTURE_SRGB_DECODE_EXT, srgbDecode)); - } - // Either do manual mipmap generation or (if that fails), just rely on the driver: - if (!this->generateMipmap(texture, textureOrigin, allowSRGBInputs)) { + if (!this->generateMipmap(texture, textureOrigin)) { GL_CALL(GenerateMipmap(target)); } texture->texturePriv().markMipMapsClean(); texture->texturePriv().setMaxMipMapLevel(SkMipMap::ComputeLevelCount( texture->width(), texture->height())); - texture->texturePriv().setMipColorMode(colorMode); // We have potentially set lots of state on the texture. Easiest to dirty it all: texture->textureParamsModified(); @@ -3993,7 +3952,7 @@ bool GrGLGpu::copySurfaceAsDraw(GrSurface* dst, GrSurfaceOrigin dstOrigin, int w = srcRect.width(); int h = srcRect.height(); - this->bindTexture(0, GrSamplerState::ClampNearest(), true, srcTex, srcOrigin); + this->bindTexture(0, GrSamplerState::ClampNearest(), srcTex, srcOrigin); GrGLIRect dstVP; this->bindSurfaceFBOForPixelOps(dst, GR_GL_FRAMEBUFFER, &dstVP, kDst_TempFBOTarget); @@ -4153,8 +4112,7 @@ bool GrGLGpu::copySurfaceAsBlitFramebuffer(GrSurface* dst, GrSurfaceOrigin dstOr // Manual implementation of mipmap generation, to work around driver bugs w/sRGB. // Uses draw calls to do a series of downsample operations to successive mips. // If this returns false, then the calling code falls back to using glGenerateMipmap. -bool GrGLGpu::generateMipmap(GrGLTexture* texture, GrSurfaceOrigin textureOrigin, - bool gammaCorrect) { +bool GrGLGpu::generateMipmap(GrGLTexture* texture, GrSurfaceOrigin textureOrigin) { // Our iterative downsample requires the ability to limit which level we're sampling: if (!this->glCaps().doManualMipmapping()) { return false; @@ -4170,17 +4128,6 @@ bool GrGLGpu::generateMipmap(GrGLTexture* texture, GrSurfaceOrigin textureOrigin return false; } - // If we're mipping an sRGB texture, we need to ensure FB sRGB is correct: - if (GrPixelConfigIsSRGB(texture->config())) { - // If we have write-control, just set the state that we want: - if (this->glCaps().srgbWriteControl()) { - this->flushFramebufferSRGB(gammaCorrect); - } else if (!gammaCorrect) { - // If we don't have write-control we can't do non-gamma-correct mipmapping: - return false; - } - } - int width = texture->width(); int height = texture->height(); int levelCount = SkMipMap::ComputeLevelCount(width, height) + 1; @@ -4217,7 +4164,7 @@ bool GrGLGpu::generateMipmap(GrGLTexture* texture, GrSurfaceOrigin textureOrigin // Bind the texture, to get things configured for filtering. // We'll be changing our base level further below: this->setTextureUnit(0); - this->bindTexture(0, GrSamplerState::ClampBilerp(), gammaCorrect, texture, textureOrigin); + this->bindTexture(0, GrSamplerState::ClampBilerp(), texture, textureOrigin); // Vertex data: if (!fMipmapProgramArrayBuffer) { diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index b63a907c9e..8bb45c2eb5 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -54,12 +54,12 @@ public: } // Used by GrGLProgram to configure OpenGL state. - void bindTexture(int unitIdx, const GrSamplerState& samplerState, bool allowSRGBInputs, - GrGLTexture* texture, GrSurfaceOrigin textureOrigin); + void bindTexture(int unitIdx, const GrSamplerState& samplerState, GrGLTexture* texture, + GrSurfaceOrigin textureOrigin); void bindTexelBuffer(int unitIdx, GrPixelConfig, GrGLBuffer*); - void generateMipmaps(const GrSamplerState& params, bool allowSRGBInputs, GrGLTexture* texture, + void generateMipmaps(const GrSamplerState& params, GrGLTexture* texture, GrSurfaceOrigin textureOrigin); // These functions should be used to bind GL objects. They track the GL state and skip redundant @@ -289,7 +289,7 @@ private: bool copySurfaceAsBlitFramebuffer(GrSurface* dst, GrSurfaceOrigin dstOrigin, GrSurface* src, GrSurfaceOrigin srcOrigin, const SkIRect& srcRect, const SkIPoint& dstPoint); - bool generateMipmap(GrGLTexture* texture, GrSurfaceOrigin textureOrigin, bool gammaCorrect); + bool generateMipmap(GrGLTexture* texture, GrSurfaceOrigin textureOrigin); void clearStencilClipAsDraw(const GrFixedClip&, bool insideStencilMask, GrRenderTarget*, GrSurfaceOrigin); diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp index 7257638e1d..95b1f0ca70 100644 --- a/src/gpu/gl/GrGLProgram.cpp +++ b/src/gpu/gl/GrGLProgram.cpp @@ -80,8 +80,7 @@ void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline int nextTexelBufferIdx = fNumTextureSamplers; fGeometryProcessor->setData(fProgramDataManager, primProc, GrFragmentProcessor::CoordTransformIter(pipeline)); - this->bindTextures(primProc, pipeline.getAllowSRGBInputs(), &nextTexSamplerIdx, - &nextTexelBufferIdx); + this->bindTextures(primProc, &nextTexSamplerIdx, &nextTexelBufferIdx); this->setFragmentData(primProc, pipeline, &nextTexSamplerIdx, &nextTexelBufferIdx); @@ -91,7 +90,7 @@ void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline fXferProcessor->setData(fProgramDataManager, xp, dstTexture, offset); if (dstTexture) { - fGpu->bindTexture(nextTexSamplerIdx++, GrSamplerState::ClampNearest(), true, + fGpu->bindTexture(nextTexSamplerIdx++, GrSamplerState::ClampNearest(), static_cast(dstTexture), pipeline.dstTextureProxy()->origin()); } @@ -101,11 +100,11 @@ void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline void GrGLProgram::generateMipmaps(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline) { - this->generateMipmaps(primProc, pipeline.getAllowSRGBInputs()); + this->generateMipmaps(primProc); GrFragmentProcessor::Iter iter(pipeline); while (const GrFragmentProcessor* fp = iter.next()) { - this->generateMipmaps(*fp, pipeline.getAllowSRGBInputs()); + this->generateMipmaps(*fp); } } @@ -120,8 +119,7 @@ void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc, GrGLSLFragmentProcessor* glslFP = glslIter.next(); while (fp && glslFP) { glslFP->setData(fProgramDataManager, *fp); - this->bindTextures(*fp, pipeline.getAllowSRGBInputs(), nextTexSamplerIdx, - nextTexelBufferIdx); + this->bindTextures(*fp, nextTexSamplerIdx, nextTexelBufferIdx); fp = iter.next(); glslFP = glslIter.next(); } @@ -160,12 +158,11 @@ void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc, } void GrGLProgram::bindTextures(const GrResourceIOProcessor& processor, - bool allowSRGBInputs, int* nextTexSamplerIdx, int* nextTexelBufferIdx) { for (int i = 0; i < processor.numTextureSamplers(); ++i) { const GrResourceIOProcessor::TextureSampler& sampler = processor.textureSampler(i); - fGpu->bindTexture((*nextTexSamplerIdx)++, sampler.samplerState(), allowSRGBInputs, + fGpu->bindTexture((*nextTexSamplerIdx)++, sampler.samplerState(), static_cast(sampler.peekTexture()), sampler.proxy()->origin()); } @@ -176,10 +173,10 @@ void GrGLProgram::bindTextures(const GrResourceIOProcessor& processor, } } -void GrGLProgram::generateMipmaps(const GrResourceIOProcessor& processor, bool allowSRGBInputs) { +void GrGLProgram::generateMipmaps(const GrResourceIOProcessor& processor) { for (int i = 0; i < processor.numTextureSamplers(); ++i) { const GrResourceIOProcessor::TextureSampler& sampler = processor.textureSampler(i); - fGpu->generateMipmaps(sampler.samplerState(), allowSRGBInputs, + fGpu->generateMipmaps(sampler.samplerState(), static_cast(sampler.peekTexture()), sampler.proxy()->origin()); } diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h index 781baa4aba..b49b410870 100644 --- a/src/gpu/gl/GrGLProgram.h +++ b/src/gpu/gl/GrGLProgram.h @@ -126,11 +126,10 @@ protected: void setRenderTargetState(const GrPrimitiveProcessor&, const GrRenderTargetProxy*); // Helper for setData() that binds textures and texel buffers to the appropriate texture units - void bindTextures(const GrResourceIOProcessor&, bool allowSRGBInputs, int* nextSamplerIdx, - int* nextTexelBufferIdx); + void bindTextures(const GrResourceIOProcessor&, int* nextSamplerIdx, int* nextTexelBufferIdx); // Helper for generateMipmaps() that ensures mipmaps are up to date - void generateMipmaps(const GrResourceIOProcessor&, bool allowSRGBInputs); + void generateMipmaps(const GrResourceIOProcessor&); // these reflect the current values of uniforms (GL uniform values travel with program) RenderTargetState fRenderTargetState; diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h index 67eab4312e..10b8e26e78 100644 --- a/src/gpu/gl/GrGLTexture.h +++ b/src/gpu/gl/GrGLTexture.h @@ -24,7 +24,6 @@ public: GrGLenum fWrapT; GrGLenum fMaxMipMapLevel; GrGLenum fSwizzleRGBA[4]; - GrGLenum fSRGBDecode; void invalidate() { memset(this, 0xff, sizeof(TexParams)); } }; diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp index ed2a847ad8..1a8bfbade2 100644 --- a/src/gpu/ops/GrDashOp.cpp +++ b/src/gpu/ops/GrDashOp.cpp @@ -326,7 +326,6 @@ private: bool fullDash, const GrUserStencilSettings* stencilSettings) : INHERITED(ClassID()) , fColor(paint.getColor()) - , fAllowsSRGBInputs(paint.getAllowSRGBInputs()) , fDisableSRGBOutputConversion(paint.getDisableOutputConversionToSRGB()) , fFullDash(fullDash) , fCap(cap) @@ -687,9 +686,6 @@ private: if (fDisableSRGBOutputConversion) { pipelineFlags |= GrPipeline::kDisableOutputConversionToSRGB_Flag; } - if (fAllowsSRGBInputs) { - pipelineFlags |= GrPipeline::kAllowSRGBInputs_Flag; - } const GrPipeline* pipeline = target->makePipeline(pipelineFlags, std::move(fProcessorSet), target->detachAppliedClip()); helper.recordDraw(target, gp.get(), pipeline); @@ -742,7 +738,6 @@ private: SkSTArray<1, LineData, true> fLines; GrColor fColor; - bool fAllowsSRGBInputs : 1; bool fDisableSRGBOutputConversion : 1; bool fDisallowCombineOnTouchOrOverlap : 1; bool fUsesLocalCoords : 1; diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp index 1bb47824fb..950fe6e26b 100644 --- a/src/gpu/ops/GrTextureOp.cpp +++ b/src/gpu/ops/GrTextureOp.cpp @@ -611,11 +611,11 @@ public: GrSamplerState::Filter filter, GrColor color, const SkRect& srcRect, const SkRect& dstRect, GrAAType aaType, SkCanvas::SrcRectConstraint constraint, - const SkMatrix& viewMatrix, sk_sp csxf, - bool allowSRBInputs) { + const SkMatrix& viewMatrix, + sk_sp csxf) { return std::unique_ptr(new TextureOp(std::move(proxy), filter, color, srcRect, dstRect, aaType, constraint, viewMatrix, - std::move(csxf), allowSRBInputs)); + std::move(csxf))); } ~TextureOp() override { @@ -644,7 +644,6 @@ public: SkString dumpInfo() const override { SkString str; - str.appendf("AllowSRGBInputs: %d\n", fAllowSRGBInputs); str.appendf("# draws: %d\n", fDraws.count()); auto proxies = this->proxies(); for (int i = 0; i < fProxyCnt; ++i) { @@ -699,15 +698,14 @@ __attribute__((no_sanitize("float-cast-overflow"))) TextureOp(sk_sp proxy, GrSamplerState::Filter filter, GrColor color, const SkRect& srcRect, const SkRect& dstRect, GrAAType aaType, SkCanvas::SrcRectConstraint constraint, const SkMatrix& viewMatrix, - sk_sp csxf, bool allowSRGBInputs) + sk_sp csxf) : INHERITED(ClassID()) , fColorSpaceXform(std::move(csxf)) , fProxy0(proxy.release()) , fFilter0(filter) , fProxyCnt(1) , fAAType(static_cast(aaType)) - , fFinalized(0) - , fAllowSRGBInputs(allowSRGBInputs ? 1 : 0) { + , fFinalized(0) { SkASSERT(aaType != GrAAType::kMixedSamples); fPerspective = viewMatrix.hasPerspective(); auto quad = GrPerspQuad(dstRect, viewMatrix); @@ -772,9 +770,6 @@ __attribute__((no_sanitize("float-cast-overflow"))) args.fCaps = &target->caps(); args.fResourceProvider = target->resourceProvider(); args.fFlags = 0; - if (fAllowSRGBInputs) { - args.fFlags |= GrPipeline::kAllowSRGBInputs_Flag; - } if (GrAAType::kMSAA == this->aaType()) { args.fFlags |= GrPipeline::kHWAntialias_Flag; } @@ -1025,7 +1020,6 @@ __attribute__((no_sanitize("float-cast-overflow"))) unsigned fDomain : 1; // Used to track whether fProxy is ref'ed or has a pending IO after finalize() is called. unsigned fFinalized : 1; - unsigned fAllowSRGBInputs : 1; typedef GrMeshDrawOp INHERITED; }; @@ -1040,10 +1034,9 @@ namespace GrTextureOp { std::unique_ptr Make(sk_sp proxy, GrSamplerState::Filter filter, GrColor color, const SkRect& srcRect, const SkRect& dstRect, GrAAType aaType, SkCanvas::SrcRectConstraint constraint, - const SkMatrix& viewMatrix, sk_sp csxf, - bool allowSRGBInputs) { + const SkMatrix& viewMatrix, sk_sp csxf) { return TextureOp::Make(std::move(proxy), filter, color, srcRect, dstRect, aaType, constraint, - viewMatrix, std::move(csxf), allowSRGBInputs); + viewMatrix, std::move(csxf)); } } // namespace GrTextureOp @@ -1075,7 +1068,6 @@ GR_DRAW_OP_TEST_DEFINE(TextureOp) { GrSamplerState::Filter filter = (GrSamplerState::Filter)random->nextULessThan( static_cast(GrSamplerState::Filter::kMipMap) + 1); auto csxf = GrTest::TestColorXform(random); - bool allowSRGBInputs = random->nextBool(); GrAAType aaType = GrAAType::kNone; if (random->nextBool()) { aaType = (fsaaType == GrFSAAType::kUnifiedMSAA) ? GrAAType::kMSAA : GrAAType::kCoverage; @@ -1083,7 +1075,7 @@ GR_DRAW_OP_TEST_DEFINE(TextureOp) { auto constraint = random->nextBool() ? SkCanvas::kStrict_SrcRectConstraint : SkCanvas::kFast_SrcRectConstraint; return GrTextureOp::Make(std::move(proxy), filter, color, srcRect, rect, aaType, constraint, - viewMatrix, std::move(csxf), allowSRGBInputs); + viewMatrix, std::move(csxf)); } #endif diff --git a/src/gpu/ops/GrTextureOp.h b/src/gpu/ops/GrTextureOp.h index d61b36e978..e99bd0a839 100644 --- a/src/gpu/ops/GrTextureOp.h +++ b/src/gpu/ops/GrTextureOp.h @@ -28,5 +28,5 @@ namespace GrTextureOp { std::unique_ptr Make(sk_sp, GrSamplerState::Filter, GrColor, const SkRect& srcRect, const SkRect& dstRect, GrAAType, SkCanvas::SrcRectConstraint, const SkMatrix& viewMatrix, - sk_sp, bool allowSRGBInputs); + sk_sp); } diff --git a/src/gpu/text/GrAtlasManager.cpp b/src/gpu/text/GrAtlasManager.cpp index e9737cc045..f75224d0bc 100644 --- a/src/gpu/text/GrAtlasManager.cpp +++ b/src/gpu/text/GrAtlasManager.cpp @@ -71,14 +71,14 @@ GrAtlasManager::GrAtlasManager(GrProxyProvider* proxyProvider, GrGlyphCache* gly GrAtlasManager::~GrAtlasManager() { } -static GrPixelConfig mask_format_to_pixel_config(GrMaskFormat format, const GrCaps& caps) { +static GrPixelConfig mask_format_to_pixel_config(GrMaskFormat format) { switch (format) { case kA8_GrMaskFormat: return kAlpha_8_GrPixelConfig; case kA565_GrMaskFormat: return kRGB_565_GrPixelConfig; case kARGB_GrMaskFormat: - return caps.srgbSupport() ? kSRGBA_8888_GrPixelConfig : kRGBA_8888_GrPixelConfig; + return kRGBA_8888_GrPixelConfig; default: SkDEBUGFAIL("unsupported GrMaskFormat"); return kAlpha_8_GrPixelConfig; @@ -208,7 +208,7 @@ void GrAtlasManager::setAtlasSizes_ForTesting(const GrDrawOpAtlasConfig configs[ bool GrAtlasManager::initAtlas(GrMaskFormat format) { int index = MaskFormatToAtlasIndex(format); if (!fAtlases[index]) { - GrPixelConfig config = mask_format_to_pixel_config(format, *fCaps); + GrPixelConfig config = mask_format_to_pixel_config(format); int width = fAtlasConfigs[index].fWidth; int height = fAtlasConfigs[index].fHeight; int numPlotsX = fAtlasConfigs[index].numPlotsX(); diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp index 76a1417ff8..602e9e14e7 100644 --- a/src/gpu/vk/GrVkCaps.cpp +++ b/src/gpu/vk/GrVkCaps.cpp @@ -29,7 +29,6 @@ GrVkCaps::GrVkCaps(const GrContextOptions& contextOptions, const GrVkInterface* **************************************************************************/ fMipMapSupport = true; // always available in Vulkan fSRGBSupport = true; // always available in Vulkan - fSRGBDecodeDisableSupport = true; // always available in Vulkan fNPOTTextureTileSupport = true; // always available in Vulkan fDiscardRenderTargetSupport = true; fReuseScratchTextures = true; //TODO: figure this out @@ -477,15 +476,13 @@ void GrVkCaps::ConfigInfo::initSampleCounts(const GrVkInterface* interface, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; - VkImageCreateFlags createFlags = GrVkFormatIsSRGB(format, nullptr) - ? VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT : 0; VkImageFormatProperties properties; GR_VK_CALL(interface, GetPhysicalDeviceImageFormatProperties(physDev, format, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL, usage, - createFlags, + 0, // createFlags &properties)); VkSampleCountFlags flags = properties.sampleCounts; if (flags & VK_SAMPLE_COUNT_1_BIT) { diff --git a/src/gpu/vk/GrVkCopyManager.cpp b/src/gpu/vk/GrVkCopyManager.cpp index c105922fc1..28ca8b411c 100644 --- a/src/gpu/vk/GrVkCopyManager.cpp +++ b/src/gpu/vk/GrVkCopyManager.cpp @@ -262,7 +262,7 @@ bool GrVkCopyManager::copySurfaceAsDraw(GrVkGpu* gpu, VkDescriptorImageInfo imageInfo; memset(&imageInfo, 0, sizeof(VkDescriptorImageInfo)); imageInfo.sampler = sampler->sampler(); - imageInfo.imageView = srcTex->textureView(true)->imageView(); + imageInfo.imageView = srcTex->textureView()->imageView(); imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; VkWriteDescriptorSet writeInfo; @@ -353,7 +353,7 @@ bool GrVkCopyManager::copySurfaceAsDraw(GrVkGpu* gpu, // One sampler, texture view, and texture SkSTArray<3, const GrVkResource*> descriptorResources; descriptorResources.push_back(sampler); - descriptorResources.push_back(srcTex->textureView(true)); + descriptorResources.push_back(srcTex->textureView()); descriptorResources.push_back(srcTex->resource()); cmdBuffer->bindDescriptorSets(gpu, diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index 2525c5c16c..772a92fef2 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -1213,14 +1213,10 @@ bool GrVkGpu::createTestingOnlyVkImage(GrPixelConfig config, int w, int h, bool mipLevels = SkMipMap::ComputeLevelCount(w, h) + 1; } - // sRGB format images may need to be aliased to linear for various reasons (legacy mode): - VkImageCreateFlags createFlags = GrVkFormatIsSRGB(pixelFormat, nullptr) - ? VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT : 0; - const VkImageCreateInfo imageCreateInfo = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // sType nullptr, // pNext - createFlags, // VkImageCreateFlags + 0, // VkImageCreateFlags VK_IMAGE_TYPE_2D, // VkImageType pixelFormat, // VkFormat {(uint32_t)w, (uint32_t)h, 1}, // VkExtent3D diff --git a/src/gpu/vk/GrVkImage.cpp b/src/gpu/vk/GrVkImage.cpp index 9480a7b9cc..a99134b744 100644 --- a/src/gpu/vk/GrVkImage.cpp +++ b/src/gpu/vk/GrVkImage.cpp @@ -136,14 +136,10 @@ bool GrVkImage::InitImageInfo(const GrVkGpu* gpu, const ImageDesc& imageDesc, Gr SkASSERT(VK_IMAGE_TILING_OPTIMAL == imageDesc.fImageTiling || VK_SAMPLE_COUNT_1_BIT == vkSamples); - // sRGB format images may need to be aliased to linear for various reasons (legacy mode): - VkImageCreateFlags createFlags = GrVkFormatIsSRGB(imageDesc.fFormat, nullptr) - ? VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT : 0; - const VkImageCreateInfo imageCreateInfo = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // sType nullptr, // pNext - createFlags, // VkImageCreateFlags + 0, // VkImageCreateFlags imageDesc.fImageType, // VkImageType imageDesc.fFormat, // VkFormat { imageDesc.fWidth, imageDesc.fHeight, 1 }, // VkExtent3D diff --git a/src/gpu/vk/GrVkPipelineState.cpp b/src/gpu/vk/GrVkPipelineState.cpp index 10e757e3c9..5d4189fca0 100644 --- a/src/gpu/vk/GrVkPipelineState.cpp +++ b/src/gpu/vk/GrVkPipelineState.cpp @@ -281,7 +281,7 @@ void GrVkPipelineState::setData(GrVkGpu* gpu, fSamplerDescriptorSet = gpu->resourceProvider().getSamplerDescriptorSet(fSamplerDSHandle); int samplerDSIdx = GrVkUniformHandler::kSamplerDescSet; fDescriptorSets[samplerDSIdx] = fSamplerDescriptorSet->descriptorSet(); - this->writeSamplers(gpu, textureBindings, pipeline.getAllowSRGBInputs()); + this->writeSamplers(gpu, textureBindings); } if (fNumTexelBuffers) { @@ -372,8 +372,7 @@ void GrVkPipelineState::writeUniformBuffers(const GrVkGpu* gpu) { void GrVkPipelineState::writeSamplers( GrVkGpu* gpu, - const SkTArray& textureBindings, - bool allowSRGBInputs) { + const SkTArray& textureBindings) { SkASSERT(fNumSamplers == textureBindings.count()); for (int i = 0; i < textureBindings.count(); ++i) { @@ -388,7 +387,7 @@ void GrVkPipelineState::writeSamplers( textureResource->ref(); fTextures.push(textureResource); - const GrVkImageView* textureView = texture->textureView(allowSRGBInputs); + const GrVkImageView* textureView = texture->textureView(); textureView->ref(); fTextureViews.push(textureView); diff --git a/src/gpu/vk/GrVkPipelineState.h b/src/gpu/vk/GrVkPipelineState.h index 2794b99d22..4ccd1d6079 100644 --- a/src/gpu/vk/GrVkPipelineState.h +++ b/src/gpu/vk/GrVkPipelineState.h @@ -108,8 +108,7 @@ private: void writeSamplers( GrVkGpu* gpu, - const SkTArray& textureBindings, - bool allowSRGBInputs); + const SkTArray& textureBindings); void writeTexelBuffers( GrVkGpu* gpu, diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp index 116b37eddd..c4c7a8f1e1 100644 --- a/src/gpu/vk/GrVkTexture.cpp +++ b/src/gpu/vk/GrVkTexture.cpp @@ -34,8 +34,7 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu, , GrVkImage(info, std::move(layout), GrBackendObjectOwnership::kOwned) , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, highest_filter_mode(desc.fConfig), mipMapsStatus) - , fTextureView(view) - , fLinearTextureView(nullptr) { + , fTextureView(view) { SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == info.fLevelCount)); this->registerWithCache(budgeted); } @@ -52,8 +51,7 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu, , GrVkImage(info, std::move(layout), ownership) , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, highest_filter_mode(desc.fConfig), mipMapsStatus) - , fTextureView(view) - , fLinearTextureView(nullptr) { + , fTextureView(view) { SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == info.fLevelCount)); this->registerWithCacheWrapped(); } @@ -70,8 +68,7 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu, , GrVkImage(info, layout, ownership) , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, highest_filter_mode(desc.fConfig), mipMapsStatus) - , fTextureView(view) - , fLinearTextureView(nullptr) { + , fTextureView(view) { SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == info.fLevelCount)); } @@ -126,7 +123,6 @@ sk_sp GrVkTexture::MakeWrappedTexture(GrVkGpu* gpu, GrVkTexture::~GrVkTexture() { // either release or abandon should have been called by the owner of this object. SkASSERT(!fTextureView); - SkASSERT(!fLinearTextureView); } void GrVkTexture::onRelease() { @@ -136,11 +132,6 @@ void GrVkTexture::onRelease() { fTextureView = nullptr; } - if (fLinearTextureView) { - fLinearTextureView->unref(this->getVkGpu()); - fLinearTextureView = nullptr; - } - this->releaseImage(this->getVkGpu()); INHERITED::onRelease(); @@ -152,11 +143,6 @@ void GrVkTexture::onAbandon() { fTextureView = nullptr; } - if (fLinearTextureView) { - fLinearTextureView->unrefAndAbandon(); - fLinearTextureView = nullptr; - } - this->abandonImage(); INHERITED::onAbandon(); } @@ -170,20 +156,8 @@ GrVkGpu* GrVkTexture::getVkGpu() const { return static_cast(this->getGpu()); } -const GrVkImageView* GrVkTexture::textureView(bool allowSRGB) { - VkFormat linearFormat; - if (allowSRGB || !GrVkFormatIsSRGB(fInfo.fFormat, &linearFormat)) { - return fTextureView; - } - - if (!fLinearTextureView) { - fLinearTextureView = GrVkImageView::Create(this->getVkGpu(), fInfo.fImage, - linearFormat, GrVkImageView::kColor_Type, - fInfo.fLevelCount); - SkASSERT(fLinearTextureView); - } - - return fLinearTextureView; +const GrVkImageView* GrVkTexture::textureView() { + return fTextureView; } bool GrVkTexture::reallocForMipmap(GrVkGpu* gpu, uint32_t mipLevels) { @@ -243,10 +217,6 @@ bool GrVkTexture::reallocForMipmap(GrVkGpu* gpu, uint32_t mipLevels) { oldResource->unref(gpu); oldView->unref(gpu); - if (fLinearTextureView) { - fLinearTextureView->unref(gpu); - fLinearTextureView = nullptr; - } this->setNewResource(info.fImage, info.fAlloc, info.fImageTiling); fTextureView = textureView; diff --git a/src/gpu/vk/GrVkTexture.h b/src/gpu/vk/GrVkTexture.h index 55239e3903..91ed671c12 100644 --- a/src/gpu/vk/GrVkTexture.h +++ b/src/gpu/vk/GrVkTexture.h @@ -33,7 +33,7 @@ public: void textureParamsModified() override {} - const GrVkImageView* textureView(bool allowSRGB); + const GrVkImageView* textureView(); bool reallocForMipmap(GrVkGpu* gpu, uint32_t mipLevels); @@ -67,7 +67,6 @@ private: GrBackendObjectOwnership); const GrVkImageView* fTextureView; - const GrVkImageView* fLinearTextureView; typedef GrTexture INHERITED; }; diff --git a/src/gpu/vk/GrVkUtil.cpp b/src/gpu/vk/GrVkUtil.cpp index e61d7bca17..2b0bba732d 100644 --- a/src/gpu/vk/GrVkUtil.cpp +++ b/src/gpu/vk/GrVkUtil.cpp @@ -167,105 +167,6 @@ bool GrVkFormatIsSupported(VkFormat format) { } } -bool GrVkFormatIsSRGB(VkFormat format, VkFormat* linearFormat) { - VkFormat linearFmt = format; - switch (format) { - case VK_FORMAT_R8_SRGB: - linearFmt = VK_FORMAT_R8_UNORM; - break; - case VK_FORMAT_R8G8_SRGB: - linearFmt = VK_FORMAT_R8G8_UNORM; - break; - case VK_FORMAT_R8G8B8_SRGB: - linearFmt = VK_FORMAT_R8G8B8_UNORM; - break; - case VK_FORMAT_B8G8R8_SRGB: - linearFmt = VK_FORMAT_B8G8R8_UNORM; - break; - case VK_FORMAT_R8G8B8A8_SRGB: - linearFmt = VK_FORMAT_R8G8B8A8_UNORM; - break; - case VK_FORMAT_B8G8R8A8_SRGB: - linearFmt = VK_FORMAT_B8G8R8A8_UNORM; - break; - case VK_FORMAT_A8B8G8R8_SRGB_PACK32: - linearFmt = VK_FORMAT_A8B8G8R8_UNORM_PACK32; - break; - case VK_FORMAT_BC1_RGB_SRGB_BLOCK: - linearFmt = VK_FORMAT_BC1_RGB_UNORM_BLOCK; - break; - case VK_FORMAT_BC1_RGBA_SRGB_BLOCK: - linearFmt = VK_FORMAT_BC1_RGBA_UNORM_BLOCK; - break; - case VK_FORMAT_BC2_SRGB_BLOCK: - linearFmt = VK_FORMAT_BC2_UNORM_BLOCK; - break; - case VK_FORMAT_BC3_SRGB_BLOCK: - linearFmt = VK_FORMAT_BC3_UNORM_BLOCK; - break; - case VK_FORMAT_BC7_SRGB_BLOCK: - linearFmt = VK_FORMAT_BC7_UNORM_BLOCK; - break; - case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: - linearFmt = VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; - break; - case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: - linearFmt = VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK; - break; - case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: - linearFmt = VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK; - break; - case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: - linearFmt = VK_FORMAT_ASTC_4x4_UNORM_BLOCK; - break; - case VK_FORMAT_ASTC_5x4_SRGB_BLOCK: - linearFmt = VK_FORMAT_ASTC_5x4_UNORM_BLOCK; - break; - case VK_FORMAT_ASTC_5x5_SRGB_BLOCK: - linearFmt = VK_FORMAT_ASTC_5x5_UNORM_BLOCK; - break; - case VK_FORMAT_ASTC_6x5_SRGB_BLOCK: - linearFmt = VK_FORMAT_ASTC_6x5_UNORM_BLOCK; - break; - case VK_FORMAT_ASTC_6x6_SRGB_BLOCK: - linearFmt = VK_FORMAT_ASTC_6x6_UNORM_BLOCK; - break; - case VK_FORMAT_ASTC_8x5_SRGB_BLOCK: - linearFmt = VK_FORMAT_ASTC_8x5_UNORM_BLOCK; - break; - case VK_FORMAT_ASTC_8x6_SRGB_BLOCK: - linearFmt = VK_FORMAT_ASTC_8x6_UNORM_BLOCK; - break; - case VK_FORMAT_ASTC_8x8_SRGB_BLOCK: - linearFmt = VK_FORMAT_ASTC_8x8_UNORM_BLOCK; - break; - case VK_FORMAT_ASTC_10x5_SRGB_BLOCK: - linearFmt = VK_FORMAT_ASTC_10x5_UNORM_BLOCK; - break; - case VK_FORMAT_ASTC_10x6_SRGB_BLOCK: - linearFmt = VK_FORMAT_ASTC_10x6_UNORM_BLOCK; - break; - case VK_FORMAT_ASTC_10x8_SRGB_BLOCK: - linearFmt = VK_FORMAT_ASTC_10x8_UNORM_BLOCK; - break; - case VK_FORMAT_ASTC_10x10_SRGB_BLOCK: - linearFmt = VK_FORMAT_ASTC_10x10_UNORM_BLOCK; - break; - case VK_FORMAT_ASTC_12x10_SRGB_BLOCK: - linearFmt = VK_FORMAT_ASTC_12x10_UNORM_BLOCK; - break; - case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: - linearFmt = VK_FORMAT_ASTC_12x12_UNORM_BLOCK; - break; - default: - break; - } - if (linearFormat) { - *linearFormat = linearFmt; - } - return (linearFmt != format); -} - bool GrSampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits* vkSamples) { SkASSERT(samples >= 1); switch (samples) { diff --git a/src/gpu/vk/GrVkUtil.h b/src/gpu/vk/GrVkUtil.h index 01688c8486..08eef1a1d0 100644 --- a/src/gpu/vk/GrVkUtil.h +++ b/src/gpu/vk/GrVkUtil.h @@ -44,12 +44,6 @@ bool GrVkFormatIsSupported(VkFormat); */ bool GrVkFormatPixelConfigPairIsValid(VkFormat, GrPixelConfig); -/** - * Returns true if the given vulkan texture format is sRGB encoded. - * Also provides the non-sRGB version, if there is one. - */ -bool GrVkFormatIsSRGB(VkFormat format, VkFormat* linearFormat); - bool GrSampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits* vkSamples); bool GrCompileVkShaderModule(const GrVkGpu* gpu, diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index f961d153e3..ed9021c301 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -841,13 +841,9 @@ sk_sp SkImage::MakeCrossContextFromPixmap(GrContext* context, if (buildMips) { SkBitmap bmp; bmp.installPixels(*pixmap); - proxy = proxyProvider->createMipMapProxyFromBitmap(bmp, dstColorSpace); + proxy = proxyProvider->createMipMapProxyFromBitmap(bmp); } else { - SkDestinationSurfaceColorMode colorMode = dstColorSpace - ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware - : SkDestinationSurfaceColorMode::kLegacy; - - if (SkImageInfoIsValid(pixmap->info(), colorMode)) { + if (SkImageInfoIsValid(pixmap->info())) { ATRACE_ANDROID_FRAMEWORK("Upload Texture [%ux%u]", pixmap->width(), pixmap->height()); // We don't need a release proc on the data in pixmap since we know we are in a // GrContext that has a resource provider. Thus the createTextureProxy call will diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp index 7914f58d3c..254d2685e1 100644 --- a/src/image/SkImage_Lazy.cpp +++ b/src/image/SkImage_Lazy.cpp @@ -812,7 +812,7 @@ sk_sp SkImage_Lazy::lockTextureProxy(GrContext* ctx, // 3. Ask the generator to return YUV planes, which the GPU can convert. If we will be mipping // the texture we fall through here and have the CPU generate the mip maps for us. if (!proxy && !willBeMipped && !ctx->contextPriv().disableGpuYUVConversion()) { - const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(cacheInfo, *ctx->contextPriv().caps()); + const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(cacheInfo); ScopedGenerator generator(fSharedGenerator); Generator_GrYUVProvider provider(generator); @@ -838,10 +838,10 @@ sk_sp SkImage_Lazy::lockTextureProxy(GrContext* ctx, SkBitmap bitmap; if (!proxy && this->lockAsBitmap(&bitmap, chint, format, genPixelsInfo, behavior)) { if (willBeMipped) { - proxy = proxyProvider->createMipMapProxyFromBitmap(bitmap, dstColorSpace); + proxy = proxyProvider->createMipMapProxyFromBitmap(bitmap); } if (!proxy) { - proxy = GrUploadBitmapToTextureProxy(proxyProvider, bitmap, dstColorSpace); + proxy = GrUploadBitmapToTextureProxy(proxyProvider, bitmap); } if (proxy && (!willBeMipped || GrMipMapped::kYes == proxy->mipMapped())) { SK_HISTOGRAM_ENUMERATION("LockTexturePath", kRGBA_LockTexturePath, diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index c20608aac2..8f7958444d 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -269,10 +269,9 @@ bool SkSurface_Gpu::onDraw(const SkDeferredDisplayList* ddl) { bool SkSurface_Gpu::Valid(const SkImageInfo& info) { switch (info.colorType()) { case kRGBA_F16_SkColorType: - return true; case kRGBA_8888_SkColorType: case kBGRA_8888_SkColorType: - return !info.colorSpace() || info.colorSpace()->gammaCloseToSRGB(); + return true; default: return !info.colorSpace(); } @@ -280,18 +279,13 @@ bool SkSurface_Gpu::Valid(const SkImageInfo& info) { bool SkSurface_Gpu::Valid(const GrCaps* caps, GrPixelConfig config, SkColorSpace* colorSpace) { switch (config) { - case kRGBA_half_GrPixelConfig: - return true; case kSRGBA_8888_GrPixelConfig: case kSBGRA_8888_GrPixelConfig: - return caps->srgbSupport() && colorSpace && colorSpace->gammaCloseToSRGB(); + return caps->srgbSupport(); + case kRGBA_half_GrPixelConfig: case kRGBA_8888_GrPixelConfig: case kBGRA_8888_GrPixelConfig: - // We may get here with either a linear-gamma color space or with a sRGB-gamma color - // space when we lack GPU sRGB support. - return !colorSpace || - (colorSpace->gammaCloseToSRGB() && !caps->srgbSupport()) || - colorSpace->gammaIsLinear(); + return true; default: return !colorSpace; } diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp index fd120072f4..a3f69c244f 100644 --- a/src/image/SkSurface_Raster.cpp +++ b/src/image/SkSurface_Raster.cpp @@ -63,9 +63,6 @@ bool SkSurfaceValidateRasterInfo(const SkImageInfo& info, size_t rowBytes) { case kRGBA_8888_SkColorType: case kBGRA_8888_SkColorType: - if (info.colorSpace() && !info.colorSpace()->gammaCloseToSRGB()) { - return false; - } break; case kRGBA_F16_SkColorType: break; diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp index bd1b17f029..e0dd512f07 100644 --- a/src/shaders/SkImageShader.cpp +++ b/src/shaders/SkImageShader.cpp @@ -117,8 +117,7 @@ SkShaderBase::Context* SkImageShader::onMakeContext(const ContextRec& rec, } return SkBitmapProcLegacyShader::MakeContext(*this, fTileModeX, fTileModeY, - SkBitmapProvider(fImage.get(), rec.fDstColorSpace), - rec, alloc); + SkBitmapProvider(fImage.get()), rec, alloc); } SkImage* SkImageShader::onIsAImage(SkMatrix* texM, TileMode xy[]) const { @@ -285,7 +284,7 @@ bool SkImageShader::onAppendStages(const StageRec& rec) const { } auto quality = rec.fPaint.getFilterQuality(); - SkBitmapProvider provider(fImage.get(), rec.fDstCS); + SkBitmapProvider provider(fImage.get()); SkDefaultBitmapController controller; std::unique_ptr state { controller.requestBitmap(provider, matrix, quality) diff --git a/src/shaders/gradients/SkGradientShader.cpp b/src/shaders/gradients/SkGradientShader.cpp index a574b7d46d..4c6a42571a 100644 --- a/src/shaders/gradients/SkGradientShader.cpp +++ b/src/shaders/gradients/SkGradientShader.cpp @@ -1288,7 +1288,7 @@ GrGradientEffect::GrGradientEffect(ClassID classID, const CreateArgs& args, bool desc.fWidth = bitmap.width(); desc.fHeight = 32; desc.fRowHeight = bitmap.height(); // always 1 here - desc.fConfig = SkImageInfo2GrPixelConfig(bitmap.info(), *caps); + desc.fConfig = SkColorType2GrPixelConfig(bitmap.colorType()); fAtlas = atlasManager->refAtlas(desc); SkASSERT(fAtlas); diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index 6910ab5b33..81fb21fa32 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -252,9 +252,6 @@ static void set_random_state(GrPaint* paint, SkRandom* random) { if (random->nextBool()) { paint->setDisableOutputConversionToSRGB(true); } - if (random->nextBool()) { - paint->setAllowSRGBInputs(true); - } } #endif diff --git a/tests/GrContextFactoryTest.cpp b/tests/GrContextFactoryTest.cpp index 92801eba83..b05f2e29ce 100644 --- a/tests/GrContextFactoryTest.cpp +++ b/tests/GrContextFactoryTest.cpp @@ -47,28 +47,6 @@ DEF_GPUTEST(GrContextFactory_NoPathRenderingIfNVPRDisabled, reporter, options) { } } -DEF_GPUTEST(GrContextFactory_RequiredSRGBSupport, reporter, options) { - // Test that if sRGB support is requested, the context always has that capability - // or the context creation fails. Also test that if the creation fails, a context - // created without that flag would not have had sRGB support. - for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) { - GrContextFactory testFactory(options); - // Test that if sRGB is requested, caps are in sync. - GrContextFactory::ContextType ctxType = static_cast(i); - GrContext* context = - testFactory.get(ctxType, GrContextFactory::ContextOverrides::kRequireSRGBSupport); - - if (context) { - REPORTER_ASSERT(reporter, context->contextPriv().caps()->srgbSupport()); - } else { - context = testFactory.get(ctxType); - if (context) { - REPORTER_ASSERT(reporter, !context->contextPriv().caps()->srgbSupport()); - } - } - } -} - DEF_GPUTEST(GrContextFactory_abandon, reporter, options) { for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) { GrContextFactory testFactory(options); diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp index 9d0394839e..930d7c0c86 100644 --- a/tests/ImageTest.cpp +++ b/tests/ImageTest.cpp @@ -485,7 +485,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsImage, reporter bool can = ctxInfo.grContext()->colorTypeSupportedAsImage(colorType); auto* gpu = ctxInfo.grContext()->contextPriv().getGpu(); GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( - nullptr, kSize, kSize, colorType, nullptr, false, GrMipMapped::kNo); + nullptr, kSize, kSize, colorType, false, GrMipMapped::kNo); auto img = SkImage::MakeFromTexture(ctxInfo.grContext(), backendTex, kTopLeft_GrSurfaceOrigin, colorType, kOpaque_SkAlphaType, nullptr); diff --git a/tests/MipMapTest.cpp b/tests/MipMapTest.cpp index 7e0a653c1e..938e723456 100644 --- a/tests/MipMapTest.cpp +++ b/tests/MipMapTest.cpp @@ -23,7 +23,7 @@ DEF_TEST(MipMap, reporter) { int width = 1 + rand.nextU() % 1000; int height = 1 + rand.nextU() % 1000; make_bitmap(&bm, width, height); - sk_sp mm(SkMipMap::Build(bm, SkDestinationSurfaceColorMode::kLegacy, nullptr)); + sk_sp mm(SkMipMap::Build(bm, nullptr)); REPORTER_ASSERT(reporter, mm->countLevels() == SkMipMap::ComputeLevelCount(width, height)); REPORTER_ASSERT(reporter, !mm->extractLevel(SkSize::Make(SK_Scalar1, SK_Scalar1), @@ -60,7 +60,7 @@ static void test_mipmap_generation(int width, int height, int expectedMipLevelCo SkBitmap bm; bm.allocN32Pixels(width, height); bm.eraseColor(SK_ColorWHITE); - sk_sp mm(SkMipMap::Build(bm, SkDestinationSurfaceColorMode::kLegacy, nullptr)); + sk_sp mm(SkMipMap::Build(bm, nullptr)); const int mipLevelCount = mm->countLevels(); REPORTER_ASSERT(reporter, mipLevelCount == expectedMipLevelCount); @@ -90,7 +90,7 @@ DEF_TEST(MipMap_DirectLevelAccess, reporter) { SkBitmap bm; bm.allocN32Pixels(1, 1); bm.eraseColor(SK_ColorWHITE); - sk_sp mm(SkMipMap::Build(bm, SkDestinationSurfaceColorMode::kLegacy, nullptr)); + sk_sp mm(SkMipMap::Build(bm, nullptr)); REPORTER_ASSERT(reporter, mm == nullptr); } diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp index e980e9928a..463e44f194 100644 --- a/tests/OnFlushCallbackTest.cpp +++ b/tests/OnFlushCallbackTest.cpp @@ -477,7 +477,7 @@ sk_sp pre_create_atlas(GrContext* context) { save_bm(bm, "atlas-fake.png"); #endif - GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bm.info(), *context->caps()); + GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bm.info()); desc.fFlags |= kRenderTarget_GrSurfaceFlag; sk_sp tmp = GrSurfaceProxy::MakeDeferred(*context->caps(), diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp index 19e05989ae..a1f8b8b234 100644 --- a/tests/ProxyTest.cpp +++ b/tests/ProxyTest.cpp @@ -223,7 +223,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { } for (auto numSamples : {1, 4}) { - GrPixelConfig config = SkImageInfo2GrPixelConfig(colorType, nullptr, caps); + GrPixelConfig config = SkColorType2GrPixelConfig(colorType); SkASSERT(kUnknown_GrPixelConfig != config); int supportedNumSamples = caps.getRenderTargetSampleCount(numSamples, config); @@ -253,7 +253,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { { GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(nullptr, kWidthHeight, - kWidthHeight, colorType, nullptr, + kWidthHeight, colorType, true, GrMipMapped::kNo); sk_sp sProxy = proxyProvider->wrapBackendTextureAsRenderTarget( backendTex, origin, supportedNumSamples); @@ -277,7 +277,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { { GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(nullptr, kWidthHeight, - kWidthHeight, colorType, nullptr, + kWidthHeight, colorType, true, GrMipMapped::kNo); sk_sp sProxy = proxyProvider->wrapRenderableBackendTexture( @@ -303,7 +303,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { // Internal offscreen texture GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(nullptr, kWidthHeight, - kWidthHeight, colorType, nullptr, + kWidthHeight, colorType, false, GrMipMapped::kNo); sk_sp sProxy = proxyProvider->wrapBackendTexture( diff --git a/tests/SRGBMipMapTest.cpp b/tests/SRGBMipMapTest.cpp deleted file mode 100644 index ac7b5cc0b7..0000000000 --- a/tests/SRGBMipMapTest.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright 2016 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "Test.h" -#include "GrCaps.h" -#include "GrClip.h" -#include "GrContext.h" -#include "GrContextPriv.h" -#include "GrProxyProvider.h" -#include "GrRenderTargetContext.h" -#include "SkCanvas.h" -#include "SkGr.h" -#include "SkSurface.h" -#include "gl/GrGLGpu.h" - -// using anonymous namespace because these functions are used as template params. -namespace { -/** convert 0..1 srgb value to 0..1 linear */ -float srgb_to_linear(float srgb) { - if (srgb <= 0.04045f) { - return srgb / 12.92f; - } else { - return powf((srgb + 0.055f) / 1.055f, 2.4f); - } -} - -/** convert 0..1 linear value to 0..1 srgb */ -float linear_to_srgb(float linear) { - if (linear <= 0.0031308) { - return linear * 12.92f; - } else { - return 1.055f * powf(linear, 1.f / 2.4f) - 0.055f; - } -} -} - -static bool check_value(U8CPU value, U8CPU expected, U8CPU error) { - if (value >= expected) { - return (value - expected) <= error; - } else { - return (expected - value) <= error; - } -} - -void read_and_check_pixels(skiatest::Reporter* reporter, GrSurfaceContext* context, - U8CPU expected, const SkImageInfo& dstInfo, - U8CPU error, const char* subtestName) { - int w = dstInfo.width(); - int h = dstInfo.height(); - SkAutoTMalloc readData(w * h); - memset(readData.get(), 0, sizeof(uint32_t) * w * h); - - if (!context->readPixels(dstInfo, readData.get(), 0, 0, 0)) { - ERRORF(reporter, "Could not read pixels for %s.", subtestName); - return; - } - - for (int j = 0; j < h; ++j) { - for (int i = 0; i < w; ++i) { - uint32_t read = readData[j * w + i]; - - bool success = - check_value(read & 0xff, expected, error) && - check_value((read >> 8) & 0xff, expected, error) && - check_value((read >> 16) & 0xff, expected, error); - - if (!success) { - ERRORF(reporter, "Expected 0xff%02x%02x%02x, read back as 0x%08x in %s at %d, %d.", - expected, expected, expected, read, subtestName, i, j); - return; - } - } - } -} - -DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SRGBMipMaps, reporter, ctxInfo) { - GrContext* context = ctxInfo.grContext(); - if (!context->contextPriv().caps()->srgbSupport()) { - return; - } - - const int rtS = 16; - const int texS = rtS * 2; - - // Fill texture with a dither of black and 60% sRGB (~ 32.5% linear) gray. Although there is - // only one likely failure mode (doing a direct downsample of the sRGB values), this pattern - // maximizes the minimum error across all three conceivable failure modes: - // 1) Likely incorrect: - // (A + B) / 2 - // 2) No input decode, decode output: - // linear_to_srgb((A + B) / 2) - // 3) Decode input, no output encode: - // (srgb_to_linear(A) + srgb_to_linear(B)) / 2 - - const U8CPU srgb60 = sk_float_round2int(0.6f * 255.0f); - static const SkPMColor colors[2] = { - SkPackARGB32(0xFF, srgb60, srgb60, srgb60), - SkPackARGB32(0xFF, 0x00, 0x00, 0x00) - }; - uint32_t texData[texS * texS]; - for (int y = 0; y < texS; ++y) { - for (int x = 0; x < texS; ++x) { - texData[y * texS + x] = colors[(x + y) % 2]; - } - } - - // We can be pretty generous with the error detection, thanks to the choice of input. - // The closest likely failure mode is off by > 0.1, so anything that encodes within - // 10/255 of optimal is more than good enough for this test. - const U8CPU expectedSRGB = sk_float_round2int( - linear_to_srgb(srgb_to_linear(srgb60 / 255.0f) / 2.0f) * 255.0f); - const U8CPU expectedLinear = srgb60 / 2; - const U8CPU error = 10; - - const SkImageInfo iiSRGBA = SkImageInfo::Make(rtS, rtS, kRGBA_8888_SkColorType, - kPremul_SkAlphaType, - SkColorSpace::MakeSRGB()); - const SkImageInfo iiRGBA = SkImageInfo::Make(rtS, rtS, kRGBA_8888_SkColorType, - kPremul_SkAlphaType); - - // Create our test texture - GrSurfaceDesc desc; - desc.fFlags = kNone_GrSurfaceFlags; - desc.fWidth = texS; - desc.fHeight = texS; - desc.fConfig = kSRGBA_8888_GrPixelConfig; - - GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider(); - sk_sp proxy = - proxyProvider->createTextureProxy(desc, SkBudgeted::kNo, texData, 0); - - // Create two render target contexts (L32 and S32) - sk_sp srgbColorSpace = SkColorSpace::MakeSRGB(); - sk_sp l32RenderTargetContext = - context->contextPriv().makeDeferredRenderTargetContext( - SkBackingFit::kExact, rtS, rtS, - kRGBA_8888_GrPixelConfig, nullptr); - sk_sp s32RenderTargetContext = - context->contextPriv().makeDeferredRenderTargetContext( - SkBackingFit::kExact, rtS, rtS, - kSRGBA_8888_GrPixelConfig, std::move(srgbColorSpace)); - - SkRect rect = SkRect::MakeWH(SkIntToScalar(rtS), SkIntToScalar(rtS)); - GrNoClip noClip; - GrPaint paint; - paint.setPorterDuffXPFactory(SkBlendMode::kSrc); - GrSamplerState mipMapSamplerState(GrSamplerState::WrapMode::kRepeat, - GrSamplerState::Filter::kMipMap); - paint.addColorTextureProcessor(std::move(proxy), SkMatrix::MakeScale(rtS), mipMapSamplerState); - - // 1) Draw texture to S32 surface (should generate/use sRGB mips) - paint.setGammaCorrect(true); - s32RenderTargetContext->drawRect(noClip, GrPaint::Clone(paint), GrAA::kNo, SkMatrix::I(), rect); - read_and_check_pixels(reporter, s32RenderTargetContext.get(), expectedSRGB, iiSRGBA, error, - "first render of sRGB"); - - // 2) Draw texture to L32 surface (should generate/use linear mips) - paint.setGammaCorrect(false); - l32RenderTargetContext->drawRect(noClip, GrPaint::Clone(paint), GrAA::kNo, SkMatrix::I(), rect); - - // Right now, this test only runs on GL (because Vulkan doesn't support legacy mip-mapping - // skbug.com/5048). On GL, we may not have sRGB decode support. In that case, rendering sRGB - // textures to a legacy surface produces nonsense, so this part of the test is meaningless. - // - // We also skip this part of the test on command buffer (via srgbDecodeDisableAffectsMipmaps), - // because that implementation of the extension doesn't ensure that mips respect the setting. - // - // TODO: Once Vulkan supports legacy mip-mapping, we can promote this to GrCaps. Right now, - // Vulkan has most of the functionality, but not the mip-mapping part that's being tested here. - GrGLGpu* glGpu = static_cast(context->contextPriv().getGpu()); - if (glGpu->glCaps().srgbDecodeDisableSupport() && - glGpu->glCaps().srgbDecodeDisableAffectsMipmaps()) { - read_and_check_pixels(reporter, l32RenderTargetContext.get(), expectedLinear, iiRGBA, - error, "re-render as linear"); - } - - // 3) Go back to sRGB - paint.setGammaCorrect(true); - s32RenderTargetContext->drawRect(noClip, std::move(paint), GrAA::kNo, SkMatrix::I(), rect); - read_and_check_pixels(reporter, s32RenderTargetContext.get(), expectedSRGB, iiSRGBA, error, - "re-render as sRGB"); -} diff --git a/tests/SkResourceCacheTest.cpp b/tests/SkResourceCacheTest.cpp index 02b75dd8c9..341eb073a9 100644 --- a/tests/SkResourceCacheTest.cpp +++ b/tests/SkResourceCacheTest.cpp @@ -44,18 +44,14 @@ static void test_mipmapcache(skiatest::Reporter* reporter, SkResourceCache* cach src.allocN32Pixels(5, 5); src.setImmutable(); - const SkDestinationSurfaceColorMode colorMode = SkDestinationSurfaceColorMode::kLegacy; - - const SkMipMap* mipmap = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src), colorMode, - cache); + const SkMipMap* mipmap = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src), cache); REPORTER_ASSERT(reporter, nullptr == mipmap); - mipmap = SkMipMapCache::AddAndRef(src, colorMode, cache); + mipmap = SkMipMapCache::AddAndRef(src, cache); REPORTER_ASSERT(reporter, mipmap); { - const SkMipMap* mm = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src), colorMode, - cache); + const SkMipMap* mm = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src), cache); REPORTER_ASSERT(reporter, mm); REPORTER_ASSERT(reporter, mm == mipmap); mm->unref(); @@ -69,7 +65,7 @@ static void test_mipmapcache(skiatest::Reporter* reporter, SkResourceCache* cach check_data(reporter, mipmap, 1, kInCache, kNotLocked); // find us again - mipmap = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src), colorMode, cache); + mipmap = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src), cache); check_data(reporter, mipmap, 2, kInCache, kLocked); cache->purgeAll(); @@ -79,19 +75,18 @@ static void test_mipmapcache(skiatest::Reporter* reporter, SkResourceCache* cach } static void test_mipmap_notify(skiatest::Reporter* reporter, SkResourceCache* cache) { - const SkDestinationSurfaceColorMode colorMode = SkDestinationSurfaceColorMode::kLegacy; const int N = 3; SkBitmap src[N]; for (int i = 0; i < N; ++i) { src[i].allocN32Pixels(5, 5); src[i].setImmutable(); - SkMipMapCache::AddAndRef(src[i], colorMode, cache)->unref(); + SkMipMapCache::AddAndRef(src[i], cache)->unref(); } for (int i = 0; i < N; ++i) { const auto desc = SkBitmapCacheDesc::Make(src[i]); - const SkMipMap* mipmap = SkMipMapCache::FindAndRef(desc, colorMode, cache); + const SkMipMap* mipmap = SkMipMapCache::FindAndRef(desc, cache); if (cache) { // if cache is null, we're working on the global cache, and other threads might purge // it, making this check fragile. @@ -101,7 +96,7 @@ static void test_mipmap_notify(skiatest::Reporter* reporter, SkResourceCache* ca src[i].reset(); // delete the underlying pixelref, which *should* remove us from the cache - mipmap = SkMipMapCache::FindAndRef(desc, colorMode, cache); + mipmap = SkMipMapCache::FindAndRef(desc, cache); REPORTER_ASSERT(reporter, !mipmap); } } diff --git a/tests/SpecialImageTest.cpp b/tests/SpecialImageTest.cpp index b2f8743b0e..d2549c4bbb 100644 --- a/tests/SpecialImageTest.cpp +++ b/tests/SpecialImageTest.cpp @@ -231,8 +231,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_MakeTexture, reporter, ctxInfo) { // gpu - const GrSurfaceDesc desc = - GrImageInfoToSurfaceDesc(bm.info(), *context->contextPriv().caps()); + const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bm.info()); sk_sp proxy = proxyProvider->createTextureProxy( desc, SkBudgeted::kNo, bm.getPixels(), bm.rowBytes()); @@ -265,7 +264,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, ctxInfo) { GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider(); SkBitmap bm = create_bm(); - const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bm.info(), *context->contextPriv().caps()); + const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bm.info()); sk_sp proxy = proxyProvider->createTextureProxy(desc, SkBudgeted::kNo, bm.getPixels(), bm.rowBytes()); diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index bb5291cbb3..9a3a3aae6d 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -101,7 +101,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsSurface, report auto* gpu = ctxInfo.grContext()->contextPriv().getGpu(); GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( - nullptr, kSize, kSize, colorType, nullptr, true, GrMipMapped::kNo); + nullptr, kSize, kSize, colorType, true, GrMipMapped::kNo); surf = SkSurface::MakeFromBackendTexture(ctxInfo.grContext(), backendTex, kTopLeft_GrSurfaceOrigin, 0, colorType, nullptr, nullptr); @@ -128,8 +128,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsSurface, report REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d", colorType, can, SkToBool(surf)); - backendTex = gpu->createTestingOnlyBackendTexture(nullptr, kSize, kSize, colorType, nullptr, - true, GrMipMapped::kNo); + backendTex = gpu->createTestingOnlyBackendTexture(nullptr, kSize, kSize, colorType, true, + GrMipMapped::kNo); surf = SkSurface::MakeFromBackendTexture(ctxInfo.grContext(), backendTex, kTopLeft_GrSurfaceOrigin, kSampleCnt, colorType, nullptr, nullptr); @@ -182,7 +182,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_maxSurfaceSamplesForColorType, repo } auto* gpu = ctxInfo.grContext()->contextPriv().getGpu(); GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( - nullptr, kSize, kSize, colorType, nullptr, true, GrMipMapped::kNo); + nullptr, kSize, kSize, colorType, true, GrMipMapped::kNo); if (!backendTex.isValid()) { continue; } @@ -915,9 +915,9 @@ static void test_surface_creation_and_snapshot_with_color_space( const char* fDescription; } testConfigs[] = { { kN32_SkColorType, nullptr, true, "N32-nullptr" }, - { kN32_SkColorType, linearColorSpace, false, "N32-linear" }, + { kN32_SkColorType, linearColorSpace, true, "N32-linear" }, { kN32_SkColorType, srgbColorSpace, true, "N32-srgb" }, - { kN32_SkColorType, oddColorSpace, false, "N32-odd" }, + { kN32_SkColorType, oddColorSpace, true, "N32-odd" }, { kRGBA_F16_SkColorType, nullptr, true, "F16-nullptr" }, { kRGBA_F16_SkColorType, linearColorSpace, true, "F16-linear" }, { kRGBA_F16_SkColorType, srgbColorSpace, true, "F16-srgb" }, @@ -978,7 +978,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCreationWithColorSpace_Gpu, reporter, GrGpu* gpu = context->contextPriv().getGpu(); static const int kSize = 10; - GrPixelConfig config = SkImageInfo2GrPixelConfig(info, *context->contextPriv().caps()); + GrPixelConfig config = SkImageInfo2GrPixelConfig(info); SkASSERT(kUnknown_GrPixelConfig != config); GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( diff --git a/tools/DDLPromiseImageHelper.cpp b/tools/DDLPromiseImageHelper.cpp index 43a2546f0e..586c2339a6 100644 --- a/tools/DDLPromiseImageHelper.cpp +++ b/tools/DDLPromiseImageHelper.cpp @@ -57,7 +57,6 @@ void DDLPromiseImageHelper::uploadAllToGPU(GrContext* context) { info.fBitmap.width(), info.fBitmap.height(), info.fBitmap.colorType(), - info.fBitmap.colorSpace(), false, GrMipMapped::kNo)); // The GMs sometimes request too large an image //SkAssertResult(callbackContext->backendTexture().isValid()); diff --git a/tools/fiddle/fiddle_main.cpp b/tools/fiddle/fiddle_main.cpp index f000025e6a..526e314220 100644 --- a/tools/fiddle/fiddle_main.cpp +++ b/tools/fiddle/fiddle_main.cpp @@ -164,8 +164,7 @@ static bool setup_backend_objects(GrContext* context, } backingTexture = resourceProvider->createTexture(backingDesc, SkBudgeted::kNo, texels.get(), - mipLevelCount, - SkDestinationSurfaceColorMode::kLegacy); + mipLevelCount); if (!backingTexture) { return false; } @@ -191,8 +190,8 @@ static bool setup_backend_objects(GrContext* context, // We use this fact to initialize it with data but don't allow mipmaps GrMipLevel level0 = { data.get(), backingDesc.fWidth*sizeof(uint32_t) }; - sk_sp tmp = resourceProvider->createTexture( - backingDesc, SkBudgeted::kNo, &level0, 1, SkDestinationSurfaceColorMode::kLegacy); + sk_sp tmp = resourceProvider->createTexture(backingDesc, SkBudgeted::kNo, + &level0, 1); if (!tmp || !tmp->asRenderTarget()) { return false; } @@ -219,9 +218,8 @@ static bool setup_backend_objects(GrContext* context, texels[i].fRowBytes = 0; } - backingTextureRenderTarget = resourceProvider->createTexture( - backingDesc, SkBudgeted::kNo, texels.get(), mipLevelCount, - SkDestinationSurfaceColorMode::kLegacy); + backingTextureRenderTarget = resourceProvider->createTexture(backingDesc, SkBudgeted::kNo, + texels.get(), mipLevelCount); if (!backingTextureRenderTarget || !backingTextureRenderTarget->asRenderTarget()) { return false; } diff --git a/tools/flags/SkCommonFlagsConfig.cpp b/tools/flags/SkCommonFlagsConfig.cpp index ba07ec84c7..0b7a74641c 100644 --- a/tools/flags/SkCommonFlagsConfig.cpp +++ b/tools/flags/SkCommonFlagsConfig.cpp @@ -430,17 +430,6 @@ SkCommandLineConfigGpu::SkCommandLineConfigGpu( // samples and we couldn't test the mixed samples backend for simple shapes. fContextOverrides |= ContextOverrides::kDisableNVPR; } - // Subtle logic: If the config has a color space attached, we're going to be rendering to sRGB, - // so we need that capability. In addition, to get the widest test coverage, we DO NOT require - // that we can disable sRGB decode. (That's for rendering sRGB sources to legacy surfaces). - // - // If the config doesn't have a color space attached, we're going to be rendering in legacy - // mode. In that case, we don't require sRGB capability and we defer to the client to decide on - // sRGB decode control. - if (fColorSpace) { - fContextOverrides |= ContextOverrides::kRequireSRGBSupport; - fContextOverrides |= ContextOverrides::kAllowSRGBWithoutDecodeControl; - } if (!useStencilBuffers) { fContextOverrides |= ContextOverrides::kAvoidStencilBuffers; } diff --git a/tools/gpu/GrContextFactory.cpp b/tools/gpu/GrContextFactory.cpp index 2bfccd9763..54f4742b73 100644 --- a/tools/gpu/GrContextFactory.cpp +++ b/tools/gpu/GrContextFactory.cpp @@ -261,9 +261,6 @@ ContextInfo GrContextFactory::getContextInfoInternal(ContextType type, ContextOv if (ContextOverrides::kDisableNVPR & overrides) { grOptions.fSuppressPathRendering = true; } - if (ContextOverrides::kAllowSRGBWithoutDecodeControl & overrides) { - grOptions.fRequireDecodeDisableForSRGB = false; - } if (ContextOverrides::kAvoidStencilBuffers & overrides) { grOptions.fAvoidStencilBuffers = true; } @@ -280,11 +277,6 @@ ContextInfo GrContextFactory::getContextInfoInternal(ContextType type, ContextOv return ContextInfo(); } } - if (ContextOverrides::kRequireSRGBSupport & overrides) { - if (!grCtx->contextPriv().caps()->srgbSupport()) { - return ContextInfo(); - } - } // We must always add new contexts by pushing to the back so that when we delete them we delete // them in reverse order in which they were made. diff --git a/tools/gpu/GrContextFactory.h b/tools/gpu/GrContextFactory.h index 5f16ea8ca9..471e3fd142 100644 --- a/tools/gpu/GrContextFactory.h +++ b/tools/gpu/GrContextFactory.h @@ -56,11 +56,9 @@ public: enum class ContextOverrides { kNone = 0x0, kDisableNVPR = 0x1, - kAllowSRGBWithoutDecodeControl = 0x2, - kAvoidStencilBuffers = 0x4, + kAvoidStencilBuffers = 0x2, - kRequireNVPRSupport = 0x8, - kRequireSRGBSupport = 0x10, + kRequireNVPRSupport = 0x4, }; static bool IsRenderingContext(ContextType type) { diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp index f3630ff721..14ba7a0035 100644 --- a/tools/gpu/GrTest.cpp +++ b/tools/gpu/GrTest.cpp @@ -165,10 +165,9 @@ void GrGpu::Stats::dumpKeyValuePairs(SkTArray* keys, SkTArray* #endif GrBackendTexture GrGpu::createTestingOnlyBackendTexture(const void* pixels, int w, int h, - SkColorType colorType, - SkColorSpace* cs, bool isRenderTarget, + SkColorType colorType, bool isRenderTarget, GrMipMapped mipMapped) { - GrPixelConfig config = SkImageInfo2GrPixelConfig(colorType, cs, *this->caps()); + GrPixelConfig config = SkColorType2GrPixelConfig(colorType); if (kUnknown_GrPixelConfig == config) { return GrBackendTexture(); } diff --git a/tools/sk_app/VulkanWindowContext.cpp b/tools/sk_app/VulkanWindowContext.cpp index c145fd2410..ad0e15ca7b 100644 --- a/tools/sk_app/VulkanWindowContext.cpp +++ b/tools/sk_app/VulkanWindowContext.cpp @@ -182,12 +182,9 @@ bool VulkanWindowContext::createSwapchain(int width, int height, // Pick our surface format. For now, just make sure it matches our sRGB request: VkFormat surfaceFormat = VK_FORMAT_UNDEFINED; VkColorSpaceKHR colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; - auto srgbColorSpace = SkColorSpace::MakeSRGB(); - bool wantSRGB = srgbColorSpace == params.fColorSpace; for (uint32_t i = 0; i < surfaceFormatCount; ++i) { VkFormat localFormat = surfaceFormats[i].format; - if (GrVkFormatIsSupported(localFormat) && - GrVkFormatIsSRGB(localFormat, nullptr) == wantSRGB) { + if (GrVkFormatIsSupported(localFormat)) { surfaceFormat = localFormat; colorSpace = surfaceFormats[i].colorSpace; break; diff --git a/tools/skpbench/skpbench.cpp b/tools/skpbench/skpbench.cpp index a4583ce0f6..5f5e96b477 100644 --- a/tools/skpbench/skpbench.cpp +++ b/tools/skpbench/skpbench.cpp @@ -381,8 +381,7 @@ int main(int argc, char** argv) { exitf(ExitErr::kUnavailable, "render target size %ix%i not supported by platform (max: %i)", width, height, ctx->maxRenderTargetSize()); } - GrPixelConfig grPixConfig = SkImageInfo2GrPixelConfig( - config->getColorType(), config->getColorSpace(), *ctx->contextPriv().caps()); + GrPixelConfig grPixConfig = SkColorType2GrPixelConfig(config->getColorType()); if (kUnknown_GrPixelConfig == grPixConfig) { exitf(ExitErr::kUnavailable, "failed to get GrPixelConfig from SkColorType: %d", config->getColorType()); -- cgit v1.2.3