aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/effects
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-08-20 05:15:06 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-20 05:15:07 -0700
commit2f0dbc761a626473c19db7de561c7072b12953c5 (patch)
tree5549b8e7359d6a55e171dd1b76634d93b343b491 /include/effects
parentd1c6b7c5007b5c609b44a9cdfe95ef64a5a8f29f (diff)
Update SkLightingShader to support rotation
This also: makes the SkLightingShader handle normal maps where the rects aren't aligned between the diffuse and normal maps. adds a light aggregating class (Lights) to SkLightingShader (along with a Builder nested class). Split out of https://codereview.chromium.org/1261433009/ (Add SkCanvas::drawLitAtlas call) Committed: https://skia.googlesource.com/skia/+/45b59ed6e4e231814dbdb9f707b3d2a7ee50de84 Review URL: https://codereview.chromium.org/1291783003
Diffstat (limited to 'include/effects')
-rw-r--r--include/effects/SkLightingImageFilter.h8
-rw-r--r--include/effects/SkPoint3.h108
2 files changed, 4 insertions, 112 deletions
diff --git a/include/effects/SkLightingImageFilter.h b/include/effects/SkLightingImageFilter.h
index c481050d49..d0b489d6a8 100644
--- a/include/effects/SkLightingImageFilter.h
+++ b/include/effects/SkLightingImageFilter.h
@@ -12,7 +12,7 @@
#include "SkColor.h"
-class SkLight;
+class SkImageFilterLight;
struct SkPoint3;
class SK_API SkLightingImageFilter : public SkImageFilter {
@@ -42,17 +42,17 @@ public:
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
protected:
- SkLightingImageFilter(SkLight* light,
+ SkLightingImageFilter(SkImageFilterLight* light,
SkScalar surfaceScale,
SkImageFilter* input,
const CropRect* cropRect);
void flatten(SkWriteBuffer&) const override;
- const SkLight* light() const { return fLight.get(); }
+ const SkImageFilterLight* light() const { return fLight.get(); }
SkScalar surfaceScale() const { return fSurfaceScale; }
private:
typedef SkImageFilter INHERITED;
- SkAutoTUnref<SkLight> fLight;
+ SkAutoTUnref<SkImageFilterLight> fLight;
SkScalar fSurfaceScale;
};
diff --git a/include/effects/SkPoint3.h b/include/effects/SkPoint3.h
deleted file mode 100644
index f31f8207ab..0000000000
--- a/include/effects/SkPoint3.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkPoint3_DEFINED
-#define SkPoint3_DEFINED
-
-#include "SkScalar.h"
-
-struct SK_API SkPoint3 {
- SkScalar fX, fY, fZ;
-
- static SkPoint3 Make(SkScalar x, SkScalar y, SkScalar z) {
- SkPoint3 pt;
- pt.set(x, y, z);
- return pt;
- }
-
- SkScalar x() const { return fX; }
- SkScalar y() const { return fY; }
- SkScalar z() const { return fZ; }
-
- void set(SkScalar x, SkScalar y, SkScalar z) { fX = x; fY = y; fZ = z; }
-
- friend bool operator==(const SkPoint3& a, const SkPoint3& b) {
- return a.fX == b.fX && a.fY == b.fY && a.fZ == b.fZ;
- }
-
- friend bool operator!=(const SkPoint3& a, const SkPoint3& b) {
- return !(a == b);
- }
-
- /** Returns the Euclidian distance from (0,0,0) to (x,y,z)
- */
- static SkScalar Length(SkScalar x, SkScalar y, SkScalar z);
-
- /** Return the Euclidian distance from (0,0,0) to the point
- */
- SkScalar length() const { return SkPoint3::Length(fX, fY, fZ); }
-
- /** Set the point (vector) to be unit-length in the same direction as it
- already points. If the point has a degenerate length (i.e., nearly 0)
- then set it to (0,0,0) and return false; otherwise return true.
- */
- bool normalize();
-
- /** Return a new point whose X, Y and Z coordinates are scaled.
- */
- SkPoint3 makeScale(SkScalar scale) const {
- SkPoint3 p;
- p.set(scale * fX, scale * fY, scale * fZ);
- return p;
- }
-
- /** Scale the point's coordinates by scale.
- */
- void scale(SkScalar value) {
- fX *= value;
- fY *= value;
- fZ *= value;
- }
-
- /** Return a new point whose X, Y and Z coordinates are the negative of the
- original point's
- */
- SkPoint3 operator-() const {
- SkPoint3 neg;
- neg.fX = -fX;
- neg.fY = -fY;
- neg.fZ = -fZ;
- return neg;
- }
-
- /** Returns a new point whose coordinates are the difference between
- a and b (i.e., a - b)
- */
- friend SkPoint3 operator-(const SkPoint3& a, const SkPoint3& b) {
- SkPoint3 v;
- v.set(a.fX - b.fX, a.fY - b.fY, a.fZ - b.fZ);
- return v;
- }
-
- /** Returns a new point whose coordinates are the sum of a and b (a + b)
- */
- friend SkPoint3 operator+(const SkPoint3& a, const SkPoint3& b) {
- SkPoint3 v;
- v.set(a.fX + b.fX, a.fY + b.fY, a.fZ + b.fZ);
- return v;
- }
-
- /** Returns the dot product of a and b, treating them as 3D vectors
- */
- static SkScalar DotProduct(const SkPoint3& a, const SkPoint3& b) {
- return a.fX * b.fX + a.fY * b.fY + a.fZ * b.fZ;
- }
-
- SkScalar dot(const SkPoint3& vec) const {
- return DotProduct(*this, vec);
- }
-};
-
-typedef SkPoint3 SkVector3;
-typedef SkPoint3 SkColor3f;
-
-#endif