Respect color space in GrTextureDomainEffect
Forgot that this was plumbed in, but not being used. From local testing, fixes color correctness in a variety of real world content. BUG=skia: Change-Id: Iad4cdf38da03719d1af144a9094c16d545139114 Reviewed-on: https://skia-review.googlesource.com/6296 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
3711e1185d
commit
c468963b96
@ -10,6 +10,7 @@
|
||||
#include "GrShaderCaps.h"
|
||||
#include "GrSimpleTextureEffect.h"
|
||||
#include "SkFloatingPoint.h"
|
||||
#include "glsl/GrGLSLColorSpaceXformHelper.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
@ -50,7 +51,8 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
|
||||
const char* outColor,
|
||||
const SkString& inCoords,
|
||||
GrGLSLFragmentProcessor::SamplerHandle sampler,
|
||||
const char* inModulateColor) {
|
||||
const char* inModulateColor,
|
||||
GrGLSLColorSpaceXformHelper* colorXformHelper) {
|
||||
SkASSERT((Mode)-1 == fMode || textureDomain.mode() == fMode);
|
||||
SkDEBUGCODE(fMode = textureDomain.mode();)
|
||||
|
||||
@ -69,8 +71,8 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
|
||||
switch (textureDomain.mode()) {
|
||||
case kIgnore_Mode: {
|
||||
builder->codeAppendf("%s = ", outColor);
|
||||
builder->appendTextureLookupAndModulate(inModulateColor, sampler,
|
||||
inCoords.c_str());
|
||||
builder->appendTextureLookupAndModulate(inModulateColor, sampler, inCoords.c_str(),
|
||||
kVec2f_GrSLType, colorXformHelper);
|
||||
builder->codeAppend(";");
|
||||
break;
|
||||
}
|
||||
@ -80,8 +82,8 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
|
||||
inCoords.c_str(), fDomainName.c_str(), fDomainName.c_str());
|
||||
|
||||
builder->codeAppendf("%s = ", outColor);
|
||||
builder->appendTextureLookupAndModulate(inModulateColor, sampler,
|
||||
clampedCoords.c_str());
|
||||
builder->appendTextureLookupAndModulate(inModulateColor, sampler, clampedCoords.c_str(),
|
||||
kVec2f_GrSLType, colorXformHelper);
|
||||
builder->codeAppend(";");
|
||||
break;
|
||||
}
|
||||
@ -99,8 +101,8 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
|
||||
// result=white;" code fails to compile.
|
||||
builder->codeAppend("vec4 outside = vec4(0.0, 0.0, 0.0, 0.0);");
|
||||
builder->codeAppend("vec4 inside = ");
|
||||
builder->appendTextureLookupAndModulate(inModulateColor, sampler,
|
||||
inCoords.c_str());
|
||||
builder->appendTextureLookupAndModulate(inModulateColor, sampler, inCoords.c_str(),
|
||||
kVec2f_GrSLType, colorXformHelper);
|
||||
builder->codeAppend(";");
|
||||
|
||||
builder->codeAppendf("highp float x = (%s).x;", inCoords.c_str());
|
||||
@ -120,8 +122,8 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
|
||||
domain);
|
||||
builder->codeAppendf("%s = any(outside) ? vec4(0.0, 0.0, 0.0, 0.0) : ",
|
||||
outColor);
|
||||
builder->appendTextureLookupAndModulate(inModulateColor, sampler,
|
||||
inCoords.c_str());
|
||||
builder->appendTextureLookupAndModulate(inModulateColor, sampler, inCoords.c_str(),
|
||||
kVec2f_GrSLType, colorXformHelper);
|
||||
builder->codeAppend(";");
|
||||
}
|
||||
break;
|
||||
@ -133,8 +135,8 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
|
||||
fDomainName.c_str(), fDomainName.c_str());
|
||||
|
||||
builder->codeAppendf("%s = ", outColor);
|
||||
builder->appendTextureLookupAndModulate(inModulateColor, sampler,
|
||||
clampedCoords.c_str());
|
||||
builder->appendTextureLookupAndModulate(inModulateColor, sampler, clampedCoords.c_str(),
|
||||
kVec2f_GrSLType, colorXformHelper);
|
||||
builder->codeAppend(";");
|
||||
break;
|
||||
}
|
||||
@ -213,6 +215,10 @@ GrGLSLFragmentProcessor* GrTextureDomainEffect::onCreateGLSLInstance() const {
|
||||
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
|
||||
|
||||
GrGLSLColorSpaceXformHelper colorSpaceHelper(args.fUniformHandler,
|
||||
tde.colorSpaceXform(),
|
||||
&fColorSpaceXformUni);
|
||||
fGLDomain.sampleTexture(fragBuilder,
|
||||
args.fUniformHandler,
|
||||
args.fShaderCaps,
|
||||
@ -220,7 +226,8 @@ GrGLSLFragmentProcessor* GrTextureDomainEffect::onCreateGLSLInstance() const {
|
||||
args.fOutputColor,
|
||||
coords2D,
|
||||
args.fTexSamplers[0],
|
||||
args.fInputColor);
|
||||
args.fInputColor,
|
||||
&colorSpaceHelper);
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -228,11 +235,14 @@ GrGLSLFragmentProcessor* GrTextureDomainEffect::onCreateGLSLInstance() const {
|
||||
const GrTextureDomainEffect& tde = fp.cast<GrTextureDomainEffect>();
|
||||
const GrTextureDomain& domain = tde.fTextureDomain;
|
||||
fGLDomain.setData(pdman, domain, tde.textureSampler(0).texture()->origin());
|
||||
if (SkToBool(tde.colorSpaceXform())) {
|
||||
pdman.setSkMatrix44(fColorSpaceXformUni, tde.colorSpaceXform()->srcToDst());
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
GrTextureDomain::GLDomain fGLDomain;
|
||||
|
||||
UniformHandle fColorSpaceXformUni;
|
||||
};
|
||||
|
||||
return new GLSLProcessor;
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
|
||||
class GrGLProgramBuilder;
|
||||
class GrGLSLColorSpaceXformHelper;
|
||||
class GrGLSLShaderBuilder;
|
||||
class GrInvariantOutput;
|
||||
class GrGLSLUniformHandler;
|
||||
@ -120,7 +121,8 @@ public:
|
||||
const char* outColor,
|
||||
const SkString& inCoords,
|
||||
GrGLSLFragmentProcessor::SamplerHandle sampler,
|
||||
const char* inModulateColor = nullptr);
|
||||
const char* inModulateColor = nullptr,
|
||||
GrGLSLColorSpaceXformHelper* colorXformHelper = nullptr);
|
||||
|
||||
/**
|
||||
* Call this from GrGLSLFragmentProcessor::setData() to upload uniforms necessary for the
|
||||
|
Loading…
Reference in New Issue
Block a user