Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Side by Side Diff: gm/lightingshader.cpp

Issue 2063793002: API change to allow for NormalSource selection at the user level. (Closed) Base URL: https://skia.googlesource.com/skia@dvonbeck-normal-factor-out
Patch Set: Small rebase and comment fix Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | samplecode/SampleLighting.cpp » ('j') | samplecode/SampleLighting.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | samplecode/SampleLighting.cpp » ('j') | samplecode/SampleLighting.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698