OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkAnimTimer.h" | 9 #include "SkAnimTimer.h" |
10 #include "SkView.h" | 10 #include "SkView.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 diffMat.setRectToRect(fDiffTex[i], r, SkMatrix::kFill_ScaleToFit); | 125 diffMat.setRectToRect(fDiffTex[i], r, SkMatrix::kFill_ScaleToFit); |
126 normalMat.setRectToRect(fNormTex[i], r, SkMatrix::kFill_ScaleToFit); | 126 normalMat.setRectToRect(fNormTex[i], r, SkMatrix::kFill_ScaleToFit); |
127 | 127 |
128 SkMatrix m; | 128 SkMatrix m; |
129 m.setRSXform(xforms[i]); | 129 m.setRSXform(xforms[i]); |
130 | 130 |
131 // TODO: correctly pull out the pure rotation | 131 // TODO: correctly pull out the pure rotation |
132 SkVector invNormRotation = { m[SkMatrix::kMScaleX], m[SkMatrix::kMSk
ewY] }; | 132 SkVector invNormRotation = { m[SkMatrix::kMScaleX], m[SkMatrix::kMSk
ewY] }; |
133 SkASSERT(SkScalarNearlyEqual(invNormRotation.lengthSqd(), SK_Scalar1
)); | 133 SkASSERT(SkScalarNearlyEqual(invNormRotation.lengthSqd(), SK_Scalar1
)); |
134 | 134 |
135 paint.setShader(SkLightingShader::Make(fAtlas, fAtlas, fLights, | 135 auto normalSource = SkLightingShader::NormalMapSource::Make(fAtlas,
invNormRotation, |
136 invNormRotation, &diffMat, &n
ormalMat)); | 136 &normalM
at); |
| 137 paint.setShader(SkLightingShader::Make(fAtlas, fLights, &diffMat, |
| 138 std::move(normalSource))); |
137 | 139 |
138 canvas->save(); | 140 canvas->save(); |
139 canvas->setMatrix(m); | 141 canvas->setMatrix(m); |
140 canvas->drawRect(r, paint); | 142 canvas->drawRect(r, paint); |
141 canvas->restore(); | 143 canvas->restore(); |
142 } | 144 } |
143 #endif | 145 #endif |
144 | 146 |
145 #ifdef SK_DEBUG | 147 #ifdef SK_DEBUG |
146 { | 148 { |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 private: | 505 private: |
504 SkAutoTUnref<DrawLitAtlasDrawable> fDrawable; | 506 SkAutoTUnref<DrawLitAtlasDrawable> fDrawable; |
505 | 507 |
506 typedef SampleView INHERITED; | 508 typedef SampleView INHERITED; |
507 }; | 509 }; |
508 | 510 |
509 ////////////////////////////////////////////////////////////////////////////// | 511 ////////////////////////////////////////////////////////////////////////////// |
510 | 512 |
511 static SkView* MyFactory() { return new DrawLitAtlasView; } | 513 static SkView* MyFactory() { return new DrawLitAtlasView; } |
512 static SkViewRegister reg(MyFactory); | 514 static SkViewRegister reg(MyFactory); |
OLD | NEW |