aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/shaders/SkLightingShader.h
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-07-17 12:30:40 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-17 17:24:50 +0000
commita8cdbd7431b6a27d28db1bc80d7557cedf7e66d0 (patch)
tree3d866605d2236b31da70535f2a4263c55b01acae /src/shaders/SkLightingShader.h
parent9e0d7e4072e43495a3907bb2bac7824e8e60c368 (diff)
Restore SkLightingShader and associated classes
This reverts https://skia-review.googlesource.com/c/skia/+/31140 (Remove SkLightingShader and associated classes) and updates the classes to ToT Change-Id: I3b1df1704cca8907aa00f081a7e93339b65ad4fa Reviewed-on: https://skia-review.googlesource.com/141545 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/shaders/SkLightingShader.h')
-rw-r--r--src/shaders/SkLightingShader.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/shaders/SkLightingShader.h b/src/shaders/SkLightingShader.h
new file mode 100644
index 0000000000..62c881ccf6
--- /dev/null
+++ b/src/shaders/SkLightingShader.h
@@ -0,0 +1,40 @@
+/*
+ * 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 SkLightingShader_DEFINED
+#define SkLightingShader_DEFINED
+
+#include "SkFlattenablePriv.h"
+#include "SkLights.h"
+#include "SkShader.h"
+
+class SkBitmap;
+class SkMatrix;
+class SkNormalSource;
+
+class SK_API SkLightingShader {
+public:
+ /** Returns a shader that lights the shape, colored by the diffuseShader, using the
+ normals from normalSource, with the set of lights provided.
+
+ @param diffuseShader the shader that provides the colors. If nullptr, uses the paint's
+ color.
+ @param normalSource the source for the shape's normals. If nullptr, assumes straight
+ up normals (<0,0,1>).
+ @param lights the lights applied to the normals
+
+ The lighting equation is currently:
+ result = (LightColor * dot(Normal, LightDir) + AmbientColor) * DiffuseColor
+
+ */
+ static sk_sp<SkShader> Make(sk_sp<SkShader> diffuseShader, sk_sp<SkNormalSource> normalSource,
+ sk_sp<SkLights> lights);
+
+ SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
+};
+
+#endif