From b3f319fbb01c74e757846d9fcfbf1da174c0cb17 Mon Sep 17 00:00:00 2001 From: robertphillips Date: Wed, 13 Aug 2014 10:46:23 -0700 Subject: Add support for new drawPicture entry point to debugger R=fmalita@google.com, fmalita@chromium.org Author: robertphillips@google.com Review URL: https://codereview.chromium.org/464063003 --- src/utils/debugger/SkDebugCanvas.cpp | 7 ++++--- src/utils/debugger/SkDrawCommand.cpp | 28 ++++++++++++++++++++++++---- src/utils/debugger/SkDrawCommand.h | 6 +++++- 3 files changed, 33 insertions(+), 8 deletions(-) (limited to 'src/utils/debugger') diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp index 516d58292f..228f25f737 100644 --- a/src/utils/debugger/SkDebugCanvas.cpp +++ b/src/utils/debugger/SkDebugCanvas.cpp @@ -519,9 +519,10 @@ void SkDebugCanvas::drawPath(const SkPath& path, const SkPaint& paint) { this->addDrawCommand(new SkDrawPathCommand(path, paint)); } -void SkDebugCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix*, const SkPaint*) { - // todo: add matrix and paint to SkDrawPictureCommand - this->addDrawCommand(new SkDrawPictureCommand(picture)); +void SkDebugCanvas::onDrawPicture(const SkPicture* picture, + const SkMatrix* matrix, + const SkPaint* paint) { + this->addDrawCommand(new SkDrawPictureCommand(picture, matrix, paint)); } void SkDebugCanvas::drawPoints(PointMode mode, size_t count, diff --git a/src/utils/debugger/SkDrawCommand.cpp b/src/utils/debugger/SkDrawCommand.cpp index c50fa2d3f5..26d2a85a8a 100644 --- a/src/utils/debugger/SkDrawCommand.cpp +++ b/src/utils/debugger/SkDrawCommand.cpp @@ -273,7 +273,7 @@ void SkConcatCommand::execute(SkCanvas* canvas) { } SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top, - const SkPaint* paint) + const SkPaint* paint) : INHERITED(DRAW_BITMAP) { fBitmap = bitmap; fLeft = left; @@ -502,16 +502,36 @@ bool SkDrawPathCommand::render(SkCanvas* canvas) const { return true; } -SkDrawPictureCommand::SkDrawPictureCommand(const SkPicture* picture) +SkDrawPictureCommand::SkDrawPictureCommand(const SkPicture* picture, + const SkMatrix* matrix, + const SkPaint* paint) : INHERITED(DRAW_PICTURE) - , fPicture(SkRef(picture)) { + , fPicture(SkRef(picture)) + , fMatrixPtr(NULL) + , fPaintPtr(NULL) { + + if (NULL != matrix) { + fMatrix = *matrix; + fMatrixPtr = &fMatrix; + } + if (NULL != paint) { + fPaint = *paint; + fPaintPtr = &fPaint; + } + SkString* temp = new SkString; temp->appendf("SkPicture: W: %d H: %d", picture->width(), picture->height()); fInfo.push(temp); + if (NULL != matrix) { + fInfo.push(SkObjectParser::MatrixToString(*matrix)); + } + if (NULL != paint) { + fInfo.push(SkObjectParser::PaintToString(*paint)); + } } void SkDrawPictureCommand::execute(SkCanvas* canvas) { - canvas->drawPicture(fPicture); + canvas->drawPicture(fPicture, fMatrixPtr, fPaintPtr); } bool SkDrawPictureCommand::render(SkCanvas* canvas) const { diff --git a/src/utils/debugger/SkDrawCommand.h b/src/utils/debugger/SkDrawCommand.h index f4569931a1..ce7b1f5f76 100644 --- a/src/utils/debugger/SkDrawCommand.h +++ b/src/utils/debugger/SkDrawCommand.h @@ -343,12 +343,16 @@ private: class SkDrawPictureCommand : public SkDrawCommand { public: - SkDrawPictureCommand(const SkPicture* picture); + SkDrawPictureCommand(const SkPicture* picture, const SkMatrix* matrix, const SkPaint* paint); virtual void execute(SkCanvas* canvas) SK_OVERRIDE; virtual bool render(SkCanvas* canvas) const SK_OVERRIDE; private: SkAutoTUnref fPicture; + SkMatrix fMatrix; + SkMatrix* fMatrixPtr; + SkPaint fPaint; + SkPaint* fPaintPtr; typedef SkDrawCommand INHERITED; }; -- cgit v1.2.3