aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/glsl
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-01-19 16:58:02 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-19 22:36:26 +0000
commitde4d301881e7fd084f1f0b359ec6f9b2bf8bd4c5 (patch)
treeedbe55dab521fec2922e3826b4e3d26150254411 /src/gpu/glsl
parent5bee0b6de6b3ad1166d067e6b5046b48b8240a29 (diff)
Replaced all calls to fragmentPosition() with sk_FragCoord
BUG=skia: Change-Id: I179576e148ea6caf6e1c40f0a216421898bcb35d Reviewed-on: https://skia-review.googlesource.com/5941 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/glsl')
-rw-r--r--src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp5
-rw-r--r--src/gpu/glsl/GrGLSLFragmentShaderBuilder.h6
-rw-r--r--src/gpu/glsl/GrGLSLProgramBuilder.cpp4
-rw-r--r--src/gpu/glsl/GrGLSLProgramBuilder.h8
-rw-r--r--src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp4
-rw-r--r--src/gpu/glsl/GrGLSLXferProcessor.cpp5
6 files changed, 10 insertions, 22 deletions
diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
index 7ef734876c..f583420f29 100644
--- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
@@ -130,11 +130,6 @@ SkString GrGLSLFragmentShaderBuilder::ensureCoords2D(const GrShaderVar& coords)
return coords2D;
}
-const char* GrGLSLFragmentShaderBuilder::fragmentPosition() {
- SkDEBUGCODE(fUsedProcessorFeatures |= GrProcessor::kFragmentPosition_RequiredFeature;)
- return "sk_FragCoord";
-}
-
const char* GrGLSLFragmentShaderBuilder::distanceVectorName() const {
return "fsDistanceVector";
}
diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h
index f7d2323074..ab806ea914 100644
--- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h
+++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h
@@ -47,11 +47,6 @@ public:
*/
virtual SkString ensureCoords2D(const GrShaderVar&) = 0;
-
- /** Returns a variable name that represents the position of the fragment in the FS. The position
- is in device space (e.g. 0,0 is the top left and pixel centers are at half-integers). */
- virtual const char* fragmentPosition() = 0;
-
// TODO: remove this method.
void declAppendf(const char* fmt, ...);
@@ -167,7 +162,6 @@ public:
// Shared GrGLSLFragmentBuilder interface.
bool enableFeature(GLSLFeature) override;
virtual SkString ensureCoords2D(const GrShaderVar&) override;
- const char* fragmentPosition() override;
const char* distanceVectorName() const override;
// GrGLSLFPFragmentBuilder interface.
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index c8058251e1..2b8a3a7264 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -20,7 +20,7 @@ const int GrGLSLProgramBuilder::kVarsPerBlock = 8;
GrGLSLProgramBuilder::GrGLSLProgramBuilder(const GrPipeline& pipeline,
const GrPrimitiveProcessor& primProc,
- const GrProgramDesc& desc)
+ GrProgramDesc* desc)
: fVS(this)
, fGS(this)
, fFS(this)
@@ -348,7 +348,7 @@ void GrGLSLProgramBuilder::emitImageStorage(const GrProcessor::ImageStorageAcces
void GrGLSLProgramBuilder::emitFSOutputSwizzle(bool hasSecondaryOutput) {
// Swizzle the fragment shader outputs if necessary.
GrSwizzle swizzle;
- swizzle.setFromKey(this->desc().header().fOutputSwizzle);
+ swizzle.setFromKey(this->desc()->header().fOutputSwizzle);
if (swizzle != GrSwizzle::RGBA()) {
fFS.codeAppendf("%s = %s.%s;", fFS.getPrimaryColorOutputName(),
fFS.getPrimaryColorOutputName(),
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.h b/src/gpu/glsl/GrGLSLProgramBuilder.h
index 2dba90fa90..3074110f60 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.h
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.h
@@ -40,8 +40,8 @@ public:
const GrPrimitiveProcessor& primitiveProcessor() const { return fPrimProc; }
const GrPipeline& pipeline() const { return fPipeline; }
- const GrProgramDesc& desc() const { return fDesc; }
- const GrProgramDesc::KeyHeader& header() const { return fDesc.header(); }
+ GrProgramDesc* desc() { return fDesc; }
+ const GrProgramDesc::KeyHeader& header() const { return fDesc->header(); }
void appendUniformDecls(GrShaderFlags visibility, SkString*) const;
@@ -99,7 +99,7 @@ public:
const GrPipeline& fPipeline;
const GrPrimitiveProcessor& fPrimProc;
- const GrProgramDesc& fDesc;
+ GrProgramDesc* fDesc;
BuiltinUniformHandles fUniformHandles;
@@ -110,7 +110,7 @@ public:
protected:
explicit GrGLSLProgramBuilder(const GrPipeline&,
const GrPrimitiveProcessor&,
- const GrProgramDesc&);
+ GrProgramDesc*);
void addFeature(GrShaderFlags shaders, uint32_t featureBit, const char* extensionName);
diff --git a/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp b/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp
index f8302b38fe..2aded892d4 100644
--- a/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp
@@ -22,7 +22,7 @@ void GrGLSLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& po
fProgramBuilder->addRTAdjustmentUniform(kHigh_GrSLPrecision,
fProgramBuilder->rtAdjustment(),
&fRtAdjustName);
- if (this->getProgramBuilder()->desc().header().fSnapVerticesToPixelCenters) {
+ if (this->getProgramBuilder()->desc()->header().fSnapVerticesToPixelCenters) {
if (kVec3f_GrSLType == posVar.getType()) {
const char* p = posVar.c_str();
this->codeAppendf("{vec2 _posTmp = vec2(%s.x/%s.z, %s.y/%s.z);", p, p, p, p);
@@ -47,7 +47,7 @@ void GrGLSLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& po
}
// We could have the GrGeometryProcessor do this, but its just easier to have it performed
// here. If we ever need to set variable pointsize, then we can reinvestigate.
- if (this->getProgramBuilder()->desc().header().fHasPointSize) {
+ if (this->getProgramBuilder()->desc()->header().fHasPointSize) {
this->codeAppend("gl_PointSize = 1.0;");
}
}
diff --git a/src/gpu/glsl/GrGLSLXferProcessor.cpp b/src/gpu/glsl/GrGLSLXferProcessor.cpp
index e2698199fd..4101080090 100644
--- a/src/gpu/glsl/GrGLSLXferProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLXferProcessor.cpp
@@ -49,11 +49,10 @@ void GrGLSLXferProcessor::emitCode(const EmitArgs& args) {
kDefault_GrSLPrecision,
"DstTextureCoordScale",
&dstCoordScaleName);
- const char* fragPos = fragBuilder->fragmentPosition();
fragBuilder->codeAppend("// Read color from copy of the destination.\n");
- fragBuilder->codeAppendf("vec2 _dstTexCoord = (%s.xy - %s) * %s;",
- fragPos, dstTopLeftName, dstCoordScaleName);
+ fragBuilder->codeAppendf("vec2 _dstTexCoord = (sk_FragCoord.xy - %s) * %s;",
+ dstTopLeftName, dstCoordScaleName);
if (!topDown) {
fragBuilder->codeAppend("_dstTexCoord.y = 1.0 - _dstTexCoord.y;");