aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2018-03-09 15:44:34 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-10 03:29:54 +0000
commit46fe9c7f6cc772639c0c7b3a71fe889139506841 (patch)
tree7af51f403bb5cc6ece29881ac9f753b261fc9c3c
parentefd4411c2349dfa595caa74f639c0635285bb245 (diff)
Remove SkDumpCanvas
Bug: skia: Change-Id: I045e84f154d0294121a4c1966dcf47c0d7e52934 Reviewed-on: https://skia-review.googlesource.com/113464 Commit-Queue: Ben Wagner <bungeman@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
-rw-r--r--docs/SkCanvas_Reference.bmh12
-rw-r--r--docs/undocumented.bmh5
-rw-r--r--gn/utils.gni2
-rw-r--r--include/core/SkCanvas.h12
-rw-r--r--include/utils/SkDumpCanvas.h167
-rw-r--r--samplecode/SamplePdfFileViewer.cpp1
-rw-r--r--src/utils/SkDumpCanvas.cpp575
-rw-r--r--tools/pinspect.cpp82
8 files changed, 12 insertions, 844 deletions
diff --git a/docs/SkCanvas_Reference.bmh b/docs/SkCanvas_Reference.bmh
index f090207882..1db1d0f077 100644
--- a/docs/SkCanvas_Reference.bmh
+++ b/docs/SkCanvas_Reference.bmh
@@ -883,7 +883,7 @@ Returns true if Canvas has direct access to its pixels.
Pixels are readable when Device is raster. Pixels are not readable when Canvas
is returned from GPU_Surface, returned by SkDocument::beginPage, returned by
SkPictureRecorder::beginRecording, or Canvas is the base of a utility class
-like SkDumpCanvas.
+like SkDebugCanvas.
pixmap is valid only while Canvas is in scope and unchanged. Any
Canvas or Surface call may invalidate the pixmap values.
@@ -924,7 +924,7 @@ converting to dstInfo.colorType() and dstInfo.alphaType() if required.
Pixels are readable when Device is raster, or backed by a GPU.
Pixels are not readable when SkCanvas is returned by SkDocument::beginPage,
returned by SkPictureRecorder::beginRecording, or Canvas is the base of a utility
-class like SkDumpCanvas.
+class like SkDebugCanvas.
The destination pixel storage must be allocated by the caller.
@@ -1016,7 +1016,7 @@ converting to pixmap.colorType() and pixmap.alphaType() if required.
Pixels are readable when Device is raster, or backed by a GPU.
Pixels are not readable when SkCanvas is returned by SkDocument::beginPage,
returned by SkPictureRecorder::beginRecording, or Canvas is the base of a utility
-class like SkDumpCanvas.
+class like SkDebugCanvas.
Caller must allocate pixel storage in pixmap if needed.
@@ -1079,7 +1079,7 @@ converting to bitmap.colorType() and bitmap.alphaType() if required.
Pixels are readable when Device is raster, or backed by a GPU.
Pixels are not readable when SkCanvas is returned by SkDocument::beginPage,
returned by SkPictureRecorder::beginRecording, or Canvas is the base of a utility
-class like SkDumpCanvas.
+class like SkDebugCanvas.
Caller must allocate pixel storage in bitmap if needed.
@@ -1143,7 +1143,7 @@ converting to imageInfo().colorType() and imageInfo().alphaType() if required.
Pixels are writable when Device is raster, or backed by a GPU.
Pixels are not writable when SkCanvas is returned by SkDocument::beginPage,
returned by SkPictureRecorder::beginRecording, or Canvas is the base of a utility
-class like SkDumpCanvas.
+class like SkDebugCanvas.
Pixel values are converted only if Color_Type and Alpha_Type
do not match. Only pixels within both source and destination rectangles
@@ -1201,7 +1201,7 @@ converting to imageInfo().colorType() and imageInfo().alphaType() if required.
Pixels are writable when Device is raster, or backed by a GPU.
Pixels are not writable when SkCanvas is returned by SkDocument::beginPage,
returned by SkPictureRecorder::beginRecording, or Canvas is the base of a utility
-class like SkDumpCanvas.
+class like SkDebugCanvas.
Pixel values are converted only if Color_Type and Alpha_Type
do not match. Only pixels within both source and destination rectangles
diff --git a/docs/undocumented.bmh b/docs/undocumented.bmh
index 70a26dec80..bd6a446e0a 100644
--- a/docs/undocumented.bmh
+++ b/docs/undocumented.bmh
@@ -248,11 +248,6 @@ FT_Load_Glyph
##
##
-#Topic Dump_Canvas
-#Class SkDumpCanvas
-##
-#Topic ##
-
#Topic Encoded_Image_Format
#EnumClass SkEncodedImageFormat
#Const kUnknown 0
diff --git a/gn/utils.gni b/gn/utils.gni
index 6801bcf336..fb9e0a2abd 100644
--- a/gn/utils.gni
+++ b/gn/utils.gni
@@ -11,7 +11,6 @@ skia_utils_sources = [
"$_include/utils/SkFrontBufferedStream.h",
"$_include/utils/SkCamera.h",
"$_include/utils/SkCanvasStateUtils.h",
- "$_include/utils/SkDumpCanvas.h",
"$_include/utils/SkEventTracer.h",
"$_include/utils/SkInterpolator.h",
"$_include/utils/SkNoDrawCanvas.h",
@@ -34,7 +33,6 @@ skia_utils_sources = [
"$_src/utils/SkCanvasStateUtils.cpp",
"$_src/utils/SkDashPath.cpp",
"$_src/utils/SkDashPathPriv.h",
- "$_src/utils/SkDumpCanvas.cpp",
"$_src/utils/SkEventTracer.cpp",
"$_src/utils/SkFloatToDecimal.cpp",
"$_src/utils/SkFloatToDecimal.h",
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index f1081bfa83..6203665359 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -291,7 +291,7 @@ public:
Pixels are readable when SkBaseDevice is raster. Pixels are not readable when SkCanvas
is returned from GPU surface, returned by SkDocument::beginPage, returned by
SkPictureRecorder::beginRecording, or SkCanvas is the base of a utility class
- like SkDumpCanvas.
+ like SkDebugCanvas.
pixmap is valid only while SkCanvas is in scope and unchanged. Any
SkCanvas or SkSurface call may invalidate the pixmap values.
@@ -312,7 +312,7 @@ public:
Pixels are readable when SkBaseDevice is raster, or backed by a GPU.
Pixels are not readable when SkCanvas is returned by SkDocument::beginPage,
returned by SkPictureRecorder::beginRecording, or SkCanvas is the base of a utility
- class like SkDumpCanvas.
+ class like SkDebugCanvas.
The destination pixel storage must be allocated by the caller.
@@ -349,7 +349,7 @@ public:
Pixels are readable when SkBaseDevice is raster, or backed by a GPU.
Pixels are not readable when SkCanvas is returned by SkDocument::beginPage,
returned by SkPictureRecorder::beginRecording, or SkCanvas is the base of a utility
- class like SkDumpCanvas.
+ class like SkDebugCanvas.
Caller must allocate pixel storage in pixmap if needed.
@@ -384,7 +384,7 @@ public:
Pixels are readable when SkBaseDevice is raster, or backed by a GPU.
Pixels are not readable when SkCanvas is returned by SkDocument::beginPage,
returned by SkPictureRecorder::beginRecording, or SkCanvas is the base of a utility
- class like SkDumpCanvas.
+ class like SkDebugCanvas.
Caller must allocate pixel storage in bitmap if needed.
@@ -419,7 +419,7 @@ public:
Pixels are writable when SkBaseDevice is raster, or backed by a GPU.
Pixels are not writable when SkCanvas is returned by SkDocument::beginPage,
returned by SkPictureRecorder::beginRecording, or SkCanvas is the base of a utility
- class like SkDumpCanvas.
+ class like SkDebugCanvas.
Pixel values are converted only if SkColorType and SkAlphaType
do not match. Only pixels within both source and destination rectangles
@@ -456,7 +456,7 @@ public:
Pixels are writable when SkBaseDevice is raster, or backed by a GPU.
Pixels are not writable when SkCanvas is returned by SkDocument::beginPage,
returned by SkPictureRecorder::beginRecording, or SkCanvas is the base of a utility
- class like SkDumpCanvas.
+ class like SkDebugCanvas.
Pixel values are converted only if SkColorType and SkAlphaType
do not match. Only pixels within both source and destination rectangles
diff --git a/include/utils/SkDumpCanvas.h b/include/utils/SkDumpCanvas.h
deleted file mode 100644
index 8a28c61412..0000000000
--- a/include/utils/SkDumpCanvas.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkDumpCanvas_DEFINED
-#define SkDumpCanvas_DEFINED
-
-#include "SkCanvas.h"
-#include "SkVertices.h"
-
-/** This class overrides all the draw methods on SkCanvas, and formats them
- as text, and then sends that to a Dumper helper object.
-
- Typical use might be to dump a display list to a log file to see what is
- being drawn.
- */
-class SkDumpCanvas : public SkCanvas {
-public:
- class Dumper;
-
- explicit SkDumpCanvas(Dumper* = nullptr);
- ~SkDumpCanvas() override;
-
- enum Verb {
- kNULL_Verb,
-
- kSave_Verb,
- kRestore_Verb,
-
- kMatrix_Verb,
-
- kClip_Verb,
-
- kDrawPaint_Verb,
- kDrawPoints_Verb,
- kDrawOval_Verb,
- kDrawArc_Verb,
- kDrawRect_Verb,
- kDrawRRect_Verb,
- kDrawDRRect_Verb,
- kDrawPath_Verb,
- kDrawBitmap_Verb,
- kDrawText_Verb,
- kDrawPicture_Verb,
- kDrawDrawable_Verb,
- kDrawVertices_Verb,
- kDrawPatch_Verb,
- kDrawData_Verb, // obsolete
- kDrawAnnotation_Verb,
-
- kCull_Verb
- };
-
- /** Subclasses of this are installed on the DumpCanvas, and then called for
- each drawing command.
- */
- class Dumper : public SkRefCnt {
- public:
-
-
- virtual void dump(SkDumpCanvas*, SkDumpCanvas::Verb, const char str[],
- const SkPaint*) = 0;
-
- private:
- typedef SkRefCnt INHERITED;
- };
-
- Dumper* getDumper() const { return fDumper; }
- void setDumper(Dumper*);
-
- int getNestLevel() const { return fNestLevel; }
-
-protected:
- void willSave() override;
- SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
- void willRestore() override;
-
- void didConcat(const SkMatrix&) override;
- void didSetMatrix(const SkMatrix&) override;
-
- void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
- virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
- const SkPaint&) override;
- virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
- const SkPaint&) override;
- virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
- SkScalar constY, const SkPaint&) override;
- virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
- const SkMatrix* matrix, const SkPaint&) override;
- void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
- const SkRect* cull, const SkPaint& paint) override;
- virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
- const SkPaint& paint) override;
- virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
- const SkPoint texCoords[4], SkBlendMode,
- const SkPaint& paint) override;
-
- void onDrawPaint(const SkPaint&) override;
- void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
- void onDrawRect(const SkRect&, const SkPaint&) override;
- void onDrawOval(const SkRect&, const SkPaint&) override;
- void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
- void onDrawRRect(const SkRRect&, const SkPaint&) override;
- void onDrawPath(const SkPath&, const SkPaint&) override;
- void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
- void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
- SrcRectConstraint) override;
- void onDrawImage(const SkImage*, SkScalar left, SkScalar top, const SkPaint*) override;
- void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
- const SkPaint*, SrcRectConstraint) override;
- void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
- const SkPaint*) override;
- void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
-
- void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
- void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
- void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;
- void onClipRegion(const SkRegion&, SkClipOp) override;
-
- void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
- void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
- void onDrawAnnotation(const SkRect&, const char key[], SkData* value) override;
-
- static const char* EdgeStyleToAAString(ClipEdgeStyle edgeStyle);
-
-private:
- Dumper* fDumper;
- int fNestLevel; // for nesting recursive elements like pictures
-
- void dump(Verb, const SkPaint*, const char format[], ...);
-
- typedef SkCanvas INHERITED;
-};
-
-/** Formats the draw commands, and send them to a function-pointer provided
- by the caller.
- */
-class SkFormatDumper : public SkDumpCanvas::Dumper {
-public:
- SkFormatDumper(void (*)(const char text[], void* refcon), void* refcon);
-
- // override from baseclass that does the formatting, and in turn calls
- // the function pointer that was passed to the constructor
- virtual void dump(SkDumpCanvas*, SkDumpCanvas::Verb, const char str[],
- const SkPaint*) override;
-
-private:
- void (*fProc)(const char*, void*);
- void* fRefcon;
-
- typedef SkDumpCanvas::Dumper INHERITED;
-};
-
-/** Subclass of Dumper that dumps the drawing command to SkDebugf
- */
-class SkDebugfDumper : public SkFormatDumper {
-public:
- SkDebugfDumper();
-
-private:
- typedef SkFormatDumper INHERITED;
-};
-
-#endif
diff --git a/samplecode/SamplePdfFileViewer.cpp b/samplecode/SamplePdfFileViewer.cpp
index ab5a73e824..1842abe2fd 100644
--- a/samplecode/SamplePdfFileViewer.cpp
+++ b/samplecode/SamplePdfFileViewer.cpp
@@ -10,7 +10,6 @@
#ifdef SAMPLE_PDF_FILE_VIEWER
#include "SampleCode.h"
-#include "SkDumpCanvas.h"
#include "SkView.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp
deleted file mode 100644
index b7c200f41d..0000000000
--- a/src/utils/SkDumpCanvas.cpp
+++ /dev/null
@@ -1,575 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkData.h"
-#include "SkDrawable.h"
-#include "SkDumpCanvas.h"
-#include "SkImage.h"
-#include "SkPatchUtils.h"
-#include "SkPicture.h"
-#include "SkPixelRef.h"
-#include "SkRegion.h"
-#include "SkRRectPriv.h"
-#include "SkString.h"
-#include "SkTextBlob.h"
-#include <stdarg.h>
-#include <stdio.h>
-
-// needed just to know that these are all subclassed from SkFlattenable
-#include "SkShader.h"
-#include "SkPathEffect.h"
-#include "SkColorFilter.h"
-#include "SkPathEffect.h"
-#include "SkMaskFilter.h"
-
-static void toString(const SkRect& r, SkString* str) {
- str->appendf("[%g,%g %g:%g]",
- SkScalarToFloat(r.fLeft), SkScalarToFloat(r.fTop),
- SkScalarToFloat(r.width()), SkScalarToFloat(r.height()));
-}
-
-static void toString(const SkIRect& r, SkString* str) {
- str->appendf("[%d,%d %d:%d]", r.fLeft, r.fTop, r.width(), r.height());
-}
-
-static void toString(const SkRRect& rrect, SkString* str) {
- SkRect r = rrect.getBounds();
- str->appendf("[%g,%g %g:%g]",
- SkScalarToFloat(r.fLeft), SkScalarToFloat(r.fTop),
- SkScalarToFloat(r.width()), SkScalarToFloat(r.height()));
- if (rrect.isOval()) {
- str->append("()");
- } else if (rrect.isSimple()) {
- const SkVector rad = SkRRectPriv::GetSimpleRadii(rrect);
- str->appendf("(%g,%g)", rad.x(), rad.y());
- } else if (rrect.isComplex()) {
- SkVector radii[4] = {
- rrect.radii(SkRRect::kUpperLeft_Corner),
- rrect.radii(SkRRect::kUpperRight_Corner),
- rrect.radii(SkRRect::kLowerRight_Corner),
- rrect.radii(SkRRect::kLowerLeft_Corner),
- };
- str->appendf("(%g,%g %g,%g %g,%g %g,%g)",
- radii[0].x(), radii[0].y(),
- radii[1].x(), radii[1].y(),
- radii[2].x(), radii[2].y(),
- radii[3].x(), radii[3].y());
- }
-}
-
-static void dumpVerbs(const SkPath& path, SkString* str) {
- SkPath::Iter iter(path, false);
- SkPoint pts[4];
- for (;;) {
- switch (iter.next(pts, false)) {
- case SkPath::kMove_Verb:
- str->appendf(" M%g,%g", pts[0].fX, pts[0].fY);
- break;
- case SkPath::kLine_Verb:
- str->appendf(" L%g,%g", pts[0].fX, pts[0].fY);
- break;
- case SkPath::kQuad_Verb:
- str->appendf(" Q%g,%g,%g,%g", pts[1].fX, pts[1].fY,
- pts[2].fX, pts[2].fY);
- break;
- case SkPath::kCubic_Verb:
- str->appendf(" C%g,%g,%g,%g,%g,%g", pts[1].fX, pts[1].fY,
- pts[2].fX, pts[2].fY, pts[3].fX, pts[3].fY);
- break;
- case SkPath::kClose_Verb:
- str->append("X");
- break;
- case SkPath::kDone_Verb:
- return;
- case SkPath::kConic_Verb:
- SkASSERT(0);
- break;
- }
- }
-}
-
-static void toString(const SkPath& path, SkString* str) {
- if (path.isEmpty()) {
- str->append("path:empty");
- } else {
- toString(path.getBounds(), str);
-#if 1
- SkString s;
- dumpVerbs(path, &s);
- str->append(s.c_str());
-#endif
- str->append("]");
- str->prepend("path:[");
- }
-}
-
-static const char* toString(SkClipOp op) {
- static const char* gOpNames[] = {
- "DIFF", "SECT", "UNION", "XOR", "RDIFF", "REPLACE"
- };
- return gOpNames[static_cast<int>(op)];
-}
-
-static void toString(const SkRegion& rgn, SkString* str) {
- str->append("Region:[");
- toString(rgn.getBounds(), str);
- str->append("]");
- if (rgn.isComplex()) {
- str->append(".complex");
- }
-}
-
-static const char* toString(SkVertices::VertexMode vm) {
- static const char* gVMNames[] = {
- "TRIANGLES", "STRIP", "FAN"
- };
- return gVMNames[vm];
-}
-
-static const char* toString(SkCanvas::PointMode pm) {
- static const char* gPMNames[] = {
- "POINTS", "LINES", "POLYGON"
- };
- return gPMNames[pm];
-}
-
-static void toString(const void* text, size_t byteLen, SkPaint::TextEncoding enc,
- SkString* str) {
- // FIXME: this code appears to be untested - and probably unused - and probably wrong
- switch (enc) {
- case SkPaint::kUTF8_TextEncoding:
- str->appendf("\"%.*s\"%s", (int)SkTMax<size_t>(byteLen, 32), (const char*) text,
- byteLen > 32 ? "..." : "");
- break;
- case SkPaint::kUTF16_TextEncoding:
- str->appendf("\"%.*ls\"%s", (int)SkTMax<size_t>(byteLen, 32), (const wchar_t*) text,
- byteLen > 64 ? "..." : "");
- break;
- case SkPaint::kUTF32_TextEncoding:
- str->appendf("\"%.*ls\"%s", (int)SkTMax<size_t>(byteLen, 32), (const wchar_t*) text,
- byteLen > 128 ? "..." : "");
- break;
- case SkPaint::kGlyphID_TextEncoding:
- str->append("<glyphs>");
- break;
-
- default:
- SkASSERT(false);
- break;
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-#define WIDE_OPEN 16384
-
-SkDumpCanvas::SkDumpCanvas(Dumper* dumper) : INHERITED(WIDE_OPEN, WIDE_OPEN) {
- fNestLevel = 0;
- SkSafeRef(dumper);
- fDumper = dumper;
-}
-
-SkDumpCanvas::~SkDumpCanvas() {
- SkSafeUnref(fDumper);
-}
-
-void SkDumpCanvas::dump(Verb verb, const SkPaint* paint,
- const char format[], ...) {
- static const size_t BUFFER_SIZE = 1024;
-
- char buffer[BUFFER_SIZE];
- va_list args;
- va_start(args, format);
- vsnprintf(buffer, BUFFER_SIZE, format, args);
- va_end(args);
-
- if (fDumper) {
- fDumper->dump(this, verb, buffer, paint);
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-void SkDumpCanvas::willSave() {
- this->dump(kSave_Verb, nullptr, "save()");
- this->INHERITED::willSave();
-}
-
-SkCanvas::SaveLayerStrategy SkDumpCanvas::getSaveLayerStrategy(const SaveLayerRec& rec) {
- SkString str;
- str.printf("saveLayer(0x%X)", rec.fSaveLayerFlags);
- if (rec.fBounds) {
- str.append(" bounds");
- toString(*rec.fBounds, &str);
- }
- const SkPaint* paint = rec.fPaint;
- if (paint) {
- if (paint->getAlpha() != 0xFF) {
- str.appendf(" alpha:0x%02X", paint->getAlpha());
- }
- if (!paint->isSrcOver()) {
- str.appendf(" blendmode:%d", (int)paint->getBlendMode());
- }
- }
- this->dump(kSave_Verb, paint, str.c_str());
- return this->INHERITED::getSaveLayerStrategy(rec);
-}
-
-void SkDumpCanvas::willRestore() {
- this->dump(kRestore_Verb, nullptr, "restore");
- this->INHERITED::willRestore();
-}
-
-void SkDumpCanvas::didConcat(const SkMatrix& matrix) {
- SkString str;
-
- switch (matrix.getType()) {
- case SkMatrix::kTranslate_Mask:
- this->dump(kMatrix_Verb, nullptr, "translate(%g %g)",
- SkScalarToFloat(matrix.getTranslateX()),
- SkScalarToFloat(matrix.getTranslateY()));
- break;
- case SkMatrix::kScale_Mask:
- this->dump(kMatrix_Verb, nullptr, "scale(%g %g)",
- SkScalarToFloat(matrix.getScaleX()),
- SkScalarToFloat(matrix.getScaleY()));
- break;
- default:
- matrix.toString(&str);
- this->dump(kMatrix_Verb, nullptr, "concat(%s)", str.c_str());
- break;
- }
-
- this->INHERITED::didConcat(matrix);
-}
-
-void SkDumpCanvas::didSetMatrix(const SkMatrix& matrix) {
- SkString str;
- matrix.toString(&str);
- this->dump(kMatrix_Verb, nullptr, "setMatrix(%s)", str.c_str());
- this->INHERITED::didSetMatrix(matrix);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-const char* SkDumpCanvas::EdgeStyleToAAString(ClipEdgeStyle edgeStyle) {
- return kSoft_ClipEdgeStyle == edgeStyle ? "AA" : "BW";
-}
-
-void SkDumpCanvas::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle) {
- SkString str;
- toString(rect, &str);
- this->dump(kClip_Verb, nullptr, "clipRect(%s %s %s)", str.c_str(), toString(op),
- EdgeStyleToAAString(edgeStyle));
- this->INHERITED::onClipRect(rect, op, edgeStyle);
-}
-
-void SkDumpCanvas::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle) {
- SkString str;
- toString(rrect, &str);
- this->dump(kClip_Verb, nullptr, "clipRRect(%s %s %s)", str.c_str(), toString(op),
- EdgeStyleToAAString(edgeStyle));
- this->INHERITED::onClipRRect(rrect, op, edgeStyle);
-}
-
-void SkDumpCanvas::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle) {
- SkString str;
- toString(path, &str);
- this->dump(kClip_Verb, nullptr, "clipPath(%s %s %s)", str.c_str(), toString(op),
- EdgeStyleToAAString(edgeStyle));
- this->INHERITED::onClipPath(path, op, edgeStyle);
-}
-
-void SkDumpCanvas::onClipRegion(const SkRegion& deviceRgn, SkClipOp op) {
- SkString str;
- toString(deviceRgn, &str);
- this->dump(kClip_Verb, nullptr, "clipRegion(%s %s)", str.c_str(), toString(op));
- this->INHERITED::onClipRegion(deviceRgn, op);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-void SkDumpCanvas::onDrawPaint(const SkPaint& paint) {
- this->dump(kDrawPaint_Verb, &paint, "drawPaint()");
-}
-
-void SkDumpCanvas::onDrawPoints(PointMode mode, size_t count,
- const SkPoint pts[], const SkPaint& paint) {
- this->dump(kDrawPoints_Verb, &paint, "drawPoints(%s, %d)", toString(mode),
- count);
-}
-
-void SkDumpCanvas::onDrawOval(const SkRect& rect, const SkPaint& paint) {
- SkString str;
- toString(rect, &str);
- this->dump(kDrawOval_Verb, &paint, "drawOval(%s)", str.c_str());
-}
-
-void SkDumpCanvas::onDrawArc(const SkRect& rect, SkScalar startAngle, SkScalar sweepAngle,
- bool useCenter, const SkPaint& paint) {
- SkString str;
- toString(rect, &str);
- this->dump(kDrawArc_Verb, &paint, "drawArc(%s, %g, %g, %d)", str.c_str(), startAngle,
- sweepAngle, useCenter);
-}
-
-void SkDumpCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) {
- SkString str;
- toString(rect, &str);
- this->dump(kDrawRect_Verb, &paint, "drawRect(%s)", str.c_str());
-}
-
-void SkDumpCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
- SkString str;
- toString(rrect, &str);
- this->dump(kDrawDRRect_Verb, &paint, "drawRRect(%s)", str.c_str());
-}
-
-void SkDumpCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
- const SkPaint& paint) {
- SkString str0, str1;
- toString(outer, &str0);
- toString(inner, &str0);
- this->dump(kDrawRRect_Verb, &paint, "drawDRRect(%s,%s)",
- str0.c_str(), str1.c_str());
-}
-
-void SkDumpCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) {
- SkString str;
- toString(path, &str);
- this->dump(kDrawPath_Verb, &paint, "drawPath(%s)", str.c_str());
-}
-
-void SkDumpCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
- const SkPaint* paint) {
- SkString str;
- bitmap.toString(&str);
- this->dump(kDrawBitmap_Verb, paint, "drawBitmap(%s %g %g)", str.c_str(),
- SkScalarToFloat(x), SkScalarToFloat(y));
-}
-
-void SkDumpCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
- const SkPaint* paint, SrcRectConstraint) {
- SkString bs, rs;
- bitmap.toString(&bs);
- toString(dst, &rs);
- // show the src-rect only if its not everything
- if (src && (src->fLeft > 0 || src->fTop > 0 ||
- src->fRight < SkIntToScalar(bitmap.width()) ||
- src->fBottom < SkIntToScalar(bitmap.height()))) {
- SkString ss;
- toString(*src, &ss);
- rs.prependf("%s ", ss.c_str());
- }
-
- this->dump(kDrawBitmap_Verb, paint, "drawBitmapRect(%s %s)", bs.c_str(), rs.c_str());
-}
-
-void SkDumpCanvas::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
- const SkRect& dst, const SkPaint* paint) {
- SkString str, centerStr, dstStr;
- bitmap.toString(&str);
- toString(center, &centerStr);
- toString(dst, &dstStr);
- this->dump(kDrawBitmap_Verb, paint, "drawBitmapNine(%s %s %s)", str.c_str(),
- centerStr.c_str(), dstStr.c_str());
-}
-
-void SkDumpCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, const SkPaint* paint) {
- SkString str;
- image->toString(&str);
- this->dump(kDrawBitmap_Verb, paint, "drawImage(%s %g %g)", str.c_str(),
- SkScalarToFloat(x), SkScalarToFloat(y));
-}
-
-void SkDumpCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
- const SkPaint* paint, SrcRectConstraint) {
- SkString bs, rs;
- image->toString(&bs);
- toString(dst, &rs);
- // show the src-rect only if its not everything
- if (src && (src->fLeft > 0 || src->fTop > 0 ||
- src->fRight < SkIntToScalar(image->width()) ||
- src->fBottom < SkIntToScalar(image->height()))) {
- SkString ss;
- toString(*src, &ss);
- rs.prependf("%s ", ss.c_str());
- }
-
- this->dump(kDrawBitmap_Verb, paint, "drawImageRectToRect(%s %s)",
- bs.c_str(), rs.c_str());
-}
-
-void SkDumpCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
- const SkPaint& paint) {
- SkString str;
- toString(text, byteLength, paint.getTextEncoding(), &str);
- this->dump(kDrawText_Verb, &paint, "drawText(%s [%d] %g %g)", str.c_str(),
- byteLength, SkScalarToFloat(x), SkScalarToFloat(y));
-}
-
-void SkDumpCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
- const SkPaint& paint) {
- SkString str;
- toString(text, byteLength, paint.getTextEncoding(), &str);
- this->dump(kDrawText_Verb, &paint, "drawPosText(%s [%d] %g %g ...)",
- str.c_str(), byteLength, SkScalarToFloat(pos[0].fX),
- SkScalarToFloat(pos[0].fY));
-}
-
-void SkDumpCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
- SkScalar constY, const SkPaint& paint) {
- SkString str;
- toString(text, byteLength, paint.getTextEncoding(), &str);
- this->dump(kDrawText_Verb, &paint, "drawPosTextH(%s [%d] %g %g ...)",
- str.c_str(), byteLength, SkScalarToFloat(xpos[0]),
- SkScalarToFloat(constY));
-}
-
-void SkDumpCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
- const SkMatrix* matrix, const SkPaint& paint) {
- SkString str;
- toString(text, byteLength, paint.getTextEncoding(), &str);
- this->dump(kDrawText_Verb, &paint, "drawTextOnPath(%s [%d])",
- str.c_str(), byteLength);
-}
-
-void SkDumpCanvas::onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
- const SkRect* cull, const SkPaint& paint) {
- SkString str;
- toString(text, byteLength, paint.getTextEncoding(), &str);
- this->dump(kDrawText_Verb, &paint, "drawTextRSXform(%s [%d])",
- str.c_str(), byteLength);
-}
-
-void SkDumpCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
- const SkPaint& paint) {
- SkString str;
- toString(blob->bounds(), &str);
- this->dump(kDrawText_Verb, &paint, "drawTextBlob(%p) [%s]", blob, str.c_str());
- // FIXME: dump the actual blob content?
-}
-
-void SkDumpCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
- const SkPaint* paint) {
- this->dump(kDrawPicture_Verb, nullptr, "drawPicture(%p) %f:%f:%f:%f", picture,
- picture->cullRect().fLeft, picture->cullRect().fTop,
- picture->cullRect().fRight, picture->cullRect().fBottom);
- fNestLevel += 1;
- this->INHERITED::onDrawPicture(picture, matrix, paint);
- fNestLevel -= 1;
- this->dump(kDrawPicture_Verb, nullptr, "endPicture(%p) %f:%f:%f:%f", picture,
- picture->cullRect().fLeft, picture->cullRect().fTop,
- picture->cullRect().fRight, picture->cullRect().fBottom);
-}
-
-void SkDumpCanvas::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
- const auto bounds = drawable->getBounds();
- this->dump(kDrawPicture_Verb, nullptr, "drawDrawable(%p) %f:%f:%f:%f", drawable,
- bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
- fNestLevel += 1;
- this->INHERITED::onDrawDrawable(drawable, matrix);
- fNestLevel -= 1;
- this->dump(kDrawPicture_Verb, nullptr, "endDrawable(%p) %f:%f:%f:%f", drawable,
- bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
-}
-
-void SkDumpCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode,
- const SkPaint& paint) {
- this->dump(kDrawVertices_Verb, &paint, "drawVertices(%s [%d] ...)",
- toString(vertices->mode()), vertices->vertexCount());
-}
-
-void SkDumpCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
- const SkPoint texCoords[4], SkBlendMode,
- const SkPaint& paint) {
- //dumps corner points and colors in clockwise order starting on upper-left corner
- this->dump(kDrawPatch_Verb, &paint, "drawPatch(Vertices{[%f, %f], [%f, %f], [%f, %f], [%f, %f]}\
- | Colors{[0x%x], [0x%x], [0x%x], [0x%x]} | TexCoords{[%f,%f], [%f,%f], [%f,%f], \
- [%f,%f]})",
- cubics[0].fX, cubics[0].fY,
- cubics[3].fX, cubics[3].fY,
- cubics[6].fX, cubics[6].fY,
- cubics[9].fX, cubics[9].fY,
- colors[0], colors[1], colors[2], colors[3],
- texCoords[0].x(), texCoords[0].y(), texCoords[1].x(), texCoords[1].y(),
- texCoords[2].x(), texCoords[2].y(), texCoords[3].x(), texCoords[3].y());
-}
-
-void SkDumpCanvas::onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) {
- SkString str;
- toString(rect, &str);
- this->dump(kDrawAnnotation_Verb, nullptr, "drawAnnotation(%s \"%s\" (%zu))",
- str.c_str(), key, value ? value->size() : 0);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////
-
-SkFormatDumper::SkFormatDumper(void (*proc)(const char*, void*), void* refcon) {
- fProc = proc;
- fRefcon = refcon;
-}
-
-static void appendPtr(SkString* str, const void* ptr, const char name[]) {
- if (ptr) {
- str->appendf(" %s:%p", name, ptr);
- }
-}
-
-static void appendFlattenable(SkString* str, const SkFlattenable* ptr,
- const char name[]) {
- if (ptr) {
- str->appendf(" %s:%p", name, ptr);
- }
-}
-
-void SkFormatDumper::dump(SkDumpCanvas* canvas, SkDumpCanvas::Verb verb,
- const char str[], const SkPaint* p) {
- SkString msg, tab;
- const int level = canvas->getNestLevel() + canvas->getSaveCount() - 1;
- SkASSERT(level >= 0);
- for (int i = 0; i < level; i++) {
-#if 0
- tab.append("\t");
-#else
- tab.append(" "); // tabs are often too wide to be useful
-#endif
- }
- msg.printf("%s%s", tab.c_str(), str);
-
- if (p) {
- msg.appendf(" color:0x%08X flags:%X", p->getColor(), p->getFlags());
- if (!p->isSrcOver()) {
- msg.appendf(" blendmode:%d", (int)p->getBlendMode());
- }
- appendFlattenable(&msg, p->getShader(), "shader");
- appendFlattenable(&msg, p->getPathEffect(), "pathEffect");
- appendFlattenable(&msg, p->getMaskFilter(), "maskFilter");
- appendFlattenable(&msg, p->getPathEffect(), "pathEffect");
- appendFlattenable(&msg, p->getColorFilter(), "filter");
-
- if (SkDumpCanvas::kDrawText_Verb == verb) {
- msg.appendf(" textSize:%g", SkScalarToFloat(p->getTextSize()));
- appendPtr(&msg, p->getTypeface(), "typeface");
- }
-
- if (p->getStyle() != SkPaint::kFill_Style) {
- msg.appendf(" strokeWidth:%g", SkScalarToFloat(p->getStrokeWidth()));
- }
- }
-
- fProc(msg.c_str(), fRefcon);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-static void dumpToDebugf(const char text[], void*) {
- SkDebugf("%s\n", text);
-}
-
-SkDebugfDumper::SkDebugfDumper() : INHERITED(dumpToDebugf, nullptr) {}
diff --git a/tools/pinspect.cpp b/tools/pinspect.cpp
deleted file mode 100644
index 29a422257d..0000000000
--- a/tools/pinspect.cpp
+++ /dev/null
@@ -1,82 +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 "SkBitmap.h"
-#include "SkCanvas.h"
-#include "SkGraphics.h"
-#include "SkOSFile.h"
-#include "SkPicture.h"
-#include "SkStream.h"
-#include "SkString.h"
-#include "SkDumpCanvas.h"
-
-static sk_sp<SkPicture> inspect(const char path[]) {
- SkFILEStream stream(path);
- if (!stream.isValid()) {
- printf("-- Can't open '%s'\n", path);
- return nullptr;
- }
-
- printf("Opening '%s'...\n", path);
-
- {
- int32_t header[3];
- if (stream.read(header, sizeof(header)) != sizeof(header)) {
- printf("-- Failed to read header (12 bytes)\n");
- return nullptr;
- }
- printf("version:%d width:%d height:%d\n", header[0], header[1], header[2]);
- }
-
- stream.rewind();
- auto pic = SkPicture::MakeFromStream(&stream);
- if (nullptr == pic) {
- SkDebugf("Could not create SkPicture: %s\n", path);
- return nullptr;
- }
- printf("picture cullRect: [%f %f %f %f]\n",
- pic->cullRect().fLeft, pic->cullRect().fTop,
- pic->cullRect().fRight, pic->cullRect().fBottom);
- return pic;
-}
-
-static void dumpOps(SkPicture* pic) {
-#ifdef SK_DEBUG
- SkDebugfDumper dumper;
- SkDumpCanvas canvas(&dumper);
- canvas.drawPicture(pic);
-#else
- printf("SK_DEBUG mode not enabled\n");
-#endif
-}
-
-int main(int argc, char** argv) {
- SkAutoGraphics ag;
- if (argc < 2) {
- printf("Usage: pinspect [--dump-ops] filename [filename ...]\n");
- return 1;
- }
-
- bool doDumpOps = false;
-
- int index = 1;
- if (!strcmp(argv[index], "--dump-ops")) {
- index += 1;
- doDumpOps = true;
- }
-
- for (; index < argc; ++index) {
- auto pic(inspect(argv[index]));
- if (doDumpOps) {
- dumpOps(pic.get());
- }
- if (index < argc - 1) {
- printf("\n");
- }
- }
- return 0;
-}