Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Unified Diff: src/gpu/effects/GrTextureDomainEffect.cpp

Issue 12531015: Adds local coords to GrEffect system. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/effects/GrTextureDomainEffect.h ('k') | src/gpu/gl/GrGLEffect.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrTextureDomainEffect.cpp
===================================================================
--- src/gpu/effects/GrTextureDomainEffect.cpp (revision 8241)
+++ src/gpu/effects/GrTextureDomainEffect.cpp (working copy)
@@ -14,19 +14,18 @@
class GrGLTextureDomainEffect : public GrGLEffect {
public:
- GrGLTextureDomainEffect(const GrBackendEffectFactory&, const GrEffectRef&);
+ GrGLTextureDomainEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
virtual void emitCode(GrGLShaderBuilder*,
- const GrEffectStage&,
+ const GrDrawEffect&,
EffectKey,
- const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE;
+ virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
- static inline EffectKey GenKey(const GrEffectStage&, const GrGLCaps&);
+ static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
private:
GrGLUniformManager::UniformHandle fNameUni;
@@ -37,27 +36,27 @@
};
GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendEffectFactory& factory,
- const GrEffectRef&)
+ const GrDrawEffect& drawEffect)
: INHERITED(factory)
- , fNameUni(GrGLUniformManager::kInvalidUniformHandle) {
+ , fNameUni(GrGLUniformManager::kInvalidUniformHandle)
+ , fEffectMatrix(drawEffect.castEffect<GrTextureDomainEffect>().coordsType()) {
fPrevDomain[0] = SK_FloatNaN;
}
void GrGLTextureDomainEffect::emitCode(GrGLShaderBuilder* builder,
- const GrEffectStage& stage,
+ const GrDrawEffect& drawEffect,
EffectKey key,
- const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
- const GrTextureDomainEffect& effect = GetEffectFromStage<GrTextureDomainEffect>(stage);
+ const GrTextureDomainEffect& texDom = drawEffect.castEffect<GrTextureDomainEffect>();
const char* coords;
- fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, vertexCoords, &coords);
+ fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
const char* domain;
fNameUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
kVec4f_GrSLType, "TexDom", &domain);
- if (GrTextureDomainEffect::kClamp_WrapMode == effect.wrapMode()) {
+ if (GrTextureDomainEffect::kClamp_WrapMode == texDom.wrapMode()) {
builder->fsCodeAppendf("\tvec2 clampCoord = clamp(%s, %s.xy, %s.zw);\n",
coords, domain, domain);
@@ -69,7 +68,7 @@
"clampCoord");
builder->fsCodeAppend(";\n");
} else {
- GrAssert(GrTextureDomainEffect::kDecal_WrapMode == effect.wrapMode());
+ GrAssert(GrTextureDomainEffect::kDecal_WrapMode == texDom.wrapMode());
if (kImagination_GrGLVendor == builder->ctxInfo().vendor()) {
// On the NexusS and GalaxyNexus, the other path (with the 'any'
@@ -106,9 +105,10 @@
}
}
-void GrGLTextureDomainEffect::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
- const GrTextureDomainEffect& effect = GetEffectFromStage<GrTextureDomainEffect>(stage);
- const GrRect& domain = effect.domain();
+void GrGLTextureDomainEffect::setData(const GrGLUniformManager& uman,
+ const GrDrawEffect& drawEffect) {
+ const GrTextureDomainEffect& texDom = drawEffect.castEffect<GrTextureDomainEffect>();
+ const GrRect& domain = texDom.domain();
float values[4] = {
SkScalarToFloat(domain.left()),
@@ -117,7 +117,7 @@
SkScalarToFloat(domain.bottom())
};
// vertical flip if necessary
- if (kBottomLeft_GrSurfaceOrigin == effect.texture(0)->origin()) {
+ if (kBottomLeft_GrSurfaceOrigin == texDom.texture(0)->origin()) {
values[1] = 1.0f - values[1];
values[3] = 1.0f - values[3];
// The top and bottom were just flipped, so correct the ordering
@@ -128,18 +128,20 @@
uman.set4fv(fNameUni, 0, 1, values);
}
fEffectMatrix.setData(uman,
- effect.getMatrix(),
- stage.getCoordChangeMatrix(),
- effect.texture(0));
+ texDom.getMatrix(),
+ drawEffect,
+ texDom.texture(0));
}
-GrGLEffect::EffectKey GrGLTextureDomainEffect::GenKey(const GrEffectStage& stage, const GrGLCaps&) {
- const GrTextureDomainEffect& effect = GetEffectFromStage<GrTextureDomainEffect>(stage);
- EffectKey key = effect.wrapMode();
+GrGLEffect::EffectKey GrGLTextureDomainEffect::GenKey(const GrDrawEffect& drawEffect,
+ const GrGLCaps&) {
+ const GrTextureDomainEffect& texDom = drawEffect.castEffect<GrTextureDomainEffect>();
+ EffectKey key = texDom.wrapMode();
key <<= GrGLEffectMatrix::kKeyBits;
- EffectKey matrixKey = GrGLEffectMatrix::GenKey(effect.getMatrix(),
- stage.getCoordChangeMatrix(),
- effect.texture(0));
+ EffectKey matrixKey = GrGLEffectMatrix::GenKey(texDom.getMatrix(),
+ drawEffect,
+ texDom.coordsType(),
+ texDom.texture(0));
return key | matrixKey;
}
@@ -150,7 +152,8 @@
const SkMatrix& matrix,
const GrRect& domain,
WrapMode wrapMode,
- bool bilerp) {
+ bool bilerp,
+ CoordsType coordsType) {
static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1};
if (kClamp_WrapMode == wrapMode && domain.contains(kFullRect)) {
return GrSimpleTextureEffect::Create(texture, matrix, bilerp);
@@ -172,7 +175,8 @@
matrix,
clippedDomain,
wrapMode,
- bilerp)));
+ bilerp,
+ coordsType)));
return CreateEffectRef(effect);
}
@@ -182,8 +186,9 @@
const SkMatrix& matrix,
const GrRect& domain,
WrapMode wrapMode,
- bool bilerp)
- : GrSingleTextureEffect(texture, matrix, bilerp)
+ bool bilerp,
+ CoordsType coordsType)
+ : GrSingleTextureEffect(texture, matrix, bilerp, coordsType)
, fWrapMode(wrapMode)
, fTextureDomain(domain) {
}
@@ -198,7 +203,8 @@
bool GrTextureDomainEffect::onIsEqual(const GrEffect& sBase) const {
const GrTextureDomainEffect& s = CastEffect<GrTextureDomainEffect>(sBase);
- return this->hasSameTextureParamsAndMatrix(s) && this->fTextureDomain == s.fTextureDomain;
+ return this->hasSameTextureParamsMatrixAndCoordsType(s) &&
+ this->fTextureDomain == s.fTextureDomain;
}
void GrTextureDomainEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const {
@@ -225,5 +231,12 @@
domain.fBottom = random->nextRangeScalar(domain.fTop, SK_Scalar1);
WrapMode wrapMode = random->nextBool() ? kClamp_WrapMode : kDecal_WrapMode;
const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random);
- return GrTextureDomainEffect::Create(textures[texIdx], matrix, domain, wrapMode);
+ bool bilerp = random->nextBool();
+ CoordsType coords = random->nextBool() ? kLocal_CoordsType : kPosition_CoordsType;
+ return GrTextureDomainEffect::Create(textures[texIdx],
+ matrix,
+ domain,
+ wrapMode,
+ bilerp,
+ coords);
}
« no previous file with comments | « src/gpu/effects/GrTextureDomainEffect.h ('k') | src/gpu/gl/GrGLEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698