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

Unified Diff: gm/lightingshader.cpp

Issue 2080993002: Added API for Bevel NormalSource. (Closed) Base URL: https://skia.googlesource.com/skia@dvonbeck-diffuse-api-change
Patch Set: Addressed patch 7 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 | gyp/core.gypi » ('j') | src/core/SkNormalBevelSource.cpp » ('J')
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 2cf4a953d800b78c0577a57f48daa020168ee698..e2f616fa67d646d6a5d9029384388b66b7f2db0d 100644
--- a/gm/lightingshader.cpp
+++ b/gm/lightingshader.cpp
@@ -112,6 +112,25 @@ protected:
canvas->drawRect(r, paint);
}
+ void drawBevelRect(SkCanvas* canvas, const SkRect& r) {
+
+ SkRect bitmapBounds = SkRect::MakeIWH(fDiffuse.width(), fDiffuse.height());
+
+ SkMatrix matrix;
+ matrix.setRectToRect(bitmapBounds, r, SkMatrix::kFill_ScaleToFit);
+
+ SkPaint paint;
+ auto diffuseShader = SkBitmapProcShader::MakeBitmapShader(fDiffuse,
+ SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, &matrix);
+ auto normalSource = SkNormalSource::MakeBevel(SkNormalSource::BevelType::kLinear,
+ 0.15f * SkIntToScalar(kTexSize),
+ 0.2f * SkIntToScalar(kTexSize));
+ paint.setShader(SkLightingShader::Make(std::move(diffuseShader), std::move(normalSource),
+ fLights));
+
+ canvas->drawRect(r, paint);
+ }
+
void onDraw(SkCanvas* canvas) override {
SkMatrix m;
SkRect r;
@@ -136,7 +155,7 @@ protected:
m.setRotate(45.0f, r.centerX(), r.centerY());
m.postTranslate(0.0f, kGMSize/2.0f - kTexSize/2.0f);
canvas->setMatrix(m);
- this->drawRect(canvas, r, kFrustum_NormalMap);
+ this->drawBevelRect(canvas, r);
egdaniel 2016/07/25 15:48:00 do we really want to change this GM from using nor
dvonbeck 2016/07/25 20:37:13 Agreed. Done.
canvas->restore();
}
« no previous file with comments | « no previous file | gyp/core.gypi » ('j') | src/core/SkNormalBevelSource.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698