Add a "bisect" mode to dm for debugging path drawing
Bug: skia: Change-Id: Idc841545dfe3d33f43c1c8a3cf23199c322f7b11 Reviewed-on: https://skia-review.googlesource.com/156929 Commit-Queue: Chris Dalton <csmartdalton@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
af1eb6bc6c
commit
184c37e61a
11
dm/DM.cpp
11
dm/DM.cpp
@ -95,6 +95,12 @@ DEFINE_int32(shard, 0, "Which shard do I run?");
|
||||
DEFINE_string(mskps, "", "Directory to read mskps from, or a single mskp file.");
|
||||
DEFINE_bool(forceRasterPipeline, false, "sets gSkForceRasterPipelineBlitter");
|
||||
|
||||
DEFINE_string(bisect, "",
|
||||
"Pair of: SKP file to bisect, followed by an l/r bisect trail string (e.g., 'lrll'). The "
|
||||
"l/r trail specifies which half to keep at each step of a binary search through the SKP's "
|
||||
"paths. An empty string performs no bisect. Only the SkPaths are bisected; all other draws "
|
||||
"are thrown out. This is useful for finding a reduced repo case for path drawing bugs.");
|
||||
|
||||
DEFINE_bool(ignoreSigInt, false, "ignore SIGINT signals during test execution");
|
||||
|
||||
DEFINE_string(dont_write, "", "File extensions to skip writing to --writePath."); // See skia:6821
|
||||
@ -793,6 +799,11 @@ static bool gather_srcs() {
|
||||
#if defined(SK_XML)
|
||||
gather_file_srcs<SVGSrc>(FLAGS_svgs, "svg");
|
||||
#endif
|
||||
if (!FLAGS_bisect.isEmpty()) {
|
||||
// An empty l/r trail string will draw all the paths.
|
||||
push_src("bisect", "",
|
||||
new BisectSrc(FLAGS_bisect[0], FLAGS_bisect.count() > 1 ? FLAGS_bisect[1] : ""));
|
||||
}
|
||||
|
||||
SkTArray<SkString> images;
|
||||
if (!CollectImages(FLAGS_images, &images)) {
|
||||
|
@ -1140,6 +1140,58 @@ Name SKPSrc::name() const { return SkOSPath::Basename(fPath.c_str()); }
|
||||
|
||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||
|
||||
BisectSrc::BisectSrc(Path path, const char* trail) : INHERITED(path), fTrail(trail) {}
|
||||
|
||||
Error BisectSrc::draw(SkCanvas* canvas) const {
|
||||
struct FoundPath {
|
||||
SkPath fPath;
|
||||
SkPaint fPaint;
|
||||
SkMatrix fViewMatrix;
|
||||
};
|
||||
|
||||
// This subclass of SkCanvas just extracts all the SkPaths (drawn via drawPath) from an SKP.
|
||||
class PathFindingCanvas : public SkCanvas {
|
||||
public:
|
||||
PathFindingCanvas(int width, int height) : SkCanvas(width, height, nullptr) {}
|
||||
const SkTArray<FoundPath>& foundPaths() const { return fFoundPaths; }
|
||||
|
||||
private:
|
||||
void onDrawPath(const SkPath& path, const SkPaint& paint) override {
|
||||
fFoundPaths.push_back() = {path, paint, this->getTotalMatrix()};
|
||||
}
|
||||
|
||||
SkTArray<FoundPath> fFoundPaths;
|
||||
};
|
||||
|
||||
PathFindingCanvas pathFinder(canvas->getBaseLayerSize().width(),
|
||||
canvas->getBaseLayerSize().height());
|
||||
Error err = this->INHERITED::draw(&pathFinder);
|
||||
if (!err.isEmpty()) {
|
||||
return err;
|
||||
}
|
||||
|
||||
int start = 0, end = pathFinder.foundPaths().count();
|
||||
for (const char* ch = fTrail.c_str(); *ch; ++ch) {
|
||||
int midpt = (start + end) / 2;
|
||||
if ('l' == *ch) {
|
||||
start = midpt;
|
||||
} else if ('r' == *ch) {
|
||||
end = midpt;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = start; i < end; ++i) {
|
||||
const FoundPath& path = pathFinder.foundPaths()[i];
|
||||
SkAutoCanvasRestore acr(canvas, true);
|
||||
canvas->concat(path.fViewMatrix);
|
||||
canvas->drawPath(path.fPath, path.fPaint);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||
|
||||
#if defined(SK_ENABLE_SKOTTIE)
|
||||
SkottieSrc::SkottieSrc(Path path) : fPath(std::move(path)) {}
|
||||
|
||||
|
@ -248,6 +248,21 @@ private:
|
||||
Path fPath;
|
||||
};
|
||||
|
||||
// This class extracts all the paths from an SKP and then removes unwanted paths according to the
|
||||
// provided l/r trail. It then just draws the remaining paths. (Non-path draws are thrown out.) It
|
||||
// is useful for finding a reduced repo case for path drawing bugs.
|
||||
class BisectSrc : public SKPSrc {
|
||||
public:
|
||||
explicit BisectSrc(Path path, const char* trail);
|
||||
|
||||
Error draw(SkCanvas*) const override;
|
||||
|
||||
private:
|
||||
SkString fTrail;
|
||||
|
||||
typedef SKPSrc INHERITED;
|
||||
};
|
||||
|
||||
|
||||
#if defined(SK_ENABLE_SKOTTIE)
|
||||
class SkottieSrc final : public Src {
|
||||
|
Loading…
Reference in New Issue
Block a user