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

Side by Side Diff: src/core/SkLight.h

Issue 2026763002: Make use of new SkLights class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix SampleApp slide Created 4 years, 6 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 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkLight_DEFINED
9 #define SkLight_DEFINED
10
11 #include "SkPoint3.h"
12
13 class SK_API SkLight {
14 public:
15 enum LightType {
16 kAmbient_LightType, // only 'fColor' is used
17 kDirectional_LightType
18 };
19
20 SkLight() : fType(kAmbient_LightType) {
21 fColor.set(0.0f, 0.0f, 0.0f);
22 fDirection.set(0.0f, 0.0f, 1.0f);
23 }
24
25 SkLight(const SkColor3f& color)
26 : fType(kAmbient_LightType)
27 , fColor(color) {
28 fDirection.set(0.0f, 0.0f, 1.0f);
29 }
30
31 SkLight(const SkColor3f& color, const SkVector3& dir)
32 : fType(kDirectional_LightType)
33 , fColor(color)
34 , fDirection(dir) {
35 if (!fDirection.normalize()) {
36 fDirection.set(0.0f, 0.0f, 1.0f);
37 }
38 }
39
40 LightType type() const { return fType; }
41 const SkColor3f& color() const { return fColor; }
42 const SkVector3& dir() const {
43 SkASSERT(kAmbient_LightType != fType);
44 return fDirection;
45 }
46
47 private:
48 LightType fType;
49 SkColor3f fColor; // linear (unpremul) color. Range is 0..1 in e ach channel.
50 SkVector3 fDirection; // direction towards the light (+Z is out of t he screen).
51 // If degenerate, it will be replaced with (0, 0, 1).
52 };
53
54
55 #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