aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/viewer/BisectSlide.h
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2018-02-20 13:23:32 -0700
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-20 20:44:33 +0000
commit2d18f41858382fff91688a6318bc39cb22233f7e (patch)
tree25769915a2ca60575f96e9742643bea056cf6110 /tools/viewer/BisectSlide.h
parent5423f1f0c59b43b09ac216966b6af12f08955be7 (diff)
Resurrect pathfinder in viewer and rename to "bisect"
Bug: skia: Change-Id: If8d2f46b8f27fefc3a0f983eb649654e0fb4afcb Reviewed-on: https://skia-review.googlesource.com/108685 Commit-Queue: Chris Dalton <csmartdalton@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tools/viewer/BisectSlide.h')
-rw-r--r--tools/viewer/BisectSlide.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/tools/viewer/BisectSlide.h b/tools/viewer/BisectSlide.h
new file mode 100644
index 0000000000..c5300c6396
--- /dev/null
+++ b/tools/viewer/BisectSlide.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef BisectSlide_DEFINED
+#define BisectSlide_DEFINED
+
+#include "SkCanvas.h"
+#include "SkPath.h"
+#include "Slide.h"
+#include <stack>
+
+/**
+ * This is a simple utility designed to extract the paths from an SKP file and then isolate a single
+ * one of them via bisect. Use the 'x' and 'X' keys to guide a binary search:
+ *
+ * 'x': Throw out half the paths.
+ * 'X': Toggle which half gets tossed and which half is kept.
+ * 'Z': Back up one level.
+ * 'D': Dump the path.
+ */
+class BisectSlide : public Slide, public SkCanvas {
+public:
+ static sk_sp<BisectSlide> Create(const char filepath[]);
+
+ // Slide overrides.
+ SkISize getDimensions() const override { return fDrawBounds.size(); }
+ bool onChar(SkUnichar c) override;
+ void draw(SkCanvas* canvas) override;
+
+private:
+ BisectSlide(const char filepath[]);
+
+ // SkCanvas override called only during creation.
+ void onDrawPath(const SkPath& path, const SkPaint& paint) override;
+
+ struct FoundPath {
+ SkPath fPath;
+ SkPaint fPaint;
+ SkMatrix fViewMatrix;
+ };
+
+ SkString fFilePath;
+ SkIRect fDrawBounds = SkIRect::MakeEmpty();
+ SkTArray<FoundPath> fFoundPaths;
+ SkTArray<FoundPath> fTossedPaths;
+ SkTArray<char> fTrail;
+ std::stack<std::pair<SkTArray<FoundPath>, SkTArray<FoundPath>>> fPathHistory;
+};
+
+#endif