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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -337,6 +337,7 @@ SkColorFilter* SkTable_ColorFilter::newComposed(const SkColorFilter* innerFilter
#include "effects/GrTextureStripAtlas.h"
#include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
class ColorTableEffect : public GrFragmentProcessor {
public:
@ -382,7 +383,7 @@ public:
static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder* b) {}
protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override;
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private:
UniformHandle fRGBAYValuesUni;
@ -392,7 +393,7 @@ private:
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.
float rgbaYValues[4];
const ColorTableEffect& cte = proc.cast<ColorTableEffect>();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,6 +8,7 @@
#include "effects/GrConstColorProcessor.h"
#include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
class GLConstColorProcessor : public GrGLFragmentProcessor {
public:
@ -39,14 +40,14 @@ public:
}
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();
// 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
// when the "illegal" color is used but we will always upload it.
if (GrColor_ILLEGAL == color || fPrevColor != color) {
static const GrGLfloat scale = 1.f / 255.f;
GrGLfloat floatColor[4] = {
static const float scale = 1.f / 255.f;
float floatColor[4] = {
GrColorUnpackR(color) * scale,
GrColorUnpackG(color) * scale,
GrColorUnpackB(color) * scale,
@ -58,7 +59,7 @@ protected:
}
private:
GrGLProgramDataManager::UniformHandle fColorUniform;
GrGLSLProgramDataManager::UniformHandle fColorUniform;
GrColor fPrevColor;
typedef GrGLFragmentProcessor INHERITED;

View File

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

View File

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

View File

@ -22,6 +22,7 @@
#include "gl/GrGLProgramDataManager.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLProgramDataManager.h"
bool GrCustomXfermode::IsSupportedMode(SkXfermode::Mode mode) {
return mode > SkXfermode::kLastCoeffMode && mode <= SkXfermode::kLastMode;
@ -168,7 +169,7 @@ private:
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;
};

View File

@ -24,6 +24,7 @@
#include "gl/GrGLGeometryProcessor.h"
#include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
///////////////////////////////////////////////////////////////////////////////
@ -821,10 +822,10 @@ public:
const GrGLSLCaps&,
GrProcessorKeyBuilder*);
void setData(const GrGLProgramDataManager&, const GrPrimitiveProcessor&) override;
void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&) override;
void setTransformData(const GrPrimitiveProcessor& primProc,
const GrGLProgramDataManager& pdman,
const GrGLSLProgramDataManager& pdman,
int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override {
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);
}
void GLDashingCircleEffect::setData(const GrGLProgramDataManager& pdman,
void GLDashingCircleEffect::setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& processor) {
const DashingCircleEffect& dce = processor.cast<DashingCircleEffect>();
if (dce.color() != fColor) {
GrGLfloat c[4];
float c[4];
GrColorToRGBAFloat(dce.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = dce.color();
@ -1032,10 +1033,10 @@ public:
const GrGLSLCaps&,
GrProcessorKeyBuilder*);
void setData(const GrGLProgramDataManager&, const GrPrimitiveProcessor&) override;
void setData(const GrGLSLProgramDataManager&, const GrPrimitiveProcessor&) override;
void setTransformData(const GrPrimitiveProcessor& primProc,
const GrGLProgramDataManager& pdman,
const GrGLSLProgramDataManager& pdman,
int index,
const SkTArray<const GrCoordTransform*, true>& transforms) override {
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);
}
void GLDashingLineEffect::setData(const GrGLProgramDataManager& pdman,
void GLDashingLineEffect::setData(const GrGLSLProgramDataManager& pdman,
const GrPrimitiveProcessor& processor) {
const DashingLineEffect& de = processor.cast<DashingLineEffect>();
if (de.color() != fColor) {
GrGLfloat c[4];
float c[4];
GrColorToRGBAFloat(de.color(), c);
pdman.set4fv(fColorUniform, 1, c);
fColor = de.color();

View File

@ -10,6 +10,7 @@
#include "gl/GrGLXferProcessor.h"
#include "gl/builders/GrGLFragmentShaderBuilder.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
@ -66,7 +67,7 @@ private:
fsBuilder->codeAppendf("%s = vec4(0);", args.fOutputPrimary);
}
void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) override {}
void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {}
typedef GrGLXferProcessor INHERITED;
};

View File

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

View File

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

View File

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

View File

@ -17,6 +17,7 @@
#include "gl/GrGLXferProcessor.h"
#include "gl/builders/GrGLFragmentShaderBuilder.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.
@ -450,7 +451,7 @@ private:
args.fOutputPrimary, args.fInputColor, args.fInputCoverage);
}
void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) override {}
void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {}
typedef GrGLXferProcessor INHERITED;
};
@ -550,7 +551,7 @@ private:
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;
};
@ -628,7 +629,7 @@ private:
args.fInputCoverage);
}
void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) override {};
void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {};
typedef GrGLXferProcessor INHERITED;
};

View File

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

View File

@ -12,6 +12,7 @@
#include "gl/GrGLContext.h"
#include "gl/GrGLFragmentProcessor.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int 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,
GrSurfaceOrigin textureOrigin) {
SkASSERT(textureDomain.mode() == fMode);
if (kIgnore_Mode != textureDomain.mode()) {
GrGLfloat values[kPrevDomainCount] = {
float values[kPrevDomainCount] = {
SkScalarToFloat(textureDomain.domain().left()),
SkScalarToFloat(textureDomain.domain().top()),
SkScalarToFloat(textureDomain.domain().right()),
@ -161,9 +162,9 @@ void GrTextureDomain::GLDomain::setData(const GrGLProgramDataManager& pdman,
// of elements so that values = (l, t, r, b).
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);
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*);
protected:
void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override;
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
private:
GrTextureDomain::GLDomain fGLDomain;
@ -200,8 +201,8 @@ void GrGLTextureDomainEffect::emitCode(EmitArgs& args) {
args.fInputColor);
}
void GrGLTextureDomainEffect::onSetData(const GrGLProgramDataManager& pdman,
const GrProcessor& processor) {
void GrGLTextureDomainEffect::onSetData(const GrGLSLProgramDataManager& pdman,
const GrProcessor& processor) {
const GrTextureDomainEffect& textureDomainEffect = processor.cast<GrTextureDomainEffect>();
const GrTextureDomain& domain = textureDomainEffect.textureDomain();
fGLDomain.setData(pdman, domain, processor.texture(0)->origin());

View File

@ -10,6 +10,7 @@
#include "GrSingleTextureEffect.h"
#include "gl/GrGLFragmentProcessor.h"
#include "glsl/GrGLSLProgramDataManager.h"
class GrGLProgramBuilder;
class GrGLShaderBuilder;
@ -122,7 +123,7 @@ public:
* 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.
*/
void setData(const GrGLProgramDataManager& pdman, const GrTextureDomain& textureDomain,
void setData(const GrGLSLProgramDataManager& pdman, const GrTextureDomain& textureDomain,
GrSurfaceOrigin textureOrigin);
enum {
@ -140,10 +141,10 @@ public:
private:
static const int kPrevDomainCount = 4;
SkDEBUGCODE(Mode fMode;)
GrGLProgramDataManager::UniformHandle fDomainUni;
SkString fDomainName;
GrGLfloat fPrevDomain[kPrevDomainCount];
SkDEBUGCODE(Mode fMode;)
GrGLSLProgramDataManager::UniformHandle fDomainUni;
SkString fDomainName;
float fPrevDomain[kPrevDomainCount];
};
protected:

View File

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

View File

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

View File

@ -8,11 +8,11 @@
#ifndef GrGLFragmentProcessor_DEFINED
#define GrGLFragmentProcessor_DEFINED
#include "GrGLProgramDataManager.h"
#include "GrGLProcessor.h"
#include "GrTextureAccess.h"
#include "glsl/GrGLSLProgramDataManager.h"
class GrGLFPBuilder;
class GrGLSLCaps;
class GrGLFragmentProcessor {
public:
@ -24,7 +24,7 @@ public:
}
}
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray;
typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray;
@ -70,7 +70,7 @@ public:
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*) {}
@ -101,7 +101,7 @@ protected:
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. */
// TODO update this to pass in GrFragmentProcessor
virtual void onSetData(const GrGLProgramDataManager&, const GrProcessor&) {}
virtual void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) {}
private:
void internalEmitChild(int, const char*, const char*, EmitArgs&);

View File

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

View File

@ -11,6 +11,7 @@
#include "GrProcessor.h"
#include "GrGLFragmentProcessor.h"
#include "GrGLPathRendering.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "SkRTConf.h"
#include "SkTSearch.h"
@ -19,7 +20,7 @@ SK_CONF_DECLARE(bool, c_DisplayCache, "gpu.displayCache", false,
"Display program cache usage.");
#endif
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
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,
GrGLenum genMode, GrGLint components,
const SkMatrix& matrix) {
GrGLfloat coefficients[3 * 3];
float coefficients[3 * 3];
SkASSERT(components >= 1 && components <= 3);
coefficients[0] = SkScalarToFloat(matrix[SkMatrix::kMScaleX]);
@ -224,7 +224,7 @@ void GrGLPathRendering::setProjectionMatrix(const SkMatrix& matrix,
fHWProjectionMatrixState.fRenderTargetSize = renderTargetSize;
fHWProjectionMatrixState.fRenderTargetOrigin = renderTargetOrigin;
GrGLfloat glMatrix[4 * 4];
float glMatrix[4 * 4];
fHWProjectionMatrixState.getRTAdjustedGLMatrix<4>(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.
*/
template<int Size> void getRTAdjustedGLMatrix(GrGLfloat* destMatrix) {
template<int Size> void getRTAdjustedGLMatrix(float* destMatrix) {
SkMatrix combined;
if (kBottomLeft_GrSurfaceOrigin == fRenderTargetOrigin) {
combined.setAll(SkIntToScalar(2) / fRenderTargetSize.fWidth, 0, -SK_Scalar1,

View File

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

View File

@ -8,9 +8,10 @@
#ifndef GrGLProcessor_DEFINED
#define GrGLProcessor_DEFINED
#include "GrGLProgramDataManager.h"
#include "GrProcessor.h"
#include "GrShaderVar.h"
#include "GrTextureAccess.h"
#include "glsl/GrGLSLProgramDataManager.h"
/** @file
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
class GrGLProcessor {
public:
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
/**
* 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.fRenderTargetOrigin = rt->origin();
GrGLfloat rtAdjustmentVec[4];
float rtAdjustmentVec[4];
fRenderTargetState.getRTAdjustmentVec(rtAdjustmentVec);
fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, rtAdjustmentVec);
}

View File

@ -13,6 +13,7 @@
#include "GrGLProgramDesc.h"
#include "GrGLTexture.h"
#include "GrGLProgramDataManager.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "SkString.h"
#include "SkXfermode.h"
@ -74,7 +75,7 @@ public:
* pos.x = dot(v.xy, pos.xz)
* pos.y = dot(v.zw, pos.yz)
*/
void getRTAdjustmentVec(GrGLfloat* destVec) {
void getRTAdjustmentVec(float* destVec) {
destVec[0] = 2.f / fRenderTargetSize.fWidth;
destVec[1] = -1.f;
if (kBottomLeft_GrSurfaceOrigin == fRenderTargetOrigin) {
@ -97,7 +98,7 @@ public:
SkTArray<const GrTextureAccess*>* textureBindings);
protected:
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray;
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()];
SkASSERT(uni.fType == kSampler2D_GrSLType);
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()];
SkASSERT(uni.fType == kFloat_GrSLType);
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
@ -91,7 +91,7 @@ void GrGLProgramDataManager::set1f(UniformHandle u, GrGLfloat v0) const {
void GrGLProgramDataManager::set1fv(UniformHandle u,
int arrayCount,
const GrGLfloat v[]) const {
const float v[]) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kFloat_GrSLType);
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()];
SkASSERT(uni.fType == kVec2f_GrSLType);
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
@ -123,7 +123,7 @@ void GrGLProgramDataManager::set2f(UniformHandle u, GrGLfloat v0, GrGLfloat v1)
void GrGLProgramDataManager::set2fv(UniformHandle u,
int arrayCount,
const GrGLfloat v[]) const {
const float v[]) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kVec2f_GrSLType);
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()];
SkASSERT(uni.fType == kVec3f_GrSLType);
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
@ -152,7 +152,7 @@ void GrGLProgramDataManager::set3f(UniformHandle u, GrGLfloat v0, GrGLfloat v1,
void GrGLProgramDataManager::set3fv(UniformHandle u,
int arrayCount,
const GrGLfloat v[]) const {
const float v[]) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kVec3f_GrSLType);
SkASSERT(arrayCount > 0);
@ -167,10 +167,10 @@ void GrGLProgramDataManager::set3fv(UniformHandle u,
}
void GrGLProgramDataManager::set4f(UniformHandle u,
GrGLfloat v0,
GrGLfloat v1,
GrGLfloat v2,
GrGLfloat v3) const {
float v0,
float v1,
float v2,
float v3) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kVec4f_GrSLType);
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
@ -185,7 +185,7 @@ void GrGLProgramDataManager::set4f(UniformHandle u,
void GrGLProgramDataManager::set4fv(UniformHandle u,
int arrayCount,
const GrGLfloat v[]) const {
const float v[]) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kVec4f_GrSLType);
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()];
SkASSERT(uni.fType == kMat33f_GrSLType);
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()];
SkASSERT(uni.fType == kMat44f_GrSLType);
SkASSERT(GrGLSLShaderVar::kNonArray == uni.fArrayCount);
@ -227,7 +227,7 @@ void GrGLProgramDataManager::setMatrix4f(UniformHandle u, const GrGLfloat matrix
void GrGLProgramDataManager::setMatrix3fv(UniformHandle u,
int arrayCount,
const GrGLfloat matrices[]) const {
const float matrices[]) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kMat33f_GrSLType);
SkASSERT(arrayCount > 0);
@ -245,7 +245,7 @@ void GrGLProgramDataManager::setMatrix3fv(UniformHandle u,
void GrGLProgramDataManager::setMatrix4fv(UniformHandle u,
int arrayCount,
const GrGLfloat matrices[]) const {
const float matrices[]) const {
const Uniform& uni = fUniforms[u.toIndex()];
SkASSERT(uni.fType == kMat44f_GrSLType);
SkASSERT(arrayCount > 0);
@ -262,7 +262,7 @@ void GrGLProgramDataManager::setMatrix4fv(UniformHandle u,
}
void GrGLProgramDataManager::setSkMatrix(UniformHandle u, const SkMatrix& matrix) const {
GrGLfloat mt[] = {
float mt[] = {
matrix.get(SkMatrix::kMScaleX),
matrix.get(SkMatrix::kMSkewY),
matrix.get(SkMatrix::kMPersp0),

View File

@ -8,6 +8,8 @@
#ifndef GrGLProgramDataManager_DEFINED
#define GrGLProgramDataManager_DEFINED
#include "glsl/GrGLSLProgramDataManager.h"
#include "GrAllocator.h"
#include "gl/GrGLTypes.h"
#include "glsl/GrGLSLShaderVar.h"
@ -23,31 +25,8 @@ class GrGLProgramBuilder;
* The resources are objects the program uses to communicate with the
* application code.
*/
class GrGLProgramDataManager : SkNoncopyable {
class GrGLProgramDataManager : public GrGLSLProgramDataManager {
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 {
GrGLSLShaderVar fVariable;
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
* array of uniforms. arrayCount must be <= the array count of the uniform.
*/
void setSampler(UniformHandle, GrGLint texUnit) const;
void set1f(UniformHandle, GrGLfloat v0) const;
void set1fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const;
void set2f(UniformHandle, GrGLfloat, GrGLfloat) const;
void set2fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const;
void set3f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat) const;
void set3fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const;
void set4f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat, GrGLfloat) const;
void set4fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const;
void setSampler(UniformHandle, int texUnit) const;
void set1f(UniformHandle, float v0) const override;
void set1fv(UniformHandle, int arrayCount, const float v[]) const override;
void set2f(UniformHandle, float, float) const override;
void set2fv(UniformHandle, int arrayCount, const float v[]) const override;
void set3f(UniformHandle, float, float, float) const override;
void set3fv(UniformHandle, int arrayCount, const float v[]) const override;
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
// arrayCount matrices into a uniform array.
void setMatrix3f(UniformHandle, const GrGLfloat matrix[]) const;
void setMatrix4f(UniformHandle, const GrGLfloat matrix[]) const;
void setMatrix3fv(UniformHandle, int arrayCount, const GrGLfloat matrices[]) const;
void setMatrix4fv(UniformHandle, int arrayCount, const GrGLfloat matrices[]) const;
void setMatrix3f(UniformHandle, const float matrix[]) const override;
void setMatrix4f(UniformHandle, const float matrix[]) const override;
void setMatrix3fv(UniformHandle, int arrayCount, const float matrices[]) const override;
void setMatrix4fv(UniformHandle, int arrayCount, const float matrices[]) const override;
// 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
typedef GrGLProgramDataManager::ShaderResourceHandle SeparableVaryingHandle;
void setPathFragmentInputTransform(SeparableVaryingHandle u, int components,
const SkMatrix& matrix) const;
const SkMatrix& matrix) const override;
private:
enum {
@ -127,7 +106,7 @@ private:
GrGLGpu* fGpu;
GrGLuint fProgramID;
typedef SkNoncopyable INHERITED;
typedef GrGLSLProgramDataManager INHERITED;
};
#endif

View File

@ -306,7 +306,8 @@ GrGLRenderer GrGLGetRenderer(const GrGLInterface* gl) {
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
dest[0] = SkScalarToFloat(src[SkMatrix::kMScaleX]);
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]);
}
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
dest[0] = SkScalarToFloat(src[SkMatrix::kMScaleX]);
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
*/
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 "gl/builders/GrGLFragmentShaderBuilder.h"
#include "gl/builders/GrGLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
void GrGLXferProcessor::emitCode(const EmitArgs& args) {
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 (fDstTopLeftUni.isValid()) {
pdm.set2f(fDstTopLeftUni, static_cast<GrGLfloat>(xp.dstTextureOffset().fX),
static_cast<GrGLfloat>(xp.dstTextureOffset().fY));
pdm.set2f(fDstTopLeftUni, static_cast<float>(xp.dstTextureOffset().fX),
static_cast<float>(xp.dstTextureOffset().fY));
pdm.set2f(fDstScaleUni, 1.f / xp.getDstTexture()->width(),
1.f / xp.getDstTexture()->height());
} else {

View File

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

View File

@ -19,6 +19,7 @@
#include "gl/GrGLSLPrettyPrint.h"
#include "gl/GrGLXferProcessor.h"
#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLProgramDataManager.h"
#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)
@ -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,
GrSLType type,
GrSLPrecision precision,
@ -152,7 +153,7 @@ GrGLProgramDataManager::UniformHandle GrGLProgramBuilder::addUniformArray(
if (outName) {
*outName = uni.fVariable.c_str();
}
return GrGLProgramDataManager::UniformHandle(fUniforms.count() - 1);
return GrGLSLProgramDataManager::UniformHandle(fUniforms.count() - 1);
}
void GrGLProgramBuilder::appendUniformDecls(ShaderVisibility visibility,

View File

@ -11,7 +11,7 @@
#include "GrGLFragmentShaderBuilder.h"
#include "GrGLGeometryShaderBuilder.h"
#include "GrGLVertexShaderBuilder.h"
#include "../GrGLProgramDataManager.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "../GrGLPrimitiveProcessor.h"
#include "../GrGLXferProcessor.h"
#include "../../GrPipeline.h"
@ -42,7 +42,7 @@ public:
virtual ~GrGLUniformBuilder() {}
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
typedef GrGLProgramDataManager::SeparableVaryingHandle SeparableVaryingHandle;
/** 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