diff options
author | robertphillips <robertphillips@google.com> | 2015-07-13 13:16:44 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-13 13:16:44 -0700 |
commit | 3d32d768cd8b66c49c070495c08f7933b9dd2423 (patch) | |
tree | 6676e917988dcecc00b5f33f5e33a4e7c2849344 /include/effects/SkLightingImageFilter.h | |
parent | 52e7657cd850f95e66eb23c6d138ee45149a1039 (diff) |
Add new SkPoint3 class
The existing Light filter and the upcoming Lighting Shader both need a Point3 class
Review URL: https://codereview.chromium.org/1229693009
Diffstat (limited to 'include/effects/SkLightingImageFilter.h')
-rw-r--r-- | include/effects/SkLightingImageFilter.h | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/include/effects/SkLightingImageFilter.h b/include/effects/SkLightingImageFilter.h index e5048eeac7..326e7b8967 100644 --- a/include/effects/SkLightingImageFilter.h +++ b/include/effects/SkLightingImageFilter.h @@ -11,35 +11,12 @@ #include "SkImageFilter.h" #include "SkColor.h" -class SK_API SkPoint3 { -public: - SkPoint3() {} - SkPoint3(SkScalar x, SkScalar y, SkScalar z) - : fX(x), fY(y), fZ(z) {} - SkScalar dot(const SkPoint3& other) const { - return fX * other.fX + fY * other.fY + fZ * other.fZ; - } - SkScalar maxComponent() const { - return fX > fY ? (fX > fZ ? fX : fZ) : (fY > fZ ? fY : fZ); - } - void normalize() { - // Small epsilon is added to prevent division by 0. - SkScalar scale = SkScalarInvert(SkScalarSqrt(dot(*this)) + SK_ScalarNearlyZero); - fX = fX * scale; - fY = fY * scale; - fZ = fZ * scale; - } - SkPoint3 operator*(SkScalar scalar) const { - return SkPoint3(fX * scalar, fY * scalar, fZ * scalar); - } - SkPoint3 operator-(const SkPoint3& other) const { - return SkPoint3(fX - other.fX, fY - other.fY, fZ - other.fZ); - } - bool operator==(const SkPoint3& other) const { - return fX == other.fX && fY == other.fY && fZ == other.fZ; - } - SkScalar fX, fY, fZ; -}; +#ifdef SK_LEGACY_SKPOINT3_CTORS +// TODO: remove this. Chromium relies on having this included here +#include "SkPoint3.h" +#else +struct SkPoint3; +#endif class SkLight; |