aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode/SampleLitAtlas.cpp
diff options
context:
space:
mode:
authorGravatar dvonbeck <dvonbeck@google.com>2016-07-06 13:58:36 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-06 13:58:36 -0700
commit5b794fad18344e8dbb840be49d1bc66ebe754b31 (patch)
tree2ca81afa233fecd04cdd517cca5f970ab501dc9c /samplecode/SampleLitAtlas.cpp
parent8b7a9e1e5a773cbc2ccf9ee1b36e8dce5ddfb8c5 (diff)
API change to allow for NormalSource selection at the user level.
Diffstat (limited to 'samplecode/SampleLitAtlas.cpp')
-rw-r--r--samplecode/SampleLitAtlas.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/samplecode/SampleLitAtlas.cpp b/samplecode/SampleLitAtlas.cpp
index f1d67e5c79..ba42ed8761 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);