Remove code that was only used by the old debugger

Change-Id: I1035d9fa5f9888f3b6c332b16a0bde69f357a4a8
Reviewed-on: https://skia-review.googlesource.com/119144
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2018-04-06 14:51:42 -04:00 committed by Skia Commit-Bot
parent 42f02aa4e3
commit 255735e53b
9 changed files with 12 additions and 1196 deletions

View File

@ -1290,7 +1290,6 @@ if (skia_enable_tools) {
"tools/debugger/SkDebugCanvas.cpp",
"tools/debugger/SkDrawCommand.cpp",
"tools/debugger/SkJsonWriteBuffer.cpp",
"tools/debugger/SkObjectParser.cpp",
"tools/fonts/SkRandomScalerContext.cpp",
"tools/fonts/SkTestFontMgr.cpp",
"tools/fonts/SkTestFontMgr.h",
@ -1783,7 +1782,6 @@ if (skia_enable_tools) {
"tools/debugger/SkDebugCanvas.cpp",
"tools/debugger/SkDrawCommand.cpp",
"tools/debugger/SkJsonWriteBuffer.cpp",
"tools/debugger/SkObjectParser.cpp",
"tools/picture_utils.cpp",
]
deps = [
@ -2117,7 +2115,6 @@ if (skia_enable_tools) {
"tools/debugger/SkDebugCanvas.cpp",
"tools/debugger/SkDrawCommand.cpp",
"tools/debugger/SkJsonWriteBuffer.cpp",
"tools/debugger/SkObjectParser.cpp",
"tools/mdbviz/MainWindow.cpp",
"tools/mdbviz/Model.cpp",
"tools/mdbviz/main.cpp",

View File

@ -6,10 +6,10 @@
*/
#include "SkCanvasPriv.h"
#include "SkClipStack.h"
#include "SkDebugCanvas.h"
#include "SkDrawCommand.h"
#include "SkPaintFilterCanvas.h"
#include "SkPicture.h"
#include "SkRectPriv.h"
#include "SkTextBlob.h"
#include "SkClipOpPriv.h"
@ -28,13 +28,9 @@
class DebugPaintFilterCanvas : public SkPaintFilterCanvas {
public:
DebugPaintFilterCanvas(SkCanvas* canvas,
bool overdrawViz,
bool overrideFilterQuality,
SkFilterQuality quality)
bool overdrawViz)
: INHERITED(canvas)
, fOverdrawViz(overdrawViz)
, fOverrideFilterQuality(overrideFilterQuality)
, fFilterQuality(quality) {}
, fOverdrawViz(overdrawViz) {}
protected:
bool onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type) const override {
@ -44,10 +40,6 @@ protected:
paint->writable()->setAlpha(0x08);
paint->writable()->setBlendMode(SkBlendMode::kSrcOver);
}
if (fOverrideFilterQuality) {
paint->writable()->setFilterQuality(fFilterQuality);
}
}
return true;
}
@ -61,24 +53,15 @@ protected:
private:
bool fOverdrawViz;
bool fOverrideFilterQuality;
SkFilterQuality fFilterQuality;
typedef SkPaintFilterCanvas INHERITED;
};
SkDebugCanvas::SkDebugCanvas(int width, int height)
: INHERITED(width, height)
, fPicture(nullptr)
, fFilter(false)
, fMegaVizMode(false)
, fOverdrawViz(false)
, fOverrideFilterQuality(false)
, fFilterQuality(kNone_SkFilterQuality)
, fClipVizColor(SK_ColorTRANSPARENT)
, fDrawGpuOpBounds(false) {
fUserMatrix.reset();
// SkPicturePlayback uses the base-class' quickReject calls to cull clipped
// operations. This can lead to problems in the debugger which expects all
// the operations in the captured skp to appear in the debug canvas. To
@ -112,57 +95,6 @@ void SkDebugCanvas::draw(SkCanvas* canvas) {
}
}
void SkDebugCanvas::applyUserTransform(SkCanvas* canvas) {
canvas->concat(fUserMatrix);
}
int SkDebugCanvas::getCommandAtPoint(int x, int y, int index) {
SkBitmap bitmap;
bitmap.allocPixels(SkImageInfo::MakeN32Premul(1, 1));
SkCanvas canvas(bitmap);
canvas.translate(SkIntToScalar(-x), SkIntToScalar(-y));
this->applyUserTransform(&canvas);
int layer = 0;
SkColor prev = bitmap.getColor(0,0);
for (int i = 0; i < index; i++) {
if (fCommandVector[i]->isVisible()) {
fCommandVector[i]->setUserMatrix(fUserMatrix);
fCommandVector[i]->execute(&canvas);
}
if (prev != bitmap.getColor(0,0)) {
layer = i;
}
prev = bitmap.getColor(0,0);
}
return layer;
}
// set up the saveLayer commands so that the active ones
// return true in their 'active' method
void SkDebugCanvas::markActiveCommands(int index) {
fActiveLayers.rewind();
for (int i = 0; i < fCommandVector.count(); ++i) {
fCommandVector[i]->setActive(false);
}
for (int i = 0; i < index; ++i) {
SkDrawCommand::Action result = fCommandVector[i]->action();
if (SkDrawCommand::kPushLayer_Action == result) {
fActiveLayers.push(fCommandVector[i]);
} else if (SkDrawCommand::kPopLayer_Action == result) {
fActiveLayers.pop();
}
}
for (int i = 0; i < fActiveLayers.count(); ++i) {
fActiveLayers[i]->setActive(true);
}
}
void SkDebugCanvas::drawTo(SkCanvas* originalCanvas, int index, int m) {
SkASSERT(!fCommandVector.isEmpty());
SkASSERT(index < fCommandVector.count());
@ -172,21 +104,13 @@ void SkDebugCanvas::drawTo(SkCanvas* originalCanvas, int index, int m) {
SkRect windowRect = SkRect::MakeWH(SkIntToScalar(originalCanvas->getBaseLayerSize().width()),
SkIntToScalar(originalCanvas->getBaseLayerSize().height()));
bool pathOpsMode = getAllowSimplifyClip();
originalCanvas->setAllowSimplifyClip(pathOpsMode);
originalCanvas->clear(SK_ColorWHITE);
originalCanvas->resetMatrix();
if (!windowRect.isEmpty()) {
originalCanvas->clipRect(windowRect, kReplace_SkClipOp);
}
this->applyUserTransform(originalCanvas);
DebugPaintFilterCanvas filterCanvas(originalCanvas, fOverdrawViz, fOverrideFilterQuality,
fFilterQuality);
if (fMegaVizMode) {
this->markActiveCommands(index);
}
DebugPaintFilterCanvas filterCanvas(originalCanvas, fOverdrawViz);
#if SK_SUPPORT_GPU
// If we have a GPU backend we can also visualize the op information
@ -198,10 +122,6 @@ void SkDebugCanvas::drawTo(SkCanvas* originalCanvas, int index, int m) {
#endif
for (int i = 0; i <= index; i++) {
if (i == index && fFilter) {
filterCanvas.clear(0xAAFFFFFF);
}
#if SK_SUPPORT_GPU
// We need to flush any pending operations, or they might combine with commands below.
// Previous operations were not registered with the audit trail when they were
@ -215,16 +135,7 @@ void SkDebugCanvas::drawTo(SkCanvas* originalCanvas, int index, int m) {
#endif
if (fCommandVector[i]->isVisible()) {
if (fMegaVizMode && fCommandVector[i]->active()) {
// "active" commands execute their visualization behaviors:
// All active saveLayers get replaced with saves so all draws go to the
// visible canvas.
// All active culls draw their cull box
fCommandVector[i]->vizExecute(&filterCanvas);
} else {
fCommandVector[i]->setUserMatrix(fUserMatrix);
fCommandVector[i]->execute(&filterCanvas);
}
fCommandVector[i]->execute(&filterCanvas);
}
#if SK_SUPPORT_GPU
if (at && acb) {
@ -245,28 +156,6 @@ void SkDebugCanvas::drawTo(SkCanvas* originalCanvas, int index, int m) {
filterCanvas.restore();
}
if (pathOpsMode) {
this->resetClipStackData();
const SkClipStack* clipStack = nullptr;//HACK filterCanvas.getClipStack();
SkClipStack::Iter iter(*clipStack, SkClipStack::Iter::kBottom_IterStart);
const SkClipStack::Element* element;
SkPath devPath;
while ((element = iter.next())) {
SkClipStack::Element::DeviceSpaceType type = element->getDeviceSpaceType();
SkPath operand;
if (type != SkClipStack::Element::DeviceSpaceType::kEmpty) {
element->asDeviceSpacePath(&operand);
}
SkClipOp elementOp = element->getOp();
this->addClipStackData(devPath, operand, elementOp);
if (elementOp == kReplace_SkClipOp) {
devPath = operand;
} else {
Op(devPath, operand, (SkPathOp) elementOp, &devPath);
}
}
this->lastClipStackData(devPath);
}
fMatrix = filterCanvas.getTotalMatrix();
fClip = filterCanvas.getDeviceClipBounds();
filterCanvas.restoreToCount(saveCount);
@ -334,30 +223,6 @@ SkDrawCommand* SkDebugCanvas::getDrawCommandAt(int index) {
return fCommandVector[index];
}
void SkDebugCanvas::setDrawCommandAt(int index, SkDrawCommand* command) {
SkASSERT(index < fCommandVector.count());
delete fCommandVector[index];
fCommandVector[index] = command;
}
const SkTDArray<SkString*>* SkDebugCanvas::getCommandInfo(int index) const {
SkASSERT(index < fCommandVector.count());
return fCommandVector[index]->Info();
}
bool SkDebugCanvas::getDrawCommandVisibilityAt(int index) {
SkASSERT(index < fCommandVector.count());
return fCommandVector[index]->isVisible();
}
const SkTDArray <SkDrawCommand*>& SkDebugCanvas::getDrawCommands() const {
return fCommandVector;
}
SkTDArray <SkDrawCommand*>& SkDebugCanvas::getDrawCommands() {
return fCommandVector;
}
GrAuditTrail* SkDebugCanvas::getAuditTrail(SkCanvas* canvas) {
GrAuditTrail* at = nullptr;
#if SK_SUPPORT_GPU
@ -448,11 +313,6 @@ void SkDebugCanvas::setOverdrawViz(bool overdrawViz) {
fOverdrawViz = overdrawViz;
}
void SkDebugCanvas::overrideTexFiltering(bool overrideTexFiltering, SkFilterQuality quality) {
fOverrideFilterQuality = overrideTexFiltering;
fFilterQuality = quality;
}
void SkDebugCanvas::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle) {
this->addDrawCommand(new SkClipPathCommand(path, op, kSoft_ClipEdgeStyle == edgeStyle));
}
@ -634,128 +494,3 @@ void SkDebugCanvas::toggleCommand(int index, bool toggle) {
SkASSERT(index < fCommandVector.count());
fCommandVector[index]->setVisible(toggle);
}
static const char* gFillTypeStrs[] = {
"kWinding_FillType",
"kEvenOdd_FillType",
"kInverseWinding_FillType",
"kInverseEvenOdd_FillType"
};
static const char* gOpStrs[] = {
"kDifference_PathOp",
"kIntersect_PathOp",
"kUnion_PathOp",
"kXor_PathOp",
"kReverseDifference_PathOp",
};
static const char kHTML4SpaceIndent[] = "&nbsp;&nbsp;&nbsp;&nbsp;";
void SkDebugCanvas::outputScalar(SkScalar num) {
if (num == (int) num) {
fClipStackData.appendf("%d", (int) num);
} else {
SkString str;
str.printf("%1.9g", num);
int width = (int) str.size();
const char* cStr = str.c_str();
while (cStr[width - 1] == '0') {
--width;
}
str.resize(width);
fClipStackData.appendf("%sf", str.c_str());
}
}
void SkDebugCanvas::outputPointsCommon(const SkPoint* pts, int count) {
for (int index = 0; index < count; ++index) {
this->outputScalar(pts[index].fX);
fClipStackData.appendf(", ");
this->outputScalar(pts[index].fY);
if (index + 1 < count) {
fClipStackData.appendf(", ");
}
}
}
void SkDebugCanvas::outputPoints(const SkPoint* pts, int count) {
this->outputPointsCommon(pts, count);
fClipStackData.appendf(");<br>");
}
void SkDebugCanvas::outputConicPoints(const SkPoint* pts, SkScalar weight) {
this->outputPointsCommon(pts, 2);
fClipStackData.appendf(", ");
this->outputScalar(weight);
fClipStackData.appendf(");<br>");
}
void SkDebugCanvas::addPathData(const SkPath& path, const char* pathName) {
SkPath::RawIter iter(path);
SkPath::FillType fillType = path.getFillType();
fClipStackData.appendf("%sSkPath %s;<br>", kHTML4SpaceIndent, pathName);
fClipStackData.appendf("%s%s.setFillType(SkPath::%s);<br>", kHTML4SpaceIndent, pathName,
gFillTypeStrs[fillType]);
iter.setPath(path);
uint8_t verb;
SkPoint pts[4];
while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
switch (verb) {
case SkPath::kMove_Verb:
fClipStackData.appendf("%s%s.moveTo(", kHTML4SpaceIndent, pathName);
this->outputPoints(&pts[0], 1);
continue;
case SkPath::kLine_Verb:
fClipStackData.appendf("%s%s.lineTo(", kHTML4SpaceIndent, pathName);
this->outputPoints(&pts[1], 1);
break;
case SkPath::kQuad_Verb:
fClipStackData.appendf("%s%s.quadTo(", kHTML4SpaceIndent, pathName);
this->outputPoints(&pts[1], 2);
break;
case SkPath::kConic_Verb:
fClipStackData.appendf("%s%s.conicTo(", kHTML4SpaceIndent, pathName);
this->outputConicPoints(&pts[1], iter.conicWeight());
break;
case SkPath::kCubic_Verb:
fClipStackData.appendf("%s%s.cubicTo(", kHTML4SpaceIndent, pathName);
this->outputPoints(&pts[1], 3);
break;
case SkPath::kClose_Verb:
fClipStackData.appendf("%s%s.close();<br>", kHTML4SpaceIndent, pathName);
break;
default:
SkDEBUGFAIL("bad verb");
return;
}
}
}
void SkDebugCanvas::addClipStackData(const SkPath& devPath, const SkPath& operand,
SkClipOp elementOp) {
if (elementOp == kReplace_SkClipOp) {
if (!lastClipStackData(devPath)) {
fSaveDevPath = operand;
}
fCalledAddStackData = false;
} else {
fClipStackData.appendf("<br>static void test(skiatest::Reporter* reporter,"
" const char* filename) {<br>");
addPathData(fCalledAddStackData ? devPath : fSaveDevPath, "path");
addPathData(operand, "pathB");
fClipStackData.appendf("%stestPathOp(reporter, path, pathB, %s, filename);<br>",
kHTML4SpaceIndent, gOpStrs[static_cast<int>(elementOp)]);
fClipStackData.appendf("}<br>");
fCalledAddStackData = true;
}
}
bool SkDebugCanvas::lastClipStackData(const SkPath& devPath) {
if (fCalledAddStackData) {
fClipStackData.appendf("<br>");
addPathData(devPath, "pathOut");
return true;
}
return false;
}

View File

@ -13,7 +13,6 @@
#include "SkDrawCommand.h"
#include "SkPath.h"
#include "SkPathOps.h"
#include "SkPicture.h"
#include "SkString.h"
#include "SkTArray.h"
#include "SkVertices.h"
@ -21,6 +20,7 @@
class GrAuditTrail;
class SkNWayCanvas;
class SkPicture;
class SkDebugCanvas : public SkCanvas {
public:
@ -28,12 +28,6 @@ public:
~SkDebugCanvas() override;
void toggleFilter(bool toggle) { fFilter = toggle; }
void setMegaVizMode(bool megaVizMode) { fMegaVizMode = megaVizMode; }
bool getMegaVizMode() const { return fMegaVizMode; }
/**
* Enable or disable overdraw visualization
*/
@ -46,21 +40,10 @@ public:
*/
void setClipVizColor(SkColor clipVizColor) { this->fClipVizColor = clipVizColor; }
SkColor getClipVizColor() const { return fClipVizColor; }
void setDrawGpuOpBounds(bool drawGpuOpBounds) { fDrawGpuOpBounds = drawGpuOpBounds; }
bool getDrawGpuOpBounds() const { return fDrawGpuOpBounds; }
bool getAllowSimplifyClip() const { return fAllowSimplifyClip; }
void setPicture(SkPicture *picture) { fPicture = picture; }
/**
* Enable or disable texure filtering override
*/
void overrideTexFiltering(bool overrideTexFiltering, SkFilterQuality);
/**
Executes all draw calls to the canvas.
@param canvas The canvas being drawn to
@ -89,11 +72,6 @@ public:
return fClip;
}
/**
Returns the index of the last draw command to write to the pixel at (x,y)
*/
int getCommandAtPoint(int x, int y, int index);
/**
Removes the command at the specified index
@param index The index of the command to delete
@ -106,37 +84,6 @@ public:
*/
SkDrawCommand *getDrawCommandAt(int index);
/**
Sets the draw command for a given index.
@param index The index to overwrite
@param command The new command
*/
void setDrawCommandAt(int index, SkDrawCommand *command);
/**
Returns information about the command at the given index.
@param index The index of the command
*/
const SkTDArray<SkString *> *getCommandInfo(int index) const;
/**
Returns the visibility of the command at the given index.
@param index The index of the command
*/
bool getDrawCommandVisibilityAt(int index);
/**
Returns the vector of draw commands
*/
SK_ATTR_DEPRECATED("please use getDrawCommandAt and getSize instead")
const SkTDArray<SkDrawCommand *> &getDrawCommands() const;
/**
Returns the vector of draw commands. Do not use this entry
point - it is going away!
*/
SkTDArray<SkDrawCommand *> &getDrawCommands();
/**
Returns length of draw command vector.
*/
@ -150,12 +97,6 @@ public:
*/
void toggleCommand(int index, bool toggle);
void setUserMatrix(SkMatrix matrix) {
fUserMatrix = matrix;
}
SkString clipStackData() const { return fClipStackData; }
/**
Returns a JSON object representing up to the Nth draw, where N is less than
SkDebugCanvas::getSize(). The encoder may use the UrlDataManager to store binary data such
@ -226,55 +167,21 @@ protected:
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
void markActiveCommands(int index);
private:
SkTDArray<SkDrawCommand*> fCommandVector;
SkPicture* fPicture;
bool fFilter;
bool fMegaVizMode;
SkMatrix fUserMatrix;
SkMatrix fMatrix;
SkIRect fClip;
SkString fClipStackData;
bool fCalledAddStackData;
SkPath fSaveDevPath;
bool fOverdrawViz;
bool fOverrideFilterQuality;
SkFilterQuality fFilterQuality;
SkColor fClipVizColor;
bool fDrawGpuOpBounds;
/**
The active saveLayer commands at a given point in the renderering.
Only used when "mega" visualization is enabled.
*/
SkTDArray<SkDrawCommand*> fActiveLayers;
/**
Adds the command to the class' vector of commands.
@param command The draw command for execution
*/
void addDrawCommand(SkDrawCommand* command);
/**
Applies any panning and zooming the user has specified before
drawing anything else into the canvas.
*/
void applyUserTransform(SkCanvas* canvas);
void resetClipStackData() { fClipStackData.reset(); fCalledAddStackData = false; }
void addClipStackData(const SkPath& devPath, const SkPath& operand, SkClipOp elementOp);
void addPathData(const SkPath& path, const char* pathName);
bool lastClipStackData(const SkPath& devPath);
void outputConicPoints(const SkPoint* pts, SkScalar weight);
void outputPoints(const SkPoint* pts, int count);
void outputPointsCommon(const SkPoint* pts, int count);
void outputScalar(SkScalar num);
GrAuditTrail* getAuditTrail(SkCanvas*);
void drawAndCollectOps(int n, SkCanvas*);

View File

@ -15,7 +15,6 @@
#include "SkImageFilter.h"
#include "SkJsonWriteBuffer.h"
#include "SkMaskFilterBase.h"
#include "SkObjectParser.h"
#include "SkPaintDefaults.h"
#include "SkPathEffect.h"
#include "SkPicture.h"
@ -206,10 +205,6 @@ SkDrawCommand::SkDrawCommand(OpType type)
, fVisible(true) {
}
SkDrawCommand::~SkDrawCommand() {
fInfo.deleteAll();
}
const char* SkDrawCommand::GetCommandString(OpType type) {
switch (type) {
case kBeginDrawPicture_OpType: return "BeginDrawPicture";
@ -258,10 +253,6 @@ const char* SkDrawCommand::GetCommandString(OpType type) {
return nullptr;
}
SkString SkDrawCommand::toString() const {
return SkString(GetCommandString(fOpType));
}
Json::Value SkDrawCommand::toJSON(UrlDataManager& urlDataManager) const {
Json::Value result;
result[SKDEBUGCANVAS_ATTRIBUTE_COMMAND] = this->GetCommandString(fOpType);
@ -1789,7 +1780,6 @@ SkClipOp get_json_clipop(Json::Value& jsonOp) {
SkClearCommand::SkClearCommand(SkColor color) : INHERITED(kClear_OpType) {
fColor = color;
fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
}
void SkClearCommand::execute(SkCanvas* canvas) const {
@ -1812,10 +1802,6 @@ SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkClipOp op, bool doAA)
fPath = path;
fOp = op;
fDoAA = doAA;
fInfo.push(SkObjectParser::PathToString(path));
fInfo.push(SkObjectParser::ClipOpToString(op));
fInfo.push(SkObjectParser::BoolToString(doAA));
}
void SkClipPathCommand::execute(SkCanvas* canvas) const {
@ -1847,9 +1833,6 @@ SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkClipOp op)
: INHERITED(kClipRegion_OpType) {
fRegion = region;
fOp = op;
fInfo.push(SkObjectParser::RegionToString(region));
fInfo.push(SkObjectParser::ClipOpToString(op));
}
void SkClipRegionCommand::execute(SkCanvas* canvas) const {
@ -1876,10 +1859,6 @@ SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkClipOp op, bool doAA)
fRect = rect;
fOp = op;
fDoAA = doAA;
fInfo.push(SkObjectParser::RectToString(rect));
fInfo.push(SkObjectParser::ClipOpToString(op));
fInfo.push(SkObjectParser::BoolToString(doAA));
}
void SkClipRectCommand::execute(SkCanvas* canvas) const {
@ -1911,10 +1890,6 @@ SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkClipOp op, bool d
fRRect = rrect;
fOp = op;
fDoAA = doAA;
fInfo.push(SkObjectParser::RRectToString(rrect));
fInfo.push(SkObjectParser::ClipOpToString(op));
fInfo.push(SkObjectParser::BoolToString(doAA));
}
void SkClipRRectCommand::execute(SkCanvas* canvas) const {
@ -1946,8 +1921,6 @@ SkClipRRectCommand* SkClipRRectCommand::fromJSON(Json::Value& command,
SkConcatCommand::SkConcatCommand(const SkMatrix& matrix)
: INHERITED(kConcat_OpType) {
fMatrix = matrix;
fInfo.push(SkObjectParser::MatrixToString(matrix));
}
void SkConcatCommand::execute(SkCanvas* canvas) const {
@ -1975,15 +1948,6 @@ SkDrawAnnotationCommand::SkDrawAnnotationCommand(const SkRect& rect, const char
, fKey(key)
, fValue(std::move(value))
{
SkString str;
str.appendf("Key: %s Value: ", key);
if (fValue && fValue->size()) {
str.append((const char*) fValue->bytes(), fValue->size());
} else {
str.appendf("no value");
}
str.appendf("\n");
fInfo.push(new SkString(str));
}
void SkDrawAnnotationCommand::execute(SkCanvas* canvas) const {
@ -2028,13 +1992,6 @@ SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left,
} else {
fPaintPtr = nullptr;
}
fInfo.push(SkObjectParser::BitmapToString(bitmap));
fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: "));
fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: "));
if (paint) {
fInfo.push(SkObjectParser::PaintToString(*paint));
}
}
void SkDrawBitmapCommand::execute(SkCanvas* canvas) const {
@ -2094,13 +2051,6 @@ SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const S
} else {
fPaintPtr = nullptr;
}
fInfo.push(SkObjectParser::BitmapToString(bitmap));
fInfo.push(SkObjectParser::IRectToString(center));
fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
if (paint) {
fInfo.push(SkObjectParser::PaintToString(*paint));
}
}
void SkDrawBitmapNineCommand::execute(SkCanvas* canvas) const {
@ -2170,16 +2120,6 @@ SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const S
fPaintPtr = nullptr;
}
fConstraint = constraint;
fInfo.push(SkObjectParser::BitmapToString(bitmap));
if (src) {
fInfo.push(SkObjectParser::RectToString(*src, "Src: "));
}
fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
if (paint) {
fInfo.push(SkObjectParser::PaintToString(*paint));
}
fInfo.push(SkObjectParser::IntToString(fConstraint, "Constraint: "));
}
void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) const {
@ -2261,13 +2201,8 @@ SkDrawImageCommand::SkDrawImageCommand(const SkImage* image, SkScalar left, SkSc
, fLeft(left)
, fTop(top) {
fInfo.push(SkObjectParser::ImageToString(image));
fInfo.push(SkObjectParser::ScalarToString(left, "Left: "));
fInfo.push(SkObjectParser::ScalarToString(top, "Top: "));
if (paint) {
fPaint.set(*paint);
fInfo.push(SkObjectParser::PaintToString(*paint));
}
}
@ -2346,12 +2281,8 @@ SkDrawImageLatticeCommand::SkDrawImageLatticeCommand(const SkImage* image,
, fLattice(lattice)
, fDst(dst) {
fInfo.push(SkObjectParser::ImageToString(image));
fInfo.push(SkObjectParser::LatticeToString(lattice));
fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
if (paint) {
fPaint.set(*paint);
fInfo.push(SkObjectParser::PaintToString(*paint));
}
}
@ -2413,16 +2344,6 @@ SkDrawImageRectCommand::SkDrawImageRectCommand(const SkImage* image, const SkRec
if (paint) {
fPaint.set(*paint);
}
fInfo.push(SkObjectParser::ImageToString(image));
if (src) {
fInfo.push(SkObjectParser::RectToString(*src, "Src: "));
}
fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
if (paint) {
fInfo.push(SkObjectParser::PaintToString(*paint));
}
fInfo.push(SkObjectParser::IntToString(fConstraint, "Constraint: "));
}
void SkDrawImageRectCommand::execute(SkCanvas* canvas) const {
@ -2514,13 +2435,6 @@ SkDrawImageNineCommand::SkDrawImageNineCommand(const SkImage* image, const SkIRe
} else {
fPaintPtr = nullptr;
}
fInfo.push(SkObjectParser::ImageToString(image));
fInfo.push(SkObjectParser::IRectToString(center));
fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
if (paint) {
fInfo.push(SkObjectParser::PaintToString(*paint));
}
}
void SkDrawImageNineCommand::execute(SkCanvas* canvas) const {
@ -2577,9 +2491,6 @@ SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint)
: INHERITED(kDrawOval_OpType) {
fOval = oval;
fPaint = paint;
fInfo.push(SkObjectParser::RectToString(oval));
fInfo.push(SkObjectParser::PaintToString(paint));
}
void SkDrawOvalCommand::execute(SkCanvas* canvas) const {
@ -2626,12 +2537,6 @@ SkDrawArcCommand::SkDrawArcCommand(const SkRect& oval, SkScalar startAngle, SkSc
fSweepAngle = sweepAngle;
fUseCenter = useCenter;
fPaint = paint;
fInfo.push(SkObjectParser::RectToString(oval));
fInfo.push(SkObjectParser::ScalarToString(startAngle, "StartAngle: "));
fInfo.push(SkObjectParser::ScalarToString(sweepAngle, "SweepAngle: "));
fInfo.push(SkObjectParser::BoolToString(useCenter));
fInfo.push(SkObjectParser::PaintToString(paint));
}
void SkDrawArcCommand::execute(SkCanvas* canvas) const {
@ -2679,8 +2584,6 @@ SkDrawArcCommand* SkDrawArcCommand::fromJSON(Json::Value& command,
SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint)
: INHERITED(kDrawPaint_OpType) {
fPaint = paint;
fInfo.push(SkObjectParser::PaintToString(paint));
}
void SkDrawPaintCommand::execute(SkCanvas* canvas) const {
@ -2710,9 +2613,6 @@ SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint)
: INHERITED(kDrawPath_OpType) {
fPath = path;
fPaint = paint;
fInfo.push(SkObjectParser::PathToString(path));
fInfo.push(SkObjectParser::PaintToString(paint));
}
void SkDrawPathCommand::execute(SkCanvas* canvas) const {
@ -2744,9 +2644,6 @@ SkDrawRegionCommand::SkDrawRegionCommand(const SkRegion& region, const SkPaint&
: INHERITED(kDrawRegion_OpType) {
fRegion = region;
fPaint = paint;
fInfo.push(SkObjectParser::RegionToString(region));
fInfo.push(SkObjectParser::PaintToString(paint));
}
void SkDrawRegionCommand::execute(SkCanvas* canvas) const {
@ -2779,23 +2676,13 @@ SkBeginDrawPictureCommand::SkBeginDrawPictureCommand(const SkPicture* picture,
const SkPaint* paint)
: INHERITED(kBeginDrawPicture_OpType)
, fPicture(SkRef(picture)) {
SkString* str = new SkString;
str->appendf("SkPicture: L: %f T: %f R: %f B: %f",
picture->cullRect().fLeft, picture->cullRect().fTop,
picture->cullRect().fRight, picture->cullRect().fBottom);
fInfo.push(str);
if (matrix) {
fMatrix.set(*matrix);
fInfo.push(SkObjectParser::MatrixToString(*matrix));
}
if (paint) {
fPaint.set(*paint);
fInfo.push(SkObjectParser::PaintToString(*paint));
}
}
void SkBeginDrawPictureCommand::execute(SkCanvas* canvas) const {
@ -2845,12 +2732,6 @@ SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count,
fPts = new SkPoint[count];
memcpy(fPts, pts, count * sizeof(SkPoint));
fPaint = paint;
fInfo.push(SkObjectParser::PointsToString(pts, count));
fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count),
"Points: "));
fInfo.push(SkObjectParser::PointModeToString(mode));
fInfo.push(SkObjectParser::PaintToString(paint));
}
void SkDrawPointsCommand::execute(SkCanvas* canvas) const {
@ -2935,11 +2816,6 @@ SkDrawPosTextCommand::SkDrawPosTextCommand(const void* text, size_t byteLength,
memcpy(fPos, pos, numPts * sizeof(SkPoint));
fPaint = paint;
fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
// TODO(chudy): Test that this works.
fInfo.push(SkObjectParser::PointsToString(pos, 1));
fInfo.push(SkObjectParser::PaintToString(paint));
}
void SkDrawPosTextCommand::execute(SkCanvas* canvas) const {
@ -2989,11 +2865,6 @@ SkDrawPosTextHCommand::SkDrawPosTextHCommand(const void* text, size_t byteLength
fConstY = constY;
fPaint = paint;
fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: "));
fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: "));
fInfo.push(SkObjectParser::PaintToString(paint));
}
void SkDrawPosTextHCommand::execute(SkCanvas* canvas) const {
@ -3030,50 +2901,13 @@ SkDrawPosTextHCommand* SkDrawPosTextHCommand::fromJSON(Json::Value& command,
return new SkDrawPosTextHCommand(text, strlen(text), xpos, y, paint);
}
static const char* gPositioningLabels[] = {
"kDefault_Positioning",
"kHorizontal_Positioning",
"kFull_Positioning",
};
SkDrawTextBlobCommand::SkDrawTextBlobCommand(sk_sp<SkTextBlob> blob, SkScalar x, SkScalar y,
const SkPaint& paint)
: INHERITED(kDrawTextBlob_OpType)
, fBlob(std::move(blob))
, fXPos(x)
, fYPos(y)
, fPaint(paint) {
std::unique_ptr<SkString> runsStr(new SkString);
fInfo.push(SkObjectParser::ScalarToString(x, "XPOS: "));
fInfo.push(SkObjectParser::ScalarToString(y, "YPOS: "));
fInfo.push(SkObjectParser::RectToString(fBlob->bounds(), "Bounds: "));
fInfo.push(runsStr.get());
fInfo.push(SkObjectParser::PaintToString(paint));
unsigned runs = 0;
SkPaint runPaint(paint);
SkTextBlobRunIterator iter(fBlob.get());
while (!iter.done()) {
std::unique_ptr<SkString> tmpStr(new SkString);
tmpStr->printf("==== Run [%d] ====", runs++);
fInfo.push(tmpStr.release());
fInfo.push(SkObjectParser::IntToString(iter.glyphCount(), "GlyphCount: "));
tmpStr.reset(new SkString("GlyphPositioning: "));
tmpStr->append(gPositioningLabels[iter.positioning()]);
fInfo.push(tmpStr.release());
iter.applyFontToPaint(&runPaint);
fInfo.push(SkObjectParser::PaintToString(runPaint));
iter.next();
}
runsStr->printf("Runs: %d", runs);
// runStr is owned by fInfo at this point.
runsStr.release();
}
, fPaint(paint) {}
void SkDrawTextBlobCommand::execute(SkCanvas* canvas) const {
canvas->drawTextBlob(fBlob, fXPos, fYPos, fPaint);
@ -3212,8 +3046,6 @@ SkDrawPatchCommand::SkDrawPatchCommand(const SkPoint cubics[12], const SkColor c
fTexCoordsPtr = nullptr;
}
fPaint = paint;
fInfo.push(SkObjectParser::PaintToString(paint));
}
void SkDrawPatchCommand::execute(SkCanvas* canvas) const {
@ -3288,9 +3120,6 @@ SkDrawRectCommand::SkDrawRectCommand(const SkRect& rect, const SkPaint& paint)
: INHERITED(kDrawRect_OpType) {
fRect = rect;
fPaint = paint;
fInfo.push(SkObjectParser::RectToString(rect));
fInfo.push(SkObjectParser::PaintToString(paint));
}
void SkDrawRectCommand::execute(SkCanvas* canvas) const {
@ -3321,9 +3150,6 @@ SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& pain
: INHERITED(kDrawRRect_OpType) {
fRRect = rrect;
fPaint = paint;
fInfo.push(SkObjectParser::RRectToString(rrect));
fInfo.push(SkObjectParser::PaintToString(paint));
}
void SkDrawRRectCommand::execute(SkCanvas* canvas) const {
@ -3358,10 +3184,6 @@ SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer,
fOuter = outer;
fInner = inner;
fPaint = paint;
fInfo.push(SkObjectParser::RRectToString(outer));
fInfo.push(SkObjectParser::RRectToString(inner));
fInfo.push(SkObjectParser::PaintToString(paint));
}
void SkDrawDRRectCommand::execute(SkCanvas* canvas) const {
@ -3401,11 +3223,6 @@ SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScal
fX = x;
fY = y;
fPaint = paint;
fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: "));
fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: "));
fInfo.push(SkObjectParser::PaintToString(paint));
}
void SkDrawTextCommand::execute(SkCanvas* canvas) const {
@ -3448,13 +3265,6 @@ SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLe
fMatrix.setIdentity();
}
fPaint = paint;
fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
fInfo.push(SkObjectParser::PathToString(path));
if (matrix) {
fInfo.push(SkObjectParser::MatrixToString(*matrix));
}
fInfo.push(SkObjectParser::PaintToString(paint));
}
void SkDrawTextOnPathCommand::execute(SkCanvas* canvas) const {
@ -3515,9 +3325,6 @@ SkDrawTextRSXformCommand::SkDrawTextRSXformCommand(const void* text, size_t byte
fCull = nullptr;
}
fPaint = paint;
fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
fInfo.push(SkObjectParser::PaintToString(paint));
}
void SkDrawTextRSXformCommand::execute(SkCanvas* canvas) const {
@ -3556,21 +3363,14 @@ SkDrawVerticesCommand::SkDrawVerticesCommand(sk_sp<SkVertices> vertices, SkBlend
: INHERITED(kDrawVertices_OpType)
, fVertices(std::move(vertices))
, fBlendMode(bmode)
, fPaint(paint)
{
// TODO(chudy)
fInfo.push(SkObjectParser::CustomTextToString("To be implemented."));
fInfo.push(SkObjectParser::PaintToString(paint));
}
, fPaint(paint) {}
void SkDrawVerticesCommand::execute(SkCanvas* canvas) const {
canvas->drawVertices(fVertices, fBlendMode, fPaint);
}
SkRestoreCommand::SkRestoreCommand()
: INHERITED(kRestore_OpType) {
fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
}
: INHERITED(kRestore_OpType) {}
void SkRestoreCommand::execute(SkCanvas* canvas) const {
canvas->restore();
@ -3614,14 +3414,6 @@ SkSaveLayerCommand::SkSaveLayerCommand(const SkCanvas::SaveLayerRec& rec)
} else {
fBackdrop = nullptr;
}
if (rec.fBounds) {
fInfo.push(SkObjectParser::RectToString(*rec.fBounds, "Bounds: "));
}
if (rec.fPaint) {
fInfo.push(SkObjectParser::PaintToString(*rec.fPaint));
}
fInfo.push(SkObjectParser::SaveLayerFlagsToString(fSaveLayerFlags));
}
SkSaveLayerCommand::~SkSaveLayerCommand() {
@ -3636,10 +3428,6 @@ void SkSaveLayerCommand::execute(SkCanvas* canvas) const {
fSaveLayerFlags));
}
void SkSaveLayerCommand::vizExecute(SkCanvas* canvas) const {
canvas->save();
}
Json::Value SkSaveLayerCommand::toJSON(UrlDataManager& urlDataManager) const {
Json::Value result = INHERITED::toJSON(urlDataManager);
if (!fBounds.isEmpty()) {
@ -3687,18 +3475,11 @@ SkSaveLayerCommand* SkSaveLayerCommand::fromJSON(Json::Value& command,
SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix)
: INHERITED(kSetMatrix_OpType) {
fUserMatrix.reset();
fMatrix = matrix;
fInfo.push(SkObjectParser::MatrixToString(matrix));
}
void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) {
fUserMatrix = userMatrix;
}
void SkSetMatrixCommand::execute(SkCanvas* canvas) const {
SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix);
canvas->setMatrix(temp);
canvas->setMatrix(fMatrix);
}
Json::Value SkSetMatrixCommand::toJSON(UrlDataManager& urlDataManager) const {

View File

@ -73,13 +73,7 @@ public:
SkDrawCommand(OpType opType);
virtual ~SkDrawCommand();
virtual SkString toString() const;
virtual const char* toCString() const {
return GetCommandString(fOpType);
}
virtual ~SkDrawCommand() {}
bool isVisible() const {
return fVisible;
@ -89,28 +83,7 @@ public:
fVisible = toggle;
}
const SkTDArray<SkString*>* Info() const { return &fInfo; }
virtual void execute(SkCanvas*) const = 0;
virtual void vizExecute(SkCanvas*) const {}
virtual void setUserMatrix(const SkMatrix&) {}
// The next "active" system is only used by save, saveLayer, and restore.
// It is used to determine which saveLayers are currently active (at a
// given point in the rendering).
// saves just return a kPushLayer action but don't track active state
// restores just return a kPopLayer action
// saveLayers return kPushLayer but also track the active state
enum Action {
kNone_Action,
kPopLayer_Action,
kPushLayer_Action,
};
virtual Action action() const { return kNone_Action; }
virtual void setActive(bool active) {}
virtual bool active() const { return false; }
OpType getType() const { return fOpType; }
virtual bool render(SkCanvas* canvas) const { return false; }
@ -145,9 +118,6 @@ public:
static bool flatten(const SkBitmap& bitmap, Json::Value* target,
UrlDataManager& urlDataManager);
protected:
SkTDArray<SkString*> fInfo;
private:
OpType fOpType;
bool fVisible;
@ -157,7 +127,6 @@ class SkRestoreCommand : public SkDrawCommand {
public:
SkRestoreCommand();
void execute(SkCanvas* canvas) const override;
Action action() const override { return kPopLayer_Action; }
static SkRestoreCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
private:
@ -754,7 +723,6 @@ class SkSaveCommand : public SkDrawCommand {
public:
SkSaveCommand();
void execute(SkCanvas* canvas) const override;
Action action() const override { return kPushLayer_Action; }
static SkSaveCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
private:
@ -768,10 +736,6 @@ public:
void execute(SkCanvas* canvas) const override;
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
static SkSaveLayerCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
void vizExecute(SkCanvas* canvas) const override;
Action action() const override{ return kPushLayer_Action; }
void setActive(bool active) override { fActive = active; }
bool active() const override { return fActive; }
const SkPaint* paint() const { return fPaintPtr; }
@ -782,21 +746,17 @@ private:
const SkImageFilter* fBackdrop;
uint32_t fSaveLayerFlags;
bool fActive;
typedef SkDrawCommand INHERITED;
};
class SkSetMatrixCommand : public SkDrawCommand {
public:
SkSetMatrixCommand(const SkMatrix& matrix);
void setUserMatrix(const SkMatrix&) override;
void execute(SkCanvas* canvas) const override;
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
static SkSetMatrixCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
private:
SkMatrix fUserMatrix;
SkMatrix fMatrix;
typedef SkDrawCommand INHERITED;

View File

@ -8,7 +8,6 @@
#include "SkJsonWriteBuffer.h"
#include "SkDrawCommand.h"
#include "SkObjectParser.h"
void SkJsonWriteBuffer::append(const char* type, const Json::Value& value) {
SkString fullName = SkStringPrintf("%02d_%s", fJson.size(), type);

View File

@ -1,424 +0,0 @@
/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkObjectParser.h"
#include "SkData.h"
#include "SkFontDescriptor.h"
#include "SkImage.h"
#include "SkPath.h"
#include "SkRRect.h"
#include "SkShader.h"
#include "SkStream.h"
#include "SkStringUtils.h"
#include "SkTypeface.h"
#include "SkUtils.h"
#include "SkClipOpPriv.h"
/* TODO(chudy): Replace all std::strings with char */
SkString* SkObjectParser::BitmapToString(const SkBitmap& bitmap) {
SkString* mBitmap = new SkString("SkBitmap: ");
mBitmap->append("W: ");
mBitmap->appendS32(bitmap.width());
mBitmap->append(" H: ");
mBitmap->appendS32(bitmap.height());
const char* ctString = "<unknown>";
switch (bitmap.colorType()) {
case kUnknown_SkColorType: ctString = "None"; break;
case kAlpha_8_SkColorType: ctString = "A8"; break;
case kRGB_565_SkColorType: ctString = "565"; break;
case kARGB_4444_SkColorType: ctString = "4444"; break;
case kRGBA_8888_SkColorType: ctString = "RGBA"; break;
case kRGB_888x_SkColorType: ctString = "RGB"; break;
case kBGRA_8888_SkColorType: ctString = "BGRA"; break;
case kRGBA_1010102_SkColorType: ctString = "1010102"; break;
case kRGB_101010x_SkColorType: ctString = "101010x"; break;
case kGray_8_SkColorType: ctString = "G8"; break;
case kRGBA_F16_SkColorType: ctString = "RGBAf16"; break;
}
mBitmap->append(" ColorType: ");
mBitmap->append(ctString);
if (bitmap.isOpaque()) {
mBitmap->append(" opaque");
} else {
mBitmap->append(" not-opaque");
}
if (bitmap.isImmutable()) {
mBitmap->append(" immutable");
} else {
mBitmap->append(" not-immutable");
}
if (bitmap.isVolatile()) {
mBitmap->append(" volatile");
} else {
mBitmap->append(" not-volatile");
}
mBitmap->append(" genID: ");
mBitmap->appendS32(bitmap.getGenerationID());
return mBitmap;
}
SkString* SkObjectParser::ImageToString(const SkImage* image) {
SkString* str = new SkString("SkImage: ");
if (!image) {
return str;
}
str->append("W: ");
str->appendS32(image->width());
str->append(" H: ");
str->appendS32(image->height());
if (image->isOpaque()) {
str->append(" opaque");
} else {
str->append(" not-opaque");
}
str->append(" uniqueID: ");
str->appendS32(image->uniqueID());
return str;
}
SkString* SkObjectParser::BoolToString(bool doAA) {
SkString* mBool = new SkString("Bool doAA: ");
if (doAA) {
mBool->append("True");
} else {
mBool->append("False");
}
return mBool;
}
SkString* SkObjectParser::CustomTextToString(const char* text) {
SkString* mText = new SkString(text);
return mText;
}
SkString* SkObjectParser::IntToString(int x, const char* text) {
SkString* mInt = new SkString(text);
mInt->append(" ");
mInt->appendScalar(SkIntToScalar(x));
return mInt;
}
SkString* SkObjectParser::IRectToString(const SkIRect& rect) {
SkString* mRect = new SkString("SkIRect: ");
mRect->append("L: ");
mRect->appendS32(rect.left());
mRect->append(", T: ");
mRect->appendS32(rect.top());
mRect->append(", R: ");
mRect->appendS32(rect.right());
mRect->append(", B: ");
mRect->appendS32(rect.bottom());
return mRect;
}
SkString* SkObjectParser::MatrixToString(const SkMatrix& matrix) {
SkString* str = new SkString("SkMatrix: ");
matrix.toString(str);
return str;
}
SkString* SkObjectParser::PaintToString(const SkPaint& paint) {
SkString* str = new SkString;
paint.toString(str);
return str;
}
SkString* SkObjectParser::PathToString(const SkPath& path) {
SkString* mPath = new SkString;
mPath->appendf("Path (%d) (", path.getGenerationID());
static const char* gFillStrings[] = {
"Winding", "EvenOdd", "InverseWinding", "InverseEvenOdd"
};
mPath->append(gFillStrings[path.getFillType()]);
mPath->append(", ");
static const char* gConvexityStrings[] = {
"Unknown", "Convex", "Concave"
};
SkASSERT(SkPath::kConcave_Convexity == 2);
mPath->append(gConvexityStrings[path.getConvexity()]);
mPath->append(", ");
if (path.isRect(nullptr)) {
mPath->append("isRect, ");
} else {
mPath->append("isNotRect, ");
}
if (path.isOval(nullptr)) {
mPath->append("isOval, ");
} else {
mPath->append("isNotOval, ");
}
SkRRect rrect;
if (path.isRRect(&rrect)) {
mPath->append("isRRect, ");
} else {
mPath->append("isNotRRect, ");
}
mPath->appendS32(path.countVerbs());
mPath->append("V, ");
mPath->appendS32(path.countPoints());
mPath->append("P): ");
static const char* gVerbStrings[] = {
"Move", "Line", "Quad", "Conic", "Cubic", "Close", "Done"
};
static const int gPtsPerVerb[] = { 1, 1, 2, 2, 3, 0, 0 };
static const int gPtOffsetPerVerb[] = { 0, 1, 1, 1, 1, 0, 0 };
SkASSERT(SkPath::kDone_Verb == 6);
SkPath::Iter iter(const_cast<SkPath&>(path), false);
SkPath::Verb verb;
SkPoint points[4];
for(verb = iter.next(points, false);
verb != SkPath::kDone_Verb;
verb = iter.next(points, false)) {
mPath->append(gVerbStrings[verb]);
mPath->append(" ");
for (int i = 0; i < gPtsPerVerb[verb]; ++i) {
mPath->append("(");
mPath->appendScalar(points[gPtOffsetPerVerb[verb]+i].fX);
mPath->append(", ");
mPath->appendScalar(points[gPtOffsetPerVerb[verb]+i].fY);
mPath->append(")");
}
if (SkPath::kConic_Verb == verb) {
mPath->append("(");
mPath->appendScalar(iter.conicWeight());
mPath->append(")");
}
mPath->append(" ");
}
SkString* boundStr = SkObjectParser::RectToString(path.getBounds(), " Bound: ");
if (boundStr) {
mPath->append(*boundStr);
delete boundStr;
}
return mPath;
}
SkString* SkObjectParser::PointsToString(const SkPoint pts[], size_t count) {
SkString* mPoints = new SkString("SkPoints pts[]: ");
for (unsigned int i = 0; i < count; i++) {
mPoints->append("(");
mPoints->appendScalar(pts[i].fX);
mPoints->append(",");
mPoints->appendScalar(pts[i].fY);
mPoints->append(")");
}
return mPoints;
}
SkString* SkObjectParser::PointModeToString(SkCanvas::PointMode mode) {
SkString* mMode = new SkString("SkCanvas::PointMode: ");
if (mode == SkCanvas::kPoints_PointMode) {
mMode->append("kPoints_PointMode");
} else if (mode == SkCanvas::kLines_PointMode) {
mMode->append("kLines_Mode");
} else if (mode == SkCanvas::kPolygon_PointMode) {
mMode->append("kPolygon_PointMode");
}
return mMode;
}
SkString* SkObjectParser::RectToString(const SkRect& rect, const char* title) {
SkString* mRect = new SkString;
if (nullptr == title) {
mRect->append("SkRect: ");
} else {
mRect->append(title);
}
mRect->append("(");
mRect->appendScalar(rect.left());
mRect->append(", ");
mRect->appendScalar(rect.top());
mRect->append(", ");
mRect->appendScalar(rect.right());
mRect->append(", ");
mRect->appendScalar(rect.bottom());
mRect->append(")");
return mRect;
}
SkString* SkObjectParser::RRectToString(const SkRRect& rrect, const char* title) {
SkString* mRRect = new SkString;
if (nullptr == title) {
mRRect->append("SkRRect (");
if (rrect.isEmpty()) {
mRRect->append("empty");
} else if (rrect.isRect()) {
mRRect->append("rect");
} else if (rrect.isOval()) {
mRRect->append("oval");
} else if (rrect.isSimple()) {
mRRect->append("simple");
} else if (rrect.isNinePatch()) {
mRRect->append("nine-patch");
} else {
SkASSERT(rrect.isComplex());
mRRect->append("complex");
}
mRRect->append("): ");
} else {
mRRect->append(title);
}
mRRect->append("(");
mRRect->appendScalar(rrect.rect().left());
mRRect->append(", ");
mRRect->appendScalar(rrect.rect().top());
mRRect->append(", ");
mRRect->appendScalar(rrect.rect().right());
mRRect->append(", ");
mRRect->appendScalar(rrect.rect().bottom());
mRRect->append(") radii: (");
for (int i = 0; i < 4; ++i) {
const SkVector& radii = rrect.radii((SkRRect::Corner) i);
mRRect->appendScalar(radii.fX);
mRRect->append(", ");
mRRect->appendScalar(radii.fY);
if (i < 3) {
mRRect->append(", ");
}
}
mRRect->append(")");
return mRRect;
}
SkString* SkObjectParser::ClipOpToString(SkClipOp op) {
SkString* mOp = new SkString("SkRegion::Op: ");
if (op == kDifference_SkClipOp) {
mOp->append("kDifference_Op");
} else if (op == kIntersect_SkClipOp) {
mOp->append("kIntersect_Op");
} else if (op == kUnion_SkClipOp) {
mOp->append("kUnion_Op");
} else if (op == kXOR_SkClipOp) {
mOp->append("kXOR_Op");
} else if (op == kReverseDifference_SkClipOp) {
mOp->append("kReverseDifference_Op");
} else if (op == kReplace_SkClipOp) {
mOp->append("kReplace_Op");
} else {
mOp->append("Unknown Type");
}
return mOp;
}
SkString* SkObjectParser::RegionToString(const SkRegion& region) {
SkString* mRegion = new SkString("SkRegion: Data unavailable.");
return mRegion;
}
SkString* SkObjectParser::SaveLayerFlagsToString(SkCanvas::SaveLayerFlags saveLayerFlags) {
SkString* mFlags = new SkString("SkCanvas::SaveFlags: ");
if (saveLayerFlags & SkCanvas::kPreserveLCDText_SaveLayerFlag) {
mFlags->append("kPreserveLCDText_SaveLayerFlag ");
}
return mFlags;
}
SkString* SkObjectParser::ScalarToString(SkScalar x, const char* text) {
SkString* mScalar = new SkString(text);
mScalar->append(" ");
mScalar->appendScalar(x);
return mScalar;
}
SkString* SkObjectParser::TextToString(const void* text, size_t byteLength,
SkPaint::TextEncoding encoding) {
SkString* decodedText = new SkString();
switch (encoding) {
case SkPaint::kUTF8_TextEncoding: {
decodedText->append("UTF-8: ");
decodedText->append((const char*)text, byteLength);
break;
}
case SkPaint::kUTF16_TextEncoding: {
decodedText->append("UTF-16: ");
size_t sizeNeeded = SkUTF16_ToUTF8((uint16_t*)text,
SkToS32(byteLength / 2),
nullptr);
SkAutoSTMalloc<0x100, char> utf8(sizeNeeded);
SkUTF16_ToUTF8((uint16_t*)text, SkToS32(byteLength / 2), utf8);
decodedText->append(utf8, sizeNeeded);
break;
}
case SkPaint::kUTF32_TextEncoding: {
decodedText->append("UTF-32: ");
const SkUnichar* begin = (const SkUnichar*)text;
const SkUnichar* end = (const SkUnichar*)((const char*)text + byteLength);
for (const SkUnichar* unichar = begin; unichar < end; ++unichar) {
decodedText->appendUnichar(*unichar);
}
break;
}
case SkPaint::kGlyphID_TextEncoding: {
decodedText->append("GlyphID: ");
const uint16_t* begin = (const uint16_t*)text;
const uint16_t* end = (const uint16_t*)((const char*)text + byteLength);
for (const uint16_t* glyph = begin; glyph < end; ++glyph) {
decodedText->append("0x");
decodedText->appendHex(*glyph);
decodedText->append(" ");
}
break;
}
default:
decodedText->append("Unknown text encoding.");
break;
}
return decodedText;
}
SkString* SkObjectParser::LatticeToString(const SkCanvas::Lattice& lattice) {
SkString* mLattice = new SkString;
mLattice->append("Lattice: ");
mLattice->append("(X: ");
mLattice->appendS32(lattice.fXCount);
mLattice->append(", Y:");
mLattice->appendS32(lattice.fYCount);
mLattice->append(", Bounds:");
if (nullptr != lattice.fBounds) {
mLattice->append(*IRectToString(*lattice.fBounds));
} else {
mLattice->append("null");
}
mLattice->append(")");
return mLattice;
}

View File

@ -1,140 +0,0 @@
/*
* 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 SKOBJECTPARSER_H_
#define SKOBJECTPARSER_H_
#include "SkCanvas.h"
#include "SkString.h"
/** \class SkObjectParser
The ObjectParser is used to return string information about parameters
in each draw command.
*/
class SkObjectParser {
public:
/**
Returns a string about a bitmap's bounds and colortype.
@param bitmap SkBitmap
*/
static SkString* BitmapToString(const SkBitmap& bitmap);
/**
Returns a string about a image
@param image SkImage
*/
static SkString* ImageToString(const SkImage* image);
/**
Returns a string representation of a boolean.
@param doAA boolean
*/
static SkString* BoolToString(bool doAA);
/**
Returns a string representation of the text pointer passed in.
*/
static SkString* CustomTextToString(const char* text);
/**
Returns a string representation of an integer with the text parameter
at the front of the string.
@param x integer
@param text
*/
static SkString* IntToString(int x, const char* text);
/**
Returns a string representation of the SkIRects coordinates.
@param rect SkIRect
*/
static SkString* IRectToString(const SkIRect& rect);
/**
Returns a string representation of an SkMatrix's contents
@param matrix SkMatrix
*/
static SkString* MatrixToString(const SkMatrix& matrix);
/**
Returns a string representation of an SkPaint's color
@param paint SkPaint
*/
static SkString* PaintToString(const SkPaint& paint);
/**
Returns a string representation of a SkPath's points.
@param path SkPath
*/
static SkString* PathToString(const SkPath& path);
/**
Returns a string representation of the points in the point array.
@param pts[] Array of SkPoints
@param count
*/
static SkString* PointsToString(const SkPoint pts[], size_t count);
/**
Returns a string representation of the SkCanvas PointMode enum.
*/
static SkString* PointModeToString(SkCanvas::PointMode mode);
/**
Returns a string representation of the SkRects coordinates.
@param rect SkRect
*/
static SkString* RectToString(const SkRect& rect, const char* title = nullptr);
/**
Returns a string representation of an SkRRect.
@param rrect SkRRect
*/
static SkString* RRectToString(const SkRRect& rrect, const char* title = nullptr);
/**
Returns a string representation of the SkRegion enum.
@param op SkRegion::op enum
*/
static SkString* ClipOpToString(SkClipOp op);
/**
Returns a string representation of the SkRegion.
@param region SkRegion
*/
static SkString* RegionToString(const SkRegion& region);
/**
Returns a string representation of the SkCanvas::SaveLayerFlags enum.
@param flags SkCanvas::SaveLayerFlags enum
*/
static SkString* SaveLayerFlagsToString(uint32_t saveLayerFlags);
/**
Returns a string representation of an SkScalar with the text parameter
at the front of the string.
@param x SkScalar
@param text
*/
static SkString* ScalarToString(SkScalar x, const char* text);
/**
Returns a string representation of the char pointer passed in.
@param text const void* that will be cast to a char*
*/
static SkString* TextToString(const void* text, size_t byteLength,
SkPaint::TextEncoding encoding);
/**
Returns a string representation of the SkCanvas::Lattice.
@param lattice SkCanvas::Lattice
*/
static SkString* LatticeToString(const SkCanvas::Lattice& lattice);
};
#endif

View File

@ -9,6 +9,7 @@
#include "SkDebugCanvas.h"
#include "SkNullCanvas.h"
#include "SkPicture.h"
#include "SkStream.h"
#ifdef SK_BUILD_FOR_WIN