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

Unified Diff: samplecode/SampleLighting.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 | « gm/lightingshader.cpp ('k') | samplecode/SampleLitAtlas.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleLighting.cpp
diff --git a/samplecode/SampleLighting.cpp b/samplecode/SampleLighting.cpp
index a27aa9de41b117667e030ff9c6cdd61c13e6de5a..5949f4961bc52267b235814f0680d11ce7d925a8 100755
--- a/samplecode/SampleLighting.cpp
+++ b/samplecode/SampleLighting.cpp
@@ -8,8 +8,10 @@
#include "SampleCode.h"
#include "Resources.h"
+#include "SkBitmapProcShader.h"
#include "SkCanvas.h"
#include "SkLightingShader.h"
+#include "SkNormalSource.h"
#include "SkPoint3.h"
static sk_sp<SkLights> create_lights(SkScalar angle, SkScalar blue) {
@@ -64,9 +66,12 @@ protected:
sk_sp<SkLights> lights(create_lights(fLightAngle, fColorFactor));
SkPaint paint;
- paint.setShader(SkLightingShader::Make(fDiffuseBitmap, fNormalBitmap,
- std::move(lights), SkVector::Make(1.0f, 0.0f),
- nullptr, nullptr));
+ sk_sp<SkShader> normalMap = SkMakeBitmapShader(fNormalBitmap,
+ SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, nullptr, nullptr);
+ sk_sp<SkNormalSource> normalSource = SkNormalSource::MakeFromNormalMap(
+ std::move(normalMap), SkMatrix::I());
+ paint.setShader(SkLightingShader::Make(fDiffuseBitmap, std::move(lights), nullptr,
+ std::move(normalSource)));
paint.setColor(SK_ColorBLACK);
SkRect r = SkRect::MakeWH((SkScalar)fDiffuseBitmap.width(),
« no previous file with comments | « gm/lightingshader.cpp ('k') | samplecode/SampleLitAtlas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698