Chromium Code Reviews| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 | 92 |
| 93 SkMatrix matrix; | 93 SkMatrix matrix; |
| 94 matrix.setRectToRect(bitmapBounds, r, SkMatrix::kFill_ScaleToFit); | 94 matrix.setRectToRect(bitmapBounds, r, SkMatrix::kFill_ScaleToFit); |
| 95 | 95 |
| 96 const SkMatrix& ctm = canvas->getTotalMatrix(); | 96 const SkMatrix& ctm = canvas->getTotalMatrix(); |
| 97 | 97 |
| 98 // TODO: correctly pull out the pure rotation | 98 // TODO: correctly pull out the pure rotation |
| 99 SkVector invNormRotation = { ctm[SkMatrix::kMScaleX], ctm[SkMatrix::kMSk ewY] }; | 99 SkVector invNormRotation = { ctm[SkMatrix::kMScaleX], ctm[SkMatrix::kMSk ewY] }; |
| 100 | 100 |
| 101 SkPaint paint; | 101 SkPaint paint; |
| 102 paint.setShader(SkLightingShader::Make(fDiffuse, fNormalMaps[mapType], f Lights, | 102 auto normalSource = SkLightingShader::NormalMapSource::Make(fNormalMaps[ mapType], |
| 103 invNormRotation, &matrix, &matrix )); | 103 invNormRotat ion, &matrix); |
| 104 paint.setShader(SkLightingShader::Make(fDiffuse, fLights, &matrix, norma lSource)); | |
|
egdaniel
2016/06/16 13:15:08
should this be a move here of normal source?
dvonbeck
2016/06/16 23:21:56
Done.
| |
| 104 | 105 |
| 105 canvas->drawRect(r, paint); | 106 canvas->drawRect(r, paint); |
| 106 } | 107 } |
| 107 | 108 |
| 108 void onDraw(SkCanvas* canvas) override { | 109 void onDraw(SkCanvas* canvas) override { |
| 109 SkMatrix m; | 110 SkMatrix m; |
| 110 SkRect r; | 111 SkRect r; |
| 111 | 112 |
| 112 { | 113 { |
| 113 r = SkRect::MakeWH(SkIntToScalar(kTexSize), SkIntToScalar(kTexSize)) ; | 114 r = SkRect::MakeWH(SkIntToScalar(kTexSize), SkIntToScalar(kTexSize)) ; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 | 168 |
| 168 sk_sp<SkLights> fLights; | 169 sk_sp<SkLights> fLights; |
| 169 | 170 |
| 170 typedef GM INHERITED; | 171 typedef GM INHERITED; |
| 171 }; | 172 }; |
| 172 | 173 |
| 173 ////////////////////////////////////////////////////////////////////////////// | 174 ////////////////////////////////////////////////////////////////////////////// |
| 174 | 175 |
| 175 DEF_GM(return new LightingShaderGM;) | 176 DEF_GM(return new LightingShaderGM;) |
| 176 } | 177 } |
| OLD | NEW |