aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2015-12-03 09:20:44 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-12-03 09:20:44 -0800
commit7ea439b2203855db97330b25945b87dd4b170b8b (patch)
treec64bdcbd415fc639ec8c4fb791846cac80ff6f44 /src/effects
parent73063dc517f424ad5660db0fbc5fe6fcc13f77f7 (diff)
Create GLSLUniformHandler class for gpu backend
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/GrCircleBlurFragmentProcessor.cpp13
-rw-r--r--src/effects/SkAlphaThresholdFilter.cpp19
-rw-r--r--src/effects/SkArithmeticMode_gpu.cpp22
-rw-r--r--src/effects/SkBlurMaskFilter.cpp52
-rw-r--r--src/effects/SkColorCubeFilter.cpp19
-rw-r--r--src/effects/SkColorMatrixFilter.cpp19
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp9
-rw-r--r--src/effects/SkLightingImageFilter.cpp139
-rw-r--r--src/effects/SkLumaColorFilter.cpp1
-rw-r--r--src/effects/SkMagnifierImageFilter.cpp35
-rw-r--r--src/effects/SkMorphologyImageFilter.cpp19
-rw-r--r--src/effects/SkPerlinNoiseShader.cpp19
-rw-r--r--src/effects/SkTableColorFilter.cpp8
-rw-r--r--src/effects/gradients/SkGradientShader.cpp59
-rw-r--r--src/effects/gradients/SkGradientShaderPriv.h6
-rw-r--r--src/effects/gradients/SkLinearGradient.cpp9
-rw-r--r--src/effects/gradients/SkRadialGradient.cpp9
-rw-r--r--src/effects/gradients/SkSweepGradient.cpp9
-rw-r--r--src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp106
19 files changed, 299 insertions, 273 deletions
diff --git a/src/effects/GrCircleBlurFragmentProcessor.cpp b/src/effects/GrCircleBlurFragmentProcessor.cpp
index 8c9d204928..88109921f7 100644
--- a/src/effects/GrCircleBlurFragmentProcessor.cpp
+++ b/src/effects/GrCircleBlurFragmentProcessor.cpp
@@ -11,12 +11,13 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
+#include "GrInvariantOutput.h"
#include "GrTextureProvider.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLUniformHandler.h"
class GrGLCircleBlurFragmentProcessor : public GrGLSLFragmentProcessor {
public:
@@ -40,11 +41,11 @@ void GrGLCircleBlurFragmentProcessor::emitCode(EmitArgs& args) {
// x,y - the center of the circle
// z - the distance at which the intensity starts falling off (e.g., the start of the table)
// w - the size of the profile texture
- fDataUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec4f_GrSLType,
- kDefault_GrSLPrecision,
- "data",
- &dataName);
+ fDataUniform = args.fUniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec4f_GrSLType,
+ kDefault_GrSLPrecision,
+ "data",
+ &dataName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
const char *fragmentPos = fragBuilder->fragmentPosition();
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index e6f1f088cb..661d0d362a 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -59,8 +59,8 @@ SkImageFilter* SkAlphaThresholdFilter::Create(const SkRegion& region,
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLUniformHandler.h"
class AlphaThresholdEffect : public GrFragmentProcessor {
@@ -139,12 +139,13 @@ private:
};
void GrGLAlphaThresholdEffect::emitCode(EmitArgs& args) {
- fInnerThresholdVar = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kFloat_GrSLType, kDefault_GrSLPrecision,
- "inner_threshold");
- fOuterThresholdVar = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kFloat_GrSLType, kDefault_GrSLPrecision,
- "outer_threshold");
+ GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
+ fInnerThresholdVar = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kFloat_GrSLType, kDefault_GrSLPrecision,
+ "inner_threshold");
+ fOuterThresholdVar = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kFloat_GrSLType, kDefault_GrSLPrecision,
+ "outer_threshold");
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
@@ -160,9 +161,9 @@ void GrGLAlphaThresholdEffect::emitCode(EmitArgs& args) {
fragBuilder->codeAppend(";\n");
fragBuilder->codeAppendf("\t\tfloat inner_thresh = %s;\n",
- args.fBuilder->getUniformCStr(fInnerThresholdVar));
+ uniformHandler->getUniformCStr(fInnerThresholdVar));
fragBuilder->codeAppendf("\t\tfloat outer_thresh = %s;\n",
- args.fBuilder->getUniformCStr(fOuterThresholdVar));
+ uniformHandler->getUniformCStr(fOuterThresholdVar));
fragBuilder->codeAppend("\t\tfloat mask = mask_color.a;\n");
fragBuilder->codeAppend("vec4 color = input_color;\n");
diff --git a/src/effects/SkArithmeticMode_gpu.cpp b/src/effects/SkArithmeticMode_gpu.cpp
index a3793243ee..ce8e426d41 100644
--- a/src/effects/SkArithmeticMode_gpu.cpp
+++ b/src/effects/SkArithmeticMode_gpu.cpp
@@ -15,8 +15,8 @@
#include "GrTexture.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLUniformHandler.h"
#include "glsl/GrGLSLXferProcessor.h"
static const bool gUseUnpremul = false;
@@ -65,10 +65,10 @@ public:
SkString dstColor("dstColor");
this->emitChild(0, nullptr, &dstColor, args);
- fKUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec4f_GrSLType, kDefault_GrSLPrecision,
- "k");
- const char* kUni = args.fBuilder->getUniformCStr(fKUni);
+ fKUni = args.fUniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec4f_GrSLType, kDefault_GrSLPrecision,
+ "k");
+ const char* kUni = args.fUniformHandler->getUniformCStr(fKUni);
add_arithmetic_code(fragBuilder,
args.fInputColor,
@@ -210,18 +210,18 @@ public:
}
private:
- void emitBlendCodeForDstRead(GrGLSLXPBuilder* pb,
- GrGLSLXPFragmentBuilder* fragBuilder,
+ void emitBlendCodeForDstRead(GrGLSLXPFragmentBuilder* fragBuilder,
+ GrGLSLUniformHandler* uniformHandler,
const char* srcColor,
const char* srcCoverage,
const char* dstColor,
const char* outColor,
const char* outColorSecondary,
const GrXferProcessor& proc) override {
- fKUni = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec4f_GrSLType, kDefault_GrSLPrecision,
- "k");
- const char* kUni = pb->getUniformCStr(fKUni);
+ fKUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec4f_GrSLType, kDefault_GrSLPrecision,
+ "k");
+ const char* kUni = uniformHandler->getUniformCStr(fKUni);
add_arithmetic_code(fragBuilder, srcColor, dstColor, outColor, kUni, fEnforcePMColor);
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 8dd82c5ac3..ca0b18042b 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -29,9 +29,9 @@
#include "effects/GrSimpleTextureEffect.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLTextureSampler.h"
+#include "glsl/GrGLSLUniformHandler.h"
#endif
SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) {
@@ -720,21 +720,22 @@ void GrGLRectBlurEffect::GenKey(GrSLPrecision precision, GrProcessorKeyBuilder*
void GrGLRectBlurEffect::emitCode(EmitArgs& args) {
+ GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
const char *rectName;
const char *profileSizeName;
const char* precisionString = GrGLSLShaderVar::PrecisionString(args.fGLSLCaps, fPrecision);
- fProxyRectUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec4f_GrSLType,
- fPrecision,
- "proxyRect",
- &rectName);
- fProfileSizeUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kFloat_GrSLType,
- kDefault_GrSLPrecision,
- "profileSize",
- &profileSizeName);
+ fProxyRectUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec4f_GrSLType,
+ fPrecision,
+ "proxyRect",
+ &rectName);
+ fProfileSizeUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kFloat_GrSLType,
+ kDefault_GrSLPrecision,
+ "profileSize",
+ &profileSizeName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
const char *fragmentPos = fragBuilder->fragmentPosition();
@@ -1063,24 +1064,25 @@ void GrGLRRectBlurEffect::emitCode(EmitArgs& args) {
const char *cornerRadiusName;
const char *blurRadiusName;
+ GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
// The proxy rect has left, top, right, and bottom edges correspond to
// components x, y, z, and w, respectively.
- fProxyRectUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec4f_GrSLType,
- kDefault_GrSLPrecision,
- "proxyRect",
- &rectName);
- fCornerRadiusUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kFloat_GrSLType,
- kDefault_GrSLPrecision,
- "cornerRadius",
- &cornerRadiusName);
- fBlurRadiusUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kFloat_GrSLType,
+ fProxyRectUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec4f_GrSLType,
kDefault_GrSLPrecision,
- "blurRadius",
- &blurRadiusName);
+ "proxyRect",
+ &rectName);
+ fCornerRadiusUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kFloat_GrSLType,
+ kDefault_GrSLPrecision,
+ "cornerRadius",
+ &cornerRadiusName);
+ fBlurRadiusUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kFloat_GrSLType,
+ kDefault_GrSLPrecision,
+ "blurRadius",
+ &blurRadiusName);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
const char* fragmentPos = fragBuilder->fragmentPosition();
diff --git a/src/effects/SkColorCubeFilter.cpp b/src/effects/SkColorCubeFilter.cpp
index a6f8e78e6e..07b229ceae 100644
--- a/src/effects/SkColorCubeFilter.cpp
+++ b/src/effects/SkColorCubeFilter.cpp
@@ -20,8 +20,8 @@
#include "SkGr.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLUniformHandler.h"
#endif
///////////////////////////////////////////////////////////////////////////////
@@ -246,14 +246,15 @@ void GrColorCubeEffect::GLSLProcessor::emitCode(EmitArgs& args) {
args.fInputColor = "vec4(1)";
}
- fColorCubeSizeUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kFloat_GrSLType, kDefault_GrSLPrecision,
- "Size");
- const char* colorCubeSizeUni = args.fBuilder->getUniformCStr(fColorCubeSizeUni);
- fColorCubeInvSizeUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kFloat_GrSLType, kDefault_GrSLPrecision,
- "InvSize");
- const char* colorCubeInvSizeUni = args.fBuilder->getUniformCStr(fColorCubeInvSizeUni);
+ GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
+ fColorCubeSizeUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kFloat_GrSLType, kDefault_GrSLPrecision,
+ "Size");
+ const char* colorCubeSizeUni = uniformHandler->getUniformCStr(fColorCubeSizeUni);
+ fColorCubeInvSizeUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kFloat_GrSLType, kDefault_GrSLPrecision,
+ "InvSize");
+ const char* colorCubeInvSizeUni = uniformHandler->getUniformCStr(fColorCubeInvSizeUni);
const char* nonZeroAlpha = "nonZeroAlpha";
const char* unPMColor = "unPMColor";
diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp
index 6e1c8ddb81..3f0f12f2d8 100644
--- a/src/effects/SkColorMatrixFilter.cpp
+++ b/src/effects/SkColorMatrixFilter.cpp
@@ -387,8 +387,8 @@ SkColorFilter* SkColorMatrixFilter::newComposed(const SkColorFilter* innerFilter
#include "GrInvariantOutput.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLUniformHandler.h"
class ColorMatrixEffect : public GrFragmentProcessor {
public:
@@ -408,12 +408,13 @@ public:
GLSLProcessor(const GrProcessor&) {}
virtual void emitCode(EmitArgs& args) override {
- fMatrixHandle = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kMat44f_GrSLType, kDefault_GrSLPrecision,
- "ColorMatrix");
- fVectorHandle = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec4f_GrSLType, kDefault_GrSLPrecision,
- "ColorMatrixVector");
+ GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
+ fMatrixHandle = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kMat44f_GrSLType, kDefault_GrSLPrecision,
+ "ColorMatrix");
+ fVectorHandle = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec4f_GrSLType, kDefault_GrSLPrecision,
+ "ColorMatrixVector");
if (nullptr == args.fInputColor) {
// could optimize this case, but we aren't for now.
@@ -426,9 +427,9 @@ public:
args.fInputColor);
fragBuilder->codeAppendf("\t%s = %s * vec4(%s.rgb / nonZeroAlpha, nonZeroAlpha) + %s;\n",
args.fOutputColor,
- args.fBuilder->getUniformCStr(fMatrixHandle),
+ uniformHandler->getUniformCStr(fMatrixHandle),
args.fInputColor,
- args.fBuilder->getUniformCStr(fVectorHandle));
+ uniformHandler->getUniformCStr(fVectorHandle));
fragBuilder->codeAppendf("\t%s = clamp(%s, 0.0, 1.0);\n",
args.fOutputColor, args.fOutputColor);
fragBuilder->codeAppendf("\t%s.rgb *= %s.a;\n", args.fOutputColor, args.fOutputColor);
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index fe918581c4..3370a76495 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -19,8 +19,8 @@
#include "effects/GrTextureDomain.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLUniformHandler.h"
#endif
namespace {
@@ -549,9 +549,9 @@ GrGLDisplacementMapEffect::~GrGLDisplacementMapEffect() {
void GrGLDisplacementMapEffect::emitCode(EmitArgs& args) {
const GrTextureDomain& domain = args.fFp.cast<GrDisplacementMapEffect>().domain();
- fScaleUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec2f_GrSLType, kDefault_GrSLPrecision, "Scale");
- const char* scaleUni = args.fBuilder->getUniformCStr(fScaleUni);
+ fScaleUni = args.fUniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec2f_GrSLType, kDefault_GrSLPrecision, "Scale");
+ const char* scaleUni = args.fUniformHandler->getUniformCStr(fScaleUni);
const char* dColor = "dColor";
const char* cCoords = "cCoords";
const char* nearZero = "1e-6"; // Since 6.10352e−5 is the smallest half float, use
@@ -610,6 +610,7 @@ void GrGLDisplacementMapEffect::emitCode(EmitArgs& args) {
fragBuilder->codeAppend("-vec2(0.5));\t\t");
fGLDomain.sampleTexture(fragBuilder,
+ args.fUniformHandler,
args.fGLSLCaps,
domain,
args.fOutputColor,
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 9b6a20f0ef..ac7488be6b 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -23,8 +23,8 @@
#include "effects/GrSingleTextureEffect.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLUniformHandler.h"
class GrGLDiffuseLightingEffect;
class GrGLSpecularLightingEffect;
@@ -599,7 +599,7 @@ public:
* This is called by GrGLLightingEffect::emitCode() before either of the two virtual functions
* below. It adds a vec3f uniform visible in the FS that represents the constant light color.
*/
- void emitLightColorUniform(GrGLSLFPBuilder*);
+ void emitLightColorUniform(GrGLSLUniformHandler*);
/**
* These two functions are called from GrGLLightingEffect's emitCode() function.
@@ -609,8 +609,10 @@ public:
* the FS. The default of emitLightColor appends the name of the constant light color uniform
* and so this function only needs to be overridden if the light color varies spatially.
*/
- virtual void emitSurfaceToLight(GrGLSLFPBuilder*, GrGLSLFragmentBuilder*, const char* z) = 0;
- virtual void emitLightColor(GrGLSLFPBuilder*,
+ virtual void emitSurfaceToLight(GrGLSLUniformHandler*,
+ GrGLSLFragmentBuilder*,
+ const char* z) = 0;
+ virtual void emitLightColor(GrGLSLUniformHandler*,
GrGLSLFragmentBuilder*,
const char *surfaceToLight);
@@ -637,7 +639,7 @@ class GrGLDistantLight : public GrGLLight {
public:
virtual ~GrGLDistantLight() {}
void setData(const GrGLSLProgramDataManager&, const SkImageFilterLight* light) const override;
- void emitSurfaceToLight(GrGLSLFPBuilder*, GrGLSLFragmentBuilder*, const char* z) override;
+ void emitSurfaceToLight(GrGLSLUniformHandler*, GrGLSLFragmentBuilder*, const char* z) override;
private:
typedef GrGLLight INHERITED;
@@ -650,7 +652,7 @@ class GrGLPointLight : public GrGLLight {
public:
virtual ~GrGLPointLight() {}
void setData(const GrGLSLProgramDataManager&, const SkImageFilterLight* light) const override;
- void emitSurfaceToLight(GrGLSLFPBuilder*, GrGLSLFragmentBuilder*, const char* z) override;
+ void emitSurfaceToLight(GrGLSLUniformHandler*, GrGLSLFragmentBuilder*, const char* z) override;
private:
typedef GrGLLight INHERITED;
@@ -663,8 +665,8 @@ class GrGLSpotLight : public GrGLLight {
public:
virtual ~GrGLSpotLight() {}
void setData(const GrGLSLProgramDataManager&, const SkImageFilterLight* light) const override;
- void emitSurfaceToLight(GrGLSLFPBuilder*, GrGLSLFragmentBuilder*, const char* z) override;
- void emitLightColor(GrGLSLFPBuilder*,
+ void emitSurfaceToLight(GrGLSLUniformHandler*, GrGLSLFragmentBuilder*, const char* z) override;
+ void emitLightColor(GrGLSLUniformHandler*,
GrGLSLFragmentBuilder*,
const char *surfaceToLight) override;
@@ -1528,7 +1530,9 @@ protected:
*/
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
- virtual void emitLightFunc(GrGLSLFPBuilder*, GrGLSLFragmentBuilder*, SkString* funcName) = 0;
+ virtual void emitLightFunc(GrGLSLUniformHandler*,
+ GrGLSLFragmentBuilder*,
+ SkString* funcName) = 0;
private:
typedef GrGLSLFragmentProcessor INHERITED;
@@ -1544,7 +1548,7 @@ private:
class GrGLDiffuseLightingEffect : public GrGLLightingEffect {
public:
GrGLDiffuseLightingEffect(const GrProcessor&);
- void emitLightFunc(GrGLSLFPBuilder*, GrGLSLFragmentBuilder*, SkString* funcName) override;
+ void emitLightFunc(GrGLSLUniformHandler*, GrGLSLFragmentBuilder*, SkString* funcName) override;
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
@@ -1560,7 +1564,7 @@ private:
class GrGLSpecularLightingEffect : public GrGLLightingEffect {
public:
GrGLSpecularLightingEffect(const GrProcessor&);
- void emitLightFunc(GrGLSLFPBuilder*, GrGLSLFragmentBuilder*, SkString* funcName) override;
+ void emitLightFunc(GrGLSLUniformHandler*, GrGLSLFragmentBuilder*, SkString* funcName) override;
protected:
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
@@ -1657,16 +1661,17 @@ GrGLLightingEffect::~GrGLLightingEffect() {
}
void GrGLLightingEffect::emitCode(EmitArgs& args) {
- fImageIncrementUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec2f_GrSLType, kDefault_GrSLPrecision,
- "ImageIncrement");
- fSurfaceScaleUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kFloat_GrSLType, kDefault_GrSLPrecision,
- "SurfaceScale");
- fLight->emitLightColorUniform(args.fBuilder);
+ GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
+ fImageIncrementUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec2f_GrSLType, kDefault_GrSLPrecision,
+ "ImageIncrement");
+ fSurfaceScaleUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kFloat_GrSLType, kDefault_GrSLPrecision,
+ "SurfaceScale");
+ fLight->emitLightColorUniform(uniformHandler);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString lightFunc;
- this->emitLightFunc(args.fBuilder, fragBuilder, &lightFunc);
+ this->emitLightFunc(uniformHandler, fragBuilder, &lightFunc);
static const GrGLSLShaderVar gSobelArgs[] = {
GrGLSLShaderVar("a", kFloat_GrSLType),
GrGLSLShaderVar("b", kFloat_GrSLType),
@@ -1716,8 +1721,8 @@ void GrGLLightingEffect::emitCode(EmitArgs& args) {
fragBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str());
fragBuilder->codeAppend("\t\tfloat m[9];\n");
- const char* imgInc = args.fBuilder->getUniformCStr(fImageIncrementUni);
- const char* surfScale = args.fBuilder->getUniformCStr(fSurfaceScaleUni);
+ const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni);
+ const char* surfScale = uniformHandler->getUniformCStr(fSurfaceScaleUni);
int index = 0;
for (int dy = 1; dy >= -1; dy--) {
@@ -1732,11 +1737,11 @@ void GrGLLightingEffect::emitCode(EmitArgs& args) {
fragBuilder->codeAppend("\t\tvec3 surfaceToLight = ");
SkString arg;
arg.appendf("%s * m[4]", surfScale);
- fLight->emitSurfaceToLight(args.fBuilder, fragBuilder, arg.c_str());
+ fLight->emitSurfaceToLight(uniformHandler, fragBuilder, arg.c_str());
fragBuilder->codeAppend(";\n");
fragBuilder->codeAppendf("\t\t%s = %s(%s(m, %s), surfaceToLight, ",
args.fOutputColor, lightFunc.c_str(), normalName.c_str(), surfScale);
- fLight->emitLightColor(args.fBuilder, fragBuilder, "surfaceToLight");
+ fLight->emitLightColor(uniformHandler, fragBuilder, "surfaceToLight");
fragBuilder->codeAppend(");\n");
SkString modulate;
GrGLSLMulVarBy4f(&modulate, args.fOutputColor, args.fInputColor);
@@ -1769,11 +1774,11 @@ GrGLDiffuseLightingEffect::GrGLDiffuseLightingEffect(const GrProcessor& proc)
: INHERITED(proc) {
}
-void GrGLDiffuseLightingEffect::emitLightFunc(GrGLSLFPBuilder* builder,
+void GrGLDiffuseLightingEffect::emitLightFunc(GrGLSLUniformHandler* uniformHandler,
GrGLSLFragmentBuilder* fragBuilder,
SkString* funcName) {
const char* kd;
- fKDUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
+ fKDUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
kFloat_GrSLType, kDefault_GrSLPrecision,
"KD", &kd);
@@ -1853,19 +1858,19 @@ GrGLSpecularLightingEffect::GrGLSpecularLightingEffect(const GrProcessor& proc)
: INHERITED(proc) {
}
-void GrGLSpecularLightingEffect::emitLightFunc(GrGLSLFPBuilder* builder,
+void GrGLSpecularLightingEffect::emitLightFunc(GrGLSLUniformHandler* uniformHandler,
GrGLSLFragmentBuilder* fragBuilder,
SkString* funcName) {
const char* ks;
const char* shininess;
- fKSUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kFloat_GrSLType, kDefault_GrSLPrecision, "KS", &ks);
- fShininessUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kFloat_GrSLType,
- kDefault_GrSLPrecision,
- "Shininess",
- &shininess);
+ fKSUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kFloat_GrSLType, kDefault_GrSLPrecision, "KS", &ks);
+ fShininessUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kFloat_GrSLType,
+ kDefault_GrSLPrecision,
+ "Shininess",
+ &shininess);
static const GrGLSLShaderVar gLightArgs[] = {
GrGLSLShaderVar("normal", kVec3f_GrSLType),
@@ -1894,16 +1899,16 @@ void GrGLSpecularLightingEffect::onSetData(const GrGLSLProgramDataManager& pdman
}
///////////////////////////////////////////////////////////////////////////////
-void GrGLLight::emitLightColorUniform(GrGLSLFPBuilder* builder) {
- fColorUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec3f_GrSLType, kDefault_GrSLPrecision,
- "LightColor");
+void GrGLLight::emitLightColorUniform(GrGLSLUniformHandler* uniformHandler) {
+ fColorUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec3f_GrSLType, kDefault_GrSLPrecision,
+ "LightColor");
}
-void GrGLLight::emitLightColor(GrGLSLFPBuilder* builder,
+void GrGLLight::emitLightColor(GrGLSLUniformHandler* uniformHandler,
GrGLSLFragmentBuilder* fragBuilder,
const char *surfaceToLight) {
- fragBuilder->codeAppend(builder->getUniformCStr(this->lightColorUni()));
+ fragBuilder->codeAppend(uniformHandler->getUniformCStr(this->lightColorUni()));
}
void GrGLLight::setData(const GrGLSLProgramDataManager& pdman,
@@ -1922,13 +1927,13 @@ void GrGLDistantLight::setData(const GrGLSLProgramDataManager& pdman,
setUniformNormal3(pdman, fDirectionUni, distantLight->direction());
}
-void GrGLDistantLight::emitSurfaceToLight(GrGLSLFPBuilder* builder,
+void GrGLDistantLight::emitSurfaceToLight(GrGLSLUniformHandler* uniformHandler,
GrGLSLFragmentBuilder* fragBuilder,
const char* z) {
const char* dir;
- fDirectionUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec3f_GrSLType, kDefault_GrSLPrecision,
- "LightDirection", &dir);
+ fDirectionUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec3f_GrSLType, kDefault_GrSLPrecision,
+ "LightDirection", &dir);
fragBuilder->codeAppend(dir);
}
@@ -1942,13 +1947,13 @@ void GrGLPointLight::setData(const GrGLSLProgramDataManager& pdman,
setUniformPoint3(pdman, fLocationUni, pointLight->location());
}
-void GrGLPointLight::emitSurfaceToLight(GrGLSLFPBuilder* builder,
+void GrGLPointLight::emitSurfaceToLight(GrGLSLUniformHandler* uniformHandler,
GrGLSLFragmentBuilder* fragBuilder,
const char* z) {
const char* loc;
- fLocationUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec3f_GrSLType, kDefault_GrSLPrecision,
- "LightLocation", &loc);
+ fLocationUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec3f_GrSLType, kDefault_GrSLPrecision,
+ "LightLocation", &loc);
fragBuilder->codeAppendf("normalize(%s - vec3(%s.xy, %s))",
loc, fragBuilder->fragmentPosition(), z);
}
@@ -1968,43 +1973,43 @@ void GrGLSpotLight::setData(const GrGLSLProgramDataManager& pdman,
setUniformNormal3(pdman, fSUni, spotLight->s());
}
-void GrGLSpotLight::emitSurfaceToLight(GrGLSLFPBuilder* builder,
+void GrGLSpotLight::emitSurfaceToLight(GrGLSLUniformHandler* uniformHandler,
GrGLSLFragmentBuilder* fragBuilder,
const char* z) {
const char* location;
- fLocationUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec3f_GrSLType, kDefault_GrSLPrecision,
- "LightLocation", &location);
+ fLocationUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec3f_GrSLType, kDefault_GrSLPrecision,
+ "LightLocation", &location);
fragBuilder->codeAppendf("normalize(%s - vec3(%s.xy, %s))",
location, fragBuilder->fragmentPosition(), z);
}
-void GrGLSpotLight::emitLightColor(GrGLSLFPBuilder* builder,
+void GrGLSpotLight::emitLightColor(GrGLSLUniformHandler* uniformHandler,
GrGLSLFragmentBuilder* fragBuilder,
const char *surfaceToLight) {
- const char* color = builder->getUniformCStr(this->lightColorUni()); // created by parent class.
+ const char* color = uniformHandler->getUniformCStr(this->lightColorUni()); // created by parent class.
const char* exponent;
const char* cosInner;
const char* cosOuter;
const char* coneScale;
const char* s;
- fExponentUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kFloat_GrSLType, kDefault_GrSLPrecision,
- "Exponent", &exponent);
- fCosInnerConeAngleUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kFloat_GrSLType, kDefault_GrSLPrecision,
- "CosInnerConeAngle", &cosInner);
- fCosOuterConeAngleUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kFloat_GrSLType, kDefault_GrSLPrecision,
- "CosOuterConeAngle", &cosOuter);
- fConeScaleUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kFloat_GrSLType, kDefault_GrSLPrecision,
- "ConeScale", &coneScale);
- fSUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec3f_GrSLType, kDefault_GrSLPrecision, "S", &s);
+ fExponentUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kFloat_GrSLType, kDefault_GrSLPrecision,
+ "Exponent", &exponent);
+ fCosInnerConeAngleUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kFloat_GrSLType, kDefault_GrSLPrecision,
+ "CosInnerConeAngle", &cosInner);
+ fCosOuterConeAngleUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kFloat_GrSLType, kDefault_GrSLPrecision,
+ "CosOuterConeAngle", &cosOuter);
+ fConeScaleUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kFloat_GrSLType, kDefault_GrSLPrecision,
+ "ConeScale", &coneScale);
+ fSUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec3f_GrSLType, kDefault_GrSLPrecision, "S", &s);
static const GrGLSLShaderVar gLightColorArgs[] = {
GrGLSLShaderVar("surfaceToLight", kVec3f_GrSLType)
diff --git a/src/effects/SkLumaColorFilter.cpp b/src/effects/SkLumaColorFilter.cpp
index a131b0f434..acdebf8418 100644
--- a/src/effects/SkLumaColorFilter.cpp
+++ b/src/effects/SkLumaColorFilter.cpp
@@ -15,7 +15,6 @@
#include "GrInvariantOutput.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLProgramBuilder.h"
#endif
void SkLumaColorFilter::filterSpan(const SkPMColor src[], int count,
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index 911294444a..45f630a085 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -19,8 +19,8 @@
#include "effects/GrSingleTextureEffect.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLUniformHandler.h"
class GrMagnifierEffect : public GrSingleTextureEffect {
@@ -120,31 +120,32 @@ GrGLMagnifierEffect::GrGLMagnifierEffect(const GrProcessor&) {
}
void GrGLMagnifierEffect::emitCode(EmitArgs& args) {
- fOffsetVar = args.fBuilder->addUniform(
- GrGLSLProgramBuilder::kFragment_Visibility,
- kVec2f_GrSLType, kDefault_GrSLPrecision, "Offset");
- fInvZoomVar = args.fBuilder->addUniform(
- GrGLSLProgramBuilder::kFragment_Visibility,
- kVec2f_GrSLType, kDefault_GrSLPrecision, "InvZoom");
- fInvInsetVar = args.fBuilder->addUniform(
- GrGLSLProgramBuilder::kFragment_Visibility,
- kVec2f_GrSLType, kDefault_GrSLPrecision, "InvInset");
- fBoundsVar = args.fBuilder->addUniform(
- GrGLSLProgramBuilder::kFragment_Visibility,
- kVec4f_GrSLType, kDefault_GrSLPrecision, "Bounds");
+ GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
+ fOffsetVar = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec2f_GrSLType, kDefault_GrSLPrecision,
+ "Offset");
+ fInvZoomVar = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec2f_GrSLType, kDefault_GrSLPrecision,
+ "InvZoom");
+ fInvInsetVar = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec2f_GrSLType, kDefault_GrSLPrecision,
+ "InvInset");
+ fBoundsVar = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec4f_GrSLType, kDefault_GrSLPrecision,
+ "Bounds");
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
fragBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str());
fragBuilder->codeAppendf("\t\tvec2 zoom_coord = %s + %s * %s;\n",
- args.fBuilder->getUniformCStr(fOffsetVar),
+ uniformHandler->getUniformCStr(fOffsetVar),
coords2D.c_str(),
- args.fBuilder->getUniformCStr(fInvZoomVar));
- const char* bounds = args.fBuilder->getUniformCStr(fBoundsVar);
+ uniformHandler->getUniformCStr(fInvZoomVar));
+ const char* bounds = uniformHandler->getUniformCStr(fBoundsVar);
fragBuilder->codeAppendf("\t\tvec2 delta = (coord - %s.xy) * %s.zw;\n", bounds, bounds);
fragBuilder->codeAppendf("\t\tdelta = min(delta, vec2(1.0, 1.0) - delta);\n");
fragBuilder->codeAppendf("\t\tdelta = delta * %s;\n",
- args.fBuilder->getUniformCStr(fInvInsetVar));
+ uniformHandler->getUniformCStr(fInvInsetVar));
fragBuilder->codeAppend("\t\tfloat weight = 0.0;\n");
fragBuilder->codeAppend("\t\tif (delta.s < 2.0 && delta.t < 2.0) {\n");
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 484ed57f37..c6bbce71cb 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -21,8 +21,8 @@
#include "effects/Gr1DKernelEffect.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLUniformHandler.h"
#endif
SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX,
@@ -288,14 +288,15 @@ GrGLMorphologyEffect::GrGLMorphologyEffect(const GrProcessor& proc) {
}
void GrGLMorphologyEffect::emitCode(EmitArgs& args) {
- fPixelSizeUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kFloat_GrSLType, kDefault_GrSLPrecision,
- "PixelSize");
- const char* pixelSizeInc = args.fBuilder->getUniformCStr(fPixelSizeUni);
- fRangeUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec2f_GrSLType, kDefault_GrSLPrecision,
- "Range");
- const char* range = args.fBuilder->getUniformCStr(fRangeUni);
+ GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
+ fPixelSizeUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kFloat_GrSLType, kDefault_GrSLPrecision,
+ "PixelSize");
+ const char* pixelSizeInc = uniformHandler->getUniformCStr(fPixelSizeUni);
+ fRangeUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec2f_GrSLType, kDefault_GrSLPrecision,
+ "Range");
+ const char* range = uniformHandler->getUniformCStr(fRangeUni);
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp
index 916cf78f0d..51d84989a8 100644
--- a/src/effects/SkPerlinNoiseShader.cpp
+++ b/src/effects/SkPerlinNoiseShader.cpp
@@ -22,8 +22,8 @@
#include "effects/GrConstColorProcessor.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLUniformHandler.h"
#endif
static const int kBlockSize = 256;
@@ -621,19 +621,20 @@ GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor)
void GrGLPerlinNoise::emitCode(EmitArgs& args) {
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
+ GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
SkString vCoords = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
- fBaseFrequencyUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec2f_GrSLType, kDefault_GrSLPrecision,
- "baseFrequency");
- const char* baseFrequencyUni = args.fBuilder->getUniformCStr(fBaseFrequencyUni);
+ fBaseFrequencyUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec2f_GrSLType, kDefault_GrSLPrecision,
+ "baseFrequency");
+ const char* baseFrequencyUni = uniformHandler->getUniformCStr(fBaseFrequencyUni);
const char* stitchDataUni = nullptr;
if (fStitchTiles) {
- fStitchDataUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec2f_GrSLType, kDefault_GrSLPrecision,
- "stitchData");
- stitchDataUni = args.fBuilder->getUniformCStr(fStitchDataUni);
+ fStitchDataUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec2f_GrSLType, kDefault_GrSLPrecision,
+ "stitchData");
+ stitchDataUni = uniformHandler->getUniformCStr(fStitchDataUni);
}
// There are 4 lines, so the center of each line is 1/8, 3/8, 5/8 and 7/8
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index 9d97411042..32617cd6fe 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -337,8 +337,8 @@ SkColorFilter* SkTable_ColorFilter::newComposed(const SkColorFilter* innerFilter
#include "effects/GrTextureStripAtlas.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLUniformHandler.h"
class ColorTableEffect : public GrFragmentProcessor {
public:
@@ -415,9 +415,9 @@ void GLColorTableEffect::onSetData(const GrGLSLProgramDataManager& pdm, const Gr
void GLColorTableEffect::emitCode(EmitArgs& args) {
const char* yoffsets;
- fRGBAYValuesUni = args.fBuilder->addUniform(GrGLSLFPBuilder::kFragment_Visibility,
- kVec4f_GrSLType, kDefault_GrSLPrecision,
- "yoffsets", &yoffsets);
+ fRGBAYValuesUni = args.fUniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec4f_GrSLType, kDefault_GrSLPrecision,
+ "yoffsets", &yoffsets);
static const float kColorScaleFactor = 255.0f / 256.0f;
static const float kColorOffsetFactor = 1.0f / 512.0f;
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index e486e08a64..8155b1cc61 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -910,8 +910,8 @@ SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
#include "GrInvariantOutput.h"
#include "gl/GrGLContext.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLUniformHandler.h"
#include "SkGr.h"
GrGLGradientEffect::GrGLGradientEffect()
@@ -920,31 +920,32 @@ GrGLGradientEffect::GrGLGradientEffect()
GrGLGradientEffect::~GrGLGradientEffect() { }
-void GrGLGradientEffect::emitUniforms(GrGLSLFPBuilder* builder, const GrGradientEffect& ge) {
+void GrGLGradientEffect::emitUniforms(GrGLSLUniformHandler* uniformHandler,
+ const GrGradientEffect& ge) {
if (SkGradientShaderBase::kTwo_GpuColorType == ge.getColorType()) { // 2 Color case
- fColorStartUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec4f_GrSLType, kDefault_GrSLPrecision,
- "GradientStartColor");
- fColorEndUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec4f_GrSLType, kDefault_GrSLPrecision,
- "GradientEndColor");
+ fColorStartUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec4f_GrSLType, kDefault_GrSLPrecision,
+ "GradientStartColor");
+ fColorEndUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec4f_GrSLType, kDefault_GrSLPrecision,
+ "GradientEndColor");
} else if (SkGradientShaderBase::kThree_GpuColorType == ge.getColorType()) { // 3 Color Case
- fColorStartUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec4f_GrSLType, kDefault_GrSLPrecision,
- "GradientStartColor");
- fColorMidUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec4f_GrSLType, kDefault_GrSLPrecision,
- "GradientMidColor");
- fColorEndUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec4f_GrSLType, kDefault_GrSLPrecision,
- "GradientEndColor");
+ fColorStartUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec4f_GrSLType, kDefault_GrSLPrecision,
+ "GradientStartColor");
+ fColorMidUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec4f_GrSLType, kDefault_GrSLPrecision,
+ "GradientMidColor");
+ fColorEndUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec4f_GrSLType, kDefault_GrSLPrecision,
+ "GradientEndColor");
} else { // if not a fast case
- fFSYUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kFloat_GrSLType, kDefault_GrSLPrecision,
- "GradientYCoordFS");
+ fFSYUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kFloat_GrSLType, kDefault_GrSLPrecision,
+ "GradientYCoordFS");
}
}
@@ -1026,8 +1027,8 @@ uint32_t GrGLGradientEffect::GenBaseGradientKey(const GrProcessor& processor) {
return key;
}
-void GrGLGradientEffect::emitColor(GrGLSLFPBuilder* builder,
- GrGLSLFragmentBuilder* fragBuilder,
+void GrGLGradientEffect::emitColor(GrGLSLFragmentBuilder* fragBuilder,
+ GrGLSLUniformHandler* uniformHandler,
const GrGLSLCaps* glslCaps,
const GrGradientEffect& ge,
const char* gradientTValue,
@@ -1036,8 +1037,8 @@ void GrGLGradientEffect::emitColor(GrGLSLFPBuilder* builder,
const TextureSamplerArray& samplers) {
if (SkGradientShaderBase::kTwo_GpuColorType == ge.getColorType()){
fragBuilder->codeAppendf("\tvec4 colorTemp = mix(%s, %s, clamp(%s, 0.0, 1.0));\n",
- builder->getUniformVariable(fColorStartUni).c_str(),
- builder->getUniformVariable(fColorEndUni).c_str(),
+ uniformHandler->getUniformVariable(fColorStartUni).c_str(),
+ uniformHandler->getUniformVariable(fColorEndUni).c_str(),
gradientTValue);
// Note that we could skip this step if both colors are known to be opaque. Two
// considerations:
@@ -1055,20 +1056,20 @@ void GrGLGradientEffect::emitColor(GrGLSLFPBuilder* builder,
fragBuilder->codeAppendf("\tfloat oneMinus2t = 1.0 - (2.0 * (%s));\n",
gradientTValue);
fragBuilder->codeAppendf("\tvec4 colorTemp = clamp(oneMinus2t, 0.0, 1.0) * %s;\n",
- builder->getUniformVariable(fColorStartUni).c_str());
+ uniformHandler->getUniformVariable(fColorStartUni).c_str());
if (!glslCaps->canUseMinAndAbsTogether()) {
// The Tegra3 compiler will sometimes never return if we have
// min(abs(oneMinus2t), 1.0), or do the abs first in a separate expression.
fragBuilder->codeAppend("\tfloat minAbs = abs(oneMinus2t);\n");
fragBuilder->codeAppend("\tminAbs = minAbs > 1.0 ? 1.0 : minAbs;\n");
fragBuilder->codeAppendf("\tcolorTemp += (1.0 - minAbs) * %s;\n",
- builder->getUniformVariable(fColorMidUni).c_str());
+ uniformHandler->getUniformVariable(fColorMidUni).c_str());
} else {
fragBuilder->codeAppendf("\tcolorTemp += (1.0 - min(abs(oneMinus2t), 1.0)) * %s;\n",
- builder->getUniformVariable(fColorMidUni).c_str());
+ uniformHandler->getUniformVariable(fColorMidUni).c_str());
}
fragBuilder->codeAppendf("\tcolorTemp += clamp(-oneMinus2t, 0.0, 1.0) * %s;\n",
- builder->getUniformVariable(fColorEndUni).c_str());
+ uniformHandler->getUniformVariable(fColorEndUni).c_str());
if (GrGradientEffect::kAfterInterp_PremulType == ge.getPremulType()) {
fragBuilder->codeAppend("\tcolorTemp.rgb *= colorTemp.a;\n");
}
@@ -1078,7 +1079,7 @@ void GrGLGradientEffect::emitColor(GrGLSLFPBuilder* builder,
} else {
fragBuilder->codeAppendf("\tvec2 coord = vec2(%s, %s);\n",
gradientTValue,
- builder->getUniformVariable(fFSYUni).c_str());
+ uniformHandler->getUniformVariable(fFSYUni).c_str());
fragBuilder->codeAppendf("\t%s = ", outputColor);
fragBuilder->appendTextureLookupAndModulate(inputColor,
samplers[0],
diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h
index 3c19152d90..203f791ceb 100644
--- a/src/effects/gradients/SkGradientShaderPriv.h
+++ b/src/effects/gradients/SkGradientShaderPriv.h
@@ -419,14 +419,14 @@ protected:
// Emits the uniform used as the y-coord to texture samples in derived classes. Subclasses
// should call this method from their emitCode().
- void emitUniforms(GrGLSLFPBuilder* builder, const GrGradientEffect&);
+ void emitUniforms(GrGLSLUniformHandler*, const GrGradientEffect&);
// emit code that gets a fragment's color from an expression for t; Has branches for 3 separate
// control flows inside -- 2 color gradients, 3 color symmetric gradients (both using
// native GLSL mix), and 4+ color gradients that use the traditional texture lookup.
- void emitColor(GrGLSLFPBuilder* builder,
- GrGLSLFragmentBuilder* fragBuilder,
+ void emitColor(GrGLSLFragmentBuilder* fragBuilder,
+ GrGLSLUniformHandler* uniformHandler,
const GrGLSLCaps* caps,
const GrGradientEffect&,
const char* gradientTValue,
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index c7d52fb0d9..53264e4d8c 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -516,7 +516,8 @@ void SkLinearGradient::LinearGradientContext::shadeSpan16(int x, int y,
#if SK_SUPPORT_GPU
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLCaps.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "SkGr.h"
/////////////////////////////////////////////////////////////////////
@@ -604,11 +605,11 @@ const GrFragmentProcessor* GrLinearGradient::TestCreate(GrProcessorTestData* d)
void GrGLLinearGradient::emitCode(EmitArgs& args) {
const GrLinearGradient& ge = args.fFp.cast<GrLinearGradient>();
- this->emitUniforms(args.fBuilder, ge);
+ this->emitUniforms(args.fUniformHandler, ge);
SkString t = args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0);
t.append(".x");
- this->emitColor(args.fBuilder,
- args.fFragBuilder,
+ this->emitColor(args.fFragBuilder,
+ args.fUniformHandler,
args.fGLSLCaps,
ge, t.c_str(),
args.fOutputColor,
diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp
index 7be8ed111b..52d06392e1 100644
--- a/src/effects/gradients/SkRadialGradient.cpp
+++ b/src/effects/gradients/SkRadialGradient.cpp
@@ -415,7 +415,8 @@ void SkRadialGradient::RadialGradientContext::shadeSpan(int x, int y,
#if SK_SUPPORT_GPU
#include "SkGr.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLCaps.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
class GrGLRadialGradient : public GrGLGradientEffect {
public:
@@ -499,12 +500,12 @@ const GrFragmentProcessor* GrRadialGradient::TestCreate(GrProcessorTestData* d)
void GrGLRadialGradient::emitCode(EmitArgs& args) {
const GrRadialGradient& ge = args.fFp.cast<GrRadialGradient>();
- this->emitUniforms(args.fBuilder, ge);
+ this->emitUniforms(args.fUniformHandler, ge);
SkString t("length(");
t.append(args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0));
t.append(")");
- this->emitColor(args.fBuilder,
- args.fFragBuilder,
+ this->emitColor(args.fFragBuilder,
+ args.fUniformHandler,
args.fGLSLCaps,
ge, t.c_str(),
args.fOutputColor,
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp
index 3df7144337..24e86d023d 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -168,7 +168,8 @@ void SkSweepGradient::SweepGradientContext::shadeSpan16(int x, int y, uint16_t*
#include "SkGr.h"
#include "gl/GrGLContext.h"
-#include "gl/builders/GrGLProgramBuilder.h"
+#include "glsl/GrGLSLCaps.h"
+#include "glsl/GrGLSLFragmentShaderBuilder.h"
class GrGLSweepGradient : public GrGLGradientEffect {
public:
@@ -247,7 +248,7 @@ const GrFragmentProcessor* GrSweepGradient::TestCreate(GrProcessorTestData* d) {
void GrGLSweepGradient::emitCode(EmitArgs& args) {
const GrSweepGradient& ge = args.fFp.cast<GrSweepGradient>();
- this->emitUniforms(args.fBuilder, ge);
+ this->emitUniforms(args.fUniformHandler, ge);
SkString coords2D = args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0);
SkString t;
// 0.1591549430918 is 1/(2*pi), used since atan returns values [-pi, pi]
@@ -260,8 +261,8 @@ void GrGLSweepGradient::emitCode(EmitArgs& args) {
t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5",
coords2D.c_str(), coords2D.c_str());
}
- this->emitColor(args.fBuilder,
- args.fFragBuilder,
+ this->emitColor(args.fFragBuilder,
+ args.fUniformHandler,
args.fGLSLCaps,
ge, t.c_str(),
args.fOutputColor,
diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
index 31ceda4f2a..ac32e72c53 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
@@ -11,10 +11,12 @@
#include "SkTwoPointConicalGradient.h"
#if SK_SUPPORT_GPU
+#include "GrCoordTransform.h"
+#include "GrInvariantOutput.h"
#include "GrPaint.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLUniformHandler.h"
// For brevity
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
@@ -223,10 +225,11 @@ GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&)
void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) {
const Edge2PtConicalEffect& ge = args.fFp.cast<Edge2PtConicalEffect>();
- this->emitUniforms(args.fBuilder, ge);
- fParamUni = args.fBuilder->addUniformArray(GrGLSLProgramBuilder::kFragment_Visibility,
- kFloat_GrSLType, kDefault_GrSLPrecision,
- "Conical2FSParams", 3);
+ GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
+ this->emitUniforms(uniformHandler, ge);
+ fParamUni = uniformHandler->addUniformArray(GrGLSLUniformHandler::kFragment_Visibility,
+ kFloat_GrSLType, kDefault_GrSLPrecision,
+ "Conical2FSParams", 3);
SkString cName("c");
SkString tName("t");
@@ -234,9 +237,9 @@ void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) {
SkString p1; // start radius squared
SkString p2; // difference in radii (r1 - r0)
- args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(0, &p0);
- args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(1, &p1);
- args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(2, &p2);
+ uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(0, &p0);
+ uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(1, &p1);
+ uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(2, &p2);
// We interpolate the linear component in coords[1].
SkASSERT(args.fCoords[0].getType() == args.fCoords[1].getType());
@@ -270,8 +273,8 @@ void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) {
fragBuilder->codeAppendf("\tif (%s * %s + %s > 0.0) {\n", tName.c_str(),
p2.c_str(), p0.c_str());
fragBuilder->codeAppend("\t");
- this->emitColor(args.fBuilder,
- fragBuilder,
+ this->emitColor(fragBuilder,
+ uniformHandler,
args.fGLSLCaps,
ge,
tName.c_str(),
@@ -505,16 +508,17 @@ GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor
void GLFocalOutside2PtConicalEffect::emitCode(EmitArgs& args) {
const FocalOutside2PtConicalEffect& ge = args.fFp.cast<FocalOutside2PtConicalEffect>();
- this->emitUniforms(args.fBuilder, ge);
- fParamUni = args.fBuilder->addUniformArray(GrGLSLProgramBuilder::kFragment_Visibility,
- kFloat_GrSLType, kDefault_GrSLPrecision,
- "Conical2FSParams", 2);
+ GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
+ this->emitUniforms(uniformHandler, ge);
+ fParamUni = uniformHandler->addUniformArray(GrGLSLUniformHandler::kFragment_Visibility,
+ kFloat_GrSLType, kDefault_GrSLPrecision,
+ "Conical2FSParams", 2);
SkString tName("t");
SkString p0; // focalX
SkString p1; // 1 - focalX * focalX
- args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(0, &p0);
- args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(1, &p1);
+ uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(0, &p0);
+ uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(1, &p1);
// if we have a vec3 from being in perspective, convert it to a vec2 first
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
@@ -543,8 +547,8 @@ void GLFocalOutside2PtConicalEffect::emitCode(EmitArgs& args) {
fragBuilder->codeAppendf("\tif (%s >= 0.0 && d >= 0.0) {\n", tName.c_str());
fragBuilder->codeAppend("\t\t");
- this->emitColor(args.fBuilder,
- fragBuilder,
+ this->emitColor(fragBuilder,
+ uniformHandler,
args.fGLSLCaps,
ge,
tName.c_str(),
@@ -714,15 +718,16 @@ GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&)
void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) {
const FocalInside2PtConicalEffect& ge = args.fFp.cast<FocalInside2PtConicalEffect>();
- this->emitUniforms(args.fBuilder, ge);
- fFocalUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kFloat_GrSLType, kDefault_GrSLPrecision,
- "Conical2FSParams");
+ GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
+ this->emitUniforms(uniformHandler, ge);
+ fFocalUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kFloat_GrSLType, kDefault_GrSLPrecision,
+ "Conical2FSParams");
SkString tName("t");
// this is the distance along x-axis from the end center to focal point in
// transformed coordinates
- GrGLSLShaderVar focal = args.fBuilder->getUniformVariable(fFocalUni);
+ GrGLSLShaderVar focal = uniformHandler->getUniformVariable(fFocalUni);
// if we have a vec3 from being in perspective, convert it to a vec2 first
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
@@ -731,10 +736,10 @@ void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) {
// t = p.x * focalX + length(p)
fragBuilder->codeAppendf("\tfloat %s = %s.x * %s + length(%s);\n", tName.c_str(),
- coords2D, focal.c_str(), coords2D);
+ coords2D, focal.c_str(), coords2D);
- this->emitColor(args.fBuilder,
- fragBuilder,
+ this->emitColor(fragBuilder,
+ uniformHandler,
args.fGLSLCaps,
ge,
tName.c_str(),
@@ -965,20 +970,21 @@ GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor
void GLCircleInside2PtConicalEffect::emitCode(EmitArgs& args) {
const CircleInside2PtConicalEffect& ge = args.fFp.cast<CircleInside2PtConicalEffect>();
- this->emitUniforms(args.fBuilder, ge);
- fCenterUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec2f_GrSLType, kDefault_GrSLPrecision,
- "Conical2FSCenter");
- fParamUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec3f_GrSLType, kDefault_GrSLPrecision,
- "Conical2FSParams");
+ GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
+ this->emitUniforms(uniformHandler, ge);
+ fCenterUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec2f_GrSLType, kDefault_GrSLPrecision,
+ "Conical2FSCenter");
+ fParamUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec3f_GrSLType, kDefault_GrSLPrecision,
+ "Conical2FSParams");
SkString tName("t");
- GrGLSLShaderVar center = args.fBuilder->getUniformVariable(fCenterUni);
+ GrGLSLShaderVar center = uniformHandler->getUniformVariable(fCenterUni);
// params.x = A
// params.y = B
// params.z = C
- GrGLSLShaderVar params = args.fBuilder->getUniformVariable(fParamUni);
+ GrGLSLShaderVar params = uniformHandler->getUniformVariable(fParamUni);
// if we have a vec3 from being in perspective, convert it to a vec2 first
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
@@ -999,8 +1005,8 @@ void GLCircleInside2PtConicalEffect::emitCode(EmitArgs& args) {
fragBuilder->codeAppendf("\tfloat %s = d + sqrt(d * d - %s.x * pDotp + %s.z);\n",
tName.c_str(), params.c_str(), params.c_str());
- this->emitColor(args.fBuilder,
- fragBuilder,
+ this->emitColor(fragBuilder,
+ uniformHandler,
args.fGLSLCaps,
ge,
tName.c_str(),
@@ -1201,20 +1207,21 @@ GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcess
void GLCircleOutside2PtConicalEffect::emitCode(EmitArgs& args) {
const CircleOutside2PtConicalEffect& ge = args.fFp.cast<CircleOutside2PtConicalEffect>();
- this->emitUniforms(args.fBuilder, ge);
- fCenterUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec2f_GrSLType, kDefault_GrSLPrecision,
- "Conical2FSCenter");
- fParamUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
- kVec4f_GrSLType, kDefault_GrSLPrecision,
- "Conical2FSParams");
+ GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
+ this->emitUniforms(uniformHandler, ge);
+ fCenterUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec2f_GrSLType, kDefault_GrSLPrecision,
+ "Conical2FSCenter");
+ fParamUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
+ kVec4f_GrSLType, kDefault_GrSLPrecision,
+ "Conical2FSParams");
SkString tName("t");
- GrGLSLShaderVar center = args.fBuilder->getUniformVariable(fCenterUni);
+ GrGLSLShaderVar center = uniformHandler->getUniformVariable(fCenterUni);
// params.x = A
// params.y = B
// params.z = C
- GrGLSLShaderVar params = args.fBuilder->getUniformVariable(fParamUni);
+ GrGLSLShaderVar params = uniformHandler->getUniformVariable(fParamUni);
// if we have a vec3 from being in perspective, convert it to a vec2 first
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
@@ -1248,10 +1255,11 @@ void GLCircleOutside2PtConicalEffect::emitCode(EmitArgs& args) {
fragBuilder->codeAppendf("\tfloat %s = d - sqrt(deter);\n", tName.c_str());
}
- fragBuilder->codeAppendf("\tif (%s >= %s.w && deter >= 0.0) {\n", tName.c_str(), params.c_str());
+ fragBuilder->codeAppendf("\tif (%s >= %s.w && deter >= 0.0) {\n",
+ tName.c_str(), params.c_str());
fragBuilder->codeAppend("\t\t");
- this->emitColor(args.fBuilder,
- fragBuilder,
+ this->emitColor(fragBuilder,
+ uniformHandler,
args.fGLSLCaps,
ge,
tName.c_str(),