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 #include "SkLightingShader.h" | 9 #include "SkLightingShader.h" |
10 #include "SkNormalSource.h" | 10 #include "SkNormalSource.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 protected: | 60 protected: |
61 enum NormalMap { | 61 enum NormalMap { |
62 kHemi_NormalMap, | 62 kHemi_NormalMap, |
63 kFrustum_NormalMap, | 63 kFrustum_NormalMap, |
64 kTetra_NormalMap, | 64 kTetra_NormalMap, |
65 | 65 |
66 kLast_NormalMap = kTetra_NormalMap | 66 kLast_NormalMap = kTetra_NormalMap |
67 }; | 67 }; |
68 | 68 |
69 static const int kNormalMapCount = kLast_NormalMap+1; | 69 static constexpr int kNormalMapCount = kLast_NormalMap+1; |
70 | 70 |
71 SkString onShortName() override { | 71 SkString onShortName() override { |
72 return SkString("lightingshader"); | 72 return SkString("lightingshader"); |
73 } | 73 } |
74 | 74 |
75 SkISize onISize() override { | 75 SkISize onISize() override { |
76 return SkISize::Make(kGMSize, kGMSize); | 76 return SkISize::Make(kGMSize, kGMSize); |
77 } | 77 } |
78 | 78 |
79 void onOnceBeforeDraw() override { | 79 void onOnceBeforeDraw() override { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 canvas->save(); | 157 canvas->save(); |
158 m.setRotate(45.0f, r.centerX(), r.centerY()); | 158 m.setRotate(45.0f, r.centerX(), r.centerY()); |
159 m.postTranslate(0.0f, -kGMSize/2.0f + kTexSize/2.0f); | 159 m.postTranslate(0.0f, -kGMSize/2.0f + kTexSize/2.0f); |
160 canvas->setMatrix(m); | 160 canvas->setMatrix(m); |
161 this->drawRect(canvas, r, kHemi_NormalMap); | 161 this->drawRect(canvas, r, kHemi_NormalMap); |
162 canvas->restore(); | 162 canvas->restore(); |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 private: | 166 private: |
167 static const int kTexSize = 128; | 167 static constexpr int kTexSize = 128; |
168 static const int kGMSize = 512; | 168 static constexpr int kGMSize = 512; |
169 | 169 |
170 SkBitmap fDiffuse; | 170 SkBitmap fDiffuse; |
171 SkBitmap fNormalMaps[kNormalMapCount]; | 171 SkBitmap fNormalMaps[kNormalMapCount]; |
172 | 172 |
173 sk_sp<SkLights> fLights; | 173 sk_sp<SkLights> fLights; |
174 | 174 |
175 typedef GM INHERITED; | 175 typedef GM INHERITED; |
176 }; | 176 }; |
177 | 177 |
178 ////////////////////////////////////////////////////////////////////////////// | 178 ////////////////////////////////////////////////////////////////////////////// |
179 | 179 |
180 DEF_GM(return new LightingShaderGM;) | 180 DEF_GM(return new LightingShaderGM;) |
181 } | 181 } |
OLD | NEW |