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

Side by Side Diff: src/gpu/gl/GrGLGpu.cpp

Issue 1814533003: Revert of sRGB support in Ganesh. Several pieces: (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLTexture.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrGLGpu.h" 8 #include "GrGLGpu.h"
9 #include "GrGLGLSL.h" 9 #include "GrGLGLSL.h"
10 #include "GrGLStencilAttachment.h" 10 #include "GrGLStencilAttachment.h"
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 case kAlpha_8_GrPixelConfig: 891 case kAlpha_8_GrPixelConfig:
892 return 1; 892 return 1;
893 case kRGB_565_GrPixelConfig: 893 case kRGB_565_GrPixelConfig:
894 case kRGBA_4444_GrPixelConfig: 894 case kRGBA_4444_GrPixelConfig:
895 case kAlpha_half_GrPixelConfig: 895 case kAlpha_half_GrPixelConfig:
896 case kRGBA_half_GrPixelConfig: 896 case kRGBA_half_GrPixelConfig:
897 return 2; 897 return 2;
898 case kRGBA_8888_GrPixelConfig: 898 case kRGBA_8888_GrPixelConfig:
899 case kBGRA_8888_GrPixelConfig: 899 case kBGRA_8888_GrPixelConfig:
900 case kSRGBA_8888_GrPixelConfig: 900 case kSRGBA_8888_GrPixelConfig:
901 case kSBGRA_8888_GrPixelConfig:
902 case kRGBA_float_GrPixelConfig: 901 case kRGBA_float_GrPixelConfig:
903 return 4; 902 return 4;
904 default: 903 default:
905 return 0; 904 return 0;
906 } 905 }
907 } 906 }
908 907
909 static inline GrGLenum check_alloc_error(const GrSurfaceDesc& desc, 908 static inline GrGLenum check_alloc_error(const GrSurfaceDesc& desc,
910 const GrGLInterface* interface) { 909 const GrGLInterface* interface) {
911 if (SkToBool(desc.fFlags & kCheckAllocation_GrSurfaceFlag)) { 910 if (SkToBool(desc.fFlags & kCheckAllocation_GrSurfaceFlag)) {
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 if (blendInfo.fWriteColor) { 2094 if (blendInfo.fWriteColor) {
2096 // Swizzle the blend to match what the shader will output. 2095 // Swizzle the blend to match what the shader will output.
2097 const GrSwizzle& swizzle = this->glCaps().glslCaps()->configOutputSwizzl e( 2096 const GrSwizzle& swizzle = this->glCaps().glslCaps()->configOutputSwizzl e(
2098 args.fPipeline->getRenderTarget()->config()); 2097 args.fPipeline->getRenderTarget()->config());
2099 this->flushBlend(blendInfo, swizzle); 2098 this->flushBlend(blendInfo, swizzle);
2100 } 2099 }
2101 2100
2102 SkSTArray<8, const GrTextureAccess*> textureAccesses; 2101 SkSTArray<8, const GrTextureAccess*> textureAccesses;
2103 program->setData(*args.fPrimitiveProcessor, pipeline, &textureAccesses); 2102 program->setData(*args.fPrimitiveProcessor, pipeline, &textureAccesses);
2104 2103
2105 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa rget());
2106 bool allowSRGB = GrAllowSRGBForDestinationPixelConfig(glRT->config());
2107
2108 int numTextureAccesses = textureAccesses.count(); 2104 int numTextureAccesses = textureAccesses.count();
2109 for (int i = 0; i < numTextureAccesses; i++) { 2105 for (int i = 0; i < numTextureAccesses; i++) {
2110 this->bindTexture(i, textureAccesses[i]->getParams(), allowSRGB, 2106 this->bindTexture(i, textureAccesses[i]->getParams(),
2111 static_cast<GrGLTexture*>(textureAccesses[i]->getTextu re())); 2107 static_cast<GrGLTexture*>(textureAccesses[i]->getTextu re()));
2112 } 2108 }
2113 2109
2110 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa rget());
2114 this->flushStencil(pipeline.getStencil()); 2111 this->flushStencil(pipeline.getStencil());
2115 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or igin()); 2112 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or igin());
2116 this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !pipeline.getStenc il().isDisabled()); 2113 this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !pipeline.getStenc il().isDisabled());
2117 2114
2118 // This must come after textures are flushed because a texture may need 2115 // This must come after textures are flushed because a texture may need
2119 // to be msaa-resolved (which will modify bound FBO state). 2116 // to be msaa-resolved (which will modify bound FBO state).
2120 this->flushRenderTarget(glRT, nullptr); 2117 this->flushRenderTarget(glRT, nullptr);
2121 2118
2122 return true; 2119 return true;
2123 } 2120 }
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
2612 if (readConfig == kBGRA_8888_GrPixelConfig && 2609 if (readConfig == kBGRA_8888_GrPixelConfig &&
2613 this->glCaps().isConfigRenderable(kRGBA_8888_GrPixelConfig, false) & & 2610 this->glCaps().isConfigRenderable(kRGBA_8888_GrPixelConfig, false) & &
2614 this->readPixelsSupported(kRGBA_8888_GrPixelConfig, kRGBA_8888_GrPix elConfig)) { 2611 this->readPixelsSupported(kRGBA_8888_GrPixelConfig, kRGBA_8888_GrPix elConfig)) {
2615 // We're trying to read BGRA but it's not supported. If RGBA is rend erable and 2612 // We're trying to read BGRA but it's not supported. If RGBA is rend erable and
2616 // we can read it back, then do a swizzling draw to a RGBA and read it back (which 2613 // we can read it back, then do a swizzling draw to a RGBA and read it back (which
2617 // will effectively be BGRA). 2614 // will effectively be BGRA).
2618 tempDrawInfo->fTempSurfaceDesc.fConfig = kRGBA_8888_GrPixelConfig; 2615 tempDrawInfo->fTempSurfaceDesc.fConfig = kRGBA_8888_GrPixelConfig;
2619 tempDrawInfo->fSwizzle = GrSwizzle::BGRA(); 2616 tempDrawInfo->fSwizzle = GrSwizzle::BGRA();
2620 tempDrawInfo->fReadConfig = kRGBA_8888_GrPixelConfig; 2617 tempDrawInfo->fReadConfig = kRGBA_8888_GrPixelConfig;
2621 ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference); 2618 ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
2622 } else if (readConfig == kSBGRA_8888_GrPixelConfig &&
2623 this->glCaps().isConfigRenderable(kSRGBA_8888_GrPixelConfig, false) &&
2624 this->readPixelsSupported(kSRGBA_8888_GrPixelConfig, kSRGBA_8888_GrP ixelConfig)) {
2625 // We're trying to read sBGRA but it's not supported. If sRGBA is re nderable and
2626 // we can read it back, then do a swizzling draw to a sRGBA and read it back (which
2627 // will effectively be sBGRA).
2628 tempDrawInfo->fTempSurfaceDesc.fConfig = kSRGBA_8888_GrPixelConfig;
2629 tempDrawInfo->fSwizzle = GrSwizzle::BGRA();
2630 tempDrawInfo->fReadConfig = kSRGBA_8888_GrPixelConfig;
2631 ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
2632 } else if (readConfig == kAlpha_8_GrPixelConfig) { 2619 } else if (readConfig == kAlpha_8_GrPixelConfig) {
2633 // onReadPixels implements a fallback for cases where we are want to read kAlpha_8, 2620 // onReadPixels implements a fallback for cases where we are want to read kAlpha_8,
2634 // it's unsupported, but 32bit RGBA reads are supported. 2621 // it's unsupported, but 32bit RGBA reads are supported.
2635 // Don't attempt to do any srgb conversions since we only care about alpha. 2622 // Don't attempt to do any srgb conversions since we only care about alpha.
2636 GrPixelConfig cpuTempConfig = kRGBA_8888_GrPixelConfig; 2623 GrPixelConfig cpuTempConfig = kRGBA_8888_GrPixelConfig;
2637 if (GrPixelConfigIsSRGB(srcSurface->config())) { 2624 if (GrPixelConfigIsSRGB(srcSurface->config())) {
2638 cpuTempConfig = kSRGBA_8888_GrPixelConfig; 2625 cpuTempConfig = kSRGBA_8888_GrPixelConfig;
2639 } 2626 }
2640 if (!this->readPixelsSupported(srcSurface, cpuTempConfig)) { 2627 if (!this->readPixelsSupported(srcSurface, cpuTempConfig)) {
2641 // If we can't read RGBA from the src try to draw to a kRGBA_888 8 (or kSRGBA_8888) 2628 // If we can't read RGBA from the src try to draw to a kRGBA_888 8 (or kSRGBA_8888)
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
3314 the generated shader code. This potentially allows greater reuse of cached sha ders. */ 3301 the generated shader code. This potentially allows greater reuse of cached sha ders. */
3315 static void get_tex_param_swizzle(GrPixelConfig config, 3302 static void get_tex_param_swizzle(GrPixelConfig config,
3316 const GrGLCaps& caps, 3303 const GrGLCaps& caps,
3317 GrGLenum* glSwizzle) { 3304 GrGLenum* glSwizzle) {
3318 const GrSwizzle& swizzle = caps.configSwizzle(config); 3305 const GrSwizzle& swizzle = caps.configSwizzle(config);
3319 for (int i = 0; i < 4; ++i) { 3306 for (int i = 0; i < 4; ++i) {
3320 glSwizzle[i] = get_component_enum_from_char(swizzle.c_str()[i]); 3307 glSwizzle[i] = get_component_enum_from_char(swizzle.c_str()[i]);
3321 } 3308 }
3322 } 3309 }
3323 3310
3324 void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, bool dstCo nfigAllowsSRGB, 3311 void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur e* texture) {
3325 GrGLTexture* texture) {
3326 SkASSERT(texture); 3312 SkASSERT(texture);
3327 3313
3328 #ifdef SK_DEBUG 3314 #ifdef SK_DEBUG
3329 if (!this->caps()->npotTextureTileSupport()) { 3315 if (!this->caps()->npotTextureTileSupport()) {
3330 const bool tileX = SkShader::kClamp_TileMode != params.getTileModeX(); 3316 const bool tileX = SkShader::kClamp_TileMode != params.getTileModeX();
3331 const bool tileY = SkShader::kClamp_TileMode != params.getTileModeY(); 3317 const bool tileY = SkShader::kClamp_TileMode != params.getTileModeY();
3332 if (tileX || tileY) { 3318 if (tileX || tileY) {
3333 const int w = texture->width(); 3319 const int w = texture->width();
3334 const int h = texture->height(); 3320 const int h = texture->height();
3335 SkASSERT(SkIsPow2(w) && SkIsPow2(h)); 3321 SkASSERT(SkIsPow2(w) && SkIsPow2(h));
(...skipping 15 matching lines...) Expand all
3351 this->setTextureUnit(unitIdx); 3337 this->setTextureUnit(unitIdx);
3352 GL_CALL(BindTexture(target, texture->textureID())); 3338 GL_CALL(BindTexture(target, texture->textureID()));
3353 fHWBoundTextureUniqueIDs[unitIdx] = textureID; 3339 fHWBoundTextureUniqueIDs[unitIdx] = textureID;
3354 } 3340 }
3355 3341
3356 ResetTimestamp timestamp; 3342 ResetTimestamp timestamp;
3357 const GrGLTexture::TexParams& oldTexParams = texture->getCachedTexParams(&ti mestamp); 3343 const GrGLTexture::TexParams& oldTexParams = texture->getCachedTexParams(&ti mestamp);
3358 bool setAll = timestamp < this->getResetTimestamp(); 3344 bool setAll = timestamp < this->getResetTimestamp();
3359 GrGLTexture::TexParams newTexParams; 3345 GrGLTexture::TexParams newTexParams;
3360 3346
3361 if (this->caps()->srgbSupport()) {
3362 // By default, the decision to allow SRGB decode is based on the destina tion config.
3363 // A texture can override that by specifying a value in GrTextureParams.
3364 newTexParams.fSRGBDecode =
3365 (dstConfigAllowsSRGB || GrTextureParams::kForceAllowSRGB_SRGBMode == params.srgbMode())
3366 ? GR_GL_DECODE_EXT : GR_GL_SKIP_DECODE_EXT;
3367
3368 if (setAll || newTexParams.fSRGBDecode != oldTexParams.fSRGBDecode) {
3369 this->setTextureUnit(unitIdx);
3370 GL_CALL(TexParameteri(target, GR_GL_TEXTURE_SRGB_DECODE_EXT, newTexP arams.fSRGBDecode));
3371 }
3372 }
3373
3374 static GrGLenum glMinFilterModes[] = { 3347 static GrGLenum glMinFilterModes[] = {
3375 GR_GL_NEAREST, 3348 GR_GL_NEAREST,
3376 GR_GL_LINEAR, 3349 GR_GL_LINEAR,
3377 GR_GL_LINEAR_MIPMAP_LINEAR 3350 GR_GL_LINEAR_MIPMAP_LINEAR
3378 }; 3351 };
3379 static GrGLenum glMagFilterModes[] = { 3352 static GrGLenum glMagFilterModes[] = {
3380 GR_GL_NEAREST, 3353 GR_GL_NEAREST,
3381 GR_GL_LINEAR, 3354 GR_GL_LINEAR,
3382 GR_GL_LINEAR 3355 GR_GL_LINEAR
3383 }; 3356 };
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
4031 4004
4032 void GrGLGpu::copySurfaceAsDraw(GrSurface* dst, 4005 void GrGLGpu::copySurfaceAsDraw(GrSurface* dst,
4033 GrSurface* src, 4006 GrSurface* src,
4034 const SkIRect& srcRect, 4007 const SkIRect& srcRect,
4035 const SkIPoint& dstPoint) { 4008 const SkIPoint& dstPoint) {
4036 int w = srcRect.width(); 4009 int w = srcRect.width();
4037 int h = srcRect.height(); 4010 int h = srcRect.height();
4038 4011
4039 GrGLTexture* srcTex = static_cast<GrGLTexture*>(src->asTexture()); 4012 GrGLTexture* srcTex = static_cast<GrGLTexture*>(src->asTexture());
4040 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_Fil terMode); 4013 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_Fil terMode);
4041 this->bindTexture(0, params, true, srcTex); 4014 this->bindTexture(0, params, srcTex);
4042 4015
4043 GrGLIRect dstVP; 4016 GrGLIRect dstVP;
4044 this->bindSurfaceFBOForCopy(dst, GR_GL_FRAMEBUFFER, &dstVP, kDst_TempFBOTarg et); 4017 this->bindSurfaceFBOForCopy(dst, GR_GL_FRAMEBUFFER, &dstVP, kDst_TempFBOTarg et);
4045 this->flushViewport(dstVP); 4018 this->flushViewport(dstVP);
4046 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; 4019 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
4047 4020
4048 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, w, h); 4021 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, w, h);
4049 4022
4050 int progIdx = TextureTargetToCopyProgramIdx(srcTex->target()); 4023 int progIdx = TextureTargetToCopyProgramIdx(srcTex->target());
4051 4024
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
4414 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || 4387 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() ||
4415 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { 4388 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) {
4416 copyParams->fFilter = GrTextureParams::kNone_FilterMode; 4389 copyParams->fFilter = GrTextureParams::kNone_FilterMode;
4417 copyParams->fWidth = texture->width(); 4390 copyParams->fWidth = texture->width();
4418 copyParams->fHeight = texture->height(); 4391 copyParams->fHeight = texture->height();
4419 return true; 4392 return true;
4420 } 4393 }
4421 } 4394 }
4422 return false; 4395 return false;
4423 } 4396 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLTexture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698