aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2018-06-01 16:10:53 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-01 20:50:56 +0000
commit9363ac40b66b761634c077c50617bf6c6fb3f3ea (patch)
tree918ba8a306af73ec33071f301e9b20b45fa58edd
parentb54d2239d36f60087efb2611d320364d7b06374c (diff)
Remove most of the remaining conflation of colorSpace and sRGB in Ganesh
Change-Id: I22cd838f15c548b459da925cd7e7d228f95fb2e2 Reviewed-on: https://skia-review.googlesource.com/131583 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
-rw-r--r--src/gpu/GrBackendTextureImageGenerator.cpp8
-rw-r--r--src/gpu/GrCaps.h3
-rw-r--r--src/gpu/GrContext.cpp6
-rw-r--r--src/gpu/GrResourceProvider.cpp13
-rw-r--r--src/gpu/GrSurfaceContext.cpp3
-rw-r--r--src/gpu/GrSurfaceProxy.cpp12
-rw-r--r--src/gpu/GrTextureProducer.cpp6
-rw-r--r--src/gpu/GrYUVProvider.cpp8
-rw-r--r--src/gpu/SkGr.cpp6
-rw-r--r--src/gpu/gl/GrGLDefines.h5
-rw-r--r--src/gpu/mtl/GrMtlTexture.mm7
-rw-r--r--src/gpu/mtl/GrMtlUtil.h6
-rw-r--r--src/gpu/mtl/GrMtlUtil.mm20
13 files changed, 10 insertions, 93 deletions
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index 3ec773da5c..56826d2857 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -196,15 +196,11 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
// because Vulkan will want to do the copy as a draw. All other copies would require a
// layout change in Vulkan and we do not change the layout of borrowed images.
GrMipMapped mipMapped = willNeedMipMaps ? GrMipMapped::kYes : GrMipMapped::kNo;
- sk_sp<SkColorSpace> colorSpace;
- if (GrPixelConfigIsSRGB(desc.fConfig)) {
- colorSpace = SkColorSpace::MakeSRGB();
- }
sk_sp<GrRenderTargetContext> rtContext(
context->contextPriv().makeDeferredRenderTargetContext(
- SkBackingFit::kExact, info.width(), info.height(), proxy->config(),
- std::move(colorSpace), 1, mipMapped, proxy->origin(), nullptr, SkBudgeted::kYes));
+ SkBackingFit::kExact, info.width(), info.height(), proxy->config(), nullptr, 1,
+ mipMapped, proxy->origin(), nullptr, SkBudgeted::kYes));
if (!rtContext) {
return nullptr;
diff --git a/src/gpu/GrCaps.h b/src/gpu/GrCaps.h
index a04699f77e..4b6f78789c 100644
--- a/src/gpu/GrCaps.h
+++ b/src/gpu/GrCaps.h
@@ -43,8 +43,7 @@ public:
/**
* Skia convention is that a device only has sRGB support if it supports sRGB formats for both
- * textures and framebuffers. In addition:
- * Decoding to linear of an sRGB texture can be disabled.
+ * textures and framebuffers.
*/
bool srgbSupport() const { return fSRGBSupport; }
/**
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index d670319c7d..f987536a5c 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -816,12 +816,6 @@ sk_sp<GrSurfaceContext> GrContextPriv::makeWrappedSurfaceContext(sk_sp<GrSurface
const SkSurfaceProps* props) {
ASSERT_SINGLE_OWNER_PRIV
- // sRGB pixel configs may only be used with near-sRGB gamma color spaces.
- if (GrPixelConfigIsSRGB(proxy->config())) {
- if (!colorSpace || !colorSpace->gammaCloseToSRGB()) {
- return nullptr;
- }
- }
if (proxy->asRenderTargetProxy()) {
return this->drawingManager()->makeRenderTargetContext(std::move(proxy),
std::move(colorSpace), props);
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index b09506e3f4..69a54dd862 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -119,19 +119,10 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc,
if (!proxy) {
return nullptr;
}
- // We use an ephemeral surface context to do the write pixels. Here it isn't clear what
- // color space to tag it with. That's ok because GrSurfaceContext::writePixels doesn't
- // do any color space conversions. Though, that is likely to change. However, if the
- // pixel config is sRGB then the passed color space here must have sRGB gamma or
- // GrSurfaceContext creation fails.
- sk_sp<SkColorSpace> colorSpace;
- if (GrPixelConfigIsSRGB(desc.fConfig)) {
- colorSpace = SkColorSpace::MakeSRGB();
- }
auto srcInfo = SkImageInfo::Make(desc.fWidth, desc.fHeight, colorType,
- kUnknown_SkAlphaType, colorSpace);
+ kUnknown_SkAlphaType);
sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeWrappedSurfaceContext(
- std::move(proxy), std::move(colorSpace));
+ std::move(proxy));
if (!sContext) {
return nullptr;
}
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index 25093cbf72..c288be55d3 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -34,9 +34,6 @@ GrSurfaceContext::GrSurfaceContext(GrContext* context,
, fSingleOwner(singleOwner)
#endif
{
- // We never should have a sRGB pixel config with a non-SRGB gamma color space.
- SkASSERT(!GrPixelConfigIsSRGB(config) ||
- (fColorSpaceInfo.colorSpace() && fColorSpaceInfo.colorSpace()->gammaCloseToSRGB()));
}
bool GrSurfaceContext::readPixels(const SkImageInfo& dstInfo, void* dstBuffer,
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index dd15b18bd4..fe8641a04f 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -323,18 +323,8 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::Copy(GrContext* context,
dstDesc.fHeight = srcRect.height();
dstDesc.fConfig = src->config();
- // We use an ephemeral surface context to make the copy. Here it isn't clear what color space
- // to tag it with. That's ok because GrSurfaceContext::copy doesn't do any color space
- // conversions. However, if the pixel config is sRGB then the passed color space here must
- // have sRGB gamma or GrSurfaceContext creation fails. See skbug.com/7611 about making this
- // with the correct color space information and returning the context to the caller.
- sk_sp<SkColorSpace> colorSpace;
- if (GrPixelConfigIsSRGB(dstDesc.fConfig)) {
- colorSpace = SkColorSpace::MakeSRGB();
- }
sk_sp<GrSurfaceContext> dstContext(context->contextPriv().makeDeferredSurfaceContext(
- dstDesc, src->origin(), mipMapped, SkBackingFit::kExact, budgeted,
- std::move(colorSpace)));
+ dstDesc, src->origin(), mipMapped, SkBackingFit::kExact, budgeted));
if (!dstContext) {
return nullptr;
}
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp
index d35d807c54..c30d155d03 100644
--- a/src/gpu/GrTextureProducer.cpp
+++ b/src/gpu/GrTextureProducer.cpp
@@ -24,14 +24,10 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context,
const SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight);
GrMipMapped mipMapped = dstWillRequireMipMaps ? GrMipMapped::kYes : GrMipMapped::kNo;
- sk_sp<SkColorSpace> colorSpace;
- if (GrPixelConfigIsSRGB(inputProxy->config())) {
- colorSpace = SkColorSpace::MakeSRGB();
- }
sk_sp<GrRenderTargetContext> copyRTC =
context->contextPriv().makeDeferredRenderTargetContextWithFallback(
SkBackingFit::kExact, dstRect.width(), dstRect.height(), inputProxy->config(),
- std::move(colorSpace), 1, mipMapped, inputProxy->origin());
+ nullptr, 1, mipMapped, inputProxy->origin());
if (!copyRTC) {
return nullptr;
}
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index bb85aabbbb..9d19b4085f 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -108,16 +108,10 @@ sk_sp<GrTextureProxy> GrYUVProvider::refAsTextureProxy(GrContext* ctx, const GrS
1, SkBudgeted::kYes, fit);
}
- // We never want to perform color-space conversion during the decode. However, if the proxy
- // config is sRGB then we must use a sRGB color space.
- sk_sp<SkColorSpace> colorSpace;
- if (GrPixelConfigIsSRGB(desc.fConfig)) {
- colorSpace = SkColorSpace::MakeSRGB();
- }
// TODO: investigate preallocating mip maps here
sk_sp<GrRenderTargetContext> renderTargetContext(
ctx->contextPriv().makeDeferredRenderTargetContext(
- SkBackingFit::kExact, desc.fWidth, desc.fHeight, desc.fConfig, std::move(colorSpace),
+ SkBackingFit::kExact, desc.fWidth, desc.fHeight, desc.fConfig, nullptr,
desc.fSampleCnt, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
if (!renderTargetContext) {
return nullptr;
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 6767a1b50f..783be5cb6c 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -123,12 +123,8 @@ sk_sp<GrTextureProxy> GrCopyBaseMipMapToTextureProxy(GrContext* ctx, GrTexturePr
}
// Copy the base layer to our proxy
- sk_sp<SkColorSpace> colorSpace;
- if (GrPixelConfigIsSRGB(proxy->config())) {
- colorSpace = SkColorSpace::MakeSRGB();
- }
sk_sp<GrSurfaceContext> sContext =
- ctx->contextPriv().makeWrappedSurfaceContext(proxy, std::move(colorSpace));
+ ctx->contextPriv().makeWrappedSurfaceContext(proxy);
SkASSERT(sContext);
SkAssertResult(sContext->copy(baseProxy));
diff --git a/src/gpu/gl/GrGLDefines.h b/src/gpu/gl/GrGLDefines.h
index 645397316b..30d0a4c2f9 100644
--- a/src/gpu/gl/GrGLDefines.h
+++ b/src/gpu/gl/GrGLDefines.h
@@ -610,17 +610,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/mtl/GrMtlTexture.mm b/src/gpu/mtl/GrMtlTexture.mm
index e029836b60..ac4e73579a 100644
--- a/src/gpu/mtl/GrMtlTexture.mm
+++ b/src/gpu/mtl/GrMtlTexture.mm
@@ -31,12 +31,7 @@ sk_sp<GrMtlTexture> GrMtlTexture::CreateNewTexture(GrMtlGpu* gpu, SkBudgeted bud
descriptor.cpuCacheMode = MTLCPUCacheModeWriteCombined;
// Shared is not available on MacOS. Is there a reason to want managed to allow mapping?
descriptor.storageMode = MTLStorageModePrivate;
-
- MTLTextureUsage texUsage = MTLTextureUsageShaderRead;
- if (GrMTLFormatIsSRGB(format, nullptr)) {
- texUsage |= MTLTextureUsagePixelFormatView;
- }
- descriptor.usage = texUsage;
+ descriptor.usage = MTLTextureUsageShaderRead;
id<MTLTexture> texture = [gpu->device() newTextureWithDescriptor:descriptor];
diff --git a/src/gpu/mtl/GrMtlUtil.h b/src/gpu/mtl/GrMtlUtil.h
index 1900c3933d..e53a8f5ee8 100644
--- a/src/gpu/mtl/GrMtlUtil.h
+++ b/src/gpu/mtl/GrMtlUtil.h
@@ -23,10 +23,4 @@ bool GrPixelConfigToMTLFormat(GrPixelConfig config, MTLPixelFormat* format);
*/
GrPixelConfig GrMTLFormatToPixelConfig(MTLPixelFormat format);
-/**
- * Returns true if the given vulkan texture format is sRGB encoded.
- * Also provides the non-sRGB version, if there is one.
- */
-bool GrMTLFormatIsSRGB(MTLPixelFormat format, MTLPixelFormat* linearFormat);
-
#endif
diff --git a/src/gpu/mtl/GrMtlUtil.mm b/src/gpu/mtl/GrMtlUtil.mm
index e8a736c8f1..3c5df209c4 100644
--- a/src/gpu/mtl/GrMtlUtil.mm
+++ b/src/gpu/mtl/GrMtlUtil.mm
@@ -113,23 +113,3 @@ GrPixelConfig GrMTLFormatToPixelConfig(MTLPixelFormat format) {
return kUnknown_GrPixelConfig;
}
}
-
-bool GrMTLFormatIsSRGB(MTLPixelFormat format, MTLPixelFormat* linearFormat) {
- MTLPixelFormat linearFmt = format;
- switch (format) {
- case MTLPixelFormatRGBA8Unorm_sRGB:
- linearFmt = MTLPixelFormatRGBA8Unorm;
- break;
- case MTLPixelFormatBGRA8Unorm_sRGB:
- linearFmt = MTLPixelFormatBGRA8Unorm;
- break;
- default:
- break;
- }
-
- if (linearFormat) {
- *linearFormat = linearFmt;
- }
- return (linearFmt != format);
-}
-