| Index: src/gpu/effects/GrHQScaleTextureEffect.cpp
|
| diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrHQScaleTextureEffect.cpp
|
| similarity index 67%
|
| copy from src/gpu/effects/GrSimpleTextureEffect.cpp
|
| copy to src/gpu/effects/GrHQScaleTextureEffect.cpp
|
| index ccf761ab946c96e8d1e5ab3dbe5d7e804aaf5eca..bcca440358862bf3f61be9cc54cf6029a944d781 100644
|
| --- a/src/gpu/effects/GrSimpleTextureEffect.cpp
|
| +++ b/src/gpu/effects/GrHQScaleTextureEffect.cpp
|
| @@ -5,7 +5,7 @@
|
| * found in the LICENSE file.
|
| */
|
|
|
| -#include "GrSimpleTextureEffect.h"
|
| +#include "GrHQScaleTextureEffect.h"
|
| #include "gl/GrGLEffect.h"
|
| #include "gl/GrGLEffectMatrix.h"
|
| #include "gl/GrGLSL.h"
|
| @@ -13,12 +13,12 @@
|
| #include "GrTBackendEffectFactory.h"
|
| #include "GrTexture.h"
|
|
|
| -class GrGLSimpleTextureEffect : public GrGLEffect {
|
| +class GrGLHQScaleTextureEffect : public GrGLEffect {
|
| public:
|
| - GrGLSimpleTextureEffect(const GrBackendEffectFactory& factory, const GrDrawEffect& drawEffect)
|
| + GrGLHQScaleTextureEffect(const GrBackendEffectFactory& factory, const GrDrawEffect& drawEffect)
|
| : INHERITED (factory) {
|
| GrEffect::CoordsType coordsType =
|
| - drawEffect.castEffect<GrSimpleTextureEffect>().coordsType();
|
| + drawEffect.castEffect<GrHQScaleTextureEffect>().coordsType();
|
| if (GrEffect::kCustom_CoordsType != coordsType) {
|
| SkNEW_IN_TLAZY(&fEffectMatrix, GrGLEffectMatrix, (coordsType));
|
| }
|
| @@ -30,35 +30,32 @@ public:
|
| const char* outputColor,
|
| const char* inputColor,
|
| const TextureSamplerArray& samplers) SK_OVERRIDE {
|
| - const GrSimpleTextureEffect& ste = drawEffect.castEffect<GrSimpleTextureEffect>();
|
| - SkString fsCoordName;
|
| + const GrHQScaleTextureEffect& ste = drawEffect.castEffect<GrHQScaleTextureEffect>();
|
| + const char* fsCoordName;
|
| GrSLType fsCoordSLType;
|
| if (GrEffect::kCustom_CoordsType == ste.coordsType()) {
|
| SkASSERT(ste.getMatrix().isIdentity());
|
| SkASSERT(1 == ste.numVertexAttribs());
|
| fsCoordSLType = kVec2f_GrSLType;
|
| const char* vsVaryingName;
|
| - const char* fsVaryingNamePtr;
|
| - GrGLShaderBuilder::VertexBuilder* vertexBuilder = builder->getVertexBuilder();
|
| - SkASSERT(NULL != vertexBuilder);
|
| - vertexBuilder->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryingName, &fsVaryingNamePtr);
|
| - fsCoordName = fsVaryingNamePtr;
|
| + builder->addVarying(kVec2f_GrSLType, "textureCoords", &vsVaryingName, &fsCoordName);
|
| const char* attrName =
|
| - vertexBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0])->c_str();
|
| - vertexBuilder->vsCodeAppendf("\t%s = %s;\n", vsVaryingName, attrName);
|
| + builder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0])->c_str();
|
| + builder->vsCodeAppendf("\t%s = %s;\n", vsVaryingName, attrName);
|
| } else {
|
| fsCoordSLType = fEffectMatrix.get()->emitCode(builder, key, &fsCoordName);
|
| }
|
| builder->fsCodeAppendf("\t%s = ", outputColor);
|
| - builder->fsAppendTextureLookupAndModulate(inputColor,
|
| - samplers[0],
|
| - fsCoordName.c_str(),
|
| - fsCoordSLType);
|
| + builder->appendTextureLookupAndModulate(GrGLShaderBuilder::kFragment_ShaderType,
|
| + inputColor,
|
| + samplers[0],
|
| + fsCoordName,
|
| + fsCoordSLType);
|
| builder->fsCodeAppend(";\n");
|
| }
|
|
|
| static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
|
| - const GrSimpleTextureEffect& ste = drawEffect.castEffect<GrSimpleTextureEffect>();
|
| + const GrHQScaleTextureEffect& ste = drawEffect.castEffect<GrHQScaleTextureEffect>();
|
| if (GrEffect::kCustom_CoordsType == ste.coordsType()) {
|
| return 1 << GrGLEffectMatrix::kKeyBits;
|
| } else {
|
| @@ -71,7 +68,7 @@ public:
|
|
|
| virtual void setData(const GrGLUniformManager& uman,
|
| const GrDrawEffect& drawEffect) SK_OVERRIDE {
|
| - const GrSimpleTextureEffect& ste = drawEffect.castEffect<GrSimpleTextureEffect>();
|
| + const GrHQScaleTextureEffect& ste = drawEffect.castEffect<GrHQScaleTextureEffect>();
|
| if (GrEffect::kCustom_CoordsType == ste.coordsType()) {
|
| SkASSERT(ste.getMatrix().isIdentity());
|
| } else {
|
| @@ -86,19 +83,19 @@ private:
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| -void GrSimpleTextureEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const {
|
| +void GrHQScaleTextureEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const {
|
| this->updateConstantColorComponentsForModulation(color, validFlags);
|
| }
|
|
|
| -const GrBackendEffectFactory& GrSimpleTextureEffect::getFactory() const {
|
| - return GrTBackendEffectFactory<GrSimpleTextureEffect>::getInstance();
|
| +const GrBackendEffectFactory& GrHQScaleTextureEffect::getFactory() const {
|
| + return GrTBackendEffectFactory<GrHQScaleTextureEffect>::getInstance();
|
| }
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| -GR_DEFINE_EFFECT_TEST(GrSimpleTextureEffect);
|
| +GR_DEFINE_EFFECT_TEST(GrHQScaleTextureEffect);
|
|
|
| -GrEffectRef* GrSimpleTextureEffect::TestCreate(SkMWCRandom* random,
|
| +GrEffectRef* GrHQScaleTextureEffect::TestCreate(SkMWCRandom* random,
|
| GrContext*,
|
| const GrDrawTargetCaps&,
|
| GrTexture* textures[]) {
|
| @@ -124,9 +121,9 @@ GrEffectRef* GrSimpleTextureEffect::TestCreate(SkMWCRandom* random,
|
| CoordsType coordsType = kCoordsTypes[random->nextULessThan(GR_ARRAY_COUNT(kCoordsTypes))];
|
|
|
| if (kCustom_CoordsType == coordsType) {
|
| - return GrSimpleTextureEffect::CreateWithCustomCoords(textures[texIdx], params);
|
| + return GrHQScaleTextureEffect::CreateWithCustomCoords(textures[texIdx], params);
|
| } else {
|
| const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random);
|
| - return GrSimpleTextureEffect::Create(textures[texIdx], matrix);
|
| + return GrHQScaleTextureEffect::Create(textures[texIdx], matrix);
|
| }
|
| }
|
|
|