2012-08-07 16:12:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef SKDEBUGGER_H_
|
|
|
|
#define SKDEBUGGER_H_
|
|
|
|
|
|
|
|
#include "SkDebugCanvas.h"
|
|
|
|
#include "SkPicture.h"
|
2012-11-19 20:44:29 +00:00
|
|
|
#include "SkTArray.h"
|
2012-08-07 16:12:23 +00:00
|
|
|
|
2013-03-12 13:07:40 +00:00
|
|
|
class SkString;
|
|
|
|
|
2012-08-07 16:12:23 +00:00
|
|
|
class SkDebugger {
|
|
|
|
public:
|
|
|
|
SkDebugger();
|
|
|
|
|
|
|
|
~SkDebugger();
|
|
|
|
|
|
|
|
void setIndex(int index) {
|
|
|
|
fIndex = index;
|
|
|
|
}
|
|
|
|
void draw(SkCanvas* canvas) {
|
2015-01-05 19:51:13 +00:00
|
|
|
if (fIndex >= 0) {
|
2012-08-07 16:12:23 +00:00
|
|
|
fDebugCanvas->drawTo(canvas, fIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void step();
|
|
|
|
void stepBack();
|
|
|
|
void play();
|
|
|
|
void rewind();
|
|
|
|
|
|
|
|
bool isCommandVisible(int index) {
|
|
|
|
return fDebugCanvas->getDrawCommandVisibilityAt(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setCommandVisible(int index, bool isVisible) {
|
|
|
|
fDebugCanvas->toggleCommand(index, isVisible);
|
|
|
|
}
|
|
|
|
|
2014-12-30 15:22:58 +00:00
|
|
|
SkDrawCommand* getDrawCommandAt(int index) {
|
|
|
|
return fDebugCanvas->getDrawCommandAt(index);
|
2014-03-25 23:31:33 +00:00
|
|
|
}
|
|
|
|
|
2012-11-19 20:44:29 +00:00
|
|
|
const SkTDArray<SkDrawCommand*>& getDrawCommands() const {
|
|
|
|
return fDebugCanvas->getDrawCommands();
|
|
|
|
}
|
|
|
|
|
2012-08-07 16:12:23 +00:00
|
|
|
void highlightCurrentCommand(bool on) {
|
|
|
|
fDebugCanvas->toggleFilter(on);
|
|
|
|
}
|
|
|
|
|
|
|
|
void loadPicture(SkPicture* picture);
|
|
|
|
|
2016-03-25 14:04:35 +00:00
|
|
|
sk_sp<SkPicture> copyPicture();
|
2012-08-07 16:12:23 +00:00
|
|
|
|
2014-12-30 15:22:58 +00:00
|
|
|
int getSize() const {
|
2012-08-07 16:12:23 +00:00
|
|
|
return fDebugCanvas->getSize();
|
|
|
|
}
|
|
|
|
|
2013-01-17 16:30:56 +00:00
|
|
|
void setUserMatrix(SkMatrix userMatrix) {
|
2012-08-07 16:12:23 +00:00
|
|
|
// Should this live in debugger instead?
|
2013-01-17 16:30:56 +00:00
|
|
|
fDebugCanvas->setUserMatrix(userMatrix);
|
2012-08-07 16:12:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int getCommandAtPoint(int x, int y, int index) {
|
|
|
|
return fDebugCanvas->getCommandAtPoint(x, y, index);
|
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
const SkTDArray<SkString*>* getCommandInfo(int index) const {
|
2012-08-07 16:12:23 +00:00
|
|
|
return fDebugCanvas->getCommandInfo(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
const SkMatrix& getCurrentMatrix() {
|
|
|
|
return fDebugCanvas->getCurrentMatrix();
|
|
|
|
}
|
|
|
|
|
|
|
|
const SkIRect& getCurrentClip() {
|
|
|
|
return fDebugCanvas->getCurrentClip();
|
|
|
|
}
|
|
|
|
|
2017-10-09 19:45:33 +00:00
|
|
|
SkRect pictureCull() const {
|
2016-11-15 15:03:32 +00:00
|
|
|
return fPicture ? fPicture->cullRect() : SkRect::MakeEmpty();
|
2012-08-07 16:12:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int index() {
|
|
|
|
return fIndex;
|
|
|
|
}
|
|
|
|
|
2013-02-06 20:13:54 +00:00
|
|
|
void setOverdrawViz(bool overDrawViz) {
|
2014-09-05 20:34:00 +00:00
|
|
|
if (fDebugCanvas) {
|
2013-02-06 20:13:54 +00:00
|
|
|
fDebugCanvas->setOverdrawViz(overDrawViz);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-19 13:53:10 +00:00
|
|
|
void setPathOps(bool pathOps) {
|
2014-09-05 20:34:00 +00:00
|
|
|
if (fDebugCanvas) {
|
2014-05-19 13:53:10 +00:00
|
|
|
fDebugCanvas->setAllowSimplifyClip(pathOps);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-03 16:32:17 +00:00
|
|
|
void setMegaViz(bool megaViz) {
|
2014-09-05 20:34:00 +00:00
|
|
|
if (fDebugCanvas) {
|
2014-03-03 16:32:17 +00:00
|
|
|
fDebugCanvas->setMegaVizMode(megaViz);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-16 17:26:13 +00:00
|
|
|
void setTexFilterOverride(bool texFilterOverride, SkFilterQuality quality) {
|
2014-09-05 20:34:00 +00:00
|
|
|
if (fDebugCanvas) {
|
2015-03-16 17:26:13 +00:00
|
|
|
fDebugCanvas->overrideTexFiltering(texFilterOverride, quality);
|
2013-10-17 17:56:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 07:01:04 +00:00
|
|
|
void getOverviewText(const SkTDArray<double>* typeTimes, double totTime,
|
2013-03-12 15:33:40 +00:00
|
|
|
SkString* overview, int numRuns);
|
2013-02-06 20:13:54 +00:00
|
|
|
|
2014-05-19 13:53:10 +00:00
|
|
|
void getClipStackText(SkString* clipStack);
|
|
|
|
|
2012-08-07 16:12:23 +00:00
|
|
|
private:
|
2016-11-15 15:03:32 +00:00
|
|
|
std::unique_ptr<SkDebugCanvas> fDebugCanvas;
|
|
|
|
sk_sp<SkPicture> fPicture;
|
2012-08-07 16:12:23 +00:00
|
|
|
|
|
|
|
int fIndex;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* SKDEBUGGER_H_ */
|