Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
BisectSlide Class Reference

#include <BisectSlide.h>

Inheritance diagram for BisectSlide:
Slide SkRefCnt SkRefCntBase

Public Member Functions

SkISize getDimensions () const override
 
bool onChar (SkUnichar c) override
 
void draw (SkCanvas *canvas) override
 
- Public Member Functions inherited from Slide
virtual void gpuTeardown ()
 
virtual bool animate (double nanos)
 
virtual void load (SkScalar winWidth, SkScalar winHeight)
 
virtual void resize (SkScalar winWidth, SkScalar winHeight)
 
virtual void unload ()
 
virtual bool onMouse (SkScalar x, SkScalar y, skui::InputState state, skui::ModifierKey modifiers)
 
virtual bool onGetControls (SkMetaData *)
 
virtual void onSetControls (const SkMetaData &)
 
const SkStringgetName ()
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static sk_sp< BisectSlideCreate (const char filepath[])
 

Additional Inherited Members

- Protected Attributes inherited from Slide
SkString fName
 

Detailed Description

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.

Definition at line 36 of file BisectSlide.h.

Member Function Documentation

◆ Create()

sk_sp< BisectSlide > BisectSlide::Create ( const char  filepath[])
static

Definition at line 20 of file BisectSlide.cpp.

20 {
21 SkFILEStream stream(filepath);
22 if (!stream.isValid()) {
23 SkDebugf("BISECT: invalid input file at \"%s\"\n", filepath);
24 return nullptr;
25 }
26
27 sk_sp<BisectSlide> bisect(new BisectSlide(filepath));
28 ToolUtils::ExtractPathsFromSKP(filepath, [&](const SkMatrix& matrix,
29 const SkPath& path,
30 const SkPaint& paint) {
32 SkIRect ibounds;
33 matrix.mapRect(&bounds, path.getBounds());
34 bounds.roundOut(&ibounds);
35 bisect->fDrawBounds.join(ibounds);
36 bisect->fFoundPaths.push_back() = {path, paint, matrix};
37 });
38 return bisect;
39}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
const Paint & paint
unsigned useCenter Optional< SkMatrix > matrix
Definition SkRecords.h:258
Optional< SkRect > bounds
Definition SkRecords.h:189
void ExtractPathsFromSKP(const char filepath[], std::function< PathSniffCallback > callback)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57

◆ draw()

void BisectSlide::draw ( SkCanvas canvas)
overridevirtual

Implements Slide.

Definition at line 103 of file BisectSlide.cpp.

103 {
104 SkAutoCanvasRestore acr(canvas, true);
105 canvas->translate(-fDrawBounds.left(), -fDrawBounds.top());
106
107 for (const FoundPath& path : fFoundPaths) {
108 SkAutoCanvasRestore acr2(canvas, true);
109 canvas->concat(path.fViewMatrix);
110 canvas->drawPath(path.fPath, path.fPaint);
111 }
112}
void translate(SkScalar dx, SkScalar dy)
void drawPath(const SkPath &path, const SkPaint &paint)
void concat(const SkMatrix &matrix)
constexpr int32_t top() const
Definition SkRect.h:120
constexpr int32_t left() const
Definition SkRect.h:113

◆ getDimensions()

SkISize BisectSlide::getDimensions ( ) const
inlineoverridevirtual

A slide may have a content dimensions that is independent of the current window size. An empty size indicates that the Slide's dimensions are equal to the window's dimensions.

Reimplemented from Slide.

Definition at line 41 of file BisectSlide.h.

41{ return fDrawBounds.size(); }
constexpr SkISize size() const
Definition SkRect.h:172

◆ onChar()

bool BisectSlide::onChar ( SkUnichar  c)
overridevirtual

Reimplemented from Slide.

Definition at line 47 of file BisectSlide.cpp.

47 {
48 switch (c) {
49 case 'X':
50 if (!fTossedPaths.empty()) {
51 using std::swap;
52 swap(fFoundPaths, fTossedPaths);
53 if ('X' == fTrail.back()) {
54 fTrail.pop_back();
55 } else {
56 fTrail.push_back('X');
57 }
58 }
59 return true;
60
61 case 'x':
62 if (fFoundPaths.size() > 1) {
63 int midpt = (fFoundPaths.size() + 1) / 2;
64 fPathHistory.emplace(fFoundPaths, fTossedPaths);
65 fTossedPaths.reset(fFoundPaths.begin() + midpt, fFoundPaths.size() - midpt);
66 fFoundPaths.resize_back(midpt);
67 fTrail.push_back('x');
68 }
69 return true;
70
71 case 'Z': {
72 if (!fPathHistory.empty()) {
73 fFoundPaths = fPathHistory.top().first;
74 fTossedPaths = fPathHistory.top().second;
75 fPathHistory.pop();
76 char ch;
77 do {
78 ch = fTrail.back();
79 fTrail.pop_back();
80 } while (ch != 'x');
81 }
82 return true;
83 }
84
85 case 'D':
86 SkDebugf("viewer --bisect %s", fFilePath.c_str());
87 if (!fTrail.empty()) {
88 SkDebugf(" ");
89 for (char ch : fTrail) {
90 SkDebugf("%c", ch);
91 }
92 }
93 SkDebugf("\n");
94 for (const FoundPath& foundPath : fFoundPaths) {
95 foundPath.fPath.dump();
96 }
97 return true;
98 }
99
100 return false;
101}
void swap(sk_sp< T > &a, sk_sp< T > &b)
Definition SkRefCnt.h:341
const char * c_str() const
Definition SkString.h:133
bool empty() const
Definition SkTArray.h:194
void resize_back(int newCount)
Definition SkTArray.h:338
void reset(int n)
Definition SkTArray.h:139
int size() const
Definition SkTArray.h:416

The documentation for this class was generated from the following files: