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

Unified Diff: gm/lightingshader.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 | « no previous file | samplecode/SampleLighting.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/lightingshader.cpp
diff --git a/gm/lightingshader.cpp b/gm/lightingshader.cpp
index ae6a24f9f0c3ce895aeae048f022c53ce0504daf..3b1c224f2bf980ab91a3e2524d36a4eaa2b22b10 100644
--- a/gm/lightingshader.cpp
+++ b/gm/lightingshader.cpp
@@ -7,7 +7,9 @@
#include "gm.h"
+#include "SkBitmapProcShader.h"
#include "SkLightingShader.h"
+#include "SkNormalSource.h"
#include "SkPoint3.h"
#include "SkShader.h"
@@ -49,7 +51,9 @@ public:
SkLights::Builder builder;
builder.add(SkLights::Light(SkColor3f::Make(1.0f, 1.0f, 1.0f),
- SkVector3::Make(1.0f, 0.0f, 0.0f)));
+ SkVector3::Make(SK_ScalarRoot2Over2,
+ 0.0f,
+ SK_ScalarRoot2Over2)));
builder.add(SkLights::Light(SkColor3f::Make(0.2f, 0.2f, 0.2f)));
fLights = builder.finish();
@@ -95,12 +99,13 @@ protected:
const SkMatrix& ctm = canvas->getTotalMatrix();
- // TODO: correctly pull out the pure rotation
- SkVector invNormRotation = { ctm[SkMatrix::kMScaleX], ctm[SkMatrix::kMSkewY] };
-
SkPaint paint;
- paint.setShader(SkLightingShader::Make(fDiffuse, fNormalMaps[mapType], fLights,
- invNormRotation, &matrix, &matrix));
+ sk_sp<SkShader> normalMap = SkMakeBitmapShader(fNormalMaps[mapType],
+ SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, &matrix, nullptr);
+ sk_sp<SkNormalSource> normalSource = SkNormalSource::MakeFromNormalMap(std::move(normalMap),
+ ctm);
+ paint.setShader(SkLightingShader::Make(fDiffuse, fLights, &matrix,
+ std::move(normalSource)));
canvas->drawRect(r, paint);
}
« no previous file with comments | « no previous file | samplecode/SampleLighting.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698