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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « samplecode/SampleLighting.cpp ('k') | src/core/SkLightingShader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
2 /*
3 * Copyright 2015 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9 #ifndef SkLight_DEFINED
10 #define SkLight_DEFINED
11
12 #include "SkPoint3.h"
13
14 class SK_API SkLight {
15 public:
16 enum LightType {
17 kAmbient_LightType, // only 'fColor' is used
18 kDirectional_LightType
19 };
20
21 SkLight() : fType(kAmbient_LightType) {
22 fColor.set(0.0f, 0.0f, 0.0f);
23 fDirection.set(0.0f, 0.0f, 1.0f);
24 }
25
26 SkLight(const SkColor3f& color)
27 : fType(kAmbient_LightType)
28 , fColor(color) {
29 fDirection.set(0.0f, 0.0f, 1.0f);
30 }
31
32 SkLight(const SkColor3f& color, const SkVector3& dir)
33 : fType(kDirectional_LightType)
34 , fColor(color)
35 , fDirection(dir) {
36 if (!fDirection.normalize()) {
37 fDirection.set(0.0f, 0.0f, 1.0f);
38 }
39 }
40
41 LightType type() const { return fType; }
42 const SkColor3f& color() const { return fColor; }
43 const SkVector3& dir() const {
44 SkASSERT(kAmbient_LightType != fType);
45 return fDirection;
46 }
47
48 private:
49 LightType fType;
50 SkColor3f fColor; // linear (unpremul) color. Range is 0..1 in e ach channel.
51 SkVector3 fDirection; // direction towards the light (+Z is out of t he screen).
52 // If degenerate, it will be replaced with (0, 0, 1).
53 };
54
55
56 #endif
OLDNEW
« 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