Bug 1055646 - Allow setting the uniforms of the blur shader on ShaderProgramOGL. r=nical

This commit is contained in:
Markus Stange
2014-09-02 14:09:26 +02:00
parent 4df2032de2
commit d35c0e34d4
2 changed files with 63 additions and 0 deletions

View File

@@ -70,6 +70,10 @@ public:
TexturePass2,
ColorMatrix,
ColorMatrixVector,
BlurRadius,
BlurOffset,
BlurAlpha,
BlurGaussianKernel,
KnownUniformCount
};
@@ -147,6 +151,19 @@ public:
return false;
}
bool UpdateArrayUniform(int cnt, const float *fp) {
if (mLocation == -1) return false;
if (cnt > 16) {
return false;
}
if (memcmp(mValue.f16v, fp, sizeof(float) * cnt) != 0) {
memcpy(mValue.f16v, fp, sizeof(float) * cnt);
return true;
}
return false;
}
KnownUniformName mName;
const char *mNameString;
int32_t mLocation;
@@ -389,6 +406,17 @@ public:
SetUniform(KnownUniform::TexturePass2, aFlag ? 1 : 0);
}
void SetBlurRadius(float aRX, float aRY);
void SetBlurAlpha(float aAlpha) {
SetUniform(KnownUniform::BlurAlpha, aAlpha);
}
void SetBlurOffset(float aOffsetX, float aOffsetY) {
float f[] = {aOffsetX, aOffsetY};
SetUniform(KnownUniform::BlurOffset, 2, f);
}
size_t GetTextureCount() const {
return mProfile.mTextureCount;
}
@@ -459,6 +487,17 @@ protected:
}
}
void SetArrayUniform(KnownUniform::KnownUniformName aKnownUniform, int aLength, float *aFloatValues)
{
ASSERT_THIS_PROGRAM;
NS_ASSERTION(aKnownUniform >= 0 && aKnownUniform < KnownUniform::KnownUniformCount, "Invalid known uniform");
KnownUniform& ku(mProfile.mUniforms[aKnownUniform]);
if (ku.UpdateArrayUniform(aLength, aFloatValues)) {
mGL->fUniform1fv(ku.mLocation, aLength, ku.mValue.f16v);
}
}
void SetUniform(KnownUniform::KnownUniformName aKnownUniform, GLint aIntValue) {
ASSERT_THIS_PROGRAM;
NS_ASSERTION(aKnownUniform >= 0 && aKnownUniform < KnownUniform::KnownUniformCount, "Invalid known uniform");