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

Side by Side Diff: samplecode/SampleLitAtlas.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 | « samplecode/SampleLighting.cpp ('k') | src/core/SkLightingShader.h » ('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 2016 Google Inc. 2 * Copyright 2016 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 "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkAnimTimer.h" 9 #include "SkAnimTimer.h"
10 #include "SkBitmapProcShader.h" 10 #include "SkBitmapProcShader.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 diffMat.setRectToRect(fDiffTex[i], r, SkMatrix::kFill_ScaleToFit); 127 diffMat.setRectToRect(fDiffTex[i], r, SkMatrix::kFill_ScaleToFit);
128 normalMat.setRectToRect(fNormTex[i], r, SkMatrix::kFill_ScaleToFit); 128 normalMat.setRectToRect(fNormTex[i], r, SkMatrix::kFill_ScaleToFit);
129 129
130 SkMatrix m; 130 SkMatrix m;
131 m.setRSXform(xforms[i]); 131 m.setRSXform(xforms[i]);
132 132
133 sk_sp<SkShader> normalMap = SkMakeBitmapShader(fAtlas, SkShader::kCl amp_TileMode, 133 sk_sp<SkShader> normalMap = SkMakeBitmapShader(fAtlas, SkShader::kCl amp_TileMode,
134 SkShader::kClamp_TileMode, &normalMat, nullptr); 134 SkShader::kClamp_TileMode, &normalMat, nullptr);
135 sk_sp<SkNormalSource> normalSource = SkNormalSource::MakeFromNormalM ap( 135 sk_sp<SkNormalSource> normalSource = SkNormalSource::MakeFromNormalM ap(
136 std::move(normalMap), m); 136 std::move(normalMap), m);
137 paint.setShader(SkLightingShader::Make(fAtlas, fLights, &diffMat, 137 sk_sp<SkShader> diffuseShader = SkBitmapProcShader::MakeBitmapShader (fAtlas,
138 std::move(normalSource))); 138 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, &diffM at);
139 paint.setShader(SkLightingShader::Make(std::move(diffuseShader),
140 std::move(normalSource), fLights));
139 141
140 canvas->save(); 142 canvas->save();
141 canvas->setMatrix(m); 143 canvas->setMatrix(m);
142 canvas->drawRect(r, paint); 144 canvas->drawRect(r, paint);
143 canvas->restore(); 145 canvas->restore();
144 } 146 }
145 #endif 147 #endif
146 148
147 #ifdef SK_DEBUG 149 #ifdef SK_DEBUG
148 { 150 {
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 private: 507 private:
506 SkAutoTUnref<DrawLitAtlasDrawable> fDrawable; 508 SkAutoTUnref<DrawLitAtlasDrawable> fDrawable;
507 509
508 typedef SampleView INHERITED; 510 typedef SampleView INHERITED;
509 }; 511 };
510 512
511 ////////////////////////////////////////////////////////////////////////////// 513 //////////////////////////////////////////////////////////////////////////////
512 514
513 static SkView* MyFactory() { return new DrawLitAtlasView; } 515 static SkView* MyFactory() { return new DrawLitAtlasView; }
514 static SkViewRegister reg(MyFactory); 516 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleLighting.cpp ('k') | src/core/SkLightingShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698