From c571c001cee4e0dfacd7bd17d5cd0a2900a853a9 Mon Sep 17 00:00:00 2001 From: brianosman Date: Thu, 17 Mar 2016 13:01:26 -0700 Subject: Revert of sRGB support in Ganesh. Several pieces: (patchset #12 id:220001 of https://codereview.chromium.org/1789663002/ ) Reason for revert: We're getting sRGB non-8888 configs? Original issue's description: > sRGB support in Ganesh. Several pieces: > > sRGB support now also requires GL_EXT_texture_sRGB_decode, which allows > us to disable sRGB -> Linear conversion when reading textures. This gives > us an easy way to support "legacy" L32 mode. We disable decoding based on > the pixel config of the render target. Textures can override that behavior > (specifically for format-conversion draws where we want that behavior). > > Added sBGRA pixel config, which is not-really-a-format. It's just sRGBA > internally, and the external format is BGR order, so TexImage calls will > swizzle correctly. This lets us interact with sRGB raster surfaces on BGR > platforms. > > Devices without sRGB support behave like they always have: conversion from > color type and profile type ignores sRGB and always returns linear pixel > configs. > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1789663002 > > Committed: https://skia.googlesource.com/skia/+/9e3f1bf4e5cd8fc59554f986f36d6b034e99f9eb TBR=reed@google.com,bsalomon@google.com,robertphillips@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1814533003 --- example/HelloWorld.cpp | 3 +- gyp/core.gyp | 1 - gyp/effects.gyp | 1 - include/gpu/GrCaps.h | 2 - include/gpu/GrColor.h | 17 ++++--- include/gpu/GrTextureParams.h | 31 +----------- include/gpu/GrTypes.h | 23 --------- include/gpu/SkGr.h | 7 ++- samplecode/SampleApp.cpp | 3 +- src/core/SkImageCacherator.cpp | 5 +- src/core/SkSpecialImage.cpp | 6 +-- src/effects/SkTableColorFilter.cpp | 3 +- src/effects/gradients/SkGradientShader.cpp | 4 +- src/gpu/GrCaps.cpp | 18 +++---- src/gpu/SkGpuDevice.cpp | 9 ++-- src/gpu/SkGr.cpp | 71 ++++++++++++---------------- src/gpu/SkGrPixelRef.cpp | 2 +- src/gpu/SkGrPriv.h | 2 +- src/gpu/effects/GrConfigConversionEffect.cpp | 5 +- src/gpu/effects/GrTextureStripAtlas.cpp | 2 +- src/gpu/gl/GrGLCaps.cpp | 43 +++-------------- src/gpu/gl/GrGLCaps.h | 3 ++ src/gpu/gl/GrGLDefines.h | 5 -- src/gpu/gl/GrGLGpu.cpp | 35 ++------------ src/gpu/gl/GrGLGpu.h | 3 +- src/gpu/gl/GrGLTexture.h | 1 - src/image/SkImage_Gpu.cpp | 3 +- src/views/SkWindow.cpp | 8 +--- tests/ReadPixelsTest.cpp | 3 +- 29 files changed, 84 insertions(+), 235 deletions(-) diff --git a/example/HelloWorld.cpp b/example/HelloWorld.cpp index 892dce1c80..bb29a0c3f5 100644 --- a/example/HelloWorld.cpp +++ b/example/HelloWorld.cpp @@ -157,8 +157,7 @@ void HelloWorldWindow::draw(SkCanvas* canvas) { fRenderTarget->writePixels(0, 0, snap->width(), snap->height(), SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType(), - info.profileType(), - *fContext->caps()), + info.profileType()), pmap.addr(), pmap.rowBytes(), GrContext::kFlushWrites_PixelOp); diff --git a/gyp/core.gyp b/gyp/core.gyp index 68e1436b11..13b8217fb1 100644 --- a/gyp/core.gyp +++ b/gyp/core.gyp @@ -20,7 +20,6 @@ '../include/c', '../include/config', '../include/core', - '../include/gpu', '../include/pathops', '../include/ports', '../include/private', diff --git a/gyp/effects.gyp b/gyp/effects.gyp index 8333a53b83..2402ed1c44 100644 --- a/gyp/effects.gyp +++ b/gyp/effects.gyp @@ -21,7 +21,6 @@ 'include_dirs': [ '../include/effects', '../include/client/android', - '../include/gpu', '../include/private', '../src/effects', '../src/opts', diff --git a/include/gpu/GrCaps.h b/include/gpu/GrCaps.h index b806dcbabc..60f213950e 100644 --- a/include/gpu/GrCaps.h +++ b/include/gpu/GrCaps.h @@ -137,7 +137,6 @@ public: /** To avoid as-yet-unnecessary complexity we don't allow any partial support of MIP Maps (e.g. only for POT textures) */ bool mipMapSupport() const { return fMipMapSupport; } - bool srgbSupport() const { return fSRGBSupport; } bool twoSidedStencilSupport() const { return fTwoSidedStencilSupport; } bool stencilWrapOpsSupport() const { return fStencilWrapOpsSupport; } bool discardRenderTargetSupport() const { return fDiscardRenderTargetSupport; } @@ -269,7 +268,6 @@ protected: bool fNPOTTextureTileSupport : 1; bool fMipMapSupport : 1; - bool fSRGBSupport : 1; bool fTwoSidedStencilSupport : 1; bool fStencilWrapOpsSupport : 1; bool fDiscardRenderTargetSupport : 1; diff --git a/include/gpu/GrColor.h b/include/gpu/GrColor.h index 77f1a6cb08..6b83237626 100644 --- a/include/gpu/GrColor.h +++ b/include/gpu/GrColor.h @@ -208,6 +208,7 @@ static inline char GrColorComponentFlagToChar(GrColorComponentFlags component) { } static inline uint32_t GrPixelConfigComponentMask(GrPixelConfig config) { + SkASSERT(config >= 0 && config < kGrPixelConfigCnt); static const uint32_t kFlags[] = { 0, // kUnknown_GrPixelConfig kA_GrColorComponentFlag, // kAlpha_8_GrPixelConfig @@ -217,7 +218,6 @@ static inline uint32_t GrPixelConfigComponentMask(GrPixelConfig config) { kRGBA_GrColorComponentFlags, // kRGBA_8888_GrPixelConfig kRGBA_GrColorComponentFlags, // kBGRA_8888_GrPixelConfig kRGBA_GrColorComponentFlags, // kSRGBA_8888_GrPixelConfig - kRGBA_GrColorComponentFlags, // kSBGRA_8888_GrPixelConfig kRGB_GrColorComponentFlags, // kETC1_GrPixelConfig kA_GrColorComponentFlag, // kLATC_GrPixelConfig kA_GrColorComponentFlag, // kR11_EAC_GrPixelConfig @@ -236,14 +236,13 @@ static inline uint32_t GrPixelConfigComponentMask(GrPixelConfig config) { GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig); GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig); GR_STATIC_ASSERT(7 == kSRGBA_8888_GrPixelConfig); - GR_STATIC_ASSERT(8 == kSBGRA_8888_GrPixelConfig); - GR_STATIC_ASSERT(9 == kETC1_GrPixelConfig); - GR_STATIC_ASSERT(10 == kLATC_GrPixelConfig); - GR_STATIC_ASSERT(11 == kR11_EAC_GrPixelConfig); - GR_STATIC_ASSERT(12 == kASTC_12x12_GrPixelConfig); - GR_STATIC_ASSERT(13 == kRGBA_float_GrPixelConfig); - GR_STATIC_ASSERT(14 == kAlpha_half_GrPixelConfig); - GR_STATIC_ASSERT(15 == kRGBA_half_GrPixelConfig); + GR_STATIC_ASSERT(8 == kETC1_GrPixelConfig); + GR_STATIC_ASSERT(9 == kLATC_GrPixelConfig); + GR_STATIC_ASSERT(10 == kR11_EAC_GrPixelConfig); + GR_STATIC_ASSERT(11 == kASTC_12x12_GrPixelConfig); + GR_STATIC_ASSERT(12 == kRGBA_float_GrPixelConfig); + GR_STATIC_ASSERT(13 == kAlpha_half_GrPixelConfig); + GR_STATIC_ASSERT(14 == kRGBA_half_GrPixelConfig); GR_STATIC_ASSERT(SK_ARRAY_COUNT(kFlags) == kGrPixelConfigCnt); } diff --git a/include/gpu/GrTextureParams.h b/include/gpu/GrTextureParams.h index 40d9ac5375..3186b1b027 100644 --- a/include/gpu/GrTextureParams.h +++ b/include/gpu/GrTextureParams.h @@ -24,11 +24,6 @@ public: static const GrTextureParams gParams(SkShader::kClamp_TileMode, kBilerp_FilterMode); return gParams; } - static const GrTextureParams& ClampNoFilterForceAllowSRGB() { - static const GrTextureParams gParams(SkShader::kClamp_TileMode, kNone_FilterMode, - kForceAllowSRGB_SRGBMode); - return gParams; - } GrTextureParams() { this->reset(); @@ -40,19 +35,10 @@ public: kMipMap_FilterMode }; - enum SRGBMode { - kRespectDestination_SRGBMode, - kForceAllowSRGB_SRGBMode, - }; - GrTextureParams(SkShader::TileMode tileXAndY, FilterMode filterMode) { this->reset(tileXAndY, filterMode); } - GrTextureParams(SkShader::TileMode tileXandY, FilterMode filterMode, SRGBMode srgbMode) { - this->reset(tileXandY, filterMode, srgbMode); - } - GrTextureParams(const SkShader::TileMode tileModes[2], FilterMode filterMode) { this->reset(tileModes, filterMode); } @@ -65,7 +51,6 @@ public: fTileModes[0] = params.fTileModes[0]; fTileModes[1] = params.fTileModes[1]; fFilterMode = params.fFilterMode; - fSRGBMode = params.fSRGBMode; return *this; } @@ -76,20 +61,12 @@ public: void reset(SkShader::TileMode tileXAndY, FilterMode filterMode) { fTileModes[0] = fTileModes[1] = tileXAndY; fFilterMode = filterMode; - fSRGBMode = kRespectDestination_SRGBMode; - } - - void reset(SkShader::TileMode tileXandY, FilterMode filterMode, SRGBMode srgbMode) { - fTileModes[0] = fTileModes[1] = tileXandY; - fFilterMode = filterMode; - fSRGBMode = srgbMode; } void reset(const SkShader::TileMode tileModes[2], FilterMode filterMode) { fTileModes[0] = tileModes[0]; fTileModes[1] = tileModes[1]; fFilterMode = filterMode; - fSRGBMode = kRespectDestination_SRGBMode; } void setClampNoFilter() { @@ -107,8 +84,6 @@ public: void setTileModeY(const SkShader::TileMode tm) { fTileModes[1] = tm; } void setTileModeXAndY(const SkShader::TileMode tm) { fTileModes[0] = fTileModes[1] = tm; } - void setSRGBMode(SRGBMode srgbMode) { fSRGBMode = srgbMode; } - SkShader::TileMode getTileModeX() const { return fTileModes[0]; } SkShader::TileMode getTileModeY() const { return fTileModes[1]; } @@ -120,13 +95,10 @@ public: FilterMode filterMode() const { return fFilterMode; } - SRGBMode srgbMode() const { return fSRGBMode; } - bool operator== (const GrTextureParams& other) const { return fTileModes[0] == other.fTileModes[0] && fTileModes[1] == other.fTileModes[1] && - fFilterMode == other.fFilterMode && - fSRGBMode == other.fSRGBMode; + fFilterMode == other.fFilterMode; } bool operator!= (const GrTextureParams& other) const { return !(*this == other); } @@ -134,6 +106,5 @@ public: private: SkShader::TileMode fTileModes[2]; FilterMode fFilterMode; - SRGBMode fSRGBMode; }; #endif diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h index 9be500d3b2..3def9aaa99 100644 --- a/include/gpu/GrTypes.h +++ b/include/gpu/GrTypes.h @@ -217,10 +217,6 @@ enum GrPixelConfig { * Premultiplied and sRGB. Byte order is r,g,b,a. */ kSRGBA_8888_GrPixelConfig, - /** - * Premultiplied and sRGB. Byte order is b,g,r,a. - */ - kSBGRA_8888_GrPixelConfig, /** * ETC1 Compressed Data */ @@ -272,10 +268,8 @@ static const int kGrPixelConfigCnt = kLast_GrPixelConfig + 1; #endif #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) static const GrPixelConfig kSkia8888_GrPixelConfig = kBGRA_8888_GrPixelConfig; - static const GrPixelConfig kSkiaGamma8888_GrPixelConfig = kSBGRA_8888_GrPixelConfig; #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) static const GrPixelConfig kSkia8888_GrPixelConfig = kRGBA_8888_GrPixelConfig; - static const GrPixelConfig kSkiaGamma8888_GrPixelConfig = kSRGBA_8888_GrPixelConfig; #else #error "SK_*32_SHIFT values must correspond to GL_BGRA or GL_RGBA format." #endif @@ -317,7 +311,6 @@ static inline bool GrPixelConfigIs8888(GrPixelConfig config) { case kRGBA_8888_GrPixelConfig: case kBGRA_8888_GrPixelConfig: case kSRGBA_8888_GrPixelConfig: - case kSBGRA_8888_GrPixelConfig: return true; default: return false; @@ -329,7 +322,6 @@ static inline bool GrPixelConfigIs8888(GrPixelConfig config) { static inline bool GrPixelConfigIsSRGB(GrPixelConfig config) { switch (config) { case kSRGBA_8888_GrPixelConfig: - case kSBGRA_8888_GrPixelConfig: return true; default: return false; @@ -344,10 +336,6 @@ static inline GrPixelConfig GrPixelConfigSwapRAndB(GrPixelConfig config) { return kRGBA_8888_GrPixelConfig; case kRGBA_8888_GrPixelConfig: return kBGRA_8888_GrPixelConfig; - case kSBGRA_8888_GrPixelConfig: - return kSRGBA_8888_GrPixelConfig; - case kSRGBA_8888_GrPixelConfig: - return kSBGRA_8888_GrPixelConfig; default: return kUnknown_GrPixelConfig; } @@ -365,7 +353,6 @@ static inline size_t GrBytesPerPixel(GrPixelConfig config) { case kRGBA_8888_GrPixelConfig: case kBGRA_8888_GrPixelConfig: case kSRGBA_8888_GrPixelConfig: - case kSBGRA_8888_GrPixelConfig: return 4; case kRGBA_half_GrPixelConfig: return 8; @@ -399,16 +386,6 @@ static inline bool GrPixelConfigIsAlphaOnly(GrPixelConfig config) { } } -static inline bool GrAllowSRGBForDestinationPixelConfig(GrPixelConfig config) { - switch (config) { - case kRGBA_8888_GrPixelConfig: - case kBGRA_8888_GrPixelConfig: - return false; - default: - return true; - } -} - /** * Optional bitfield flags that can be set on GrSurfaceDesc (below). */ diff --git a/include/gpu/SkGr.h b/include/gpu/SkGr.h index 6a73636c69..aacc5d25db 100644 --- a/include/gpu/SkGr.h +++ b/include/gpu/SkGr.h @@ -15,7 +15,6 @@ #include "SkFilterQuality.h" #include "SkImageInfo.h" -class GrCaps; class GrContext; class GrTexture; class GrTextureParams; @@ -71,10 +70,10 @@ static inline GrColor SkPMColorToGrColor(SkPMColor c) { GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, const GrTextureParams&); // TODO: Move SkImageInfo2GrPixelConfig to SkGrPriv.h (requires cleanup to SkWindow its subclasses). -GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType, SkColorProfileType, const GrCaps&); +GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType, SkColorProfileType); -static inline GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info, const GrCaps& caps) { - return SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType(), info.profileType(), caps); +static inline GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info) { + return SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType(), info.profileType()); } GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality paintFilterQuality, diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index ed1dbc77a2..72122234d9 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -310,8 +310,7 @@ public: fCurRenderTarget->writePixels(0, 0, bm.width(), bm.height(), SkImageInfo2GrPixelConfig(bm.colorType(), bm.alphaType(), - bm.profileType(), - *fCurContext->caps()), + bm.profileType()), bm.getPixels(), bm.rowBytes(), GrContext::kFlushWrites_PixelOp); diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp index bb389e986b..12c09cbe0a 100644 --- a/src/core/SkImageCacherator.cpp +++ b/src/core/SkImageCacherator.cpp @@ -171,8 +171,7 @@ bool SkImageCacherator::lockAsBitmap(SkBitmap* bitmap, const SkImage* client, } const uint32_t pixelOpsFlags = 0; - if (!tex->readPixels(0, 0, bitmap->width(), bitmap->height(), - SkImageInfo2GrPixelConfig(fInfo, *tex->getContext()->caps()), + if (!tex->readPixels(0, 0, bitmap->width(), bitmap->height(), SkImageInfo2GrPixelConfig(fInfo), bitmap->getPixels(), bitmap->rowBytes(), pixelOpsFlags)) { bitmap->reset(); return false; @@ -274,7 +273,7 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& key } } - const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(fInfo, *ctx->caps()); + const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(fInfo); // 3. Ask the generator to return a compressed form that the GPU might support SkAutoTUnref data(this->refEncoded(ctx)); diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp index b59bb41405..b17d5d4147 100644 --- a/src/core/SkSpecialImage.cpp +++ b/src/core/SkSpecialImage.cpp @@ -10,8 +10,6 @@ #include "SkSpecialImage.h" #include "SkSpecialSurface.h" -#include "GrContext.h" - /////////////////////////////////////////////////////////////////////////////// class SkSpecialImage_Base : public SkSpecialImage { public: @@ -168,7 +166,7 @@ public: #if SK_SUPPORT_GPU GrTexture* texture = as_IB(fImage.get())->peekTexture(); if (texture) { - GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info, *texture->getContext()->caps()); + GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info); desc.fFlags = kRenderTarget_GrSurfaceFlag; return SkSpecialSurface::NewRenderTarget(this->proxy(), texture->getContext(), desc); @@ -386,7 +384,7 @@ public: } SkSpecialSurface* onNewSurface(const SkImageInfo& info) const override { - GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info, *fTexture->getContext()->caps()); + GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info); desc.fFlags = kRenderTarget_GrSurfaceFlag; return SkSpecialSurface::NewRenderTarget(this->proxy(), fTexture->getContext(), desc); diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp index f49043f512..3a6c070fab 100644 --- a/src/effects/SkTableColorFilter.cpp +++ b/src/effects/SkTableColorFilter.cpp @@ -7,7 +7,6 @@ #include "SkTableColorFilter.h" -#include "GrContext.h" #include "SkBitmap.h" #include "SkColorPriv.h" #include "SkReadBuffer.h" @@ -467,7 +466,7 @@ const GrFragmentProcessor* ColorTableEffect::Create(GrContext* context, SkBitmap desc.fHeight = 128; desc.fRowHeight = bitmap.height(); desc.fContext = context; - desc.fConfig = SkImageInfo2GrPixelConfig(bitmap.info(), *context->caps()); + desc.fConfig = SkImageInfo2GrPixelConfig(bitmap.info()); GrTextureStripAtlas* atlas = GrTextureStripAtlas::GetAtlas(desc); int row = atlas->lockRow(bitmap); SkAutoTUnref texture; diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp index 6a8befd81d..9fe6c91a01 100644 --- a/src/effects/gradients/SkGradientShader.cpp +++ b/src/effects/gradients/SkGradientShader.cpp @@ -12,8 +12,6 @@ #include "SkTwoPointConicalGradient.h" #include "SkSweepGradient.h" -#include "GrContext.h" - void SkGradientShaderBase::Descriptor::flatten(SkWriteBuffer& buffer) const { buffer.writeColorArray(fColors, fCount); if (fPos) { @@ -1119,7 +1117,7 @@ GrGradientEffect::GrGradientEffect(GrContext* ctx, desc.fHeight = 32; desc.fRowHeight = bitmap.height(); desc.fContext = ctx; - desc.fConfig = SkImageInfo2GrPixelConfig(bitmap.info(), *ctx->caps()); + desc.fConfig = SkImageInfo2GrPixelConfig(bitmap.info()); fAtlas = GrTextureStripAtlas::GetAtlas(desc); SkASSERT(fAtlas); diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp index 000f90c6a6..c544d6ef77 100644 --- a/src/gpu/GrCaps.cpp +++ b/src/gpu/GrCaps.cpp @@ -83,7 +83,6 @@ void GrShaderCaps::applyOptionsOverrides(const GrContextOptions& options) { GrCaps::GrCaps(const GrContextOptions& options) { fMipMapSupport = false; fNPOTTextureTileSupport = false; - fSRGBSupport = false; fTwoSidedStencilSupport = false; fStencilWrapOpsSupport = false; fDiscardRenderTargetSupport = false; @@ -158,7 +157,6 @@ SkString GrCaps::dump() const { static const char* gNY[] = {"NO", "YES"}; r.appendf("MIP Map Support : %s\n", gNY[fMipMapSupport]); r.appendf("NPOT Texture Tile Support : %s\n", gNY[fNPOTTextureTileSupport]); - r.appendf("sRGB Support : %s\n", gNY[fSRGBSupport]); r.appendf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilSupport]); r.appendf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSupport]); r.appendf("Discard Render Target Support : %s\n", gNY[fDiscardRenderTargetSupport]); @@ -212,7 +210,6 @@ SkString GrCaps::dump() const { "RGBA8888", // kRGBA_8888_GrPixelConfig, "BGRA8888", // kBGRA_8888_GrPixelConfig, "SRGBA8888",// kSRGBA_8888_GrPixelConfig, - "SBGRA8888",// kSBGRA_8888_GrPixelConfig, "ETC1", // kETC1_GrPixelConfig, "LATC", // kLATC_GrPixelConfig, "R11EAC", // kR11_EAC_GrPixelConfig, @@ -229,14 +226,13 @@ SkString GrCaps::dump() const { GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig); GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig); GR_STATIC_ASSERT(7 == kSRGBA_8888_GrPixelConfig); - GR_STATIC_ASSERT(8 == kSBGRA_8888_GrPixelConfig); - GR_STATIC_ASSERT(9 == kETC1_GrPixelConfig); - GR_STATIC_ASSERT(10 == kLATC_GrPixelConfig); - GR_STATIC_ASSERT(11 == kR11_EAC_GrPixelConfig); - GR_STATIC_ASSERT(12 == kASTC_12x12_GrPixelConfig); - GR_STATIC_ASSERT(13 == kRGBA_float_GrPixelConfig); - GR_STATIC_ASSERT(14 == kAlpha_half_GrPixelConfig); - GR_STATIC_ASSERT(15 == kRGBA_half_GrPixelConfig); + GR_STATIC_ASSERT(8 == kETC1_GrPixelConfig); + GR_STATIC_ASSERT(9 == kLATC_GrPixelConfig); + GR_STATIC_ASSERT(10 == kR11_EAC_GrPixelConfig); + GR_STATIC_ASSERT(11 == kASTC_12x12_GrPixelConfig); + GR_STATIC_ASSERT(12 == kRGBA_float_GrPixelConfig); + GR_STATIC_ASSERT(13 == kAlpha_half_GrPixelConfig); + GR_STATIC_ASSERT(14 == kRGBA_half_GrPixelConfig); GR_STATIC_ASSERT(SK_ARRAY_COUNT(kConfigNames) == kGrPixelConfigCnt); SkASSERT(!this->isConfigRenderable(kUnknown_GrPixelConfig, false)); diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 823e9b84ff..c2d8bdad32 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -193,7 +193,6 @@ GrRenderTarget* SkGpuDevice::CreateRenderTarget( SkColorType ct = origInfo.colorType(); SkAlphaType at = origInfo.alphaType(); - SkColorProfileType pt = origInfo.profileType(); if (kRGB_565_SkColorType == ct) { at = kOpaque_SkAlphaType; // force this setting } else if (ct != kBGRA_8888_SkColorType && ct != kRGBA_8888_SkColorType) { @@ -203,13 +202,13 @@ GrRenderTarget* SkGpuDevice::CreateRenderTarget( if (kOpaque_SkAlphaType != at) { at = kPremul_SkAlphaType; // force this setting } - const SkImageInfo info = SkImageInfo::Make(origInfo.width(), origInfo.height(), ct, at, pt); + const SkImageInfo info = SkImageInfo::Make(origInfo.width(), origInfo.height(), ct, at); GrSurfaceDesc desc; desc.fFlags = kRenderTarget_GrSurfaceFlag; desc.fWidth = info.width(); desc.fHeight = info.height(); - desc.fConfig = SkImageInfo2GrPixelConfig(info, *context->caps()); + desc.fConfig = SkImageInfo2GrPixelConfig(info); desc.fSampleCnt = sampleCount; desc.fTextureStorageAllocator = textureStorageAllocator; desc.fIsMipMapped = false; @@ -228,7 +227,7 @@ bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size ASSERT_SINGLE_OWNER // TODO: teach fRenderTarget to take ImageInfo directly to specify the src pixels - GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo, *fContext->caps()); + GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo); if (kUnknown_GrPixelConfig == config) { return false; } @@ -245,7 +244,7 @@ bool SkGpuDevice::onWritePixels(const SkImageInfo& info, const void* pixels, siz int x, int y) { ASSERT_SINGLE_OWNER // TODO: teach fRenderTarget to take ImageInfo directly to specify the src pixels - GrPixelConfig config = SkImageInfo2GrPixelConfig(info, *fContext->caps()); + GrPixelConfig config = SkImageInfo2GrPixelConfig(info); if (kUnknown_GrPixelConfig == config) { return false; } diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 866f34d06c..1463336c49 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -43,12 +43,12 @@ # include "etc1.h" #endif -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 = 0; return desc; } @@ -213,7 +213,7 @@ static GrTexture* load_etc1_texture(GrContext* ctx, const SkBitmap &bm, GrSurfac } GrTexture* GrUploadBitmapToTexture(GrContext* ctx, const SkBitmap& bitmap) { - GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info(), *ctx->caps()); + GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info()); if (GrTexture *texture = load_etc1_texture(ctx, bitmap, desc)) { return texture; } @@ -238,8 +238,8 @@ GrTexture* GrUploadPixmapToTexture(GrContext* ctx, const SkPixmap& pixmap) { SkPixmap tmpPixmap; SkBitmap tmpBitmap; + GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(pixmap.info()); const GrCaps* caps = ctx->caps(); - GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(pixmap.info(), *caps); if (kIndex_8_SkColorType == pixmap.colorType()) { if (caps->isConfigTexturable(kIndex_8_GrPixelConfig)) { @@ -263,7 +263,7 @@ GrTexture* GrUploadPixmapToTexture(GrContext* ctx, const SkPixmap& pixmap) { } pmap = &tmpPixmap; // must rebuild desc, since we've forced the info to be N32 - desc = GrImageInfoToSurfaceDesc(pmap->info(), *caps); + desc = GrImageInfoToSurfaceDesc(pmap->info()); } } @@ -289,7 +289,7 @@ void GrInstallBitmapUniqueKeyInvalidator(const GrUniqueKey& key, SkPixelRef* pix GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext* ctx, const SkBitmap& bitmap) { - GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info(), *ctx->caps()); + GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info()); if (kIndex_8_SkColorType != bitmap.colorType() && !bitmap.readyToDraw()) { GrTexture* texture = load_etc1_texture(ctx, bitmap, desc); if (texture) { @@ -358,38 +358,29 @@ GrTexture* GrRefCachedBitmapTexture(GrContext* ctx, const SkBitmap& bitmap, // alphatype is ignore for now, but if GrPixelConfig is expanded to encompass // alpha info, that will be considered. -GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, SkColorProfileType pt, - const GrCaps& caps) { - if (kSRGB_SkColorProfileType == pt && caps.srgbSupport()) { - switch (ct) { - case kRGBA_8888_SkColorType: - return kSRGBA_8888_GrPixelConfig; - case kBGRA_8888_SkColorType: - return kSBGRA_8888_GrPixelConfig; - default: - break; - } - } else { - switch (ct) { - case kUnknown_SkColorType: - return kUnknown_GrPixelConfig; - case kAlpha_8_SkColorType: - return kAlpha_8_GrPixelConfig; - case kRGB_565_SkColorType: - return kRGB_565_GrPixelConfig; - case kARGB_4444_SkColorType: - return kRGBA_4444_GrPixelConfig; - case kRGBA_8888_SkColorType: - return kRGBA_8888_GrPixelConfig; - case kBGRA_8888_SkColorType: - return kBGRA_8888_GrPixelConfig; - case kIndex_8_SkColorType: - return kIndex_8_GrPixelConfig; - case kGray_8_SkColorType: - return kAlpha_8_GrPixelConfig; // TODO: gray8 support on gpu - case kRGBA_F16_SkColorType: - return kRGBA_half_GrPixelConfig; - } +GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, SkColorProfileType pt) { + switch (ct) { + case kUnknown_SkColorType: + return kUnknown_GrPixelConfig; + case kAlpha_8_SkColorType: + return kAlpha_8_GrPixelConfig; + case kRGB_565_SkColorType: + return kRGB_565_GrPixelConfig; + case kARGB_4444_SkColorType: + return kRGBA_4444_GrPixelConfig; + case kRGBA_8888_SkColorType: + //if (kSRGB_SkColorProfileType == pt) { + // return kSRGBA_8888_GrPixelConfig; + //} + return kRGBA_8888_GrPixelConfig; + case kBGRA_8888_SkColorType: + return kBGRA_8888_GrPixelConfig; + case kIndex_8_SkColorType: + return kIndex_8_GrPixelConfig; + case kGray_8_SkColorType: + return kAlpha_8_GrPixelConfig; // TODO: gray8 support on gpu + case kRGBA_F16_SkColorType: + return kRGBA_half_GrPixelConfig; } SkASSERT(0); // shouldn't get here return kUnknown_GrPixelConfig; @@ -422,10 +413,6 @@ bool GrPixelConfig2ColorAndProfileType(GrPixelConfig config, SkColorType* ctOut, ct = kRGBA_8888_SkColorType; pt = kSRGB_SkColorProfileType; break; - case kSBGRA_8888_GrPixelConfig: - ct = kBGRA_8888_SkColorType; - pt = kSRGB_SkColorProfileType; - break; default: return false; } diff --git a/src/gpu/SkGrPixelRef.cpp b/src/gpu/SkGrPixelRef.cpp index e21d3b9d6d..f61d92e186 100644 --- a/src/gpu/SkGrPixelRef.cpp +++ b/src/gpu/SkGrPixelRef.cpp @@ -75,7 +75,7 @@ static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorTyp srcRect = *subset; } desc.fFlags = kRenderTarget_GrSurfaceFlag; - desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType, dstPT, *context->caps()); + desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType, dstPT); desc.fTextureStorageAllocator = texture->desc().fTextureStorageAllocator; desc.fIsMipMapped = false; diff --git a/src/gpu/SkGrPriv.h b/src/gpu/SkGrPriv.h index 579216a2ea..555f415513 100644 --- a/src/gpu/SkGrPriv.h +++ b/src/gpu/SkGrPriv.h @@ -95,7 +95,7 @@ bool SkPaintToGrPaintWithTexture(GrContext* context, ////////////////////////////////////////////////////////////////////////////// -GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&, const GrCaps&); +GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&); bool GrPixelConfig2ColorAndProfileType(GrPixelConfig, SkColorType*, SkColorProfileType*); diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index bedcc78370..dc41203406 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -98,7 +98,7 @@ GrConfigConversionEffect::GrConfigConversionEffect(GrTexture* texture, const GrSwizzle& swizzle, PMConversion pmConversion, const SkMatrix& matrix) - : INHERITED(texture, matrix, GrTextureParams::ClampNoFilterForceAllowSRGB()) + : INHERITED(texture, matrix) , fSwizzle(swizzle) , fPMConversion(pmConversion) { this->initClassID(); @@ -296,8 +296,7 @@ const GrFragmentProcessor* GrConfigConversionEffect::Create(GrTexture* texture, // If we returned a GrConfigConversionEffect that was equivalent to a GrSimpleTextureEffect // then we may pollute our texture cache with redundant shaders. So in the case that no // conversions were requested we instead return a GrSimpleTextureEffect. - return GrSimpleTextureEffect::Create(texture, matrix, - GrTextureParams::ClampNoFilterForceAllowSRGB()); + return GrSimpleTextureEffect::Create(texture, matrix); } else { if (kRGBA_8888_GrPixelConfig != texture->config() && kBGRA_8888_GrPixelConfig != texture->config() && diff --git a/src/gpu/effects/GrTextureStripAtlas.cpp b/src/gpu/effects/GrTextureStripAtlas.cpp index 1543a2e9db..1ac3dab2aa 100644 --- a/src/gpu/effects/GrTextureStripAtlas.cpp +++ b/src/gpu/effects/GrTextureStripAtlas.cpp @@ -158,7 +158,7 @@ int GrTextureStripAtlas::lockRow(const SkBitmap& data) { // that is not currently in use fTexture->writePixels(0, rowNumber * fDesc.fRowHeight, fDesc.fWidth, fDesc.fRowHeight, - SkImageInfo2GrPixelConfig(data.info(), *this->getContext()->caps()), + SkImageInfo2GrPixelConfig(data.info()), data.getPixels(), data.rowBytes(), GrContext::kDontFlush_PixelOpsFlag); diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index af31480ba7..40885359fb 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -1435,31 +1435,27 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa } 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. + bool srgbSupport = false; if (kGL_GrGLStandard == standard) { if (ctxInfo.version() >= GR_GL_VER(3,0)) { - fSRGBSupport = true; + srgbSupport = true; } else if (ctxInfo.hasExtension("GL_EXT_texture_sRGB")) { if (ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") || ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) { - fSRGBSupport = true; + srgbSupport = true; } } // All the above srgb extensions support toggling srgb writes - fSRGBWriteControl = fSRGBSupport; + fSRGBWriteControl = srgbSupport; } else { // See https://bug.skia.org/4148 for PowerVR issue. - fSRGBSupport = kPowerVRRogue_GrGLRenderer != ctxInfo.renderer() && + srgbSupport = kPowerVRRogue_GrGLRenderer != ctxInfo.renderer() && (ctxInfo.version() >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT_sRGB")); // ES through 3.1 requires EXT_srgb_write_control to support toggling // sRGB writing for destinations. fSRGBWriteControl = ctxInfo.hasExtension("GL_EXT_sRGB_write_control"); } - if (!ctxInfo.hasExtension("GL_EXT_texture_sRGB_decode")) { - // To support "legacy" L32 mode, we require the ability to turn off sRGB decode: - fSRGBSupport = false; - } fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_SRGB_ALPHA; fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_SRGB8_ALPHA8; // GL does not do srgb<->rgb conversions when transferring between cpu and gpu. Thus, the @@ -1468,7 +1464,7 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa GR_GL_RGBA; fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE; fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType; - if (fSRGBSupport) { + if (srgbSupport) { fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag | allRenderFlags; } @@ -1477,26 +1473,6 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa } fConfigTable[kSRGBA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); - // sBGRA is not a "real" thing in OpenGL, but GPUs support it, and on platforms where - // kN32 == BGRA, we need some way to work with it. (The default framebuffer on Windows - // is in this format, for example). - fConfigTable[kSBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_SRGB_ALPHA; - fConfigTable[kSBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_SRGB8_ALPHA8; - // GL does not do srgb<->rgb conversions when transferring between cpu and gpu. Thus, the - // external format is GL_BGRA. - fConfigTable[kSBGRA_8888_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] = - GR_GL_BGRA; - fConfigTable[kSBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE; - fConfigTable[kSBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType; - if (fSRGBSupport) { - fConfigTable[kSBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag | - allRenderFlags; - } - if (texStorageSupported) { - fConfigTable[kSBGRA_8888_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexStorage_Flag; - } - fConfigTable[kSBGRA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); - fConfigTable[kRGB_565_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGB; if (this->ES2CompatibilitySupport()) { fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGB565; @@ -1816,11 +1792,6 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa if (ctxInfo.standard() == kGLES_GrGLStandard && ctxInfo.version() == GR_GL_VER(2,0)) { fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kTexImage_ExternalFormatUsage] = GR_GL_SRGB_ALPHA; - - // Additionally, because we had to "invent" sBGRA, there is no way to make it work - // in ES 2.0, because there is no we can use. So just make that format - // unsupported. (If we have no sRGB support at all, this will get overwritten below). - fConfigTable[kSBGRA_8888_GrPixelConfig].fFlags = 0; } // If BGRA is supported as an internal format it must always be specified to glTex[Sub]Image diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index ed673e7ce7..376610d8b0 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -120,10 +120,12 @@ public: const GrGLInterface* glInterface); bool isConfigTexturable(GrPixelConfig config) const override { + SkASSERT(kGrPixelConfigCnt > config); return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kTextureable_Flag); } bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override { + SkASSERT(kGrPixelConfigCnt > config); if (withMSAA) { return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderableWithMSAA_Flag); } else { @@ -132,6 +134,7 @@ public: } bool isConfigTexSupportEnabled(GrPixelConfig config) const { + SkASSERT(kGrPixelConfigCnt > config); return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kCanUseTexStorage_Flag); } diff --git a/src/gpu/gl/GrGLDefines.h b/src/gpu/gl/GrGLDefines.h index ff4c457250..cd73be401b 100644 --- a/src/gpu/gl/GrGLDefines.h +++ b/src/gpu/gl/GrGLDefines.h @@ -506,17 +506,12 @@ /* TextureUsage */ #define GR_GL_FRAMEBUFFER_ATTACHMENT 0x93A3 -/* TextureSRGBDecode */ -#define GR_GL_DECODE_EXT 0x8A49 -#define GR_GL_SKIP_DECODE_EXT 0x8A4A - /* TextureParameterName */ #define GR_GL_TEXTURE_MAG_FILTER 0x2800 #define GR_GL_TEXTURE_MIN_FILTER 0x2801 #define GR_GL_TEXTURE_WRAP_S 0x2802 #define GR_GL_TEXTURE_WRAP_T 0x2803 #define GR_GL_TEXTURE_USAGE 0x93A2 -#define GR_GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 /* TextureTarget */ /* GL_TEXTURE_2D */ diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 62baf79002..76cb1a068a 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -898,7 +898,6 @@ static inline GrGLint config_alignment(GrPixelConfig config) { case kRGBA_8888_GrPixelConfig: case kBGRA_8888_GrPixelConfig: case kSRGBA_8888_GrPixelConfig: - case kSBGRA_8888_GrPixelConfig: case kRGBA_float_GrPixelConfig: return 4; default: @@ -2101,15 +2100,13 @@ bool GrGLGpu::flushGLState(const GrPipeline& pipeline, const GrPrimitiveProcesso SkSTArray<8, const GrTextureAccess*> textureAccesses; program->setData(primProc, pipeline, &textureAccesses); - GrGLRenderTarget* glRT = static_cast(pipeline.getRenderTarget()); - bool allowSRGB = GrAllowSRGBForDestinationPixelConfig(glRT->config()); - int numTextureAccesses = textureAccesses.count(); for (int i = 0; i < numTextureAccesses; i++) { - this->bindTexture(i, textureAccesses[i]->getParams(), allowSRGB, + this->bindTexture(i, textureAccesses[i]->getParams(), static_cast(textureAccesses[i]->getTexture())); } + GrGLRenderTarget* glRT = static_cast(pipeline.getRenderTarget()); this->flushStencil(pipeline.getStencil()); this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->origin()); this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !pipeline.getStencil().isDisabled()); @@ -2610,16 +2607,6 @@ bool GrGLGpu::onGetReadPixelsInfo(GrSurface* srcSurface, int width, int height, tempDrawInfo->fSwizzle = GrSwizzle::BGRA(); tempDrawInfo->fReadConfig = kRGBA_8888_GrPixelConfig; ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference); - } else if (readConfig == kSBGRA_8888_GrPixelConfig && - this->glCaps().isConfigRenderable(kSRGBA_8888_GrPixelConfig, false) && - this->readPixelsSupported(kSRGBA_8888_GrPixelConfig, kSRGBA_8888_GrPixelConfig)) { - // We're trying to read sBGRA but it's not supported. If sRGBA is renderable and - // we can read it back, then do a swizzling draw to a sRGBA and read it back (which - // will effectively be sBGRA). - tempDrawInfo->fTempSurfaceDesc.fConfig = kSRGBA_8888_GrPixelConfig; - tempDrawInfo->fSwizzle = GrSwizzle::BGRA(); - tempDrawInfo->fReadConfig = kSRGBA_8888_GrPixelConfig; - ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference); } else if (readConfig == kAlpha_8_GrPixelConfig) { // onReadPixels implements a fallback for cases where we are want to read kAlpha_8, // it's unsupported, but 32bit RGBA reads are supported. @@ -3324,8 +3311,7 @@ static void get_tex_param_swizzle(GrPixelConfig config, } } -void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, bool dstConfigAllowsSRGB, - GrGLTexture* texture) { +void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* texture) { SkASSERT(texture); #ifdef SK_DEBUG @@ -3361,19 +3347,6 @@ void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, bool dstCo bool setAll = timestamp < this->getResetTimestamp(); GrGLTexture::TexParams newTexParams; - if (this->caps()->srgbSupport()) { - // By default, the decision to allow SRGB decode is based on the destination config. - // A texture can override that by specifying a value in GrTextureParams. - newTexParams.fSRGBDecode = - (dstConfigAllowsSRGB || GrTextureParams::kForceAllowSRGB_SRGBMode == params.srgbMode()) - ? 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)); - } - } - static GrGLenum glMinFilterModes[] = { GR_GL_NEAREST, GR_GL_LINEAR, @@ -4041,7 +4014,7 @@ void GrGLGpu::copySurfaceAsDraw(GrSurface* dst, GrGLTexture* srcTex = static_cast(src->asTexture()); GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_FilterMode); - this->bindTexture(0, params, true, srcTex); + this->bindTexture(0, params, srcTex); GrGLIRect dstVP; this->bindSurfaceFBOForCopy(dst, GR_GL_FRAMEBUFFER, &dstVP, kDst_TempFBOTarget); diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index a3582739e7..e365601e1f 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -59,8 +59,7 @@ public: void discard(GrRenderTarget*) override; // Used by GrGLProgram to configure OpenGL state. - void bindTexture(int unitIdx, const GrTextureParams& params, bool dstConfigAllowsSRGB, - GrGLTexture* texture); + void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* texture); bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeight, size_t rowBytes, GrPixelConfig readConfig, DrawPreference*, diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h index 6ee8dcfe2b..937b8be13e 100644 --- a/src/gpu/gl/GrGLTexture.h +++ b/src/gpu/gl/GrGLTexture.h @@ -25,7 +25,6 @@ public: GrGLenum fWrapT; GrGLenum fMaxMipMapLevel; GrGLenum fSwizzleRGBA[4]; - GrGLenum fSRGBDecode; void invalidate() { memset(this, 0xff, sizeof(TexParams)); } }; diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index a1f032f6a1..5e687b751a 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -111,8 +111,7 @@ static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes) bool SkImage_Gpu::onReadPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, int srcX, int srcY, CachingHint) const { GrPixelConfig config = SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType(), - info.profileType(), - *fTexture->getContext()->caps()); + info.profileType()); uint32_t flags = 0; if (kUnpremul_SkAlphaType == info.alphaType() && kPremul_SkAlphaType == fAlphaType) { // let the GPU perform this transformation for us diff --git a/src/views/SkWindow.cpp b/src/views/SkWindow.cpp index 056b3eab50..82c1a43c0a 100644 --- a/src/views/SkWindow.cpp +++ b/src/views/SkWindow.cpp @@ -329,13 +329,9 @@ GrRenderTarget* SkWindow::renderTarget(const AttachmentInfo& attachmentInfo, // TODO: Query the actual framebuffer for sRGB capable. However, to // preserve old (fake-linear) behavior, we don't do this. Instead, rely // on the flag (currently driven via 'C' mode in SampleApp). - // - // Also, we may not have real sRGB support (ANGLE, in particular), so check for - // that, and fall back to L32: - desc.fConfig = grContext->caps()->srgbSupport() && - (info().profileType() == kSRGB_SkColorProfileType || + desc.fConfig = (info().profileType() == kSRGB_SkColorProfileType || info().colorType() == kRGBA_F16_SkColorType) - ? kSkiaGamma8888_GrPixelConfig + ? kSRGBA_8888_GrPixelConfig // This may not be the right byte-order : kSkia8888_GrPixelConfig; desc.fOrigin = kBottomLeft_GrSurfaceOrigin; desc.fSampleCnt = attachmentInfo.fSampleCount; diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp index 87e51163da..77a11e5f8b 100644 --- a/tests/ReadPixelsTest.cpp +++ b/tests/ReadPixelsTest.cpp @@ -424,8 +424,7 @@ static void test_readpixels_texture(skiatest::Reporter* reporter, GrTexture* tex GrPixelConfig dstConfig = SkImageInfo2GrPixelConfig(gReadPixelsConfigs[c].fColorType, gReadPixelsConfigs[c].fAlphaType, - kLinear_SkColorProfileType, - *texture->getContext()->caps()); + kLinear_SkColorProfileType); uint32_t flags = 0; if (gReadPixelsConfigs[c].fAlphaType == kUnpremul_SkAlphaType) { flags = GrContext::kUnpremul_PixelOpsFlag; -- cgit v1.2.3