OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "Resources.h" | 9 #include "Resources.h" |
10 | 10 |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkErrorInternals.h" | 12 #include "SkErrorInternals.h" |
13 #include "SkGr.h" | 13 #include "SkGr.h" |
| 14 #include "SkPoint3.h" |
14 #include "SkReadBuffer.h" | 15 #include "SkReadBuffer.h" |
15 #include "SkShader.h" | 16 #include "SkShader.h" |
16 #include "SkWriteBuffer.h" | 17 #include "SkWriteBuffer.h" |
17 #include "GrFragmentProcessor.h" | 18 #include "GrFragmentProcessor.h" |
18 #include "GrCoordTransform.h" | 19 #include "GrCoordTransform.h" |
19 #include "gl/GrGLProcessor.h" | 20 #include "gl/GrGLProcessor.h" |
20 #include "gl/builders/GrGLProgramBuilder.h" | 21 #include "gl/builders/GrGLProgramBuilder.h" |
21 | 22 |
22 /////////////////////////////////////////////////////////////////////////////// | 23 /////////////////////////////////////////////////////////////////////////////// |
23 | 24 |
24 struct SkVector3 { | |
25 SkScalar fX, fY, fZ; | |
26 | |
27 bool operator==(const SkVector3& other) const { | |
28 return fX == other.fX && fY == other.fY && fZ == other.fZ; | |
29 } | |
30 | |
31 bool operator!=(const SkVector3& other) const { | |
32 return !(*this == other); | |
33 } | |
34 }; | |
35 | |
36 class LightingShader : public SkShader { | 25 class LightingShader : public SkShader { |
37 public: | 26 public: |
38 struct Light { | 27 struct Light { |
39 SkVector3 fDirection; | 28 SkVector3 fDirection; |
40 SkColor fColor; // assumed to be linear color | 29 SkColor fColor; // assumed to be linear color |
41 }; | 30 }; |
42 | 31 |
43 LightingShader(const SkBitmap& diffuse, const SkBitmap& normal, const Light&
light, | 32 LightingShader(const SkBitmap& diffuse, const SkBitmap& normal, const Light&
light, |
44 const SkColor ambient) | 33 const SkColor ambient) |
45 : fDiffuseMap(diffuse) | 34 : fDiffuseMap(diffuse) |
(...skipping 374 matching lines...) Loading... |
420 } | 409 } |
421 | 410 |
422 private: | 411 private: |
423 typedef SampleView INHERITED; | 412 typedef SampleView INHERITED; |
424 }; | 413 }; |
425 | 414 |
426 ////////////////////////////////////////////////////////////////////////////// | 415 ////////////////////////////////////////////////////////////////////////////// |
427 | 416 |
428 static SkView* MyFactory() { return new LightingView; } | 417 static SkView* MyFactory() { return new LightingView; } |
429 static SkViewRegister reg(MyFactory); | 418 static SkViewRegister reg(MyFactory); |
OLD | NEW |