| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 fNormalMaps[kFrustum_NormalMap] = make_frustum_normalmap(kTexSize); | 85 fNormalMaps[kFrustum_NormalMap] = make_frustum_normalmap(kTexSize); |
| 86 fNormalMaps[kTetra_NormalMap] = make_tetra_normalmap(kTexSize); | 86 fNormalMaps[kTetra_NormalMap] = make_tetra_normalmap(kTexSize); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void drawRect(SkCanvas* canvas, const SkRect& r, NormalMap mapType) { | 89 void drawRect(SkCanvas* canvas, const SkRect& r, NormalMap mapType) { |
| 90 | 90 |
| 91 SkRect bitmapBounds = SkRect::MakeIWH(fDiffuse.width(), fDiffuse.height(
)); | 91 SkRect bitmapBounds = SkRect::MakeIWH(fDiffuse.width(), fDiffuse.height(
)); |
| 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 paint.setShader(SkLightingShader::Make(fDiffuse, fNormalMaps[mapType], f
Lights, |
| 103 invNormRotation, &matrix, &matrix
)); | 103 invNormRotation, &matrix, &matrix
)); |
| 104 | 104 |
| 105 canvas->drawRect(r, paint); | 105 canvas->drawRect(r, paint); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 167 |
| 168 SkAutoTUnref<const SkLightingShader::Lights> fLights; | 168 SkAutoTUnref<const SkLightingShader::Lights> 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 |