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

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: Small init fix 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 | src/core/SkLightingShader.h » ('j') | src/core/SkLightingShader.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..0be9ad9ddc77b7cd9799fcbc4cd3191c44a77475 100644
--- a/gm/lightingshader.cpp
+++ b/gm/lightingshader.cpp
@@ -112,6 +112,26 @@ 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;
robertphillips 2016/07/11 19:13:21 Add '\n'
dvonbeck 2016/07/13 14:23:37 Done.
+ 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 +156,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);
canvas->restore();
}
« no previous file with comments | « no previous file | src/core/SkLightingShader.h » ('j') | src/core/SkLightingShader.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698