diff options
author | reed <reed@google.com> | 2016-07-07 12:47:17 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-07 12:47:17 -0700 |
commit | 45561a0b15fe045ba272c328684c3f7ae290785a (patch) | |
tree | 185647ba5e92daf0899b1d8985dbf4a46a76f7b9 /tools/debugger | |
parent | a76a10b730ae3fb2abb7c06839ca9c5d14df5ca7 (diff) |
drawTextRSXform
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2130643004
Review-Url: https://codereview.chromium.org/2130643004
Diffstat (limited to 'tools/debugger')
-rw-r--r-- | tools/debugger/SkDebugCanvas.cpp | 5 | ||||
-rw-r--r-- | tools/debugger/SkDebugCanvas.h | 2 | ||||
-rw-r--r-- | tools/debugger/SkDrawCommand.cpp | 60 | ||||
-rw-r--r-- | tools/debugger/SkDrawCommand.h | 22 |
4 files changed, 89 insertions, 0 deletions
diff --git a/tools/debugger/SkDebugCanvas.cpp b/tools/debugger/SkDebugCanvas.cpp index ceea782193..b80eeea0b1 100644 --- a/tools/debugger/SkDebugCanvas.cpp +++ b/tools/debugger/SkDebugCanvas.cpp @@ -644,6 +644,11 @@ void SkDebugCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const new SkDrawTextOnPathCommand(text, byteLength, path, matrix, paint)); } +void SkDebugCanvas::onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[], + const SkRect* cull, const SkPaint& paint) { + this->addDrawCommand(new SkDrawTextRSXformCommand(text, byteLength, xform, cull, paint)); +} + void SkDebugCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint) { this->addDrawCommand(new SkDrawTextBlobCommand(blob, x, y, paint)); diff --git a/tools/debugger/SkDebugCanvas.h b/tools/debugger/SkDebugCanvas.h index d0cdf82a36..e8d9113438 100644 --- a/tools/debugger/SkDebugCanvas.h +++ b/tools/debugger/SkDebugCanvas.h @@ -204,6 +204,8 @@ protected: SkScalar constY, const SkPaint&) override; 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[], const SkRect*, + const SkPaint&) override; void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint) override; diff --git a/tools/debugger/SkDrawCommand.cpp b/tools/debugger/SkDrawCommand.cpp index 6c9287fa31..d58b3c935e 100644 --- a/tools/debugger/SkDrawCommand.cpp +++ b/tools/debugger/SkDrawCommand.cpp @@ -204,6 +204,7 @@ const char* SkDrawCommand::GetCommandString(OpType type) { case kDrawText_OpType: return "DrawText"; case kDrawTextBlob_OpType: return "DrawTextBlob"; case kDrawTextOnPath_OpType: return "DrawTextOnPath"; + case kDrawTextRSXform_OpType: return "drawTextRSXform"; case kDrawVertices_OpType: return "DrawVertices"; case kEndDrawPicture_OpType: return "EndDrawPicture"; case kRestore_OpType: return "Restore"; @@ -257,6 +258,7 @@ SkDrawCommand* SkDrawCommand::fromJSON(Json::Value& command, UrlDataManager& url INSTALL_FACTORY(DrawPosText); INSTALL_FACTORY(DrawPosTextH); INSTALL_FACTORY(DrawTextOnPath); + INSTALL_FACTORY(DrawTextRSXform); INSTALL_FACTORY(DrawTextBlob); INSTALL_FACTORY(DrawRect); @@ -2956,6 +2958,8 @@ SkDrawTextCommand* SkDrawTextCommand::fromJSON(Json::Value& command, paint); } +/////////////////////////////////////////////////////////////////////////////////////////////////// + SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLength, const SkPath& path, const SkMatrix* matrix, const SkPaint& paint) @@ -3017,6 +3021,62 @@ SkDrawTextOnPathCommand* SkDrawTextOnPathCommand::fromJSON(Json::Value& command, return new SkDrawTextOnPathCommand(text, strlen(text), path, matrixPtr, paint); } +/////////////////////////////////////////////////////////////////////////////////////////////////// + +SkDrawTextRSXformCommand::SkDrawTextRSXformCommand(const void* text, size_t byteLength, + const SkRSXform xform[], const SkRect* cull, + const SkPaint& paint) + : INHERITED(kDrawTextOnPath_OpType) +{ + fText = new char[byteLength]; + memcpy(fText, text, byteLength); + fByteLength = byteLength; + int count = paint.countText(text, byteLength); + fXform = new SkRSXform[count]; + memcpy(fXform, xform, count * sizeof(SkRSXform)); + if (cull) { + fCullStorage = *cull; + fCull = &fCullStorage; + } else { + fCull = nullptr; + } + fPaint = paint; + + fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding())); + fInfo.push(SkObjectParser::PaintToString(paint)); +} + +void SkDrawTextRSXformCommand::execute(SkCanvas* canvas) const { + canvas->drawTextRSXform(fText, fByteLength, fXform, fCull, fPaint); +} + +Json::Value SkDrawTextRSXformCommand::toJSON(UrlDataManager& urlDataManager) const { + Json::Value result = INHERITED::toJSON(urlDataManager); + result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, + ((const char*) fText) + fByteLength); + result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager); + return result; +} + +SkDrawTextRSXformCommand* SkDrawTextRSXformCommand::fromJSON(Json::Value& command, + UrlDataManager& urlDataManager) { + const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); + size_t byteLength = strlen(text); + SkPaint paint; + extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &paint); + + // TODO: handle xform and cull + int count = paint.countText(text, byteLength); + SkAutoTArray<SkRSXform> xform(count); + for (int i = 0; i < count; ++i) { + xform[i].fSCos = 1; + xform[i].fSSin = xform[i].fTx = xform[i].fTy = 0; + } + return new SkDrawTextRSXformCommand(text, byteLength, &xform[0], nullptr, paint); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// + SkDrawVerticesCommand::SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount, const SkPoint vertices[], const SkPoint texs[], const SkColor colors[], SkXfermode* xfermode, diff --git a/tools/debugger/SkDrawCommand.h b/tools/debugger/SkDrawCommand.h index 8b8ada267f..dc639ec3a3 100644 --- a/tools/debugger/SkDrawCommand.h +++ b/tools/debugger/SkDrawCommand.h @@ -14,6 +14,7 @@ #include "SkTLazy.h" #include "SkPath.h" #include "SkRRect.h" +#include "SkRSXform.h" #include "SkString.h" #include "SkTDArray.h" #include "SkJSONCPP.h" @@ -48,6 +49,7 @@ public: kDrawText_OpType, kDrawTextBlob_OpType, kDrawTextOnPath_OpType, + kDrawTextRSXform_OpType, kDrawVertices_OpType, kEndDrawPicture_OpType, kRestore_OpType, @@ -526,6 +528,26 @@ private: typedef SkDrawCommand INHERITED; }; +class SkDrawTextRSXformCommand : public SkDrawCommand { +public: + SkDrawTextRSXformCommand(const void* text, size_t byteLength, const SkRSXform[], + const SkRect*, const SkPaint& paint); + ~SkDrawTextRSXformCommand() override { delete[] fText; delete[] fXform; } + void execute(SkCanvas* canvas) const override; + Json::Value toJSON(UrlDataManager& urlDataManager) const override; + static SkDrawTextRSXformCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager); + +private: + char* fText; + size_t fByteLength; + SkRSXform* fXform; + SkRect* fCull; + SkRect fCullStorage; + SkPaint fPaint; + + typedef SkDrawCommand INHERITED; +}; + class SkDrawPosTextHCommand : public SkDrawCommand { public: SkDrawPosTextHCommand(const void* text, size_t byteLength, const SkScalar xpos[], |