Remove sRGB overrides on GrTextureParams. Use GrPaint flags instead.
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2002253002 Review-Url: https://codereview.chromium.org/2002253002
This commit is contained in:
parent
910fff4244
commit
a167e74b4b
@ -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
|
||||
|
@ -367,11 +367,10 @@ bool GrContext::writeSurfacePixels(GrSurface* surface,
|
||||
if (!drawContext) {
|
||||
return false;
|
||||
}
|
||||
// SRGBTODO: AllowSRGBInputs? (We could force it on here, so we don't need the
|
||||
// per-texture override in config conversion effect?)
|
||||
GrPaint paint;
|
||||
paint.addColorFragmentProcessor(fp);
|
||||
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
|
||||
paint.setAllowSRGBInputs(true);
|
||||
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
|
||||
drawContext->drawRect(GrNoClip(), paint, matrix, rect, nullptr);
|
||||
|
||||
@ -479,11 +478,10 @@ bool GrContext::readSurfacePixels(GrSurface* src,
|
||||
GrConfigConversionEffect::kNone_PMConversion, textureMatrix));
|
||||
}
|
||||
if (fp) {
|
||||
// SRGBTODO: AllowSRGBInputs? (We could force it on here, so we don't need the
|
||||
// per-texture override in config conversion effect?)
|
||||
GrPaint paint;
|
||||
paint.addColorFragmentProcessor(fp);
|
||||
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
|
||||
paint.setAllowSRGBInputs(true);
|
||||
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
|
||||
sk_sp<GrDrawContext> drawContext(
|
||||
this->drawContext(sk_ref_sp(temp->asRenderTarget())));
|
||||
|
@ -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<GrConfigConversionEffect>();
|
||||
@ -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() &&
|
||||
|
@ -3101,7 +3101,7 @@ static void get_tex_param_swizzle(GrPixelConfig config,
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, bool dstConfigAllowsSRGB,
|
||||
void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, bool allowSRGBInputs,
|
||||
GrGLTexture* texture) {
|
||||
SkASSERT(texture);
|
||||
|
||||
@ -3141,9 +3141,7 @@ void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, bool dstCo
|
||||
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;
|
||||
newTexParams.fSRGBDecode = allowSRGBInputs ? GR_GL_DECODE_EXT : GR_GL_SKIP_DECODE_EXT;
|
||||
|
||||
if (setAll || newTexParams.fSRGBDecode != oldTexParams.fSRGBDecode) {
|
||||
this->setTextureUnit(unitIdx);
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
void discard(GrRenderTarget*) override;
|
||||
|
||||
// Used by GrGLProgram to configure OpenGL state.
|
||||
void bindTexture(int unitIdx, const GrTextureParams& params, bool dstConfigAllowsSRGB,
|
||||
void bindTexture(int unitIdx, const GrTextureParams& params, bool allowSRGBInputs,
|
||||
GrGLTexture* texture);
|
||||
|
||||
void bindTexelBuffer(int unitIdx, intptr_t offsetInBytes, GrPixelConfig, GrGLBuffer*);
|
||||
|
Loading…
Reference in New Issue
Block a user