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

Side by Side Diff: gm/lightingshader.cpp

Issue 2064153002: Changed SkLightingShader API to take in a shader as color source (Closed) Base URL: https://skia.googlesource.com/skia@dvonbeck-diffuse-factor-out
Patch Set: rebase Created 4 years, 5 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') | src/core/SkLightingShader.h » ('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 "SkBitmapProcShader.h" 10 #include "SkBitmapProcShader.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 void drawRect(SkCanvas* canvas, const SkRect& r, NormalMap mapType) { 91 void drawRect(SkCanvas* canvas, const SkRect& r, NormalMap mapType) {
92 92
93 SkRect bitmapBounds = SkRect::MakeIWH(fDiffuse.width(), fDiffuse.height( )); 93 SkRect bitmapBounds = SkRect::MakeIWH(fDiffuse.width(), fDiffuse.height( ));
94 94
95 SkMatrix matrix; 95 SkMatrix matrix;
96 matrix.setRectToRect(bitmapBounds, r, SkMatrix::kFill_ScaleToFit); 96 matrix.setRectToRect(bitmapBounds, r, SkMatrix::kFill_ScaleToFit);
97 97
98 const SkMatrix& ctm = canvas->getTotalMatrix(); 98 const SkMatrix& ctm = canvas->getTotalMatrix();
99 99
100 SkPaint paint; 100 SkPaint paint;
101 sk_sp<SkShader> diffuseShader = SkMakeBitmapShader(fDiffuse,
102 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, &matrix, n ullptr);
101 sk_sp<SkShader> normalMap = SkMakeBitmapShader(fNormalMaps[mapType], 103 sk_sp<SkShader> normalMap = SkMakeBitmapShader(fNormalMaps[mapType],
102 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, &matrix, n ullptr); 104 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, &matrix, n ullptr);
103 sk_sp<SkNormalSource> normalSource = SkNormalSource::MakeFromNormalMap(s td::move(normalMap), 105 sk_sp<SkNormalSource> normalSource = SkNormalSource::MakeFromNormalMap(s td::move(normalMap),
104 c tm); 106 c tm);
105 paint.setShader(SkLightingShader::Make(fDiffuse, fLights, &matrix, 107 paint.setShader(SkLightingShader::Make(std::move(diffuseShader), std::mo ve(normalSource),
106 std::move(normalSource))); 108 fLights));
107 109
108 canvas->drawRect(r, paint); 110 canvas->drawRect(r, paint);
109 } 111 }
110 112
111 void onDraw(SkCanvas* canvas) override { 113 void onDraw(SkCanvas* canvas) override {
112 SkMatrix m; 114 SkMatrix m;
113 SkRect r; 115 SkRect r;
114 116
115 { 117 {
116 r = SkRect::MakeWH(SkIntToScalar(kTexSize), SkIntToScalar(kTexSize)) ; 118 r = SkRect::MakeWH(SkIntToScalar(kTexSize), SkIntToScalar(kTexSize)) ;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 172
171 sk_sp<SkLights> fLights; 173 sk_sp<SkLights> fLights;
172 174
173 typedef GM INHERITED; 175 typedef GM INHERITED;
174 }; 176 };
175 177
176 ////////////////////////////////////////////////////////////////////////////// 178 //////////////////////////////////////////////////////////////////////////////
177 179
178 DEF_GM(return new LightingShaderGM;) 180 DEF_GM(return new LightingShaderGM;)
179 } 181 }
OLDNEW
« no previous file with comments | « no previous file | samplecode/SampleLighting.cpp » ('j') | src/core/SkLightingShader.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698