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

Unified Diff: samplecode/SampleLitAtlas.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: Addressed remaining patch 8 comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/SampleLighting.cpp ('k') | src/core/SkLightingShader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleLitAtlas.cpp
diff --git a/samplecode/SampleLitAtlas.cpp b/samplecode/SampleLitAtlas.cpp
index f1d67e5c7933b0050e491e51c0d974898e810268..ba42ed8761ac9ad72fadd3f6514e2805f53359d8 100644
--- a/samplecode/SampleLitAtlas.cpp
+++ b/samplecode/SampleLitAtlas.cpp
@@ -7,13 +7,15 @@
#include "SampleCode.h"
#include "SkAnimTimer.h"
-#include "SkView.h"
+#include "SkBitmapProcShader.h"
#include "SkCanvas.h"
#include "SkDrawable.h"
#include "SkLightingShader.h"
#include "SkLights.h"
+#include "SkNormalSource.h"
#include "SkRandom.h"
#include "SkRSXform.h"
+#include "SkView.h"
#include "sk_tool_utils.h"
@@ -128,12 +130,12 @@ protected:
SkMatrix m;
m.setRSXform(xforms[i]);
- // TODO: correctly pull out the pure rotation
- SkVector invNormRotation = { m[SkMatrix::kMScaleX], m[SkMatrix::kMSkewY] };
- SkASSERT(SkScalarNearlyEqual(invNormRotation.lengthSqd(), SK_Scalar1));
-
- paint.setShader(SkLightingShader::Make(fAtlas, fAtlas, fLights,
- invNormRotation, &diffMat, &normalMat));
+ sk_sp<SkShader> normalMap = SkMakeBitmapShader(fAtlas, SkShader::kClamp_TileMode,
+ SkShader::kClamp_TileMode, &normalMat, nullptr);
+ sk_sp<SkNormalSource> normalSource = SkNormalSource::MakeFromNormalMap(
+ std::move(normalMap), m);
+ paint.setShader(SkLightingShader::Make(fAtlas, fLights, &diffMat,
+ std::move(normalSource)));
canvas->save();
canvas->setMatrix(m);
« 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