aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkFloatingPoint.h6
-rw-r--r--include/core/SkScalar.h6
-rw-r--r--src/gpu/effects/GrTextureDomainEffect.cpp29
3 files changed, 32 insertions, 9 deletions
diff --git a/include/core/SkFloatingPoint.h b/include/core/SkFloatingPoint.h
index b3e490d604..d388cdb47b 100644
--- a/include/core/SkFloatingPoint.h
+++ b/include/core/SkFloatingPoint.h
@@ -87,4 +87,10 @@ static inline float sk_float_copysign(float x, float y) {
#define sk_float_ceil2int(x) (int)sk_float_ceil(x)
#endif
+extern const uint32_t gIEEENotANumber;
+extern const uint32_t gIEEEInfinity;
+
+#define SK_FloatNaN (*reinterpret_cast<const float*>(&gIEEENotANumber))
+#define SK_FloatInfinity (*reinterpret_cast<const float*>(&gIEEEInfinity))
+
#endif
diff --git a/include/core/SkScalar.h b/include/core/SkScalar.h
index 82ac6e33cf..ea97a79865 100644
--- a/include/core/SkScalar.h
+++ b/include/core/SkScalar.h
@@ -29,8 +29,6 @@
as a 16.16 fixed point integer.
*/
typedef float SkScalar;
- extern const uint32_t gIEEENotANumber;
- extern const uint32_t gIEEEInfinity;
/** SK_Scalar1 is defined to be 1.0 represented as an SkScalar
*/
@@ -40,7 +38,7 @@
#define SK_ScalarHalf (0.5f)
/** SK_ScalarInfinity is defined to be infinity as an SkScalar
*/
- #define SK_ScalarInfinity (*SkTCast<const float*>(&gIEEEInfinity))
+ #define SK_ScalarInfinity SK_FloatInfinity
/** SK_ScalarMax is defined to be the largest value representable as an SkScalar
*/
#define SK_ScalarMax (3.402823466e+38f)
@@ -49,7 +47,7 @@
#define SK_ScalarMin (-SK_ScalarMax)
/** SK_ScalarNaN is defined to be 'Not a Number' as an SkScalar
*/
- #define SK_ScalarNaN (*SkTCast<const float*>(&gIEEENotANumber))
+ #define SK_ScalarNaN SK_FloatNaN
/** SkScalarIsNaN(n) returns true if argument is not a number
*/
static inline bool SkScalarIsNaN(float x) { return x != x; }
diff --git a/src/gpu/effects/GrTextureDomainEffect.cpp b/src/gpu/effects/GrTextureDomainEffect.cpp
index 14ada8edd1..9909c3a649 100644
--- a/src/gpu/effects/GrTextureDomainEffect.cpp
+++ b/src/gpu/effects/GrTextureDomainEffect.cpp
@@ -8,6 +8,8 @@
#include "GrTextureDomainEffect.h"
#include "GrTBackendEffectFactory.h"
#include "gl/GrGLEffect.h"
+#include "gl/GrGLEffectMatrix.h"
+#include "SkFloatingPoint.h"
class GrGLTextureDomainEffect : public GrGLEffect {
public:
@@ -23,10 +25,12 @@ public:
virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE;
- static inline EffectKey GenKey(const GrEffectStage&, const GrGLCaps&) { return 0; }
+ static inline EffectKey GenKey(const GrEffectStage&, const GrGLCaps&);
private:
GrGLUniformManager::UniformHandle fNameUni;
+ GrGLEffectMatrix fEffectMatrix;
+ GrGLfloat fPrevDomain[4];
typedef GrGLEffect INHERITED;
};
@@ -35,21 +39,24 @@ GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendEffectFactory& f
const GrEffect&)
: INHERITED(factory)
, fNameUni(GrGLUniformManager::kInvalidUniformHandle) {
+ fRequiresTextureMatrix = false;
+ fPrevDomain[0] = SK_FloatNaN;
}
void GrGLTextureDomainEffect::emitCode(GrGLShaderBuilder* builder,
const GrEffectStage&,
- EffectKey,
+ EffectKey key,
const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
-
+ const char* coords;
+ fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, vertexCoords, &coords);
fNameUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
kVec4f_GrSLType, "TexDom");
builder->fFSCode.appendf("\tvec2 clampCoord = clamp(%s, %s.xy, %s.zw);\n",
- builder->defaultTexCoordsName(),
+ coords,
builder->getUniformCStr(fNameUni),
builder->getUniformCStr(fNameUni));
@@ -80,7 +87,19 @@ void GrGLTextureDomainEffect::setData(const GrGLUniformManager& uman, const GrEf
// of elements so that values = (l, t, r, b).
SkTSwap(values[1], values[3]);
}
- uman.set4fv(fNameUni, 0, 1, values);
+ if (0 != memcmp(values, fPrevDomain, 4 * sizeof(GrGLfloat))) {
+ uman.set4fv(fNameUni, 0, 1, values);
+ }
+ fEffectMatrix.setData(uman,
+ effect.getMatrix(),
+ stage.getCoordChangeMatrix(),
+ effect.texture(0));
+}
+
+GrGLEffect::EffectKey GrGLTextureDomainEffect::GenKey(const GrEffectStage& stage, const GrGLCaps&) {
+ const GrTextureDomainEffect& effect =
+ static_cast<const GrTextureDomainEffect&>(*stage.getEffect());
+ return GrGLEffectMatrix::GenKey(effect.getMatrix(), effect.getMatrix(), effect.texture(0));
}