aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/shaders/SkLightingShader.h
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2017-05-30 16:39:47 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-30 21:01:46 +0000
commit5edba45dca995baed5e66dfaaa7859132e716314 (patch)
tree0333422088e6ed781db5c6e2cf4ed330b69a0957 /src/shaders/SkLightingShader.h
parent64790a3714467300848971aa153aca8cea91cf7b (diff)
[Reland] Relocate shaders to own dir
Consolidate all shader impls under src/shaders/. (reland of https://skia-review.googlesource.com/c/17927/) Change-Id: I7918bdc1aafe842ed194412ba95b9ae53a2ec1d7 Reviewed-on: https://skia-review.googlesource.com/18146 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'src/shaders/SkLightingShader.h')
-rw-r--r--src/shaders/SkLightingShader.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/shaders/SkLightingShader.h b/src/shaders/SkLightingShader.h
new file mode 100644
index 0000000000..aa90710aa4
--- /dev/null
+++ b/src/shaders/SkLightingShader.h
@@ -0,0 +1,39 @@
+/*
+ * 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 "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