Chromium Code Reviews| Index: src/gpu/gl/GrGLGpu.cpp |
| diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp |
| index f9cba433c742e29b03951d773a009d2dda0e5a06..e9f608e036c832631a7b69bd7411547eb97a488b 100644 |
| --- a/src/gpu/gl/GrGLGpu.cpp |
| +++ b/src/gpu/gl/GrGLGpu.cpp |
| @@ -895,6 +895,7 @@ 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: |
| @@ -2098,13 +2099,15 @@ bool GrGLGpu::flushGLState(const DrawArgs& args) { |
| SkSTArray<8, const GrTextureAccess*> textureAccesses; |
| program->setData(*args.fPrimitiveProcessor, pipeline, &textureAccesses); |
| + GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTarget()); |
| + GrSRGBPolicy srgbPolicy = GrPixelConfigSRGBPolicy(glRT->config()); |
| + |
| int numTextureAccesses = textureAccesses.count(); |
| for (int i = 0; i < numTextureAccesses; i++) { |
| - this->bindTexture(i, textureAccesses[i]->getParams(), |
| + this->bindTexture(i, textureAccesses[i]->getParams(), srgbPolicy, |
| static_cast<GrGLTexture*>(textureAccesses[i]->getTexture())); |
| } |
| - GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTarget()); |
| this->flushStencil(pipeline.getStencil()); |
| this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->origin()); |
| this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !pipeline.getStencil().isDisabled()); |
| @@ -2581,6 +2584,16 @@ 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); |
|
Brian Osman
2016/03/11 17:15:24
This block of code may make no sense, given how sB
|
| } 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. |
| @@ -3273,7 +3286,8 @@ static void get_tex_param_swizzle(GrPixelConfig config, |
| } |
| } |
| -void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* texture) { |
| +void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrSRGBPolicy srgbPolicy, |
| + GrGLTexture* texture) { |
| SkASSERT(texture); |
| #ifdef SK_DEBUG |
| @@ -3309,6 +3323,27 @@ void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur |
| bool setAll = timestamp < this->getResetTimestamp(); |
| GrGLTexture::TexParams newTexParams; |
| + if (this->caps()->srgbSupport()) { |
| + static GrGLenum glSRGBDecodeModes[] = { |
| + GR_GL_DECODE_EXT, // kUnknown_GrSRGBPolicy |
| + GR_GL_DECODE_EXT, // kAllowSRGB_GrSRGBPolicy |
| + GR_GL_SKIP_DECODE_EXT // kSuppressSRGB_GrSRGBPolicy |
| + }; |
| + |
| + // 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. |
| + if (kUnknown_GrSRGBPolicy != params.srgbPolicy()) { |
| + srgbPolicy = params.srgbPolicy(); |
| + } |
| + |
| + SkASSERT(srgbPolicy >= kAllowSRGB_GrSRGBPolicy && srgbPolicy <= kSuppressSRGB_GrSRGBPolicy); |
| + newTexParams.fSRGBDecode = glSRGBDecodeModes[srgbPolicy]; |
| + 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, |
| @@ -3976,7 +4011,7 @@ void GrGLGpu::copySurfaceAsDraw(GrSurface* dst, |
| GrGLTexture* srcTex = static_cast<GrGLTexture*>(src->asTexture()); |
| GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_FilterMode); |
| - this->bindTexture(0, params, srcTex); |
| + this->bindTexture(0, params, kAllowSRGB_GrSRGBPolicy, srcTex); |
| GrGLIRect dstVP; |
| this->bindSurfaceFBOForCopy(dst, GR_GL_FRAMEBUFFER, &dstVP, kDst_TempFBOTarget); |