Create GLSL base class for ProgramDataManager

BUG=skia:

Review URL: https://codereview.chromium.org/1428543003
This commit is contained in:
egdaniel 2015-10-28 07:26:40 -07:00 committed by Commit bot
parent fe6876280f
commit 018fb62d12
60 changed files with 440 additions and 327 deletions

View File

@ -13,6 +13,7 @@
#include "effects/GrXfermodeFragmentProcessor.h" #include "effects/GrXfermodeFragmentProcessor.h"
#include "gl/GrGLProcessor.h" #include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "Resources.h" #include "Resources.h"
#include "SkReadBuffer.h" #include "SkReadBuffer.h"
#include "SkShader.h" #include "SkShader.h"
@ -76,7 +77,7 @@ public:
"%s = color * %s;", "%s = color * %s;",
args.fOutputColor, GrGLSLExpr4(args.fInputColor).c_str()); args.fOutputColor, GrGLSLExpr4(args.fInputColor).c_str());
} }
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override {} void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override {}
}; };
return new DCGLFP; return new DCGLFP;
} }

View File

@ -368,6 +368,7 @@
'<(skia_src_path)/gpu/glsl/GrGLSL_impl.h', '<(skia_src_path)/gpu/glsl/GrGLSL_impl.h',
'<(skia_src_path)/gpu/glsl/GrGLSLCaps.cpp', '<(skia_src_path)/gpu/glsl/GrGLSLCaps.cpp',
'<(skia_src_path)/gpu/glsl/GrGLSLCaps.h', '<(skia_src_path)/gpu/glsl/GrGLSLCaps.h',
'<(skia_src_path)/gpu/glsl/GrGLSLProgramDataManager.h',
'<(skia_src_path)/gpu/glsl/GrGLSLShaderVar.h', '<(skia_src_path)/gpu/glsl/GrGLSLShaderVar.h',
# Sk files # Sk files

View File

@ -132,6 +132,7 @@ private:
#include "GrTextureAccess.h" #include "GrTextureAccess.h"
#include "gl/GrGLProcessor.h" #include "gl/GrGLProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "SkGr.h" #include "SkGr.h"
#include "SkGrPriv.h" #include "SkGrPriv.h"
@ -237,7 +238,7 @@ public:
} }
protected: protected:
void onSetData(const GrGLProgramDataManager& pdman, const GrProcessor& proc) override { void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor& proc) override {
const LightingFP& lightingFP = proc.cast<LightingFP>(); const LightingFP& lightingFP = proc.cast<LightingFP>();
const SkVector3& lightDir = lightingFP.lightDir(); const SkVector3& lightDir = lightingFP.lightDir();
@ -267,16 +268,16 @@ public:
private: private:
SkVector3 fLightDir; SkVector3 fLightDir;
GrGLProgramDataManager::UniformHandle fLightDirUni; GrGLSLProgramDataManager::UniformHandle fLightDirUni;
SkColor3f fLightColor; SkColor3f fLightColor;
GrGLProgramDataManager::UniformHandle fLightColorUni; GrGLSLProgramDataManager::UniformHandle fLightColorUni;
SkColor3f fAmbientColor; SkColor3f fAmbientColor;
GrGLProgramDataManager::UniformHandle fAmbientColorUni; GrGLSLProgramDataManager::UniformHandle fAmbientColorUni;
SkVector fInvNormRotation; SkVector fInvNormRotation;
GrGLProgramDataManager::UniformHandle fXformUni; GrGLSLProgramDataManager::UniformHandle fXformUni;
}; };
void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override { void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override {

View File

@ -15,6 +15,7 @@
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
class GrGLCircleBlurFragmentProcessor : public GrGLFragmentProcessor { class GrGLCircleBlurFragmentProcessor : public GrGLFragmentProcessor {
public: public:
@ -22,10 +23,10 @@ public:
void emitCode(EmitArgs&) override; void emitCode(EmitArgs&) override;
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
GrGLProgramDataManager::UniformHandle fDataUniform; GrGLSLProgramDataManager::UniformHandle fDataUniform;
typedef GrGLFragmentProcessor INHERITED; typedef GrGLFragmentProcessor INHERITED;
}; };
@ -63,7 +64,7 @@ void GrGLCircleBlurFragmentProcessor::emitCode(EmitArgs& args) {
fsBuilder->codeAppendf("%s = src * intensity;\n", args.fOutputColor ); fsBuilder->codeAppendf("%s = src * intensity;\n", args.fOutputColor );
} }
void GrGLCircleBlurFragmentProcessor::onSetData(const GrGLProgramDataManager& pdman, void GrGLCircleBlurFragmentProcessor::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& proc) { const GrProcessor& proc) {
const GrCircleBlurFragmentProcessor& cbfp = proc.cast<GrCircleBlurFragmentProcessor>(); const GrCircleBlurFragmentProcessor& cbfp = proc.cast<GrCircleBlurFragmentProcessor>();
const SkRect& circle = cbfp.circle(); const SkRect& circle = cbfp.circle();

View File

@ -59,6 +59,7 @@ SkImageFilter* SkAlphaThresholdFilter::Create(const SkRegion& region,
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
class AlphaThresholdEffect : public GrFragmentProcessor { class AlphaThresholdEffect : public GrFragmentProcessor {
@ -126,12 +127,12 @@ public:
virtual void emitCode(EmitArgs&) override; virtual void emitCode(EmitArgs&) override;
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
GrGLProgramDataManager::UniformHandle fInnerThresholdVar; GrGLSLProgramDataManager::UniformHandle fInnerThresholdVar;
GrGLProgramDataManager::UniformHandle fOuterThresholdVar; GrGLSLProgramDataManager::UniformHandle fOuterThresholdVar;
typedef GrGLFragmentProcessor INHERITED; typedef GrGLFragmentProcessor INHERITED;
}; };
@ -182,7 +183,7 @@ void GrGLAlphaThresholdEffect::emitCode(EmitArgs& args) {
(GrGLSLExpr4(args.fInputColor) * GrGLSLExpr4("color")).c_str()); (GrGLSLExpr4(args.fInputColor) * GrGLSLExpr4("color")).c_str());
} }
void GrGLAlphaThresholdEffect::onSetData(const GrGLProgramDataManager& pdman, void GrGLAlphaThresholdEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& proc) { const GrProcessor& proc) {
const AlphaThresholdEffect& alpha_threshold = proc.cast<AlphaThresholdEffect>(); const AlphaThresholdEffect& alpha_threshold = proc.cast<AlphaThresholdEffect>();
pdman.set1f(fInnerThresholdVar, alpha_threshold.innerThreshold()); pdman.set1f(fInnerThresholdVar, alpha_threshold.innerThreshold());

View File

@ -15,8 +15,8 @@
#include "GrTexture.h" #include "GrTexture.h"
#include "gl/GrGLCaps.h" #include "gl/GrGLCaps.h"
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/GrGLProgramDataManager.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
static const bool gUseUnpremul = false; static const bool gUseUnpremul = false;
@ -80,14 +80,14 @@ public:
} }
protected: protected:
void onSetData(const GrGLProgramDataManager& pdman, const GrProcessor& proc) override { void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor& proc) override {
const GrArithmeticFP& arith = proc.cast<GrArithmeticFP>(); const GrArithmeticFP& arith = proc.cast<GrArithmeticFP>();
pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4()); pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4());
fEnforcePMColor = arith.enforcePMColor(); fEnforcePMColor = arith.enforcePMColor();
} }
private: private:
GrGLProgramDataManager::UniformHandle fKUni; GrGLSLProgramDataManager::UniformHandle fKUni;
bool fEnforcePMColor; bool fEnforcePMColor;
typedef GrGLFragmentProcessor INHERITED; typedef GrGLFragmentProcessor INHERITED;
@ -218,14 +218,14 @@ private:
add_arithmetic_code(fsBuilder, srcColor, dstColor, outColor, kUni, fEnforcePMColor); add_arithmetic_code(fsBuilder, srcColor, dstColor, outColor, kUni, fEnforcePMColor);
} }
void onSetData(const GrGLProgramDataManager& pdman, void onSetData(const GrGLSLProgramDataManager& pdman,
const GrXferProcessor& processor) override { const GrXferProcessor& processor) override {
const ArithmeticXP& arith = processor.cast<ArithmeticXP>(); const ArithmeticXP& arith = processor.cast<ArithmeticXP>();
pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4()); pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4());
fEnforcePMColor = arith.enforcePMColor(); fEnforcePMColor = arith.enforcePMColor();
}; };
GrGLProgramDataManager::UniformHandle fKUni; GrGLSLProgramDataManager::UniformHandle fKUni;
bool fEnforcePMColor; bool fEnforcePMColor;
typedef GrGLXferProcessor INHERITED; typedef GrGLXferProcessor INHERITED;

View File

@ -29,6 +29,7 @@
#include "effects/GrSimpleTextureEffect.h" #include "effects/GrSimpleTextureEffect.h"
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#endif #endif
SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) { SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) {
@ -682,10 +683,10 @@ public:
static void GenKey(GrSLPrecision precision, GrProcessorKeyBuilder* b); static void GenKey(GrSLPrecision precision, GrProcessorKeyBuilder* b);
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
typedef GrGLProgramDataManager::UniformHandle UniformHandle; typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
UniformHandle fProxyRectUniform; UniformHandle fProxyRectUniform;
UniformHandle fProfileSizeUniform; UniformHandle fProfileSizeUniform;
@ -763,7 +764,7 @@ void GrGLRectBlurEffect::emitCode(EmitArgs& args) {
fsBuilder->codeAppendf("%s = src * final;", args.fOutputColor); fsBuilder->codeAppendf("%s = src * final;", args.fOutputColor);
} }
void GrGLRectBlurEffect::onSetData(const GrGLProgramDataManager& pdman, void GrGLRectBlurEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& proc) { const GrProcessor& proc) {
const GrRectBlurEffect& rbe = proc.cast<GrRectBlurEffect>(); const GrRectBlurEffect& rbe = proc.cast<GrRectBlurEffect>();
SkRect rect = rbe.getRect(); SkRect rect = rbe.getRect();
@ -1047,12 +1048,12 @@ public:
virtual void emitCode(EmitArgs&) override; virtual void emitCode(EmitArgs&) override;
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
GrGLProgramDataManager::UniformHandle fProxyRectUniform; GrGLSLProgramDataManager::UniformHandle fProxyRectUniform;
GrGLProgramDataManager::UniformHandle fCornerRadiusUniform; GrGLSLProgramDataManager::UniformHandle fCornerRadiusUniform;
GrGLProgramDataManager::UniformHandle fBlurRadiusUniform; GrGLSLProgramDataManager::UniformHandle fBlurRadiusUniform;
typedef GrGLFragmentProcessor INHERITED; typedef GrGLFragmentProcessor INHERITED;
}; };
@ -1110,8 +1111,8 @@ void GrGLRRectBlurEffect::emitCode(EmitArgs& args) {
fsBuilder->codeAppend(";"); fsBuilder->codeAppend(";");
} }
void GrGLRRectBlurEffect::onSetData(const GrGLProgramDataManager& pdman, void GrGLRRectBlurEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& proc) { const GrProcessor& proc) {
const GrRRectBlurEffect& brre = proc.cast<GrRRectBlurEffect>(); const GrRRectBlurEffect& brre = proc.cast<GrRRectBlurEffect>();
SkRRect rrect = brre.getRRect(); SkRRect rrect = brre.getRRect();

View File

@ -20,6 +20,7 @@
#include "SkGr.h" #include "SkGr.h"
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#endif #endif
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -183,11 +184,11 @@ public:
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*); static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
GrGLProgramDataManager::UniformHandle fColorCubeSizeUni; GrGLSLProgramDataManager::UniformHandle fColorCubeSizeUni;
GrGLProgramDataManager::UniformHandle fColorCubeInvSizeUni; GrGLSLProgramDataManager::UniformHandle fColorCubeInvSizeUni;
typedef GrGLFragmentProcessor INHERITED; typedef GrGLFragmentProcessor INHERITED;
}; };
@ -291,8 +292,8 @@ void GrColorCubeEffect::GLProcessor::emitCode(EmitArgs& args) {
cubeIdx, nonZeroAlpha, args.fInputColor); cubeIdx, nonZeroAlpha, args.fInputColor);
} }
void GrColorCubeEffect::GLProcessor::onSetData(const GrGLProgramDataManager& pdman, void GrColorCubeEffect::GLProcessor::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& proc) { const GrProcessor& proc) {
const GrColorCubeEffect& colorCube = proc.cast<GrColorCubeEffect>(); const GrColorCubeEffect& colorCube = proc.cast<GrColorCubeEffect>();
SkScalar size = SkIntToScalar(colorCube.colorCubeSize()); SkScalar size = SkIntToScalar(colorCube.colorCubeSize());
pdman.set1f(fColorCubeSizeUni, SkScalarToFloat(size)); pdman.set1f(fColorCubeSizeUni, SkScalarToFloat(size));

View File

@ -387,6 +387,7 @@ SkColorFilter* SkColorMatrixFilter::newComposed(const SkColorFilter* innerFilter
#include "GrInvariantOutput.h" #include "GrInvariantOutput.h"
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
class ColorMatrixEffect : public GrFragmentProcessor { class ColorMatrixEffect : public GrFragmentProcessor {
public: public:
@ -433,19 +434,19 @@ public:
} }
protected: protected:
virtual void onSetData(const GrGLProgramDataManager& uniManager, virtual void onSetData(const GrGLSLProgramDataManager& uniManager,
const GrProcessor& proc) override { const GrProcessor& proc) override {
const ColorMatrixEffect& cme = proc.cast<ColorMatrixEffect>(); const ColorMatrixEffect& cme = proc.cast<ColorMatrixEffect>();
const float* m = cme.fMatrix.fMat; const float* m = cme.fMatrix.fMat;
// The GL matrix is transposed from SkColorMatrix. // The GL matrix is transposed from SkColorMatrix.
GrGLfloat mt[] = { float mt[] = {
m[0], m[5], m[10], m[15], m[0], m[5], m[10], m[15],
m[1], m[6], m[11], m[16], m[1], m[6], m[11], m[16],
m[2], m[7], m[12], m[17], m[2], m[7], m[12], m[17],
m[3], m[8], m[13], m[18], m[3], m[8], m[13], m[18],
}; };
static const float kScale = 1.0f / 255.0f; static const float kScale = 1.0f / 255.0f;
GrGLfloat vec[] = { float vec[] = {
m[4] * kScale, m[9] * kScale, m[14] * kScale, m[19] * kScale, m[4] * kScale, m[9] * kScale, m[14] * kScale, m[19] * kScale,
}; };
uniManager.setMatrix4fv(fMatrixHandle, 1, mt); uniManager.setMatrix4fv(fMatrixHandle, 1, mt);
@ -453,8 +454,8 @@ public:
} }
private: private:
GrGLProgramDataManager::UniformHandle fMatrixHandle; GrGLSLProgramDataManager::UniformHandle fMatrixHandle;
GrGLProgramDataManager::UniformHandle fVectorHandle; GrGLSLProgramDataManager::UniformHandle fVectorHandle;
typedef GrGLFragmentProcessor INHERITED; typedef GrGLFragmentProcessor INHERITED;
}; };

View File

@ -19,6 +19,7 @@
#include "effects/GrTextureDomain.h" #include "effects/GrTextureDomain.h"
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#endif #endif
namespace { namespace {
@ -314,12 +315,12 @@ public:
const GrTextureDomain::GLDomain& glDomain() const { return fGLDomain; } const GrTextureDomain::GLDomain& glDomain() const { return fGLDomain; }
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
SkDisplacementMapEffect::ChannelSelectorType fXChannelSelector; SkDisplacementMapEffect::ChannelSelectorType fXChannelSelector;
SkDisplacementMapEffect::ChannelSelectorType fYChannelSelector; SkDisplacementMapEffect::ChannelSelectorType fYChannelSelector;
GrGLProgramDataManager::UniformHandle fScaleUni; GrGLSLProgramDataManager::UniformHandle fScaleUni;
GrTextureDomain::GLDomain fGLDomain; GrTextureDomain::GLDomain fGLDomain;
typedef GrGLFragmentProcessor INHERITED; typedef GrGLFragmentProcessor INHERITED;
@ -610,8 +611,8 @@ void GrGLDisplacementMapEffect::emitCode(EmitArgs& args) {
fsBuilder->codeAppend(";\n"); fsBuilder->codeAppend(";\n");
} }
void GrGLDisplacementMapEffect::onSetData(const GrGLProgramDataManager& pdman, void GrGLDisplacementMapEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& proc) { const GrProcessor& proc) {
const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMapEffect>(); const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMapEffect>();
GrTexture* colorTex = displacementMap.texture(1); GrTexture* colorTex = displacementMap.texture(1);
SkScalar scaleX = displacementMap.scale().fX / colorTex->width(); SkScalar scaleX = displacementMap.scale().fX / colorTex->width();

View File

@ -23,12 +23,13 @@
#include "effects/GrSingleTextureEffect.h" #include "effects/GrSingleTextureEffect.h"
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
class GrGLDiffuseLightingEffect; class GrGLDiffuseLightingEffect;
class GrGLSpecularLightingEffect; class GrGLSpecularLightingEffect;
// For brevity // For brevity
typedef GrGLProgramDataManager::UniformHandle UniformHandle; typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
#endif #endif
namespace { namespace {
@ -39,13 +40,13 @@ const SkScalar gOneHalf = 0.5f;
const SkScalar gOneQuarter = 0.25f; const SkScalar gOneQuarter = 0.25f;
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
void setUniformPoint3(const GrGLProgramDataManager& pdman, UniformHandle uni, void setUniformPoint3(const GrGLSLProgramDataManager& pdman, UniformHandle uni,
const SkPoint3& point) { const SkPoint3& point) {
GR_STATIC_ASSERT(sizeof(SkPoint3) == 3 * sizeof(GrGLfloat)); GR_STATIC_ASSERT(sizeof(SkPoint3) == 3 * sizeof(float));
pdman.set3fv(uni, 1, &point.fX); pdman.set3fv(uni, 1, &point.fX);
} }
void setUniformNormal3(const GrGLProgramDataManager& pdman, UniformHandle uni, void setUniformNormal3(const GrGLSLProgramDataManager& pdman, UniformHandle uni,
const SkPoint3& point) { const SkPoint3& point) {
setUniformPoint3(pdman, uni, point); setUniformPoint3(pdman, uni, point);
} }
@ -611,7 +612,7 @@ public:
// This is called from GrGLLightingEffect's setData(). Subclasses of GrGLLight must call // This is called from GrGLLightingEffect's setData(). Subclasses of GrGLLight must call
// INHERITED::setData(). // INHERITED::setData().
virtual void setData(const GrGLProgramDataManager&, const SkImageFilterLight* light) const; virtual void setData(const GrGLSLProgramDataManager&, const SkImageFilterLight* light) const;
protected: protected:
/** /**
@ -631,7 +632,7 @@ private:
class GrGLDistantLight : public GrGLLight { class GrGLDistantLight : public GrGLLight {
public: public:
virtual ~GrGLDistantLight() {} virtual ~GrGLDistantLight() {}
void setData(const GrGLProgramDataManager&, const SkImageFilterLight* light) const override; void setData(const GrGLSLProgramDataManager&, const SkImageFilterLight* light) const override;
void emitSurfaceToLight(GrGLFPBuilder*, const char* z) override; void emitSurfaceToLight(GrGLFPBuilder*, const char* z) override;
private: private:
@ -644,7 +645,7 @@ private:
class GrGLPointLight : public GrGLLight { class GrGLPointLight : public GrGLLight {
public: public:
virtual ~GrGLPointLight() {} virtual ~GrGLPointLight() {}
void setData(const GrGLProgramDataManager&, const SkImageFilterLight* light) const override; void setData(const GrGLSLProgramDataManager&, const SkImageFilterLight* light) const override;
void emitSurfaceToLight(GrGLFPBuilder*, const char* z) override; void emitSurfaceToLight(GrGLFPBuilder*, const char* z) override;
private: private:
@ -657,7 +658,7 @@ private:
class GrGLSpotLight : public GrGLLight { class GrGLSpotLight : public GrGLLight {
public: public:
virtual ~GrGLSpotLight() {} virtual ~GrGLSpotLight() {}
void setData(const GrGLProgramDataManager&, const SkImageFilterLight* light) const override; void setData(const GrGLSLProgramDataManager&, const SkImageFilterLight* light) const override;
void emitSurfaceToLight(GrGLFPBuilder*, const char* z) override; void emitSurfaceToLight(GrGLFPBuilder*, const char* z) override;
void emitLightColor(GrGLFPBuilder*, const char *surfaceToLight) override; void emitLightColor(GrGLFPBuilder*, const char *surfaceToLight) override;
@ -1519,7 +1520,7 @@ protected:
/** /**
* Subclasses of GrGLLightingEffect must call INHERITED::onSetData(); * Subclasses of GrGLLightingEffect must call INHERITED::onSetData();
*/ */
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
virtual void emitLightFunc(GrGLFPBuilder*, SkString* funcName) = 0; virtual void emitLightFunc(GrGLFPBuilder*, SkString* funcName) = 0;
@ -1540,7 +1541,7 @@ public:
void emitLightFunc(GrGLFPBuilder*, SkString* funcName) override; void emitLightFunc(GrGLFPBuilder*, SkString* funcName) override;
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
typedef GrGLLightingEffect INHERITED; typedef GrGLLightingEffect INHERITED;
@ -1556,7 +1557,7 @@ public:
void emitLightFunc(GrGLFPBuilder*, SkString* funcName) override; void emitLightFunc(GrGLFPBuilder*, SkString* funcName) override;
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
typedef GrGLLightingEffect INHERITED; typedef GrGLLightingEffect INHERITED;
@ -1742,8 +1743,8 @@ void GrGLLightingEffect::GenKey(const GrProcessor& proc,
b->add32(lighting.boundaryMode() << 2 | lighting.light()->type()); b->add32(lighting.boundaryMode() << 2 | lighting.light()->type());
} }
void GrGLLightingEffect::onSetData(const GrGLProgramDataManager& pdman, void GrGLLightingEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& proc) { const GrProcessor& proc) {
const GrLightingEffect& lighting = proc.cast<GrLightingEffect>(); const GrLightingEffect& lighting = proc.cast<GrLightingEffect>();
GrTexture* texture = lighting.texture(0); GrTexture* texture = lighting.texture(0);
float ySign = texture->origin() == kTopLeft_GrSurfaceOrigin ? -1.0f : 1.0f; float ySign = texture->origin() == kTopLeft_GrSurfaceOrigin ? -1.0f : 1.0f;
@ -1784,8 +1785,8 @@ void GrGLDiffuseLightingEffect::emitLightFunc(GrGLFPBuilder* builder, SkString*
funcName); funcName);
} }
void GrGLDiffuseLightingEffect::onSetData(const GrGLProgramDataManager& pdman, void GrGLDiffuseLightingEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& proc) { const GrProcessor& proc) {
INHERITED::onSetData(pdman, proc); INHERITED::onSetData(pdman, proc);
const GrDiffuseLightingEffect& diffuse = proc.cast<GrDiffuseLightingEffect>(); const GrDiffuseLightingEffect& diffuse = proc.cast<GrDiffuseLightingEffect>();
pdman.set1f(fKDUni, diffuse.kd()); pdman.set1f(fKDUni, diffuse.kd());
@ -1874,8 +1875,8 @@ void GrGLSpecularLightingEffect::emitLightFunc(GrGLFPBuilder* builder, SkString*
funcName); funcName);
} }
void GrGLSpecularLightingEffect::onSetData(const GrGLProgramDataManager& pdman, void GrGLSpecularLightingEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& effect) { const GrProcessor& effect) {
INHERITED::onSetData(pdman, effect); INHERITED::onSetData(pdman, effect);
const GrSpecularLightingEffect& spec = effect.cast<GrSpecularLightingEffect>(); const GrSpecularLightingEffect& spec = effect.cast<GrSpecularLightingEffect>();
pdman.set1f(fKSUni, spec.ks()); pdman.set1f(fKSUni, spec.ks());
@ -1893,7 +1894,7 @@ void GrGLLight::emitLightColor(GrGLFPBuilder* builder, const char *surfaceToLigh
builder->getFragmentShaderBuilder()->codeAppend(builder->getUniformCStr(this->lightColorUni())); builder->getFragmentShaderBuilder()->codeAppend(builder->getUniformCStr(this->lightColorUni()));
} }
void GrGLLight::setData(const GrGLProgramDataManager& pdman, void GrGLLight::setData(const GrGLSLProgramDataManager& pdman,
const SkImageFilterLight* light) const { const SkImageFilterLight* light) const {
setUniformPoint3(pdman, fColorUni, setUniformPoint3(pdman, fColorUni,
light->color().makeScale(SkScalarInvert(SkIntToScalar(255)))); light->color().makeScale(SkScalarInvert(SkIntToScalar(255))));
@ -1901,7 +1902,7 @@ void GrGLLight::setData(const GrGLProgramDataManager& pdman,
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void GrGLDistantLight::setData(const GrGLProgramDataManager& pdman, void GrGLDistantLight::setData(const GrGLSLProgramDataManager& pdman,
const SkImageFilterLight* light) const { const SkImageFilterLight* light) const {
INHERITED::setData(pdman, light); INHERITED::setData(pdman, light);
SkASSERT(light->type() == SkImageFilterLight::kDistant_LightType); SkASSERT(light->type() == SkImageFilterLight::kDistant_LightType);
@ -1919,7 +1920,7 @@ void GrGLDistantLight::emitSurfaceToLight(GrGLFPBuilder* builder, const char* z)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void GrGLPointLight::setData(const GrGLProgramDataManager& pdman, void GrGLPointLight::setData(const GrGLSLProgramDataManager& pdman,
const SkImageFilterLight* light) const { const SkImageFilterLight* light) const {
INHERITED::setData(pdman, light); INHERITED::setData(pdman, light);
SkASSERT(light->type() == SkImageFilterLight::kPoint_LightType); SkASSERT(light->type() == SkImageFilterLight::kPoint_LightType);
@ -1939,7 +1940,7 @@ void GrGLPointLight::emitSurfaceToLight(GrGLFPBuilder* builder, const char* z) {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void GrGLSpotLight::setData(const GrGLProgramDataManager& pdman, void GrGLSpotLight::setData(const GrGLSLProgramDataManager& pdman,
const SkImageFilterLight* light) const { const SkImageFilterLight* light) const {
INHERITED::setData(pdman, light); INHERITED::setData(pdman, light);
SkASSERT(light->type() == SkImageFilterLight::kSpot_LightType); SkASSERT(light->type() == SkImageFilterLight::kSpot_LightType);

View File

@ -20,6 +20,7 @@
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/GrGLTexture.h" #include "gl/GrGLTexture.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
class GrMagnifierEffect : public GrSingleTextureEffect { class GrMagnifierEffect : public GrSingleTextureEffect {
@ -95,7 +96,7 @@ private:
}; };
// For brevity // For brevity
typedef GrGLProgramDataManager::UniformHandle UniformHandle; typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
class GrGLMagnifierEffect : public GrGLFragmentProcessor { class GrGLMagnifierEffect : public GrGLFragmentProcessor {
public: public:
@ -104,7 +105,7 @@ public:
virtual void emitCode(EmitArgs&) override; virtual void emitCode(EmitArgs&) override;
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
UniformHandle fOffsetVar; UniformHandle fOffsetVar;
@ -171,8 +172,8 @@ void GrGLMagnifierEffect::emitCode(EmitArgs& args) {
fsBuilder->codeAppend(modulate.c_str()); fsBuilder->codeAppend(modulate.c_str());
} }
void GrGLMagnifierEffect::onSetData(const GrGLProgramDataManager& pdman, void GrGLMagnifierEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& effect) { const GrProcessor& effect) {
const GrMagnifierEffect& zoom = effect.cast<GrMagnifierEffect>(); const GrMagnifierEffect& zoom = effect.cast<GrMagnifierEffect>();
pdman.set2f(fOffsetVar, zoom.x_offset(), zoom.y_offset()); pdman.set2f(fOffsetVar, zoom.x_offset(), zoom.y_offset());
pdman.set2f(fInvZoomVar, zoom.x_inv_zoom(), zoom.y_inv_zoom()); pdman.set2f(fInvZoomVar, zoom.x_inv_zoom(), zoom.y_inv_zoom());

View File

@ -21,6 +21,7 @@
#include "effects/Gr1DKernelEffect.h" #include "effects/Gr1DKernelEffect.h"
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#endif #endif
SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX, SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX,
@ -262,7 +263,7 @@ public:
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder* b); static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder* b);
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
int width() const { return GrMorphologyEffect::WidthFromRadius(fRadius); } int width() const { return GrMorphologyEffect::WidthFromRadius(fRadius); }
@ -271,8 +272,8 @@ private:
Gr1DKernelEffect::Direction fDirection; Gr1DKernelEffect::Direction fDirection;
bool fUseRange; bool fUseRange;
GrMorphologyEffect::MorphologyType fType; GrMorphologyEffect::MorphologyType fType;
GrGLProgramDataManager::UniformHandle fPixelSizeUni; GrGLSLProgramDataManager::UniformHandle fPixelSizeUni;
GrGLProgramDataManager::UniformHandle fRangeUni; GrGLSLProgramDataManager::UniformHandle fRangeUni;
typedef GrGLFragmentProcessor INHERITED; typedef GrGLFragmentProcessor INHERITED;
}; };
@ -363,7 +364,7 @@ void GrGLMorphologyEffect::GenKey(const GrProcessor& proc,
b->add32(key); b->add32(key);
} }
void GrGLMorphologyEffect::onSetData(const GrGLProgramDataManager& pdman, void GrGLMorphologyEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& proc) { const GrProcessor& proc) {
const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>(); const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>();
GrTexture& texture = *m.texture(0); GrTexture& texture = *m.texture(0);

View File

@ -22,6 +22,7 @@
#include "effects/GrConstColorProcessor.h" #include "effects/GrConstColorProcessor.h"
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#endif #endif
static const int kBlockSize = 256; static const int kBlockSize = 256;
@ -492,15 +493,15 @@ public:
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder* b); static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder* b);
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
GrGLProgramDataManager::UniformHandle fStitchDataUni; GrGLSLProgramDataManager::UniformHandle fStitchDataUni;
SkPerlinNoiseShader::Type fType; SkPerlinNoiseShader::Type fType;
bool fStitchTiles; bool fStitchTiles;
int fNumOctaves; int fNumOctaves;
GrGLProgramDataManager::UniformHandle fBaseFrequencyUni; GrGLSLProgramDataManager::UniformHandle fBaseFrequencyUni;
private: private:
typedef GrGLFragmentProcessor INHERITED; typedef GrGLFragmentProcessor INHERITED;
@ -894,7 +895,8 @@ void GrGLPerlinNoise::GenKey(const GrProcessor& processor, const GrGLSLCaps&,
b->add32(key); b->add32(key);
} }
void GrGLPerlinNoise::onSetData(const GrGLProgramDataManager& pdman, const GrProcessor& processor) { void GrGLPerlinNoise::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) {
INHERITED::onSetData(pdman, processor); INHERITED::onSetData(pdman, processor);
const GrPerlinNoiseEffect& turbulence = processor.cast<GrPerlinNoiseEffect>(); const GrPerlinNoiseEffect& turbulence = processor.cast<GrPerlinNoiseEffect>();

View File

@ -337,6 +337,7 @@ SkColorFilter* SkTable_ColorFilter::newComposed(const SkColorFilter* innerFilter
#include "effects/GrTextureStripAtlas.h" #include "effects/GrTextureStripAtlas.h"
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
class ColorTableEffect : public GrFragmentProcessor { class ColorTableEffect : public GrFragmentProcessor {
public: public:
@ -382,7 +383,7 @@ public:
static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder* b) {} static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder* b) {}
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
UniformHandle fRGBAYValuesUni; UniformHandle fRGBAYValuesUni;
@ -392,7 +393,7 @@ private:
GLColorTableEffect::GLColorTableEffect(const GrProcessor&) { GLColorTableEffect::GLColorTableEffect(const GrProcessor&) {
} }
void GLColorTableEffect::onSetData(const GrGLProgramDataManager& pdm, const GrProcessor& proc) { void GLColorTableEffect::onSetData(const GrGLSLProgramDataManager& pdm, const GrProcessor& proc) {
// The textures are organized in a strip where the rows are ordered a, r, g, b. // The textures are organized in a strip where the rows are ordered a, r, g, b.
float rgbaYValues[4]; float rgbaYValues[4];
const ColorTableEffect& cte = proc.cast<ColorTableEffect>(); const ColorTableEffect& cte = proc.cast<ColorTableEffect>();

View File

@ -910,6 +910,7 @@ SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
#include "GrInvariantOutput.h" #include "GrInvariantOutput.h"
#include "gl/GrGLContext.h" #include "gl/GrGLContext.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "SkGr.h" #include "SkGr.h"
GrGLGradientEffect::GrGLGradientEffect() GrGLGradientEffect::GrGLGradientEffect()
@ -946,8 +947,8 @@ void GrGLGradientEffect::emitUniforms(GrGLFPBuilder* builder, const GrGradientEf
} }
} }
static inline void set_color_uni(const GrGLProgramDataManager& pdman, static inline void set_color_uni(const GrGLSLProgramDataManager& pdman,
const GrGLProgramDataManager::UniformHandle uni, const GrGLSLProgramDataManager::UniformHandle uni,
const SkColor* color) { const SkColor* color) {
pdman.set4f(uni, pdman.set4f(uni,
SkColorGetR(*color) / 255.f, SkColorGetR(*color) / 255.f,
@ -956,8 +957,8 @@ static inline void set_color_uni(const GrGLProgramDataManager& pdman,
SkColorGetA(*color) / 255.f); SkColorGetA(*color) / 255.f);
} }
static inline void set_mul_color_uni(const GrGLProgramDataManager& pdman, static inline void set_mul_color_uni(const GrGLSLProgramDataManager& pdman,
const GrGLProgramDataManager::UniformHandle uni, const GrGLSLProgramDataManager::UniformHandle uni,
const SkColor* color){ const SkColor* color){
float a = SkColorGetA(*color) / 255.f; float a = SkColorGetA(*color) / 255.f;
float aDiv255 = a / 255.f; float aDiv255 = a / 255.f;
@ -968,8 +969,8 @@ static inline void set_mul_color_uni(const GrGLProgramDataManager& pdman,
a); a);
} }
void GrGLGradientEffect::onSetData(const GrGLProgramDataManager& pdman, void GrGLGradientEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) { const GrProcessor& processor) {
const GrGradientEffect& e = processor.cast<GrGradientEffect>(); const GrGradientEffect& e = processor.cast<GrGradientEffect>();

View File

@ -297,6 +297,7 @@ static inline int next_dither_toggle16(int toggle) {
#include "GrCoordTransform.h" #include "GrCoordTransform.h"
#include "GrFragmentProcessor.h" #include "GrFragmentProcessor.h"
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "glsl/GrGLSLProgramDataManager.h"
class GrInvariantOutput; class GrInvariantOutput;
@ -401,7 +402,7 @@ public:
virtual ~GrGLGradientEffect(); virtual ~GrGLGradientEffect();
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
protected: protected:
/** /**
@ -444,10 +445,10 @@ private:
GR_STATIC_ASSERT(kBaseKeyBitCnt <= 32); GR_STATIC_ASSERT(kBaseKeyBitCnt <= 32);
SkScalar fCachedYCoord; SkScalar fCachedYCoord;
GrGLProgramDataManager::UniformHandle fFSYUni; GrGLSLProgramDataManager::UniformHandle fFSYUni;
GrGLProgramDataManager::UniformHandle fColorStartUni; GrGLSLProgramDataManager::UniformHandle fColorStartUni;
GrGLProgramDataManager::UniformHandle fColorMidUni; GrGLSLProgramDataManager::UniformHandle fColorMidUni;
GrGLProgramDataManager::UniformHandle fColorEndUni; GrGLSLProgramDataManager::UniformHandle fColorEndUni;
typedef GrGLFragmentProcessor INHERITED; typedef GrGLFragmentProcessor INHERITED;
}; };

View File

@ -13,8 +13,9 @@
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "GrPaint.h" #include "GrPaint.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
// For brevity // For brevity
typedef GrGLProgramDataManager::UniformHandle UniformHandle; typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
static const SkScalar kErrorTol = 0.00001f; static const SkScalar kErrorTol = 0.00001f;
static const SkScalar kEdgeErrorTol = 5.f * kErrorTol; static const SkScalar kEdgeErrorTol = 5.f * kErrorTol;
@ -147,7 +148,7 @@ public:
static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKeyBuilder* b); static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKeyBuilder* b);
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
UniformHandle fParamUni; UniformHandle fParamUni;
@ -273,8 +274,8 @@ void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) {
fsBuilder->codeAppend("\t}\n"); fsBuilder->codeAppend("\t}\n");
} }
void GLEdge2PtConicalEffect::onSetData(const GrGLProgramDataManager& pdman, void GLEdge2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) { const GrProcessor& processor) {
INHERITED::onSetData(pdman, processor); INHERITED::onSetData(pdman, processor);
const Edge2PtConicalEffect& data = processor.cast<Edge2PtConicalEffect>(); const Edge2PtConicalEffect& data = processor.cast<Edge2PtConicalEffect>();
SkScalar radius0 = data.radius(); SkScalar radius0 = data.radius();
@ -423,7 +424,7 @@ public:
static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKeyBuilder* b); static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKeyBuilder* b);
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
UniformHandle fParamUni; UniformHandle fParamUni;
@ -540,8 +541,8 @@ void GLFocalOutside2PtConicalEffect::emitCode(EmitArgs& args) {
fsBuilder->codeAppend("\t}\n"); fsBuilder->codeAppend("\t}\n");
} }
void GLFocalOutside2PtConicalEffect::onSetData(const GrGLProgramDataManager& pdman, void GLFocalOutside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) { const GrProcessor& processor) {
INHERITED::onSetData(pdman, processor); INHERITED::onSetData(pdman, processor);
const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtConicalEffect>(); const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtConicalEffect>();
SkASSERT(data.isFlipped() == fIsFlipped); SkASSERT(data.isFlipped() == fIsFlipped);
@ -629,7 +630,7 @@ public:
static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKeyBuilder* b); static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKeyBuilder* b);
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
UniformHandle fFocalUni; UniformHandle fFocalUni;
@ -723,8 +724,8 @@ void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) {
args.fSamplers); args.fSamplers);
} }
void GLFocalInside2PtConicalEffect::onSetData(const GrGLProgramDataManager& pdman, void GLFocalInside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) { const GrProcessor& processor) {
INHERITED::onSetData(pdman, processor); INHERITED::onSetData(pdman, processor);
const FocalInside2PtConicalEffect& data = processor.cast<FocalInside2PtConicalEffect>(); const FocalInside2PtConicalEffect& data = processor.cast<FocalInside2PtConicalEffect>();
SkScalar focal = data.focal(); SkScalar focal = data.focal();
@ -866,7 +867,7 @@ public:
static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKeyBuilder* b); static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKeyBuilder* b);
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
UniformHandle fCenterUni; UniformHandle fCenterUni;
UniformHandle fParamUni; UniformHandle fParamUni;
@ -983,8 +984,8 @@ void GLCircleInside2PtConicalEffect::emitCode(EmitArgs& args) {
args.fSamplers); args.fSamplers);
} }
void GLCircleInside2PtConicalEffect::onSetData(const GrGLProgramDataManager& pdman, void GLCircleInside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) { const GrProcessor& processor) {
INHERITED::onSetData(pdman, processor); INHERITED::onSetData(pdman, processor);
const CircleInside2PtConicalEffect& data = processor.cast<CircleInside2PtConicalEffect>(); const CircleInside2PtConicalEffect& data = processor.cast<CircleInside2PtConicalEffect>();
SkScalar centerX = data.centerX(); SkScalar centerX = data.centerX();
@ -1088,7 +1089,7 @@ public:
static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKeyBuilder* b); static void GenKey(const GrProcessor&, const GrGLSLCaps& caps, GrProcessorKeyBuilder* b);
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
UniformHandle fCenterUni; UniformHandle fCenterUni;
UniformHandle fParamUni; UniformHandle fParamUni;
@ -1229,8 +1230,8 @@ void GLCircleOutside2PtConicalEffect::emitCode(EmitArgs& args) {
fsBuilder->codeAppend("\t}\n"); fsBuilder->codeAppend("\t}\n");
} }
void GLCircleOutside2PtConicalEffect::onSetData(const GrGLProgramDataManager& pdman, void GLCircleOutside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) { const GrProcessor& processor) {
INHERITED::onSetData(pdman, processor); INHERITED::onSetData(pdman, processor);
const CircleOutside2PtConicalEffect& data = processor.cast<CircleOutside2PtConicalEffect>(); const CircleOutside2PtConicalEffect& data = processor.cast<CircleOutside2PtConicalEffect>();
SkASSERT(data.isFlipped() == fIsFlipped); SkASSERT(data.isFlipped() == fIsFlipped);

View File

@ -131,18 +131,19 @@ public:
b->add32(key); b->add32(key);
} }
void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProcessor& gp) override { void setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& gp) override {
const DefaultGeoProc& dgp = gp.cast<DefaultGeoProc>(); const DefaultGeoProc& dgp = gp.cast<DefaultGeoProc>();
if (!dgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dgp.viewMatrix())) { if (!dgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dgp.viewMatrix())) {
fViewMatrix = dgp.viewMatrix(); fViewMatrix = dgp.viewMatrix();
GrGLfloat viewMatrix[3 * 3]; float viewMatrix[3 * 3];
GrGLGetMatrix<3>(viewMatrix, fViewMatrix); GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
} }
if (dgp.color() != fColor && !dgp.hasVertexColor()) { if (dgp.color() != fColor && !dgp.hasVertexColor()) {
GrGLfloat c[4]; float c[4];
GrColorToRGBAFloat(dgp.color(), c); GrColorToRGBAFloat(dgp.color(), c);
pdman.set4fv(fColorUniform, 1, c); pdman.set4fv(fColorUniform, 1, c);
fColor = dgp.color(); fColor = dgp.color();
@ -156,7 +157,7 @@ public:
} }
void setTransformData(const GrPrimitiveProcessor& primProc, void setTransformData(const GrPrimitiveProcessor& primProc,
const GrGLProgramDataManager& pdman, const GrGLSLProgramDataManager& pdman,
int index, int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override { const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataHelper<DefaultGeoProc>(primProc, pdman, index, transforms); this->setTransformDataHelper<DefaultGeoProc>(primProc, pdman, index, transforms);

View File

@ -10,6 +10,7 @@
#include "GrCoordTransform.h" #include "GrCoordTransform.h"
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "effects/GrConstColorProcessor.h" #include "effects/GrConstColorProcessor.h"
#include "effects/GrXfermodeFragmentProcessor.h" #include "effects/GrXfermodeFragmentProcessor.h"
@ -231,12 +232,12 @@ const GrFragmentProcessor* GrFragmentProcessor::OverrideInput(const GrFragmentPr
} }
private: private:
void onSetData(const GrGLProgramDataManager& pdman, void onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& fp) override { const GrProcessor& fp) override {
GrColor color = fp.cast<ReplaceInputFragmentProcessor>().fColor; GrColor color = fp.cast<ReplaceInputFragmentProcessor>().fColor;
if (!fHaveSetColor || color != fPreviousColor) { if (!fHaveSetColor || color != fPreviousColor) {
static const GrGLfloat scale = 1.f / 255.f; static const float scale = 1.f / 255.f;
GrGLfloat floatColor[4] = { float floatColor[4] = {
GrColorUnpackR(color) * scale, GrColorUnpackR(color) * scale,
GrColorUnpackG(color) * scale, GrColorUnpackG(color) * scale,
GrColorUnpackB(color) * scale, GrColorUnpackB(color) * scale,
@ -248,7 +249,7 @@ const GrFragmentProcessor* GrFragmentProcessor::OverrideInput(const GrFragmentPr
} }
} }
GrGLProgramDataManager::UniformHandle fColorUni; GrGLSLProgramDataManager::UniformHandle fColorUni;
bool fHaveSetColor; bool fHaveSetColor;
GrColor fPreviousColor; GrColor fPreviousColor;
}; };

View File

@ -25,6 +25,7 @@
#include "gl/GrGLProcessor.h" #include "gl/GrGLProcessor.h"
#include "gl/GrGLGeometryProcessor.h" #include "gl/GrGLGeometryProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
// TODO(joshualitt) - Break this file up during GrBatch post implementation cleanup // TODO(joshualitt) - Break this file up during GrBatch post implementation cleanup
@ -139,10 +140,11 @@ public:
b->add32(key); b->add32(key);
} }
void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProcessor& gp) override { void setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& gp) override {
const CircleEdgeEffect& ce = gp.cast<CircleEdgeEffect>(); const CircleEdgeEffect& ce = gp.cast<CircleEdgeEffect>();
if (ce.color() != fColor) { if (ce.color() != fColor) {
GrGLfloat c[4]; float c[4];
GrColorToRGBAFloat(ce.color(), c); GrColorToRGBAFloat(ce.color(), c);
pdman.set4fv(fColorUniform, 1, c); pdman.set4fv(fColorUniform, 1, c);
fColor = ce.color(); fColor = ce.color();
@ -150,7 +152,7 @@ public:
} }
void setTransformData(const GrPrimitiveProcessor& primProc, void setTransformData(const GrPrimitiveProcessor& primProc,
const GrGLProgramDataManager& pdman, const GrGLSLProgramDataManager& pdman,
int index, int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override { const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataHelper<CircleEdgeEffect>(primProc, pdman, index, transforms); this->setTransformDataHelper<CircleEdgeEffect>(primProc, pdman, index, transforms);
@ -307,10 +309,10 @@ public:
b->add32(key); b->add32(key);
} }
void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProcessor& gp) override { void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& gp) override {
const EllipseEdgeEffect& ee = gp.cast<EllipseEdgeEffect>(); const EllipseEdgeEffect& ee = gp.cast<EllipseEdgeEffect>();
if (ee.color() != fColor) { if (ee.color() != fColor) {
GrGLfloat c[4]; float c[4];
GrColorToRGBAFloat(ee.color(), c); GrColorToRGBAFloat(ee.color(), c);
pdman.set4fv(fColorUniform, 1, c); pdman.set4fv(fColorUniform, 1, c);
fColor = ee.color(); fColor = ee.color();
@ -318,7 +320,7 @@ public:
} }
void setTransformData(const GrPrimitiveProcessor& primProc, void setTransformData(const GrPrimitiveProcessor& primProc,
const GrGLProgramDataManager& pdman, const GrGLSLProgramDataManager& pdman,
int index, int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override { const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataHelper<EllipseEdgeEffect>(primProc, pdman, index, transforms); this->setTransformDataHelper<EllipseEdgeEffect>(primProc, pdman, index, transforms);
@ -497,18 +499,19 @@ public:
b->add32(key); b->add32(key);
} }
void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProcessor& gp) override { void setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& gp) override {
const DIEllipseEdgeEffect& dee = gp.cast<DIEllipseEdgeEffect>(); const DIEllipseEdgeEffect& dee = gp.cast<DIEllipseEdgeEffect>();
if (!dee.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dee.viewMatrix())) { if (!dee.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dee.viewMatrix())) {
fViewMatrix = dee.viewMatrix(); fViewMatrix = dee.viewMatrix();
GrGLfloat viewMatrix[3 * 3]; float viewMatrix[3 * 3];
GrGLGetMatrix<3>(viewMatrix, fViewMatrix); GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
} }
if (dee.color() != fColor) { if (dee.color() != fColor) {
GrGLfloat c[4]; float c[4];
GrColorToRGBAFloat(dee.color(), c); GrColorToRGBAFloat(dee.color(), c);
pdman.set4fv(fColorUniform, 1, c); pdman.set4fv(fColorUniform, 1, c);
fColor = dee.color(); fColor = dee.color();

View File

@ -71,10 +71,11 @@ public:
} }
} }
void setData(const GrGLProgramDataManager& pd, const GrPrimitiveProcessor& primProc) override { void setData(const GrGLSLProgramDataManager& pd,
const GrPrimitiveProcessor& primProc) override {
const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>(); const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>();
if (pathProc.opts().readsColor() && pathProc.color() != fColor) { if (pathProc.opts().readsColor() && pathProc.color() != fColor) {
GrGLfloat c[4]; float c[4];
GrColorToRGBAFloat(pathProc.color(), c); GrColorToRGBAFloat(pathProc.color(), c);
pd.set4fv(fColorUniform, 1, c); pd.set4fv(fColorUniform, 1, c);
fColor = pathProc.color(); fColor = pathProc.color();
@ -82,7 +83,7 @@ public:
} }
void setTransformData(const GrPrimitiveProcessor& primProc, void setTransformData(const GrPrimitiveProcessor& primProc,
const GrGLProgramDataManager& pdman, const GrGLSLProgramDataManager& pdman,
int index, int index,
const SkTArray<const GrCoordTransform*, true>& coordTransforms) override { const SkTArray<const GrCoordTransform*, true>& coordTransforms) override {
const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>(); const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>();

View File

@ -28,6 +28,7 @@
#include "gl/GrGLProcessor.h" #include "gl/GrGLProcessor.h"
#include "gl/GrGLGeometryProcessor.h" #include "gl/GrGLGeometryProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
GrAAConvexPathRenderer::GrAAConvexPathRenderer() { GrAAConvexPathRenderer::GrAAConvexPathRenderer() {
} }
@ -605,10 +606,11 @@ public:
b->add32(key); b->add32(key);
} }
void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProcessor& gp) override { void setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& gp) override {
const QuadEdgeEffect& qe = gp.cast<QuadEdgeEffect>(); const QuadEdgeEffect& qe = gp.cast<QuadEdgeEffect>();
if (qe.color() != fColor) { if (qe.color() != fColor) {
GrGLfloat c[4]; float c[4];
GrColorToRGBAFloat(qe.color(), c); GrColorToRGBAFloat(qe.color(), c);
pdman.set4fv(fColorUniform, 1, c); pdman.set4fv(fColorUniform, 1, c);
fColor = qe.color(); fColor = qe.color();
@ -616,7 +618,7 @@ public:
} }
void setTransformData(const GrPrimitiveProcessor& primProc, void setTransformData(const GrPrimitiveProcessor& primProc,
const GrGLProgramDataManager& pdman, const GrGLSLProgramDataManager& pdman,
int index, int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override { const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataHelper<QuadEdgeEffect>(primProc, pdman, index, transforms); this->setTransformDataHelper<QuadEdgeEffect>(primProc, pdman, index, transforms);

View File

@ -11,6 +11,7 @@
#include "gl/GrGLGeometryProcessor.h" #include "gl/GrGLGeometryProcessor.h"
#include "gl/GrGLUtil.h" #include "gl/GrGLUtil.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
class GrGLConicEffect : public GrGLGeometryProcessor { class GrGLConicEffect : public GrGLGeometryProcessor {
public: public:
@ -22,19 +23,19 @@ public:
const GrGLSLCaps&, const GrGLSLCaps&,
GrProcessorKeyBuilder*); GrProcessorKeyBuilder*);
void setData(const GrGLProgramDataManager& pdman, void setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& primProc) override { const GrPrimitiveProcessor& primProc) override {
const GrConicEffect& ce = primProc.cast<GrConicEffect>(); const GrConicEffect& ce = primProc.cast<GrConicEffect>();
if (!ce.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(ce.viewMatrix())) { if (!ce.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(ce.viewMatrix())) {
fViewMatrix = ce.viewMatrix(); fViewMatrix = ce.viewMatrix();
GrGLfloat viewMatrix[3 * 3]; float viewMatrix[3 * 3];
GrGLGetMatrix<3>(viewMatrix, fViewMatrix); GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
} }
if (ce.color() != fColor) { if (ce.color() != fColor) {
GrGLfloat c[4]; float c[4];
GrColorToRGBAFloat(ce.color(), c); GrColorToRGBAFloat(ce.color(), c);
pdman.set4fv(fColorUniform, 1, c); pdman.set4fv(fColorUniform, 1, c);
fColor = ce.color(); fColor = ce.color();
@ -47,7 +48,7 @@ public:
} }
void setTransformData(const GrPrimitiveProcessor& primProc, void setTransformData(const GrPrimitiveProcessor& primProc,
const GrGLProgramDataManager& pdman, const GrGLSLProgramDataManager& pdman,
int index, int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override { const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataHelper<GrConicEffect>(primProc, pdman, index, transforms); this->setTransformDataHelper<GrConicEffect>(primProc, pdman, index, transforms);
@ -238,19 +239,19 @@ public:
const GrGLSLCaps&, const GrGLSLCaps&,
GrProcessorKeyBuilder*); GrProcessorKeyBuilder*);
void setData(const GrGLProgramDataManager& pdman, void setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& primProc) override { const GrPrimitiveProcessor& primProc) override {
const GrQuadEffect& qe = primProc.cast<GrQuadEffect>(); const GrQuadEffect& qe = primProc.cast<GrQuadEffect>();
if (!qe.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(qe.viewMatrix())) { if (!qe.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(qe.viewMatrix())) {
fViewMatrix = qe.viewMatrix(); fViewMatrix = qe.viewMatrix();
GrGLfloat viewMatrix[3 * 3]; float viewMatrix[3 * 3];
GrGLGetMatrix<3>(viewMatrix, fViewMatrix); GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
} }
if (qe.color() != fColor) { if (qe.color() != fColor) {
GrGLfloat c[4]; float c[4];
GrColorToRGBAFloat(qe.color(), c); GrColorToRGBAFloat(qe.color(), c);
pdman.set4fv(fColorUniform, 1, c); pdman.set4fv(fColorUniform, 1, c);
fColor = qe.color(); fColor = qe.color();
@ -263,7 +264,7 @@ public:
} }
void setTransformData(const GrPrimitiveProcessor& primProc, void setTransformData(const GrPrimitiveProcessor& primProc,
const GrGLProgramDataManager& pdman, const GrGLSLProgramDataManager& pdman,
int index, int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override { const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataHelper<GrQuadEffect>(primProc, pdman, index, transforms); this->setTransformDataHelper<GrQuadEffect>(primProc, pdman, index, transforms);
@ -440,19 +441,19 @@ public:
const GrGLSLCaps&, const GrGLSLCaps&,
GrProcessorKeyBuilder*); GrProcessorKeyBuilder*);
void setData(const GrGLProgramDataManager& pdman, void setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& primProc) override { const GrPrimitiveProcessor& primProc) override {
const GrCubicEffect& ce = primProc.cast<GrCubicEffect>(); const GrCubicEffect& ce = primProc.cast<GrCubicEffect>();
if (!ce.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(ce.viewMatrix())) { if (!ce.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(ce.viewMatrix())) {
fViewMatrix = ce.viewMatrix(); fViewMatrix = ce.viewMatrix();
GrGLfloat viewMatrix[3 * 3]; float viewMatrix[3 * 3];
GrGLGetMatrix<3>(viewMatrix, fViewMatrix); GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
} }
if (ce.color() != fColor) { if (ce.color() != fColor) {
GrGLfloat c[4]; float c[4];
GrColorToRGBAFloat(ce.color(), c); GrColorToRGBAFloat(ce.color(), c);
pdman.set4fv(fColorUniform, 1, c); pdman.set4fv(fColorUniform, 1, c);
fColor = ce.color(); fColor = ce.color();

View File

@ -8,6 +8,7 @@
#include "GrBicubicEffect.h" #include "GrBicubicEffect.h"
#include "GrInvariantOutput.h" #include "GrInvariantOutput.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#define DS(x) SkDoubleToScalar(x) #define DS(x) SkDoubleToScalar(x)
@ -32,10 +33,10 @@ public:
} }
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
typedef GrGLProgramDataManager::UniformHandle UniformHandle; typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
UniformHandle fCoefficientsUni; UniformHandle fCoefficientsUni;
UniformHandle fImageIncrementUni; UniformHandle fImageIncrementUni;
@ -105,8 +106,8 @@ void GrGLBicubicEffect::emitCode(EmitArgs& args) {
GrGLSLExpr4(args.fInputColor)).c_str()); GrGLSLExpr4(args.fInputColor)).c_str());
} }
void GrGLBicubicEffect::onSetData(const GrGLProgramDataManager& pdman, void GrGLBicubicEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) { const GrProcessor& processor) {
const GrBicubicEffect& bicubicEffect = processor.cast<GrBicubicEffect>(); const GrBicubicEffect& bicubicEffect = processor.cast<GrBicubicEffect>();
const GrTexture& texture = *processor.texture(0); const GrTexture& texture = *processor.texture(0);
float imageIncrement[2]; float imageIncrement[2];

View File

@ -12,6 +12,7 @@
#include "gl/GrGLTexture.h" #include "gl/GrGLTexture.h"
#include "gl/GrGLGeometryProcessor.h" #include "gl/GrGLGeometryProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
class GrGLBitmapTextGeoProc : public GrGLGeometryProcessor { class GrGLBitmapTextGeoProc : public GrGLGeometryProcessor {
public: public:
@ -78,10 +79,10 @@ public:
} }
} }
void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProcessor& gp) override { void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& gp) override {
const GrBitmapTextGeoProc& btgp = gp.cast<GrBitmapTextGeoProc>(); const GrBitmapTextGeoProc& btgp = gp.cast<GrBitmapTextGeoProc>();
if (btgp.color() != fColor && !btgp.hasVertexColor()) { if (btgp.color() != fColor && !btgp.hasVertexColor()) {
GrGLfloat c[4]; float c[4];
GrColorToRGBAFloat(btgp.color(), c); GrColorToRGBAFloat(btgp.color(), c);
pdman.set4fv(fColorUniform, 1, c); pdman.set4fv(fColorUniform, 1, c);
fColor = btgp.color(); fColor = btgp.color();
@ -89,7 +90,7 @@ public:
} }
void setTransformData(const GrPrimitiveProcessor& primProc, void setTransformData(const GrPrimitiveProcessor& primProc,
const GrGLProgramDataManager& pdman, const GrGLSLProgramDataManager& pdman,
int index, int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override { const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataHelper<GrBitmapTextGeoProc>(primProc, pdman, index, transforms); this->setTransformDataHelper<GrBitmapTextGeoProc>(primProc, pdman, index, transforms);

View File

@ -8,6 +8,7 @@
#include "effects/GrConstColorProcessor.h" #include "effects/GrConstColorProcessor.h"
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
class GLConstColorProcessor : public GrGLFragmentProcessor { class GLConstColorProcessor : public GrGLFragmentProcessor {
public: public:
@ -39,14 +40,14 @@ public:
} }
protected: protected:
void onSetData(const GrGLProgramDataManager& pdm, const GrProcessor& processor) override { void onSetData(const GrGLSLProgramDataManager& pdm, const GrProcessor& processor) override {
GrColor color = processor.cast<GrConstColorProcessor>().color(); GrColor color = processor.cast<GrConstColorProcessor>().color();
// We use the "illegal" color value as an uninit sentinel. However, ut isn't inherently // We use the "illegal" color value as an uninit sentinel. However, ut isn't inherently
// illegal to use this processor with unpremul colors. So we correctly handle the case // illegal to use this processor with unpremul colors. So we correctly handle the case
// when the "illegal" color is used but we will always upload it. // when the "illegal" color is used but we will always upload it.
if (GrColor_ILLEGAL == color || fPrevColor != color) { if (GrColor_ILLEGAL == color || fPrevColor != color) {
static const GrGLfloat scale = 1.f / 255.f; static const float scale = 1.f / 255.f;
GrGLfloat floatColor[4] = { float floatColor[4] = {
GrColorUnpackR(color) * scale, GrColorUnpackR(color) * scale,
GrColorUnpackG(color) * scale, GrColorUnpackG(color) * scale,
GrColorUnpackB(color) * scale, GrColorUnpackB(color) * scale,
@ -58,7 +59,7 @@ protected:
} }
private: private:
GrGLProgramDataManager::UniformHandle fColorUniform; GrGLSLProgramDataManager::UniformHandle fColorUniform;
GrColor fPrevColor; GrColor fPrevColor;
typedef GrGLFragmentProcessor INHERITED; typedef GrGLFragmentProcessor INHERITED;

View File

@ -11,6 +11,7 @@
#include "gl/GrGLContext.h" #include "gl/GrGLContext.h"
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
class AARectEffect : public GrFragmentProcessor { class AARectEffect : public GrFragmentProcessor {
@ -87,10 +88,10 @@ public:
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*); static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
GrGLProgramDataManager::UniformHandle fRectUniform; GrGLSLProgramDataManager::UniformHandle fRectUniform;
SkRect fPrevRect; SkRect fPrevRect;
typedef GrGLFragmentProcessor INHERITED; typedef GrGLFragmentProcessor INHERITED;
}; };
@ -138,7 +139,8 @@ void GLAARectEffect::emitCode(EmitArgs& args) {
(GrGLSLExpr4(args.fInputColor) * GrGLSLExpr1("alpha")).c_str()); (GrGLSLExpr4(args.fInputColor) * GrGLSLExpr1("alpha")).c_str());
} }
void GLAARectEffect::onSetData(const GrGLProgramDataManager& pdman, const GrProcessor& processor) { void GLAARectEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) {
const AARectEffect& aare = processor.cast<AARectEffect>(); const AARectEffect& aare = processor.cast<AARectEffect>();
const SkRect& rect = aare.getRect(); const SkRect& rect = aare.getRect();
if (rect != fPrevRect) { if (rect != fPrevRect) {
@ -173,10 +175,10 @@ public:
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*); static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
GrGLProgramDataManager::UniformHandle fEdgeUniform; GrGLSLProgramDataManager::UniformHandle fEdgeUniform;
SkScalar fPrevEdges[3 * GrConvexPolyEffect::kMaxEdges]; SkScalar fPrevEdges[3 * GrConvexPolyEffect::kMaxEdges];
typedef GrGLFragmentProcessor INHERITED; typedef GrGLFragmentProcessor INHERITED;
}; };
@ -222,7 +224,8 @@ void GrGLConvexPolyEffect::emitCode(EmitArgs& args) {
(GrGLSLExpr4(args.fInputColor) * GrGLSLExpr1("alpha")).c_str()); (GrGLSLExpr4(args.fInputColor) * GrGLSLExpr1("alpha")).c_str());
} }
void GrGLConvexPolyEffect::onSetData(const GrGLProgramDataManager& pdman, const GrProcessor& effect) { void GrGLConvexPolyEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& effect) {
const GrConvexPolyEffect& cpe = effect.cast<GrConvexPolyEffect>(); const GrConvexPolyEffect& cpe = effect.cast<GrConvexPolyEffect>();
size_t byteSize = 3 * cpe.getEdgeCount() * sizeof(SkScalar); size_t byteSize = 3 * cpe.getEdgeCount() * sizeof(SkScalar);
if (0 != memcmp(fPrevEdges, cpe.getEdges(), byteSize)) { if (0 != memcmp(fPrevEdges, cpe.getEdges(), byteSize)) {

View File

@ -9,9 +9,10 @@
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/GrGLTexture.h" #include "gl/GrGLTexture.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
// For brevity // For brevity
typedef GrGLProgramDataManager::UniformHandle UniformHandle; typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
class GrGLConvolutionEffect : public GrGLFragmentProcessor { class GrGLConvolutionEffect : public GrGLFragmentProcessor {
public: public:
@ -22,7 +23,7 @@ public:
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*); static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
protected: protected:
void onSetData(const GrGLProgramDataManager& pdman, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor&) override;
private: private:
int width() const { return Gr1DKernelEffect::WidthFromRadius(fRadius); } int width() const { return Gr1DKernelEffect::WidthFromRadius(fRadius); }
@ -100,8 +101,8 @@ void GrGLConvolutionEffect::emitCode(EmitArgs& args) {
fsBuilder->codeAppend(modulate.c_str()); fsBuilder->codeAppend(modulate.c_str());
} }
void GrGLConvolutionEffect::onSetData(const GrGLProgramDataManager& pdman, void GrGLConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) { const GrProcessor& processor) {
const GrConvolutionEffect& conv = processor.cast<GrConvolutionEffect>(); const GrConvolutionEffect& conv = processor.cast<GrConvolutionEffect>();
GrTexture& texture = *conv.texture(0); GrTexture& texture = *conv.texture(0);
// the code we generated was for a specific kernel radius // the code we generated was for a specific kernel radius

View File

@ -81,7 +81,7 @@ private:
} }
} }
void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) override {}; void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {};
typedef GrGLXferProcessor INHERITED; typedef GrGLXferProcessor INHERITED;
}; };

View File

@ -22,6 +22,7 @@
#include "gl/GrGLProgramDataManager.h" #include "gl/GrGLProgramDataManager.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLCaps.h" #include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLProgramDataManager.h"
bool GrCustomXfermode::IsSupportedMode(SkXfermode::Mode mode) { bool GrCustomXfermode::IsSupportedMode(SkXfermode::Mode mode) {
return mode > SkXfermode::kLastCoeffMode && mode <= SkXfermode::kLastMode; return mode > SkXfermode::kLastCoeffMode && mode <= SkXfermode::kLastMode;
@ -168,7 +169,7 @@ private:
GrGLSLBlend::AppendMode(fsBuilder, srcColor, dstColor, outColor, xp.mode()); GrGLSLBlend::AppendMode(fsBuilder, srcColor, dstColor, outColor, xp.mode());
} }
void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) override {} void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {}
typedef GrGLXferProcessor INHERITED; typedef GrGLXferProcessor INHERITED;
}; };

View File

@ -24,6 +24,7 @@
#include "gl/GrGLGeometryProcessor.h" #include "gl/GrGLGeometryProcessor.h"
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -821,10 +822,10 @@ public:
const GrGLSLCaps&, const GrGLSLCaps&,
GrProcessorKeyBuilder*); GrProcessorKeyBuilder*);
void setData(const GrGLProgramDataManager&, const GrPrimitiveProcessor&) override; void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&) override;
void setTransformData(const GrPrimitiveProcessor& primProc, void setTransformData(const GrPrimitiveProcessor& primProc,
const GrGLProgramDataManager& pdman, const GrGLSLProgramDataManager& pdman,
int index, int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override { const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataHelper<DashingCircleEffect>(primProc, pdman, index, transforms); this->setTransformDataHelper<DashingCircleEffect>(primProc, pdman, index, transforms);
@ -896,11 +897,11 @@ void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
fsBuilder->codeAppendf("%s = vec4(alpha);", args.fOutputCoverage); fsBuilder->codeAppendf("%s = vec4(alpha);", args.fOutputCoverage);
} }
void GLDashingCircleEffect::setData(const GrGLProgramDataManager& pdman, void GLDashingCircleEffect::setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& processor) { const GrPrimitiveProcessor& processor) {
const DashingCircleEffect& dce = processor.cast<DashingCircleEffect>(); const DashingCircleEffect& dce = processor.cast<DashingCircleEffect>();
if (dce.color() != fColor) { if (dce.color() != fColor) {
GrGLfloat c[4]; float c[4];
GrColorToRGBAFloat(dce.color(), c); GrColorToRGBAFloat(dce.color(), c);
pdman.set4fv(fColorUniform, 1, c); pdman.set4fv(fColorUniform, 1, c);
fColor = dce.color(); fColor = dce.color();
@ -1032,10 +1033,10 @@ public:
const GrGLSLCaps&, const GrGLSLCaps&,
GrProcessorKeyBuilder*); GrProcessorKeyBuilder*);
void setData(const GrGLProgramDataManager&, const GrPrimitiveProcessor&) override; void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&) override;
void setTransformData(const GrPrimitiveProcessor& primProc, void setTransformData(const GrPrimitiveProcessor& primProc,
const GrGLProgramDataManager& pdman, const GrGLSLProgramDataManager& pdman,
int index, int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override { const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataHelper<DashingLineEffect>(primProc, pdman, index, transforms); this->setTransformDataHelper<DashingLineEffect>(primProc, pdman, index, transforms);
@ -1120,11 +1121,11 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
fsBuilder->codeAppendf("%s = vec4(alpha);", args.fOutputCoverage); fsBuilder->codeAppendf("%s = vec4(alpha);", args.fOutputCoverage);
} }
void GLDashingLineEffect::setData(const GrGLProgramDataManager& pdman, void GLDashingLineEffect::setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& processor) { const GrPrimitiveProcessor& processor) {
const DashingLineEffect& de = processor.cast<DashingLineEffect>(); const DashingLineEffect& de = processor.cast<DashingLineEffect>();
if (de.color() != fColor) { if (de.color() != fColor) {
GrGLfloat c[4]; float c[4];
GrColorToRGBAFloat(de.color(), c); GrColorToRGBAFloat(de.color(), c);
pdman.set4fv(fColorUniform, 1, c); pdman.set4fv(fColorUniform, 1, c);
fColor = de.color(); fColor = de.color();

View File

@ -10,6 +10,7 @@
#include "gl/GrGLXferProcessor.h" #include "gl/GrGLXferProcessor.h"
#include "gl/builders/GrGLFragmentShaderBuilder.h" #include "gl/builders/GrGLFragmentShaderBuilder.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
/** /**
* This xfer processor disables color writing. Thus color and coverage and ignored and no blending * This xfer processor disables color writing. Thus color and coverage and ignored and no blending
@ -66,7 +67,7 @@ private:
fsBuilder->codeAppendf("%s = vec4(0);", args.fOutputPrimary); fsBuilder->codeAppendf("%s = vec4(0);", args.fOutputPrimary);
} }
void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) override {} void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {}
typedef GrGLXferProcessor INHERITED; typedef GrGLXferProcessor INHERITED;
}; };

View File

@ -15,6 +15,7 @@
#include "gl/GrGLTexture.h" #include "gl/GrGLTexture.h"
#include "gl/GrGLGeometryProcessor.h" #include "gl/GrGLGeometryProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
// Assuming a radius of a little less than the diagonal of the fragment // Assuming a radius of a little less than the diagonal of the fragment
#define SK_DistanceFieldAAFactor "0.65" #define SK_DistanceFieldAAFactor "0.65"
@ -143,7 +144,7 @@ public:
fsBuilder->codeAppendf("%s = vec4(val);", args.fOutputCoverage); fsBuilder->codeAppendf("%s = vec4(val);", args.fOutputCoverage);
} }
void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProcessor& proc) override { void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& proc) override {
#ifdef SK_GAMMA_APPLY_TO_A8 #ifdef SK_GAMMA_APPLY_TO_A8
const GrDistanceFieldA8TextGeoProc& dfTexEffect = proc.cast<GrDistanceFieldA8TextGeoProc>(); const GrDistanceFieldA8TextGeoProc& dfTexEffect = proc.cast<GrDistanceFieldA8TextGeoProc>();
float distanceAdjust = dfTexEffect.getDistanceAdjust(); float distanceAdjust = dfTexEffect.getDistanceAdjust();
@ -156,13 +157,13 @@ public:
if (!dfa8gp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dfa8gp.viewMatrix())) { if (!dfa8gp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dfa8gp.viewMatrix())) {
fViewMatrix = dfa8gp.viewMatrix(); fViewMatrix = dfa8gp.viewMatrix();
GrGLfloat viewMatrix[3 * 3]; float viewMatrix[3 * 3];
GrGLGetMatrix<3>(viewMatrix, fViewMatrix); GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
} }
if (dfa8gp.color() != fColor && !dfa8gp.hasVertexColor()) { if (dfa8gp.color() != fColor && !dfa8gp.hasVertexColor()) {
GrGLfloat c[4]; float c[4];
GrColorToRGBAFloat(dfa8gp.color(), c); GrColorToRGBAFloat(dfa8gp.color(), c);
pdman.set4fv(fColorUniform, 1, c); pdman.set4fv(fColorUniform, 1, c);
fColor = dfa8gp.color(); fColor = dfa8gp.color();
@ -370,7 +371,7 @@ public:
fsBuilder->codeAppendf("%s = vec4(val);", args.fOutputCoverage); fsBuilder->codeAppendf("%s = vec4(val);", args.fOutputCoverage);
} }
void setData(const GrGLProgramDataManager& pdman, const GrPrimitiveProcessor& proc) override { void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& proc) override {
SkASSERT(fTextureSizeUni.isValid()); SkASSERT(fTextureSizeUni.isValid());
GrTexture* texture = proc.texture(0); GrTexture* texture = proc.texture(0);
@ -386,13 +387,13 @@ public:
if (!dfpgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dfpgp.viewMatrix())) { if (!dfpgp.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dfpgp.viewMatrix())) {
fViewMatrix = dfpgp.viewMatrix(); fViewMatrix = dfpgp.viewMatrix();
GrGLfloat viewMatrix[3 * 3]; float viewMatrix[3 * 3];
GrGLGetMatrix<3>(viewMatrix, fViewMatrix); GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
} }
if (dfpgp.color() != fColor) { if (dfpgp.color() != fColor) {
GrGLfloat c[4]; float c[4];
GrColorToRGBAFloat(dfpgp.color(), c); GrColorToRGBAFloat(dfpgp.color(), c);
pdman.set4fv(fColorUniform, 1, c); pdman.set4fv(fColorUniform, 1, c);
fColor = dfpgp.color(); fColor = dfpgp.color();
@ -639,7 +640,7 @@ public:
fsBuilder->codeAppendf("%s = val;", args.fOutputCoverage); fsBuilder->codeAppendf("%s = val;", args.fOutputCoverage);
} }
void setData(const GrGLProgramDataManager& pdman, void setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& processor) override { const GrPrimitiveProcessor& processor) override {
SkASSERT(fDistanceAdjustUni.isValid()); SkASSERT(fDistanceAdjustUni.isValid());
@ -655,13 +656,13 @@ public:
if (!dflcd.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dflcd.viewMatrix())) { if (!dflcd.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(dflcd.viewMatrix())) {
fViewMatrix = dflcd.viewMatrix(); fViewMatrix = dflcd.viewMatrix();
GrGLfloat viewMatrix[3 * 3]; float viewMatrix[3 * 3];
GrGLGetMatrix<3>(viewMatrix, fViewMatrix); GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
} }
if (dflcd.color() != fColor) { if (dflcd.color() != fColor) {
GrGLfloat c[4]; float c[4];
GrColorToRGBAFloat(dflcd.color(), c); GrColorToRGBAFloat(dflcd.color(), c);
pdman.set4fv(fColorUniform, 1, c); pdman.set4fv(fColorUniform, 1, c);
fColor = dflcd.color(); fColor = dflcd.color();

View File

@ -8,6 +8,7 @@
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/GrGLTexture.h" #include "gl/GrGLTexture.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
class GrGLMatrixConvolutionEffect : public GrGLFragmentProcessor { class GrGLMatrixConvolutionEffect : public GrGLFragmentProcessor {
public: public:
@ -17,10 +18,10 @@ public:
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*); static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
typedef GrGLProgramDataManager::UniformHandle UniformHandle; typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
SkISize fKernelSize; SkISize fKernelSize;
bool fConvolveAlpha; bool fConvolveAlpha;
@ -111,8 +112,8 @@ void GrGLMatrixConvolutionEffect::GenKey(const GrProcessor& processor,
b->add32(GrTextureDomain::GLDomain::DomainKey(m.domain())); b->add32(GrTextureDomain::GLDomain::DomainKey(m.domain()));
} }
void GrGLMatrixConvolutionEffect::onSetData(const GrGLProgramDataManager& pdman, void GrGLMatrixConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) { const GrProcessor& processor) {
const GrMatrixConvolutionEffect& conv = processor.cast<GrMatrixConvolutionEffect>(); const GrMatrixConvolutionEffect& conv = processor.cast<GrMatrixConvolutionEffect>();
GrTexture& texture = *conv.texture(0); GrTexture& texture = *conv.texture(0);
// the code we generated was for a specific kernel size // the code we generated was for a specific kernel size

View File

@ -12,6 +12,7 @@
#include "SkRect.h" #include "SkRect.h"
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@ -98,12 +99,12 @@ public:
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*); static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
GrGLProgramDataManager::UniformHandle fCircleUniform; GrGLSLProgramDataManager::UniformHandle fCircleUniform;
SkPoint fPrevCenter; SkPoint fPrevCenter;
SkScalar fPrevRadius; SkScalar fPrevRadius;
typedef GrGLFragmentProcessor INHERITED; typedef GrGLFragmentProcessor INHERITED;
}; };
@ -153,7 +154,8 @@ void GLCircleEffect::GenKey(const GrProcessor& processor, const GrGLSLCaps&,
b->add32(ce.getEdgeType()); b->add32(ce.getEdgeType());
} }
void GLCircleEffect::onSetData(const GrGLProgramDataManager& pdman, const GrProcessor& processor) { void GLCircleEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) {
const CircleEffect& ce = processor.cast<CircleEffect>(); const CircleEffect& ce = processor.cast<CircleEffect>();
if (ce.getRadius() != fPrevRadius || ce.getCenter() != fPrevCenter) { if (ce.getRadius() != fPrevRadius || ce.getCenter() != fPrevCenter) {
SkScalar radius = ce.getRadius(); SkScalar radius = ce.getRadius();
@ -269,12 +271,12 @@ public:
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*); static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
GrGLProgramDataManager::UniformHandle fEllipseUniform; GrGLSLProgramDataManager::UniformHandle fEllipseUniform;
SkPoint fPrevCenter; SkPoint fPrevCenter;
SkVector fPrevRadii; SkVector fPrevRadii;
typedef GrGLFragmentProcessor INHERITED; typedef GrGLFragmentProcessor INHERITED;
}; };
@ -334,7 +336,8 @@ void GLEllipseEffect::GenKey(const GrProcessor& effect, const GrGLSLCaps&,
b->add32(ee.getEdgeType()); b->add32(ee.getEdgeType());
} }
void GLEllipseEffect::onSetData(const GrGLProgramDataManager& pdman, const GrProcessor& effect) { void GLEllipseEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& effect) {
const EllipseEffect& ee = effect.cast<EllipseEffect>(); const EllipseEffect& ee = effect.cast<EllipseEffect>();
if (ee.getRadii() != fPrevRadii || ee.getCenter() != fPrevCenter) { if (ee.getRadii() != fPrevRadii || ee.getCenter() != fPrevCenter) {
SkScalar invRXSqd = 1.f / (ee.getRadii().fX * ee.getRadii().fX); SkScalar invRXSqd = 1.f / (ee.getRadii().fX * ee.getRadii().fX);

View File

@ -17,6 +17,7 @@
#include "gl/GrGLXferProcessor.h" #include "gl/GrGLXferProcessor.h"
#include "gl/builders/GrGLFragmentShaderBuilder.h" #include "gl/builders/GrGLFragmentShaderBuilder.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
/** /**
* Wraps the shader outputs and HW blend state that comprise a Porter Duff blend mode with coverage. * Wraps the shader outputs and HW blend state that comprise a Porter Duff blend mode with coverage.
@ -450,7 +451,7 @@ private:
args.fOutputPrimary, args.fInputColor, args.fInputCoverage); args.fOutputPrimary, args.fInputColor, args.fInputCoverage);
} }
void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) override {} void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {}
typedef GrGLXferProcessor INHERITED; typedef GrGLXferProcessor INHERITED;
}; };
@ -550,7 +551,7 @@ private:
GrGLSLBlend::AppendMode(fsBuilder, srcColor, dstColor, outColor, xp.getXfermode()); GrGLSLBlend::AppendMode(fsBuilder, srcColor, dstColor, outColor, xp.getXfermode());
} }
void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) override {} void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {}
typedef GrGLXferProcessor INHERITED; typedef GrGLXferProcessor INHERITED;
}; };
@ -628,7 +629,7 @@ private:
args.fInputCoverage); args.fInputCoverage);
} }
void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) override {}; void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {};
typedef GrGLXferProcessor INHERITED; typedef GrGLXferProcessor INHERITED;
}; };

View File

@ -14,6 +14,7 @@
#include "SkRRect.h" #include "SkRRect.h"
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
// The effects defined here only handle rrect radii >= kRadiusMin. // The effects defined here only handle rrect radii >= kRadiusMin.
static const SkScalar kRadiusMin = SK_ScalarHalf; static const SkScalar kRadiusMin = SK_ScalarHalf;
@ -133,11 +134,11 @@ public:
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*); static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
GrGLProgramDataManager::UniformHandle fInnerRectUniform; GrGLSLProgramDataManager::UniformHandle fInnerRectUniform;
GrGLProgramDataManager::UniformHandle fRadiusPlusHalfUniform; GrGLSLProgramDataManager::UniformHandle fRadiusPlusHalfUniform;
SkRRect fPrevRRect; SkRRect fPrevRRect;
typedef GrGLFragmentProcessor INHERITED; typedef GrGLFragmentProcessor INHERITED;
}; };
@ -281,8 +282,8 @@ void GLCircularRRectEffect::GenKey(const GrProcessor& processor, const GrGLSLCap
b->add32((crre.getCircularCornerFlags() << 3) | crre.getEdgeType()); b->add32((crre.getCircularCornerFlags() << 3) | crre.getEdgeType());
} }
void GLCircularRRectEffect::onSetData(const GrGLProgramDataManager& pdman, void GLCircularRRectEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) { const GrProcessor& processor) {
const CircularRRectEffect& crre = processor.cast<CircularRRectEffect>(); const CircularRRectEffect& crre = processor.cast<CircularRRectEffect>();
const SkRRect& rrect = crre.getRRect(); const SkRRect& rrect = crre.getRRect();
if (rrect != fPrevRRect) { if (rrect != fPrevRRect) {
@ -479,11 +480,11 @@ public:
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*); static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
GrGLProgramDataManager::UniformHandle fInnerRectUniform; GrGLSLProgramDataManager::UniformHandle fInnerRectUniform;
GrGLProgramDataManager::UniformHandle fInvRadiiSqdUniform; GrGLSLProgramDataManager::UniformHandle fInvRadiiSqdUniform;
SkRRect fPrevRRect; SkRRect fPrevRRect;
typedef GrGLFragmentProcessor INHERITED; typedef GrGLFragmentProcessor INHERITED;
}; };
@ -572,8 +573,8 @@ void GLEllipticalRRectEffect::GenKey(const GrProcessor& effect, const GrGLSLCaps
b->add32(erre.getRRect().getType() | erre.getEdgeType() << 3); b->add32(erre.getRRect().getType() | erre.getEdgeType() << 3);
} }
void GLEllipticalRRectEffect::onSetData(const GrGLProgramDataManager& pdman, void GLEllipticalRRectEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& effect) { const GrProcessor& effect) {
const EllipticalRRectEffect& erre = effect.cast<EllipticalRRectEffect>(); const EllipticalRRectEffect& erre = effect.cast<EllipticalRRectEffect>();
const SkRRect& rrect = erre.getRRect(); const SkRRect& rrect = erre.getRRect();
if (rrect != fPrevRRect) { if (rrect != fPrevRRect) {

View File

@ -12,6 +12,7 @@
#include "gl/GrGLContext.h" #include "gl/GrGLContext.h"
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index) GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index)
: fIndex(index) { : fIndex(index) {
@ -142,12 +143,12 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLShaderBuilder* builder,
} }
} }
void GrTextureDomain::GLDomain::setData(const GrGLProgramDataManager& pdman, void GrTextureDomain::GLDomain::setData(const GrGLSLProgramDataManager& pdman,
const GrTextureDomain& textureDomain, const GrTextureDomain& textureDomain,
GrSurfaceOrigin textureOrigin) { GrSurfaceOrigin textureOrigin) {
SkASSERT(textureDomain.mode() == fMode); SkASSERT(textureDomain.mode() == fMode);
if (kIgnore_Mode != textureDomain.mode()) { if (kIgnore_Mode != textureDomain.mode()) {
GrGLfloat values[kPrevDomainCount] = { float values[kPrevDomainCount] = {
SkScalarToFloat(textureDomain.domain().left()), SkScalarToFloat(textureDomain.domain().left()),
SkScalarToFloat(textureDomain.domain().top()), SkScalarToFloat(textureDomain.domain().top()),
SkScalarToFloat(textureDomain.domain().right()), SkScalarToFloat(textureDomain.domain().right()),
@ -161,9 +162,9 @@ void GrTextureDomain::GLDomain::setData(const GrGLProgramDataManager& pdman,
// of elements so that values = (l, t, r, b). // of elements so that values = (l, t, r, b).
SkTSwap(values[1], values[3]); SkTSwap(values[1], values[3]);
} }
if (0 != memcmp(values, fPrevDomain, kPrevDomainCount * sizeof(GrGLfloat))) { if (0 != memcmp(values, fPrevDomain, kPrevDomainCount * sizeof(float))) {
pdman.set4fv(fDomainUni, 1, values); pdman.set4fv(fDomainUni, 1, values);
memcpy(fPrevDomain, values, kPrevDomainCount * sizeof(GrGLfloat)); memcpy(fPrevDomain, values, kPrevDomainCount * sizeof(float));
} }
} }
} }
@ -180,7 +181,7 @@ public:
static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*); static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*);
protected: protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private: private:
GrTextureDomain::GLDomain fGLDomain; GrTextureDomain::GLDomain fGLDomain;
@ -200,8 +201,8 @@ void GrGLTextureDomainEffect::emitCode(EmitArgs& args) {
args.fInputColor); args.fInputColor);
} }
void GrGLTextureDomainEffect::onSetData(const GrGLProgramDataManager& pdman, void GrGLTextureDomainEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) { const GrProcessor& processor) {
const GrTextureDomainEffect& textureDomainEffect = processor.cast<GrTextureDomainEffect>(); const GrTextureDomainEffect& textureDomainEffect = processor.cast<GrTextureDomainEffect>();
const GrTextureDomain& domain = textureDomainEffect.textureDomain(); const GrTextureDomain& domain = textureDomainEffect.textureDomain();
fGLDomain.setData(pdman, domain, processor.texture(0)->origin()); fGLDomain.setData(pdman, domain, processor.texture(0)->origin());

View File

@ -10,6 +10,7 @@
#include "GrSingleTextureEffect.h" #include "GrSingleTextureEffect.h"
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "glsl/GrGLSLProgramDataManager.h"
class GrGLProgramBuilder; class GrGLProgramBuilder;
class GrGLShaderBuilder; class GrGLShaderBuilder;
@ -122,7 +123,7 @@ public:
* Call this from GrGLProcessor::setData() to upload uniforms necessary for the texture * Call this from GrGLProcessor::setData() to upload uniforms necessary for the texture
* domain. The rectangle is automatically adjusted to account for the texture's origin. * domain. The rectangle is automatically adjusted to account for the texture's origin.
*/ */
void setData(const GrGLProgramDataManager& pdman, const GrTextureDomain& textureDomain, void setData(const GrGLSLProgramDataManager& pdman, const GrTextureDomain& textureDomain,
GrSurfaceOrigin textureOrigin); GrSurfaceOrigin textureOrigin);
enum { enum {
@ -140,10 +141,10 @@ public:
private: private:
static const int kPrevDomainCount = 4; static const int kPrevDomainCount = 4;
SkDEBUGCODE(Mode fMode;) SkDEBUGCODE(Mode fMode;)
GrGLProgramDataManager::UniformHandle fDomainUni; GrGLSLProgramDataManager::UniformHandle fDomainUni;
SkString fDomainName; SkString fDomainName;
GrGLfloat fPrevDomain[kPrevDomainCount]; float fPrevDomain[kPrevDomainCount];
}; };
protected: protected:

View File

@ -12,6 +12,7 @@
#include "GrProcessor.h" #include "GrProcessor.h"
#include "gl/GrGLFragmentProcessor.h" #include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
namespace { namespace {
@ -52,9 +53,9 @@ public:
class GLProcessor : public GrGLFragmentProcessor { class GLProcessor : public GrGLFragmentProcessor {
public: public:
static const GrGLfloat kJPEGConversionMatrix[16]; static const float kJPEGConversionMatrix[16];
static const GrGLfloat kRec601ConversionMatrix[16]; static const float kRec601ConversionMatrix[16];
static const GrGLfloat kRec709ConversionMatrix[16]; static const float kRec709ConversionMatrix[16];
// this class always generates the same code. // this class always generates the same code.
static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*) {} static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*) {}
@ -81,8 +82,8 @@ public:
} }
protected: protected:
virtual void onSetData(const GrGLProgramDataManager& pdman, virtual void onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) override { const GrProcessor& processor) override {
const YUVtoRGBEffect& yuvEffect = processor.cast<YUVtoRGBEffect>(); const YUVtoRGBEffect& yuvEffect = processor.cast<YUVtoRGBEffect>();
switch (yuvEffect.getColorSpace()) { switch (yuvEffect.getColorSpace()) {
case kJPEG_SkYUVColorSpace: case kJPEG_SkYUVColorSpace:
@ -98,7 +99,7 @@ public:
} }
private: private:
GrGLProgramDataManager::UniformHandle fMatrixUni; GrGLSLProgramDataManager::UniformHandle fMatrixUni;
typedef GrGLFragmentProcessor INHERITED; typedef GrGLFragmentProcessor INHERITED;
}; };
@ -152,17 +153,17 @@ private:
typedef GrFragmentProcessor INHERITED; typedef GrFragmentProcessor INHERITED;
}; };
const GrGLfloat YUVtoRGBEffect::GLProcessor::kJPEGConversionMatrix[16] = { const float YUVtoRGBEffect::GLProcessor::kJPEGConversionMatrix[16] = {
1.0f, 0.0f, 1.402f, -0.701f, 1.0f, 0.0f, 1.402f, -0.701f,
1.0f, -0.34414f, -0.71414f, 0.529f, 1.0f, -0.34414f, -0.71414f, 0.529f,
1.0f, 1.772f, 0.0f, -0.886f, 1.0f, 1.772f, 0.0f, -0.886f,
0.0f, 0.0f, 0.0f, 1.0}; 0.0f, 0.0f, 0.0f, 1.0};
const GrGLfloat YUVtoRGBEffect::GLProcessor::kRec601ConversionMatrix[16] = { const float YUVtoRGBEffect::GLProcessor::kRec601ConversionMatrix[16] = {
1.164f, 0.0f, 1.596f, -0.87075f, 1.164f, 0.0f, 1.596f, -0.87075f,
1.164f, -0.391f, -0.813f, 0.52925f, 1.164f, -0.391f, -0.813f, 0.52925f,
1.164f, 2.018f, 0.0f, -1.08175f, 1.164f, 2.018f, 0.0f, -1.08175f,
0.0f, 0.0f, 0.0f, 1.0}; 0.0f, 0.0f, 0.0f, 1.0};
const GrGLfloat YUVtoRGBEffect::GLProcessor::kRec709ConversionMatrix[16] = { const float YUVtoRGBEffect::GLProcessor::kRec709ConversionMatrix[16] = {
1.164f, 0.0f, 1.793f, -0.96925f, 1.164f, 0.0f, 1.793f, -0.96925f,
1.164f, -0.213f, -0.533f, 0.30025f, 1.164f, -0.213f, -0.533f, 0.30025f,
1.164f, 2.112f, 0.0f, -1.12875f, 1.164f, 2.112f, 0.0f, -1.12875f,

View File

@ -10,7 +10,7 @@
#include "builders/GrGLFragmentShaderBuilder.h" #include "builders/GrGLFragmentShaderBuilder.h"
#include "builders/GrGLProgramBuilder.h" #include "builders/GrGLProgramBuilder.h"
void GrGLFragmentProcessor::setData(const GrGLProgramDataManager& pdman, void GrGLFragmentProcessor::setData(const GrGLSLProgramDataManager& pdman,
const GrFragmentProcessor& processor) { const GrFragmentProcessor& processor) {
this->onSetData(pdman, processor); this->onSetData(pdman, processor);
SkASSERT(fChildProcessors.count() == processor.numChildProcessors()); SkASSERT(fChildProcessors.count() == processor.numChildProcessors());

View File

@ -8,11 +8,11 @@
#ifndef GrGLFragmentProcessor_DEFINED #ifndef GrGLFragmentProcessor_DEFINED
#define GrGLFragmentProcessor_DEFINED #define GrGLFragmentProcessor_DEFINED
#include "GrGLProgramDataManager.h"
#include "GrGLProcessor.h" #include "GrGLProcessor.h"
#include "GrTextureAccess.h" #include "glsl/GrGLSLProgramDataManager.h"
class GrGLFPBuilder; class GrGLFPBuilder;
class GrGLSLCaps;
class GrGLFragmentProcessor { class GrGLFragmentProcessor {
public: public:
@ -24,7 +24,7 @@ public:
} }
} }
typedef GrGLProgramDataManager::UniformHandle UniformHandle; typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray; typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray;
typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray; typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray;
@ -70,7 +70,7 @@ public:
virtual void emitCode(EmitArgs&) = 0; virtual void emitCode(EmitArgs&) = 0;
void setData(const GrGLProgramDataManager& pdman, const GrFragmentProcessor& processor); void setData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& processor);
static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*) {} static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*) {}
@ -101,7 +101,7 @@ protected:
parameter is guaranteed to be of the same type that created this GrGLFragmentProcessor and parameter is guaranteed to be of the same type that created this GrGLFragmentProcessor and
to have an identical processor key as the one that created this GrGLFragmentProcessor. */ to have an identical processor key as the one that created this GrGLFragmentProcessor. */
// TODO update this to pass in GrFragmentProcessor // TODO update this to pass in GrFragmentProcessor
virtual void onSetData(const GrGLProgramDataManager&, const GrProcessor&) {} virtual void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) {}
private: private:
void internalEmitChild(int, const char*, const char*, EmitArgs&); void internalEmitChild(int, const char*, const char*, EmitArgs&);

View File

@ -24,7 +24,7 @@ public:
// By default we use the identity matrix // By default we use the identity matrix
void setTransformData(const GrPrimitiveProcessor&, void setTransformData(const GrPrimitiveProcessor&,
const GrGLProgramDataManager& pdman, const GrGLSLProgramDataManager& pdman,
int index, int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override { const SkTArray<const GrCoordTransform*, true>& transforms) override {
this->setTransformDataMatrix(SkMatrix::I(), pdman, index, transforms); this->setTransformDataMatrix(SkMatrix::I(), pdman, index, transforms);
@ -33,7 +33,7 @@ public:
// A helper which subclasses can use if needed // A helper which subclasses can use if needed
template <class GeometryProcessor> template <class GeometryProcessor>
void setTransformDataHelper(const GrPrimitiveProcessor& primProc, void setTransformDataHelper(const GrPrimitiveProcessor& primProc,
const GrGLProgramDataManager& pdman, const GrGLSLProgramDataManager& pdman,
int index, int index,
const SkTArray<const GrCoordTransform*, true>& transforms) { const SkTArray<const GrCoordTransform*, true>& transforms) {
const GeometryProcessor& gp = primProc.cast<GeometryProcessor>(); const GeometryProcessor& gp = primProc.cast<GeometryProcessor>();
@ -87,7 +87,7 @@ protected:
private: private:
void setTransformDataMatrix(const SkMatrix& localMatrix, void setTransformDataMatrix(const SkMatrix& localMatrix,
const GrGLProgramDataManager& pdman, const GrGLSLProgramDataManager& pdman,
int index, int index,
const SkTArray<const GrCoordTransform*, true>& transforms) { const SkTArray<const GrCoordTransform*, true>& transforms) {
SkSTArray<2, Transform, true>& procTransforms = fInstalledTransforms[index]; SkSTArray<2, Transform, true>& procTransforms = fInstalledTransforms[index];

View File

@ -11,6 +11,7 @@
#include "GrProcessor.h" #include "GrProcessor.h"
#include "GrGLFragmentProcessor.h" #include "GrGLFragmentProcessor.h"
#include "GrGLPathRendering.h" #include "GrGLPathRendering.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "SkRTConf.h" #include "SkRTConf.h"
#include "SkTSearch.h" #include "SkTSearch.h"
@ -19,7 +20,7 @@ SK_CONF_DECLARE(bool, c_DisplayCache, "gpu.displayCache", false,
"Display program cache usage."); "Display program cache usage.");
#endif #endif
typedef GrGLProgramDataManager::UniformHandle UniformHandle; typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
struct GrGLGpu::ProgramCache::Entry { struct GrGLGpu::ProgramCache::Entry {

View File

@ -186,7 +186,7 @@ void GrGLPathRendering::onDrawPaths(const DrawPathArgs& args, const GrPathRange*
void GrGLPathRendering::setProgramPathFragmentInputTransform(GrGLuint program, GrGLint location, void GrGLPathRendering::setProgramPathFragmentInputTransform(GrGLuint program, GrGLint location,
GrGLenum genMode, GrGLint components, GrGLenum genMode, GrGLint components,
const SkMatrix& matrix) { const SkMatrix& matrix) {
GrGLfloat coefficients[3 * 3]; float coefficients[3 * 3];
SkASSERT(components >= 1 && components <= 3); SkASSERT(components >= 1 && components <= 3);
coefficients[0] = SkScalarToFloat(matrix[SkMatrix::kMScaleX]); coefficients[0] = SkScalarToFloat(matrix[SkMatrix::kMScaleX]);
@ -224,7 +224,7 @@ void GrGLPathRendering::setProjectionMatrix(const SkMatrix& matrix,
fHWProjectionMatrixState.fRenderTargetSize = renderTargetSize; fHWProjectionMatrixState.fRenderTargetSize = renderTargetSize;
fHWProjectionMatrixState.fRenderTargetOrigin = renderTargetOrigin; fHWProjectionMatrixState.fRenderTargetOrigin = renderTargetOrigin;
GrGLfloat glMatrix[4 * 4]; float glMatrix[4 * 4];
fHWProjectionMatrixState.getRTAdjustedGLMatrix<4>(glMatrix); fHWProjectionMatrixState.getRTAdjustedGLMatrix<4>(glMatrix);
GL_CALL(MatrixLoadf(GR_GL_PATH_PROJECTION, glMatrix)); GL_CALL(MatrixLoadf(GR_GL_PATH_PROJECTION, glMatrix));
} }

View File

@ -94,7 +94,7 @@ private:
/** /**
* Gets a matrix that goes from local coordinates to GL normalized device coords. * Gets a matrix that goes from local coordinates to GL normalized device coords.
*/ */
template<int Size> void getRTAdjustedGLMatrix(GrGLfloat* destMatrix) { template<int Size> void getRTAdjustedGLMatrix(float* destMatrix) {
SkMatrix combined; SkMatrix combined;
if (kBottomLeft_GrSurfaceOrigin == fRenderTargetOrigin) { if (kBottomLeft_GrSurfaceOrigin == fRenderTargetOrigin) {
combined.setAll(SkIntToScalar(2) / fRenderTargetSize.fWidth, 0, -SK_Scalar1, combined.setAll(SkIntToScalar(2) / fRenderTargetSize.fWidth, 0, -SK_Scalar1,

View File

@ -10,6 +10,7 @@
#include "GrPrimitiveProcessor.h" #include "GrPrimitiveProcessor.h"
#include "GrGLProcessor.h" #include "GrGLProcessor.h"
#include "glsl/GrGLSLProgramDataManager.h"
class GrBatchTracker; class GrBatchTracker;
class GrPrimitiveProcessor; class GrPrimitiveProcessor;
@ -19,7 +20,7 @@ class GrGLPrimitiveProcessor {
public: public:
virtual ~GrGLPrimitiveProcessor() {} virtual ~GrGLPrimitiveProcessor() {}
typedef GrGLProgramDataManager::UniformHandle UniformHandle; typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray; typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray;
typedef SkSTArray<2, const GrCoordTransform*, true> ProcCoords; typedef SkSTArray<2, const GrCoordTransform*, true> ProcCoords;
@ -63,12 +64,12 @@ public:
GrPrimitiveProcessor parameter is guaranteed to be of the same type that created this GrPrimitiveProcessor parameter is guaranteed to be of the same type that created this
GrGLPrimitiveProcessor and to have an identical processor key as the one that created this GrGLPrimitiveProcessor and to have an identical processor key as the one that created this
GrGLPrimitiveProcessor. */ GrGLPrimitiveProcessor. */
virtual void setData(const GrGLProgramDataManager&, const GrPrimitiveProcessor&) = 0; virtual void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&) = 0;
static SkMatrix GetTransformMatrix(const SkMatrix& localMatrix, const GrCoordTransform&); static SkMatrix GetTransformMatrix(const SkMatrix& localMatrix, const GrCoordTransform&);
virtual void setTransformData(const GrPrimitiveProcessor&, virtual void setTransformData(const GrPrimitiveProcessor&,
const GrGLProgramDataManager& pdman, const GrGLSLProgramDataManager& pdman,
int index, int index,
const SkTArray<const GrCoordTransform*, true>& transforms) = 0; const SkTArray<const GrCoordTransform*, true>& transforms) = 0;
@ -77,9 +78,9 @@ protected:
struct Transform { struct Transform {
Transform() : fType(kVoid_GrSLType) { fCurrentValue = SkMatrix::InvalidMatrix(); } Transform() : fType(kVoid_GrSLType) { fCurrentValue = SkMatrix::InvalidMatrix(); }
GrGLProgramDataManager::UniformHandle fHandle; GrGLSLProgramDataManager::UniformHandle fHandle;
SkMatrix fCurrentValue; SkMatrix fCurrentValue;
GrSLType fType; GrSLType fType;
}; };
SkSTArray<8, SkSTArray<2, Transform, true> > fInstalledTransforms; SkSTArray<8, SkSTArray<2, Transform, true> > fInstalledTransforms;

View File

@ -8,9 +8,10 @@
#ifndef GrGLProcessor_DEFINED #ifndef GrGLProcessor_DEFINED
#define GrGLProcessor_DEFINED #define GrGLProcessor_DEFINED
#include "GrGLProgramDataManager.h"
#include "GrProcessor.h" #include "GrProcessor.h"
#include "GrShaderVar.h"
#include "GrTextureAccess.h" #include "GrTextureAccess.h"
#include "glsl/GrGLSLProgramDataManager.h"
/** @file /** @file
This file contains specializations for OpenGL of the shader stages declared in This file contains specializations for OpenGL of the shader stages declared in
@ -29,7 +30,7 @@
// TODO delete this and make TextureSampler its own thing // TODO delete this and make TextureSampler its own thing
class GrGLProcessor { class GrGLProcessor {
public: public:
typedef GrGLProgramDataManager::UniformHandle UniformHandle; typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
/** /**
* Passed to GrGLProcessors so they can add transformed coordinates to their shader code. * Passed to GrGLProcessors so they can add transformed coordinates to their shader code.

View File

@ -135,7 +135,7 @@ void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc,
fRenderTargetState.fRenderTargetSize = size; fRenderTargetState.fRenderTargetSize = size;
fRenderTargetState.fRenderTargetOrigin = rt->origin(); fRenderTargetState.fRenderTargetOrigin = rt->origin();
GrGLfloat rtAdjustmentVec[4]; float rtAdjustmentVec[4];
fRenderTargetState.getRTAdjustmentVec(rtAdjustmentVec); fRenderTargetState.getRTAdjustmentVec(rtAdjustmentVec);
fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, rtAdjustmentVec); fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, rtAdjustmentVec);
} }

View File

@ -13,6 +13,7 @@
#include "GrGLProgramDesc.h" #include "GrGLProgramDesc.h"
#include "GrGLTexture.h" #include "GrGLTexture.h"
#include "GrGLProgramDataManager.h" #include "GrGLProgramDataManager.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "SkString.h" #include "SkString.h"
#include "SkXfermode.h" #include "SkXfermode.h"
@ -74,7 +75,7 @@ public:
* pos.x = dot(v.xy, pos.xz) * pos.x = dot(v.xy, pos.xz)
* pos.y = dot(v.zw, pos.yz) * pos.y = dot(v.zw, pos.yz)
*/ */
void getRTAdjustmentVec(GrGLfloat* destVec) { void getRTAdjustmentVec(float* destVec) {
destVec[0] = 2.f / fRenderTargetSize.fWidth; destVec[0] = 2.f / fRenderTargetSize.fWidth;
destVec[1] = -1.f; destVec[1] = -1.f;
if (kBottomLeft_GrSurfaceOrigin == fRenderTargetOrigin) { if (kBottomLeft_GrSurfaceOrigin == fRenderTargetOrigin) {
@ -97,7 +98,7 @@ public:
SkTArray<const GrTextureAccess*>* textureBindings); SkTArray<const GrTextureAccess*>* textureBindings);
protected: protected:
typedef GrGLProgramDataManager::UniformHandle UniformHandle; typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray;
typedef GrGLProgramDataManager::SeparableVaryingInfoArray SeparableVaryingInfoArray; typedef GrGLProgramDataManager::SeparableVaryingInfoArray SeparableVaryingInfoArray;

View File

@ -60,7 +60,7 @@ GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID,
} }
} }
void GrGLProgramDataManager::setSampler(UniformHandle u, GrGLint texUnit) const { void GrGLProgramDataManager::setSampler(UniformHandle u, int texUnit) const {
const Uniform& uni = fUniforms[u.toIndex()]; const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kSampler2D_GrSLType); SkASSERT(uni.fType == kSampler2D_GrSLType);
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
@ -76,7 +76,7 @@ void GrGLProgramDataManager::setSampler(UniformHandle u, GrGLint texUnit) const
} }
} }
void GrGLProgramDataManager::set1f(UniformHandle u, GrGLfloat v0) const { void GrGLProgramDataManager::set1f(UniformHandle u, float v0) const {
const Uniform& uni = fUniforms[u.toIndex()]; const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kFloat_GrSLType); SkASSERT(uni.fType == kFloat_GrSLType);
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
@ -91,7 +91,7 @@ void GrGLProgramDataManager::set1f(UniformHandle u, GrGLfloat v0) const {
void GrGLProgramDataManager::set1fv(UniformHandle u, void GrGLProgramDataManager::set1fv(UniformHandle u,
int arrayCount, int arrayCount,
const GrGLfloat v[]) const { const float v[]) const {
const Uniform& uni = fUniforms[u.toIndex()]; const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kFloat_GrSLType); SkASSERT(uni.fType == kFloat_GrSLType);
SkASSERT(arrayCount > 0); SkASSERT(arrayCount > 0);
@ -108,7 +108,7 @@ void GrGLProgramDataManager::set1fv(UniformHandle u,
} }
} }
void GrGLProgramDataManager::set2f(UniformHandle u, GrGLfloat v0, GrGLfloat v1) const { void GrGLProgramDataManager::set2f(UniformHandle u, float v0, float v1) const {
const Uniform& uni = fUniforms[u.toIndex()]; const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kVec2f_GrSLType); SkASSERT(uni.fType == kVec2f_GrSLType);
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
@ -123,7 +123,7 @@ void GrGLProgramDataManager::set2f(UniformHandle u, GrGLfloat v0, GrGLfloat v1)
void GrGLProgramDataManager::set2fv(UniformHandle u, void GrGLProgramDataManager::set2fv(UniformHandle u,
int arrayCount, int arrayCount,
const GrGLfloat v[]) const { const float v[]) const {
const Uniform& uni = fUniforms[u.toIndex()]; const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kVec2f_GrSLType); SkASSERT(uni.fType == kVec2f_GrSLType);
SkASSERT(arrayCount > 0); SkASSERT(arrayCount > 0);
@ -137,7 +137,7 @@ void GrGLProgramDataManager::set2fv(UniformHandle u,
} }
} }
void GrGLProgramDataManager::set3f(UniformHandle u, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2) const { void GrGLProgramDataManager::set3f(UniformHandle u, float v0, float v1, float v2) const {
const Uniform& uni = fUniforms[u.toIndex()]; const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kVec3f_GrSLType); SkASSERT(uni.fType == kVec3f_GrSLType);
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
@ -152,7 +152,7 @@ void GrGLProgramDataManager::set3f(UniformHandle u, GrGLfloat v0, GrGLfloat v1,
void GrGLProgramDataManager::set3fv(UniformHandle u, void GrGLProgramDataManager::set3fv(UniformHandle u,
int arrayCount, int arrayCount,
const GrGLfloat v[]) const { const float v[]) const {
const Uniform& uni = fUniforms[u.toIndex()]; const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kVec3f_GrSLType); SkASSERT(uni.fType == kVec3f_GrSLType);
SkASSERT(arrayCount > 0); SkASSERT(arrayCount > 0);
@ -167,10 +167,10 @@ void GrGLProgramDataManager::set3fv(UniformHandle u,
} }
void GrGLProgramDataManager::set4f(UniformHandle u, void GrGLProgramDataManager::set4f(UniformHandle u,
GrGLfloat v0, float v0,
GrGLfloat v1, float v1,
GrGLfloat v2, float v2,
GrGLfloat v3) const { float v3) const {
const Uniform& uni = fUniforms[u.toIndex()]; const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kVec4f_GrSLType); SkASSERT(uni.fType == kVec4f_GrSLType);
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
@ -185,7 +185,7 @@ void GrGLProgramDataManager::set4f(UniformHandle u,
void GrGLProgramDataManager::set4fv(UniformHandle u, void GrGLProgramDataManager::set4fv(UniformHandle u,
int arrayCount, int arrayCount,
const GrGLfloat v[]) const { const float v[]) const {
const Uniform& uni = fUniforms[u.toIndex()]; const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kVec4f_GrSLType); SkASSERT(uni.fType == kVec4f_GrSLType);
SkASSERT(arrayCount > 0); SkASSERT(arrayCount > 0);
@ -199,7 +199,7 @@ void GrGLProgramDataManager::set4fv(UniformHandle u,
} }
} }
void GrGLProgramDataManager::setMatrix3f(UniformHandle u, const GrGLfloat matrix[]) const { void GrGLProgramDataManager::setMatrix3f(UniformHandle u, const float matrix[]) const {
const Uniform& uni = fUniforms[u.toIndex()]; const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kMat33f_GrSLType); SkASSERT(uni.fType == kMat33f_GrSLType);
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
@ -212,7 +212,7 @@ void GrGLProgramDataManager::setMatrix3f(UniformHandle u, const GrGLfloat matrix
} }
} }
void GrGLProgramDataManager::setMatrix4f(UniformHandle u, const GrGLfloat matrix[]) const { void GrGLProgramDataManager::setMatrix4f(UniformHandle u, const float matrix[]) const {
const Uniform& uni = fUniforms[u.toIndex()]; const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kMat44f_GrSLType); SkASSERT(uni.fType == kMat44f_GrSLType);
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount); SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
@ -227,7 +227,7 @@ void GrGLProgramDataManager::setMatrix4f(UniformHandle u, const GrGLfloat matrix
void GrGLProgramDataManager::setMatrix3fv(UniformHandle u, void GrGLProgramDataManager::setMatrix3fv(UniformHandle u,
int arrayCount, int arrayCount,
const GrGLfloat matrices[]) const { const float matrices[]) const {
const Uniform& uni = fUniforms[u.toIndex()]; const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kMat33f_GrSLType); SkASSERT(uni.fType == kMat33f_GrSLType);
SkASSERT(arrayCount > 0); SkASSERT(arrayCount > 0);
@ -245,7 +245,7 @@ void GrGLProgramDataManager::setMatrix3fv(UniformHandle u,
void GrGLProgramDataManager::setMatrix4fv(UniformHandle u, void GrGLProgramDataManager::setMatrix4fv(UniformHandle u,
int arrayCount, int arrayCount,
const GrGLfloat matrices[]) const { const float matrices[]) const {
const Uniform& uni = fUniforms[u.toIndex()]; const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kMat44f_GrSLType); SkASSERT(uni.fType == kMat44f_GrSLType);
SkASSERT(arrayCount > 0); SkASSERT(arrayCount > 0);
@ -262,7 +262,7 @@ void GrGLProgramDataManager::setMatrix4fv(UniformHandle u,
} }
void GrGLProgramDataManager::setSkMatrix(UniformHandle u, const SkMatrix& matrix) const { void GrGLProgramDataManager::setSkMatrix(UniformHandle u, const SkMatrix& matrix) const {
GrGLfloat mt[] = { float mt[] = {
matrix.get(SkMatrix::kMScaleX), matrix.get(SkMatrix::kMScaleX),
matrix.get(SkMatrix::kMSkewY), matrix.get(SkMatrix::kMSkewY),
matrix.get(SkMatrix::kMPersp0), matrix.get(SkMatrix::kMPersp0),

View File

@ -8,6 +8,8 @@
#ifndef GrGLProgramDataManager_DEFINED #ifndef GrGLProgramDataManager_DEFINED
#define GrGLProgramDataManager_DEFINED #define GrGLProgramDataManager_DEFINED
#include "glsl/GrGLSLProgramDataManager.h"
#include "GrAllocator.h" #include "GrAllocator.h"
#include "gl/GrGLTypes.h" #include "gl/GrGLTypes.h"
#include "glsl/GrGLSLShaderVar.h" #include "glsl/GrGLSLShaderVar.h"
@ -23,31 +25,8 @@ class GrGLProgramBuilder;
* The resources are objects the program uses to communicate with the * The resources are objects the program uses to communicate with the
* application code. * application code.
*/ */
class GrGLProgramDataManager : SkNoncopyable { class GrGLProgramDataManager : public GrGLSLProgramDataManager {
public: public:
// Opaque handle to a resource
class ShaderResourceHandle {
public:
ShaderResourceHandle(int value)
: fValue(value) {
SkASSERT(this->isValid());
}
ShaderResourceHandle()
: fValue(kInvalid_ShaderResourceHandle) {
}
bool operator==(const ShaderResourceHandle& other) const { return other.fValue == fValue; }
bool isValid() const { return kInvalid_ShaderResourceHandle != fValue; }
int toIndex() const { SkASSERT(this->isValid()); return fValue; }
private:
static const int kInvalid_ShaderResourceHandle = -1;
int fValue;
};
typedef ShaderResourceHandle UniformHandle;
struct UniformInfo { struct UniformInfo {
GrGLSLShaderVar fVariable; GrGLSLShaderVar fVariable;
uint32_t fVisibility; uint32_t fVisibility;
@ -71,29 +50,29 @@ public:
/** Functions for uploading uniform values. The varities ending in v can be used to upload to an /** Functions for uploading uniform values. The varities ending in v can be used to upload to an
* array of uniforms. arrayCount must be <= the array count of the uniform. * array of uniforms. arrayCount must be <= the array count of the uniform.
*/ */
void setSampler(UniformHandle, GrGLint texUnit) const; void setSampler(UniformHandle, int texUnit) const;
void set1f(UniformHandle, GrGLfloat v0) const;
void set1fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; void set1f(UniformHandle, float v0) const override;
void set2f(UniformHandle, GrGLfloat, GrGLfloat) const; void set1fv(UniformHandle, int arrayCount, const float v[]) const override;
void set2fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; void set2f(UniformHandle, float, float) const override;
void set3f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat) const; void set2fv(UniformHandle, int arrayCount, const float v[]) const override;
void set3fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; void set3f(UniformHandle, float, float, float) const override;
void set4f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat, GrGLfloat) const; void set3fv(UniformHandle, int arrayCount, const float v[]) const override;
void set4fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; void set4f(UniformHandle, float, float, float, float) const override;
void set4fv(UniformHandle, int arrayCount, const float v[]) const override;
// matrices are column-major, the first three upload a single matrix, the latter three upload // matrices are column-major, the first three upload a single matrix, the latter three upload
// arrayCount matrices into a uniform array. // arrayCount matrices into a uniform array.
void setMatrix3f(UniformHandle, const GrGLfloat matrix[]) const; void setMatrix3f(UniformHandle, const float matrix[]) const override;
void setMatrix4f(UniformHandle, const GrGLfloat matrix[]) const; void setMatrix4f(UniformHandle, const float matrix[]) const override;
void setMatrix3fv(UniformHandle, int arrayCount, const GrGLfloat matrices[]) const; void setMatrix3fv(UniformHandle, int arrayCount, const float matrices[]) const override;
void setMatrix4fv(UniformHandle, int arrayCount, const GrGLfloat matrices[]) const; void setMatrix4fv(UniformHandle, int arrayCount, const float matrices[]) const override;
// convenience method for uploading a SkMatrix to a 3x3 matrix uniform // convenience method for uploading a SkMatrix to a 3x3 matrix uniform
void setSkMatrix(UniformHandle, const SkMatrix&) const; void setSkMatrix(UniformHandle, const SkMatrix&) const override;
// for nvpr only // for nvpr only
typedef GrGLProgramDataManager::ShaderResourceHandle SeparableVaryingHandle;
void setPathFragmentInputTransform(SeparableVaryingHandle u, int components, void setPathFragmentInputTransform(SeparableVaryingHandle u, int components,
const SkMatrix& matrix) const; const SkMatrix& matrix) const override;
private: private:
enum { enum {
@ -127,7 +106,7 @@ private:
GrGLGpu* fGpu; GrGLGpu* fGpu;
GrGLuint fProgramID; GrGLuint fProgramID;
typedef SkNoncopyable INHERITED; typedef GrGLSLProgramDataManager INHERITED;
}; };
#endif #endif

View File

@ -306,7 +306,8 @@ GrGLRenderer GrGLGetRenderer(const GrGLInterface* gl) {
return GrGLGetRendererFromString((const char*) v); return GrGLGetRendererFromString((const char*) v);
} }
template<> void GrGLGetMatrix<3>(GrGLfloat* dest, const SkMatrix& src) { template<> void GrGLGetMatrix<3>(float* dest, const SkMatrix& src) {
GR_STATIC_ASSERT(sizeof(float) == sizeof (GrGLfloat));
// Col 0 // Col 0
dest[0] = SkScalarToFloat(src[SkMatrix::kMScaleX]); dest[0] = SkScalarToFloat(src[SkMatrix::kMScaleX]);
dest[1] = SkScalarToFloat(src[SkMatrix::kMSkewY]); dest[1] = SkScalarToFloat(src[SkMatrix::kMSkewY]);
@ -323,7 +324,8 @@ template<> void GrGLGetMatrix<3>(GrGLfloat* dest, const SkMatrix& src) {
dest[8] = SkScalarToFloat(src[SkMatrix::kMPersp2]); dest[8] = SkScalarToFloat(src[SkMatrix::kMPersp2]);
} }
template<> void GrGLGetMatrix<4>(GrGLfloat* dest, const SkMatrix& src) { template<> void GrGLGetMatrix<4>(float* dest, const SkMatrix& src) {
GR_STATIC_ASSERT(sizeof(float) == sizeof (GrGLfloat));
// Col 0 // Col 0
dest[0] = SkScalarToFloat(src[SkMatrix::kMScaleX]); dest[0] = SkScalarToFloat(src[SkMatrix::kMScaleX]);
dest[1] = SkScalarToFloat(src[SkMatrix::kMSkewY]); dest[1] = SkScalarToFloat(src[SkMatrix::kMSkewY]);

View File

@ -141,7 +141,7 @@ void GrGLClearErr(const GrGLInterface* gl);
/** /**
* Helper for converting SkMatrix to a column-major GL float array * Helper for converting SkMatrix to a column-major GL float array
*/ */
template<int MatrixSize> void GrGLGetMatrix(GrGLfloat* dest, const SkMatrix& src); template<int MatrixSize> void GrGLGetMatrix(float* dest, const SkMatrix& src);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -10,6 +10,7 @@
#include "GrXferProcessor.h" #include "GrXferProcessor.h"
#include "gl/builders/GrGLFragmentShaderBuilder.h" #include "gl/builders/GrGLFragmentShaderBuilder.h"
#include "gl/builders/GrGLProgramBuilder.h" #include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
void GrGLXferProcessor::emitCode(const EmitArgs& args) { void GrGLXferProcessor::emitCode(const EmitArgs& args) {
if (!args.fXP.willReadDstColor()) { if (!args.fXP.willReadDstColor()) {
@ -77,11 +78,11 @@ void GrGLXferProcessor::emitCode(const EmitArgs& args) {
} }
} }
void GrGLXferProcessor::setData(const GrGLProgramDataManager& pdm, const GrXferProcessor& xp) { void GrGLXferProcessor::setData(const GrGLSLProgramDataManager& pdm, const GrXferProcessor& xp) {
if (xp.getDstTexture()) { if (xp.getDstTexture()) {
if (fDstTopLeftUni.isValid()) { if (fDstTopLeftUni.isValid()) {
pdm.set2f(fDstTopLeftUni, static_cast<GrGLfloat>(xp.dstTextureOffset().fX), pdm.set2f(fDstTopLeftUni, static_cast<float>(xp.dstTextureOffset().fX),
static_cast<GrGLfloat>(xp.dstTextureOffset().fY)); static_cast<float>(xp.dstTextureOffset().fY));
pdm.set2f(fDstScaleUni, 1.f / xp.getDstTexture()->width(), pdm.set2f(fDstScaleUni, 1.f / xp.getDstTexture()->width(),
1.f / xp.getDstTexture()->height()); 1.f / xp.getDstTexture()->height());
} else { } else {

View File

@ -8,7 +8,8 @@
#ifndef GrGLXferProcessor_DEFINED #ifndef GrGLXferProcessor_DEFINED
#define GrGLXferProcessor_DEFINED #define GrGLXferProcessor_DEFINED
#include "GrGLFragmentProcessor.h" #include "GrGLProcessor.h"
#include "glsl/GrGLSLProgramDataManager.h"
class GrGLXPBuilder; class GrGLXPBuilder;
class GrXferProcessor; class GrXferProcessor;
@ -56,7 +57,7 @@ public:
to have an identical processor key as the one that created this GrGLXferProcessor. This to have an identical processor key as the one that created this GrGLXferProcessor. This
function calls onSetData on the subclass of GrGLXferProcessor function calls onSetData on the subclass of GrGLXferProcessor
*/ */
void setData(const GrGLProgramDataManager& pdm, const GrXferProcessor& xp); void setData(const GrGLSLProgramDataManager& pdm, const GrXferProcessor& xp);
private: private:
/** /**
@ -78,10 +79,10 @@ private:
SkFAIL("emitBlendCodeForDstRead not implemented."); SkFAIL("emitBlendCodeForDstRead not implemented.");
} }
virtual void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) = 0; virtual void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) = 0;
GrGLProgramDataManager::UniformHandle fDstTopLeftUni; GrGLSLProgramDataManager::UniformHandle fDstTopLeftUni;
GrGLProgramDataManager::UniformHandle fDstScaleUni; GrGLSLProgramDataManager::UniformHandle fDstScaleUni;
typedef GrGLProcessor INHERITED; typedef GrGLProcessor INHERITED;
}; };

View File

@ -19,6 +19,7 @@
#include "gl/GrGLSLPrettyPrint.h" #include "gl/GrGLSLPrettyPrint.h"
#include "gl/GrGLXferProcessor.h" #include "gl/GrGLXferProcessor.h"
#include "glsl/GrGLSLCaps.h" #include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLProgramDataManager.h"
#define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X)
#define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X) #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X)
@ -118,7 +119,7 @@ void GrGLProgramBuilder::nameVariable(SkString* out, char prefix, const char* na
} }
} }
GrGLProgramDataManager::UniformHandle GrGLProgramBuilder::addUniformArray( GrGLSLProgramDataManager::UniformHandle GrGLProgramBuilder::addUniformArray(
uint32_t visibility, uint32_t visibility,
GrSLType type, GrSLType type,
GrSLPrecision precision, GrSLPrecision precision,
@ -152,7 +153,7 @@ GrGLProgramDataManager::UniformHandle GrGLProgramBuilder::addUniformArray(
if (outName) { if (outName) {
*outName = uni.fVariable.c_str(); *outName = uni.fVariable.c_str();
} }
return GrGLProgramDataManager::UniformHandle(fUniforms.count() - 1); return GrGLSLProgramDataManager::UniformHandle(fUniforms.count() - 1);
} }
void GrGLProgramBuilder::appendUniformDecls(ShaderVisibility visibility, void GrGLProgramBuilder::appendUniformDecls(ShaderVisibility visibility,

View File

@ -11,7 +11,7 @@
#include "GrGLFragmentShaderBuilder.h" #include "GrGLFragmentShaderBuilder.h"
#include "GrGLGeometryShaderBuilder.h" #include "GrGLGeometryShaderBuilder.h"
#include "GrGLVertexShaderBuilder.h" #include "GrGLVertexShaderBuilder.h"
#include "../GrGLProgramDataManager.h" #include "glsl/GrGLSLProgramDataManager.h"
#include "../GrGLPrimitiveProcessor.h" #include "../GrGLPrimitiveProcessor.h"
#include "../GrGLXferProcessor.h" #include "../GrGLXferProcessor.h"
#include "../../GrPipeline.h" #include "../../GrPipeline.h"
@ -42,7 +42,7 @@ public:
virtual ~GrGLUniformBuilder() {} virtual ~GrGLUniformBuilder() {}
typedef GrGLProgramDataManager::UniformHandle UniformHandle; typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
typedef GrGLProgramDataManager::SeparableVaryingHandle SeparableVaryingHandle; typedef GrGLProgramDataManager::SeparableVaryingHandle SeparableVaryingHandle;
/** Add a uniform variable to the current program, that has visibility in one or more shaders. /** Add a uniform variable to the current program, that has visibility in one or more shaders.

View File

@ -0,0 +1,78 @@
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrGLSLProgramDataManager_DEFINED
#define GrGLSLProgramDataManager_DEFINED
#include "SkTypes.h"
/** Manages the resources used by a shader program.
* The resources are objects the program uses to communicate with the
* application code.
*/
class GrGLSLProgramDataManager : SkNoncopyable {
public:
// Opaque handle to a resource
class ShaderResourceHandle {
public:
ShaderResourceHandle(int value)
: fValue(value) {
SkASSERT(this->isValid());
}
ShaderResourceHandle()
: fValue(kInvalid_ShaderResourceHandle) {
}
bool operator==(const ShaderResourceHandle& other) const { return other.fValue == fValue; }
bool isValid() const { return kInvalid_ShaderResourceHandle != fValue; }
int toIndex() const { SkASSERT(this->isValid()); return fValue; }
private:
static const int kInvalid_ShaderResourceHandle = -1;
int fValue;
};
typedef ShaderResourceHandle UniformHandle;
virtual ~GrGLSLProgramDataManager() {}
/** Functions for uploading uniform values. The varities ending in v can be used to upload to an
* array of uniforms. arrayCount must be <= the array count of the uniform.
*/
virtual void set1f(UniformHandle, float v0) const = 0;
virtual void set1fv(UniformHandle, int arrayCount, const float v[]) const = 0;
virtual void set2f(UniformHandle, float, float) const = 0;
virtual void set2fv(UniformHandle, int arrayCount, const float v[]) const = 0;
virtual void set3f(UniformHandle, float, float, float) const = 0;
virtual void set3fv(UniformHandle, int arrayCount, const float v[]) const = 0;
virtual void set4f(UniformHandle, float, float, float, float) const = 0;
virtual void set4fv(UniformHandle, int arrayCount, const float v[]) const = 0;
// matrices are column-major, the first three upload a single matrix, the latter three upload
// arrayCount matrices into a uniform array.
virtual void setMatrix3f(UniformHandle, const float matrix[]) const = 0;
virtual void setMatrix4f(UniformHandle, const float matrix[]) const = 0;
virtual void setMatrix3fv(UniformHandle, int arrayCount, const float matrices[]) const = 0;
virtual void setMatrix4fv(UniformHandle, int arrayCount, const float matrices[]) const = 0;
// convenience method for uploading a SkMatrix to a 3x3 matrix uniform
virtual void setSkMatrix(UniformHandle, const SkMatrix&) const = 0;
// for nvpr only
typedef ShaderResourceHandle SeparableVaryingHandle;
virtual void setPathFragmentInputTransform(SeparableVaryingHandle u, int components,
const SkMatrix& matrix) const = 0;
protected:
GrGLSLProgramDataManager() {}
private:
typedef SkNoncopyable INHERITED;
};
#endif