OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "gm.h" | 8 #include "gm.h" |
9 | 9 |
10 #include "SkLightingShader.h" | 10 #include "SkLightingShader.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 } | 39 } |
40 | 40 |
41 namespace skiagm { | 41 namespace skiagm { |
42 | 42 |
43 // This GM exercises lighting shaders. | 43 // This GM exercises lighting shaders. |
44 class LightingShaderGM : public GM { | 44 class LightingShaderGM : public GM { |
45 public: | 45 public: |
46 LightingShaderGM() { | 46 LightingShaderGM() { |
47 this->setBGColor(sk_tool_utils::color_to_565(0xFFCCCCCC)); | 47 this->setBGColor(sk_tool_utils::color_to_565(0xFFCCCCCC)); |
48 | 48 |
49 SkLightingShader::Lights::Builder builder; | 49 SkLights::Builder builder; |
50 | 50 |
51 builder.add(SkLight(SkColor3f::Make(1.0f, 1.0f, 1.0f), | 51 builder.add(SkLights::Light(SkColor3f::Make(1.0f, 1.0f, 1.0f), |
52 SkVector3::Make(1.0f, 0.0f, 0.0f))); | 52 SkVector3::Make(1.0f, 0.0f, 0.0f))); |
53 builder.add(SkLight(SkColor3f::Make(0.2f, 0.2f, 0.2f))); | 53 builder.add(SkLights::Light(SkColor3f::Make(0.2f, 0.2f, 0.2f))); |
54 | 54 |
55 fLights.reset(builder.finish()); | 55 fLights = builder.finish(); |
56 } | 56 } |
57 | 57 |
58 protected: | 58 protected: |
59 enum NormalMap { | 59 enum NormalMap { |
60 kHemi_NormalMap, | 60 kHemi_NormalMap, |
61 kFrustum_NormalMap, | 61 kFrustum_NormalMap, |
62 kTetra_NormalMap, | 62 kTetra_NormalMap, |
63 | 63 |
64 kLast_NormalMap = kTetra_NormalMap | 64 kLast_NormalMap = kTetra_NormalMap |
65 }; | 65 }; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 canvas->setMatrix(m); | 155 canvas->setMatrix(m); |
156 this->drawRect(canvas, r, kHemi_NormalMap); | 156 this->drawRect(canvas, r, kHemi_NormalMap); |
157 canvas->restore(); | 157 canvas->restore(); |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 private: | 161 private: |
162 static const int kTexSize = 128; | 162 static const int kTexSize = 128; |
163 static const int kGMSize = 512; | 163 static const int kGMSize = 512; |
164 | 164 |
165 SkBitmap fDiffuse; | 165 SkBitmap fDiffuse; |
166 SkBitmap fNormalMaps[kNormalMapCount]; | 166 SkBitmap fNormalMaps[kNormalMapCount]; |
167 | 167 |
168 SkAutoTUnref<const SkLightingShader::Lights> fLights; | 168 sk_sp<SkLights> fLights; |
169 | 169 |
170 typedef GM INHERITED; | 170 typedef GM INHERITED; |
171 }; | 171 }; |
172 | 172 |
173 ////////////////////////////////////////////////////////////////////////////// | 173 ////////////////////////////////////////////////////////////////////////////// |
174 | 174 |
175 DEF_GM(return new LightingShaderGM;) | 175 DEF_GM(return new LightingShaderGM;) |
176 } | 176 } |
OLD | NEW |