Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
BisectSlide.h
Go to the documentation of this file.
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
13#include "include/core/SkPath.h"
14#include "include/core/SkRect.h"
16#include "include/core/SkSize.h"
20#include "tools/viewer/Slide.h"
21
22#include <stack>
23#include <utility>
24
25class 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 */
36class BisectSlide : public Slide {
37public:
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
45private:
46 BisectSlide(const char filepath[]);
47
48 struct FoundPath {
50 SkPaint fPaint;
52 };
53
54 SkString fFilePath;
55 SkIRect fDrawBounds = SkIRect::MakeEmpty();
59 std::stack<std::pair<skia_private::TArray<FoundPath>, skia_private::TArray<FoundPath>>>
60 fPathHistory;
61};
62
63#endif
SkPath fPath
SkMatrix fViewMatrix
static sk_sp< Effect > Create()
int32_t SkUnichar
Definition SkTypes.h:175
void draw(SkCanvas *canvas) override
SkISize getDimensions() const override
Definition BisectSlide.h:41
bool onChar(SkUnichar c) override
Definition Slide.h:29
constexpr SkISize size() const
Definition SkRect.h:172
static constexpr SkIRect MakeEmpty()
Definition SkRect.h:45