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

Unified Diff: samplecode/PerlinPatch.cpp

Issue 2269673002: 'g' key toggles showgrid for PerlinPatch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/PerlinPatch.cpp
diff --git a/samplecode/PerlinPatch.cpp b/samplecode/PerlinPatch.cpp
index 8f7e28d4d0eba02546c8e40cd6030f722210f967..a2033c35ff3ec0180362432f006734ef53343ebe 100644
--- a/samplecode/PerlinPatch.cpp
+++ b/samplecode/PerlinPatch.cpp
@@ -71,6 +71,8 @@ class PerlinPatchView : public SampleView {
SkScalar fTexY;
SkScalar fTexScale;
SkMatrix fInvMatrix;
+ bool fShowGrid = false;
+
public:
PerlinPatchView() : fXFreq(0.025f), fYFreq(0.025f), fSeed(0.0f),
fTexX(100.0), fTexY(50.0), fTexScale(1.0f) {
@@ -114,6 +116,13 @@ protected:
SampleCode::TitleR(evt, "PerlinPatch");
return true;
}
+ SkUnichar uni;
+ if (SampleCode::CharQ(*evt, &uni)) {
+ switch (uni) {
+ case 'g': fShowGrid = !fShowGrid; this->inval(nullptr); return true;
+ default: break;
+ }
+ }
return this->INHERITED::onQuery(evt);
}
@@ -147,7 +156,12 @@ protected:
fShaderCompose = SkShader::MakeComposeShader(fShader0, fShader1, nullptr);
paint.setShader(fShaderCompose);
- canvas->drawPatch(fPts, nullptr, texCoords, xfer, paint);
+
+ const SkPoint* tex = texCoords;
+ if (fShowGrid) {
+ tex = nullptr;
+ }
+ canvas->drawPatch(fPts, nullptr, tex, xfer, paint);
draw_control_points(canvas, fPts);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698