diff options
Diffstat (limited to 'tools/debugger')
-rw-r--r-- | tools/debugger/SkDebugCanvas.cpp | 5 | ||||
-rw-r--r-- | tools/debugger/SkDebugCanvas.h | 8 | ||||
-rw-r--r-- | tools/debugger/SkDrawCommand.cpp | 59 | ||||
-rw-r--r-- | tools/debugger/SkDrawCommand.h | 20 |
4 files changed, 86 insertions, 6 deletions
diff --git a/tools/debugger/SkDebugCanvas.cpp b/tools/debugger/SkDebugCanvas.cpp index 67f4bd3dc9..cf813b90d7 100644 --- a/tools/debugger/SkDebugCanvas.cpp +++ b/tools/debugger/SkDebugCanvas.cpp @@ -343,6 +343,11 @@ void SkDebugCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar left, this->addDrawCommand(new SkDrawBitmapCommand(bitmap, left, top, paint)); } +void SkDebugCanvas::onDrawBitmapLattice(const SkBitmap& bitmap, const Lattice& lattice, + const SkRect& dst, const SkPaint* paint) { + this->addDrawCommand(new SkDrawBitmapLatticeCommand(bitmap, lattice, dst, paint)); +} + void SkDebugCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst, const SkPaint* paint, SrcRectConstraint constraint) { this->addDrawCommand(new SkDrawBitmapRectCommand(bitmap, src, dst, paint, diff --git a/tools/debugger/SkDebugCanvas.h b/tools/debugger/SkDebugCanvas.h index 66c46811d4..2987e0cc79 100644 --- a/tools/debugger/SkDebugCanvas.h +++ b/tools/debugger/SkDebugCanvas.h @@ -10,6 +10,7 @@ #define SKDEBUGCANVAS_H_ #include "SkCanvas.h" +#include "SkCanvasVirtualEnforcer.h" #include "SkDrawCommand.h" #include "SkPath.h" #include "SkPathOps.h" @@ -22,7 +23,12 @@ class GrAuditTrail; class SkNWayCanvas; class SkPicture; +// TODO: Continue filling in missing functionality so this can be switched on +#if 0 +class SkDebugCanvas : public SkCanvasVirtualEnforcer<SkCanvas> { +#else class SkDebugCanvas : public SkCanvas { +#endif public: SkDebugCanvas(int width, int height); @@ -149,6 +155,8 @@ protected: void onDrawPath(const SkPath&, const SkPaint&) override; void onDrawRegion(const SkRegion&, const SkPaint&) override; void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override; + void onDrawBitmapLattice(const SkBitmap&, const Lattice&, const SkRect&, + 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; diff --git a/tools/debugger/SkDrawCommand.cpp b/tools/debugger/SkDrawCommand.cpp index ba54c88924..2dc11f4ef5 100644 --- a/tools/debugger/SkDrawCommand.cpp +++ b/tools/debugger/SkDrawCommand.cpp @@ -225,6 +225,7 @@ const char* SkDrawCommand::GetCommandString(OpType type) { case kConcat_OpType: return "Concat"; case kDrawAnnotation_OpType: return "DrawAnnotation"; case kDrawBitmap_OpType: return "DrawBitmap"; + case kDrawBitmapLattice_OpType: return "DrawBitmapLattice"; case kDrawBitmapNine_OpType: return "DrawBitmapNine"; case kDrawBitmapRect_OpType: return "DrawBitmapRect"; case kDrawDRRect_OpType: return "DrawDRRect"; @@ -2076,6 +2077,57 @@ SkDrawBitmapCommand* SkDrawBitmapCommand::fromJSON(Json::Value& command, return result; } +SkDrawBitmapLatticeCommand::SkDrawBitmapLatticeCommand(const SkBitmap& bitmap, + const SkCanvas::Lattice& lattice, + const SkRect& dst, const SkPaint* paint) + : INHERITED(kDrawBitmapLattice_OpType) + , fBitmap(bitmap) + , fLattice(lattice) + , fDst(dst) { + + if (paint) { + fPaint.set(*paint); + } +} + +void SkDrawBitmapLatticeCommand::execute(SkCanvas* canvas) const { + canvas->drawBitmapLattice(fBitmap, fLattice, fDst, fPaint.getMaybeNull()); +} + +bool SkDrawBitmapLatticeCommand::render(SkCanvas* canvas) const { + SkAutoCanvasRestore acr(canvas, true); + canvas->clear(0xFFFFFFFF); + + xlate_and_scale_to_bounds(canvas, fDst); + + this->execute(canvas); + return true; +} + +Json::Value SkDrawBitmapLatticeCommand::toJSON(UrlDataManager& urlDataManager) const { + Json::Value result = INHERITED::toJSON(urlDataManager); + Json::Value encoded; + if (flatten(fBitmap, &encoded, urlDataManager)) { + result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; + result[SKDEBUGCANVAS_ATTRIBUTE_LATTICE] = MakeJsonLattice(fLattice); + result[SKDEBUGCANVAS_ATTRIBUTE_DST] = MakeJsonRect(fDst); + if (fPaint.isValid()) { + result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaint.get(), urlDataManager); + } + } + + SkString desc; + result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(str_append(&desc, fDst)->c_str()); + + return result; +} + +SkDrawBitmapLatticeCommand* SkDrawBitmapLatticeCommand::fromJSON(Json::Value& command, + UrlDataManager& urlDataManager) { + SkDEBUGFAIL("Not implemented yet."); + return nullptr; +} + SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst, const SkPaint* paint) : INHERITED(kDrawBitmapNine_OpType) { @@ -2324,12 +2376,7 @@ SkDrawImageLatticeCommand::SkDrawImageLatticeCommand(const SkImage* image, } void SkDrawImageLatticeCommand::execute(SkCanvas* canvas) const { - SkLatticeIter iter(fLattice, fDst); - SkRect srcR, dstR; - while (iter.next(&srcR, &dstR)) { - canvas->legacy_drawImageRect(fImage.get(), &srcR, dstR, - fPaint.getMaybeNull(), SkCanvas::kStrict_SrcRectConstraint); - } + canvas->drawImageLattice(fImage.get(), fLattice, fDst, fPaint.getMaybeNull()); } bool SkDrawImageLatticeCommand::render(SkCanvas* canvas) const { diff --git a/tools/debugger/SkDrawCommand.h b/tools/debugger/SkDrawCommand.h index 257029c913..a52eb43762 100644 --- a/tools/debugger/SkDrawCommand.h +++ b/tools/debugger/SkDrawCommand.h @@ -35,6 +35,7 @@ public: kConcat_OpType, kDrawAnnotation_OpType, kDrawBitmap_OpType, + kDrawBitmapLattice_OpType, kDrawBitmapNine_OpType, kDrawBitmapRect_OpType, kDrawDRRect_OpType, @@ -265,6 +266,25 @@ private: typedef SkDrawCommand INHERITED; }; +class SkDrawBitmapLatticeCommand : public SkDrawCommand { +public: + SkDrawBitmapLatticeCommand(const SkBitmap& bitmap, const SkCanvas::Lattice& lattice, + const SkRect& dst, const SkPaint* paint); + void execute(SkCanvas* canvas) const override; + bool render(SkCanvas* canvas) const override; + Json::Value toJSON(UrlDataManager& urlDataManager) const override; + static SkDrawBitmapLatticeCommand* fromJSON(Json::Value& command, + UrlDataManager& urlDataManager); + +private: + SkBitmap fBitmap; + SkCanvas::Lattice fLattice; + SkRect fDst; + SkTLazy<SkPaint> fPaint; + + typedef SkDrawCommand INHERITED; +}; + class SkDrawBitmapNineCommand : public SkDrawCommand { public: SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center, |