aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects
diff options
context:
space:
mode:
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/SkLightingImageFilter.cpp21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index b82f6ad916..ae49462b5e 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -60,15 +60,6 @@ inline void shiftMatrixLeft(int m[9]) {
m[7] = m[8];
}
-static inline void fast_normalize(SkPoint3* vector) {
- // add a tiny bit so we don't have to worry about divide-by-zero
- SkScalar magSq = vector->dot(*vector) + SK_ScalarNearlyZero;
- SkScalar scale = sk_float_rsqrt(magSq);
- vector->fX *= scale;
- vector->fY *= scale;
- vector->fZ *= scale;
-}
-
class DiffuseLightingType {
public:
DiffuseLightingType(SkScalar kd)
@@ -99,7 +90,7 @@ public:
const SkPoint3& lightColor) const {
SkPoint3 halfDir(surfaceTolight);
halfDir.fZ += SK_Scalar1; // eye position is always (0, 0, 1)
- fast_normalize(&halfDir);
+ halfDir.normalize();
SkScalar colorScale = SkScalarMul(fKS,
SkScalarPow(normal.dot(halfDir), fShininess));
colorScale = SkScalarClampMax(colorScale, SK_Scalar1);
@@ -122,7 +113,7 @@ inline SkPoint3 pointToNormal(SkScalar x, SkScalar y, SkScalar surfaceScale) {
SkPoint3 vector = SkPoint3::Make(SkScalarMul(-x, surfaceScale),
SkScalarMul(-y, surfaceScale),
SK_Scalar1);
- fast_normalize(&vector);
+ vector.normalize();
return vector;
}
@@ -809,7 +800,7 @@ public:
fLocation.fY - SkIntToScalar(y),
fLocation.fZ - SkScalarMul(SkIntToScalar(z),
surfaceScale));
- fast_normalize(&direction);
+ direction.normalize();
return direction;
};
const SkPoint3& lightColor(const SkPoint3&) const { return this->color(); }
@@ -875,7 +866,7 @@ public:
fSpecularExponent(SkScalarPin(specularExponent, kSpecularExponentMin, kSpecularExponentMax))
{
fS = target - location;
- fast_normalize(&fS);
+ fS.normalize();
fCosOuterConeAngle = SkScalarCos(SkDegreesToRadians(cutoffAngle));
const SkScalar antiAliasThreshold = 0.016f;
fCosInnerConeAngle = fCosOuterConeAngle + antiAliasThreshold;
@@ -897,7 +888,7 @@ public:
SkPoint3 target = SkPoint3::Make(target2.fX, target2.fY,
SkScalarAve(targetZ.fX, targetZ.fY));
SkPoint3 s = target - location;
- fast_normalize(&s);
+ s.normalize();
return new SkSpotLight(location,
target,
fSpecularExponent,
@@ -913,7 +904,7 @@ public:
fLocation.fY - SkIntToScalar(y),
fLocation.fZ - SkScalarMul(SkIntToScalar(z),
surfaceScale));
- fast_normalize(&direction);
+ direction.normalize();
return direction;
};
SkPoint3 lightColor(const SkPoint3& surfaceToLight) const {