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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 SkAutoTUnref<SkShader> fShader(SkLightingShader::Create( | |
102 fDiffuse, | |
103 fNormalMaps[mapType], | |
104 fLights, | |
105 invNormRotation, &matrix
, &matrix)); | |
106 | |
107 SkPaint paint; | 101 SkPaint paint; |
108 paint.setShader(fShader); | 102 paint.setShader(SkLightingShader::Make(fDiffuse, fNormalMaps[mapType], f
Lights, |
| 103 invNormRotation, &matrix, &matrix
)); |
109 | 104 |
110 canvas->drawRect(r, paint); | 105 canvas->drawRect(r, paint); |
111 } | 106 } |
112 | 107 |
113 void onDraw(SkCanvas* canvas) override { | 108 void onDraw(SkCanvas* canvas) override { |
114 SkMatrix m; | 109 SkMatrix m; |
115 SkRect r; | 110 SkRect r; |
116 | 111 |
117 { | 112 { |
118 r = SkRect::MakeWH(SkIntToScalar(kTexSize), SkIntToScalar(kTexSize))
; | 113 r = SkRect::MakeWH(SkIntToScalar(kTexSize), SkIntToScalar(kTexSize))
; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 167 |
173 SkAutoTUnref<const SkLightingShader::Lights> fLights; | 168 SkAutoTUnref<const SkLightingShader::Lights> fLights; |
174 | 169 |
175 typedef GM INHERITED; | 170 typedef GM INHERITED; |
176 }; | 171 }; |
177 | 172 |
178 ////////////////////////////////////////////////////////////////////////////// | 173 ////////////////////////////////////////////////////////////////////////////// |
179 | 174 |
180 DEF_GM(return new LightingShaderGM;) | 175 DEF_GM(return new LightingShaderGM;) |
181 } | 176 } |
OLD | NEW |