diff options
author | Brian Osman <brianosman@google.com> | 2018-05-29 11:23:35 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-29 15:44:35 +0000 |
commit | 616f1cb4564229322944234ee20fc96ab5716464 (patch) | |
tree | f5ff5c07b4897efb4ed7e04e071395f85aac88b5 /tools/debugger | |
parent | ae0f6cc345b193243353578883169fa055806468 (diff) |
Added drawAtlas support to SkDebugCanvas
No serialization yet (like drawVertices, etc...), but should support
capture and playback.
Change-Id: I7b54cc95fb828471a8faa6abd4eaca0ad0d2cb70
Reviewed-on: https://skia-review.googlesource.com/130503
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Diffstat (limited to 'tools/debugger')
-rw-r--r-- | tools/debugger/SkDebugCanvas.cpp | 7 | ||||
-rw-r--r-- | tools/debugger/SkDebugCanvas.h | 2 | ||||
-rw-r--r-- | tools/debugger/SkDrawCommand.cpp | 24 | ||||
-rw-r--r-- | tools/debugger/SkDrawCommand.h | 20 |
4 files changed, 53 insertions, 0 deletions
diff --git a/tools/debugger/SkDebugCanvas.cpp b/tools/debugger/SkDebugCanvas.cpp index cf813b90d7..93163c9579 100644 --- a/tools/debugger/SkDebugCanvas.cpp +++ b/tools/debugger/SkDebugCanvas.cpp @@ -473,6 +473,13 @@ void SkDebugCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode, paint)); } +void SkDebugCanvas::onDrawAtlas(const SkImage* image, const SkRSXform xform[], const SkRect tex[], + const SkColor colors[], int count, SkBlendMode bmode, + const SkRect* cull, const SkPaint* paint) { + this->addDrawCommand(new SkDrawAtlasCommand(image, xform, tex, colors, count, bmode, cull, + paint)); +} + void SkDebugCanvas::onDrawShadowRec(const SkPath& path, const SkDrawShadowRec& rec) { this->addDrawCommand(new SkDrawShadowCommand(path, rec)); } diff --git a/tools/debugger/SkDebugCanvas.h b/tools/debugger/SkDebugCanvas.h index 2987e0cc79..63c3f0b8dc 100644 --- a/tools/debugger/SkDebugCanvas.h +++ b/tools/debugger/SkDebugCanvas.h @@ -168,6 +168,8 @@ protected: const SkPaint*) override; void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst, const SkPaint*) override; + void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], + int, SkBlendMode, const SkRect*, const SkPaint*) override; void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override; void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override; void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override; diff --git a/tools/debugger/SkDrawCommand.cpp b/tools/debugger/SkDrawCommand.cpp index 2dc11f4ef5..4740b4bf27 100644 --- a/tools/debugger/SkDrawCommand.cpp +++ b/tools/debugger/SkDrawCommand.cpp @@ -250,6 +250,7 @@ const char* SkDrawCommand::GetCommandString(OpType type) { case kDrawTextOnPath_OpType: return "DrawTextOnPath"; case kDrawTextRSXform_OpType: return "DrawTextRSXform"; case kDrawVertices_OpType: return "DrawVertices"; + case kDrawAtlas_OpType: return "DrawAtlas"; case kEndDrawPicture_OpType: return "EndDrawPicture"; case kRestore_OpType: return "Restore"; case kSave_OpType: return "Save"; @@ -3510,6 +3511,29 @@ void SkDrawVerticesCommand::execute(SkCanvas* canvas) const { canvas->drawVertices(fVertices, fBlendMode, fPaint); } +/////////////////////////////////////////////////////////////////////////////////////////////////// + +SkDrawAtlasCommand::SkDrawAtlasCommand(const SkImage* image, const SkRSXform xform[], + const SkRect tex[], const SkColor colors[], int count, + SkBlendMode bmode, const SkRect* cull, + const SkPaint* paint) + : INHERITED(kDrawAtlas_OpType) + , fImage(SkRef(image)) + , fXform(xform, count) + , fTex(tex, count) + , fColors(colors, colors ? count : 0) + , fBlendMode(bmode) + , fCull(cull) + , fPaint(paint) {} + +void SkDrawAtlasCommand::execute(SkCanvas* canvas) const { + canvas->drawAtlas(fImage.get(), fXform.begin(), fTex.begin(), + fColors.isEmpty() ? nullptr : fColors.begin(), fXform.count(), fBlendMode, + fCull.getMaybeNull(), fPaint.getMaybeNull()); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// + SkRestoreCommand::SkRestoreCommand() : INHERITED(kRestore_OpType) {} diff --git a/tools/debugger/SkDrawCommand.h b/tools/debugger/SkDrawCommand.h index a52eb43762..5a14c4fbff 100644 --- a/tools/debugger/SkDrawCommand.h +++ b/tools/debugger/SkDrawCommand.h @@ -60,6 +60,7 @@ public: kDrawTextOnPath_OpType, kDrawTextRSXform_OpType, kDrawVertices_OpType, + kDrawAtlas_OpType, kEndDrawPicture_OpType, kRestore_OpType, kSave_OpType, @@ -742,6 +743,25 @@ private: typedef SkDrawCommand INHERITED; }; +class SkDrawAtlasCommand : public SkDrawCommand { +public: + SkDrawAtlasCommand(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int, + SkBlendMode, const SkRect*, const SkPaint*); + + void execute(SkCanvas* canvas) const override; + +private: + sk_sp<const SkImage> fImage; + SkTDArray<SkRSXform> fXform; + SkTDArray<SkRect> fTex; + SkTDArray<SkColor> fColors; + SkBlendMode fBlendMode; + SkTLazy<SkRect> fCull; + SkTLazy<SkPaint> fPaint; + + typedef SkDrawCommand INHERITED; +}; + class SkSaveCommand : public SkDrawCommand { public: SkSaveCommand(); |