Debian Codegraph @

tools/viewer/BisectSlide.h

raw
1 /*
2 * Copyright 2018 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef BisectSlide_DEFINED
9 #define BisectSlide_DEFINED
10
11 #include "include/core/SkMatrix.h"
12 #include "include/core/SkPaint.h"
13 #include "include/core/SkPath.h"
14 #include "include/core/SkRect.h"
15 #include "include/core/SkRefCnt.h"
16 #include "include/core/SkSize.h"
17 #include "include/core/SkString.h"
18 #include "include/core/SkTypes.h"
19 #include "include/private/base/SkTArray.h"
20 #include "tools/viewer/Slide.h"
21
22 #include <stack>
23 #include <utility>
24
25 class SkCanvas;
26
27 /**
28 * This is a simple utility designed to extract the paths from an SKP file and then isolate a single
29 * one of them via bisect. Use the 'x' and 'X' keys to guide a binary search:
30 *
31 * 'x': Throw out half the paths.
32 * 'X': Toggle which half gets tossed and which half is kept.
33 * 'Z': Back up one level.
34 * 'D': Dump the path.
35 */
36 class BisectSlide : public Slide {
37 public:
38 static sk_sp<BisectSlide> Create(const char filepath[]);
39
40 // Slide overrides.
41 SkISize getDimensions() const override { return fDrawBounds.size(); }
42 bool onChar(SkUnichar c) override;
43 void draw(SkCanvas* canvas) override;
44
45 private:
46 explicit BisectSlide(const char filepath[]);
47
48 struct FoundPath {
49 SkPath fPath;
50 SkPaint fPaint;
51 SkMatrix fViewMatrix;
52 };
53
54 SkString fFilePath;
55 SkIRect fDrawBounds = SkIRect::MakeEmpty();
56 skia_private::TArray<FoundPath> fFoundPaths;
57 skia_private::TArray<FoundPath> fTossedPaths;
58 skia_private::TArray<char> fTrail;
59 std::stack<std::pair<skia_private::TArray<FoundPath>, skia_private::TArray<FoundPath>>>
60 fPathHistory;
61 };
62
63 #endif