From 255735e53b2d2fd1db1dde19e14cfcf1a68602b1 Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Fri, 6 Apr 2018 14:51:42 -0400 Subject: 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 Commit-Queue: Brian Osman --- tools/debugger/SkDebugCanvas.cpp | 275 +---------------------- tools/debugger/SkDebugCanvas.h | 95 +------- tools/debugger/SkDrawCommand.cpp | 227 +------------------ tools/debugger/SkDrawCommand.h | 42 +--- tools/debugger/SkJsonWriteBuffer.cpp | 1 - tools/debugger/SkObjectParser.cpp | 424 ----------------------------------- tools/debugger/SkObjectParser.h | 140 ------------ 7 files changed, 11 insertions(+), 1193 deletions(-) delete mode 100644 tools/debugger/SkObjectParser.cpp delete mode 100644 tools/debugger/SkObjectParser.h (limited to 'tools/debugger') diff --git a/tools/debugger/SkDebugCanvas.cpp b/tools/debugger/SkDebugCanvas.cpp index 8644025c48..156f957de3 100644 --- a/tools/debugger/SkDebugCanvas.cpp +++ b/tools/debugger/SkDebugCanvas.cpp @@ -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* 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* 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 & SkDebugCanvas::getDrawCommands() const { - return fCommandVector; -} - -SkTDArray & 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[] = "    "; - -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(");
"); -} - -void SkDebugCanvas::outputConicPoints(const SkPoint* pts, SkScalar weight) { - this->outputPointsCommon(pts, 2); - fClipStackData.appendf(", "); - this->outputScalar(weight); - fClipStackData.appendf(");
"); -} - -void SkDebugCanvas::addPathData(const SkPath& path, const char* pathName) { - SkPath::RawIter iter(path); - SkPath::FillType fillType = path.getFillType(); - fClipStackData.appendf("%sSkPath %s;
", kHTML4SpaceIndent, pathName); - fClipStackData.appendf("%s%s.setFillType(SkPath::%s);
", 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();
", 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("
static void test(skiatest::Reporter* reporter," - " const char* filename) {
"); - addPathData(fCalledAddStackData ? devPath : fSaveDevPath, "path"); - addPathData(operand, "pathB"); - fClipStackData.appendf("%stestPathOp(reporter, path, pathB, %s, filename);
", - kHTML4SpaceIndent, gOpStrs[static_cast(elementOp)]); - fClipStackData.appendf("}
"); - fCalledAddStackData = true; - } -} - -bool SkDebugCanvas::lastClipStackData(const SkPath& devPath) { - if (fCalledAddStackData) { - fClipStackData.appendf("
"); - addPathData(devPath, "pathOut"); - return true; - } - return false; -} diff --git a/tools/debugger/SkDebugCanvas.h b/tools/debugger/SkDebugCanvas.h index 45266d3795..2a3dcbbf49 100644 --- a/tools/debugger/SkDebugCanvas.h +++ b/tools/debugger/SkDebugCanvas.h @@ -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 *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 &getDrawCommands() const; - - /** - Returns the vector of draw commands. Do not use this entry - point - it is going away! - */ - SkTDArray &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 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 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*); diff --git a/tools/debugger/SkDrawCommand.cpp b/tools/debugger/SkDrawCommand.cpp index 076dac57a5..27a2765404 100644 --- a/tools/debugger/SkDrawCommand.cpp +++ b/tools/debugger/SkDrawCommand.cpp @@ -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 blob, SkScalar x, SkScalar y, const SkPaint& paint) : INHERITED(kDrawTextBlob_OpType) , fBlob(std::move(blob)) , fXPos(x) , fYPos(y) - , fPaint(paint) { - - std::unique_ptr 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 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 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 { diff --git a/tools/debugger/SkDrawCommand.h b/tools/debugger/SkDrawCommand.h index d2eee9b63b..64830a48c7 100644 --- a/tools/debugger/SkDrawCommand.h +++ b/tools/debugger/SkDrawCommand.h @@ -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* 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 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; diff --git a/tools/debugger/SkJsonWriteBuffer.cpp b/tools/debugger/SkJsonWriteBuffer.cpp index 9a9a032d6b..c9edf68546 100644 --- a/tools/debugger/SkJsonWriteBuffer.cpp +++ b/tools/debugger/SkJsonWriteBuffer.cpp @@ -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); diff --git a/tools/debugger/SkObjectParser.cpp b/tools/debugger/SkObjectParser.cpp deleted file mode 100644 index a529b5b40f..0000000000 --- a/tools/debugger/SkObjectParser.cpp +++ /dev/null @@ -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 = ""; - 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(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; -} diff --git a/tools/debugger/SkObjectParser.h b/tools/debugger/SkObjectParser.h deleted file mode 100644 index 2532c5c493..0000000000 --- a/tools/debugger/SkObjectParser.h +++ /dev/null @@ -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 -- cgit v1.2.3