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

Side by Side Diff: gm/lightingshader.cpp

Issue 1829303002: move setshader to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: addressing comments from #8 Created 4 years, 9 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 | « gm/imagefiltersscaled.cpp ('k') | gm/perlinnoise.cpp » ('j') | no next file with comments »
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 }
OLDNEW
« no previous file with comments | « gm/imagefiltersscaled.cpp ('k') | gm/perlinnoise.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698