Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Unified Diff: src/core/SkLight.h

Issue 1291783003: Update SkLightingShader to support rotation (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix gyp file Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/SampleLighting.cpp ('k') | src/core/SkLightingShader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkLight.h
diff --git a/src/core/SkLight.h b/src/core/SkLight.h
new file mode 100644
index 0000000000000000000000000000000000000000..4a6e149c76afbc765541645f1d5809c765fd00e8
--- /dev/null
+++ b/src/core/SkLight.h
@@ -0,0 +1,56 @@
+
+/*
+ * 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 SkLight_DEFINED
+#define SkLight_DEFINED
+
+#include "SkPoint3.h"
+
+class SK_API SkLight {
+public:
+ enum LightType {
+ kAmbient_LightType, // only 'fColor' is used
+ kDirectional_LightType
+ };
+
+ SkLight() : fType(kAmbient_LightType) {
+ fColor.set(0.0f, 0.0f, 0.0f);
+ fDirection.set(0.0f, 0.0f, 1.0f);
+ }
+
+ SkLight(const SkColor3f& color)
+ : fType(kAmbient_LightType)
+ , fColor(color) {
+ fDirection.set(0.0f, 0.0f, 1.0f);
+ }
+
+ SkLight(const SkColor3f& color, const SkVector3& dir)
+ : fType(kDirectional_LightType)
+ , fColor(color)
+ , fDirection(dir) {
+ if (!fDirection.normalize()) {
+ fDirection.set(0.0f, 0.0f, 1.0f);
+ }
+ }
+
+ LightType type() const { return fType; }
+ const SkColor3f& color() const { return fColor; }
+ const SkVector3& dir() const {
+ SkASSERT(kAmbient_LightType != fType);
+ return fDirection;
+ }
+
+private:
+ LightType fType;
+ SkColor3f fColor; // linear (unpremul) color. Range is 0..1 in each channel.
+ SkVector3 fDirection; // direction towards the light (+Z is out of the screen).
+ // If degenerate, it will be replaced with (0, 0, 1).
+};
+
+
+#endif
« no previous file with comments | « samplecode/SampleLighting.cpp ('k') | src/core/SkLightingShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698