Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Unified Diff: tools/debugger/SkDrawCommand.cpp

Issue 1775203002: Add SkDrawPosTextHCommand JSON, fix skiaserve build. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix position count, always define target. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/debugger/SkDrawCommand.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/debugger/SkDrawCommand.cpp
diff --git a/tools/debugger/SkDrawCommand.cpp b/tools/debugger/SkDrawCommand.cpp
index 1790536b5c34b8a4493a0dd60bd5720423b2a19e..9ea9a9c46c9717302940f65eebb367dadcb8ad26 100644
--- a/tools/debugger/SkDrawCommand.cpp
+++ b/tools/debugger/SkDrawCommand.cpp
@@ -245,6 +245,7 @@ SkDrawCommand* SkDrawCommand::fromJSON(Json::Value& command, UrlDataManager& url
INSTALL_FACTORY(DrawPoints);
INSTALL_FACTORY(DrawText);
INSTALL_FACTORY(DrawPosText);
+ INSTALL_FACTORY(DrawPosTextH);
INSTALL_FACTORY(DrawTextOnPath);
INSTALL_FACTORY(DrawTextBlob);
@@ -2368,7 +2369,8 @@ Json::Value SkDrawPosTextCommand::toJSON(UrlDataManager& urlDataManager) const {
result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText,
((const char*) fText) + fByteLength);
Json::Value coords(Json::arrayValue);
- for (size_t i = 0; i < fByteLength; i++) {
+ size_t numCoords = fPaint.textToGlyphs(fText, fByteLength, nullptr);
+ for (size_t i = 0; i < numCoords; i++) {
coords.append(make_json_point(fPos[i]));
}
result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = coords;
@@ -2416,6 +2418,36 @@ void SkDrawPosTextHCommand::execute(SkCanvas* canvas) const {
canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint);
}
+Json::Value SkDrawPosTextHCommand::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_Y] = Json::Value(fConstY);
+ Json::Value xpos(Json::arrayValue);
+ size_t numXpos = fPaint.textToGlyphs(fText, fByteLength, nullptr);
+ for (size_t i = 0; i < numXpos; i++) {
+ xpos.append(Json::Value(fXpos[i]));
+ }
+ result[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS] = xpos;
+ result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManager);
+ return result;
+}
+
+SkDrawPosTextHCommand* SkDrawPosTextHCommand::fromJSON(Json::Value& command,
+ UrlDataManager& urlDataManager) {
+ const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString();
+ SkPaint paint;
+ extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &paint);
+ Json::Value jsonXpos = command[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS];
+ int count = (int) jsonXpos.size();
+ SkScalar* xpos = (SkScalar*) sk_malloc_throw(count * sizeof(SkScalar));
+ for (int i = 0; i < count; i++) {
+ xpos[i] = jsonXpos[i].asFloat();
+ }
+ SkScalar y = command[SKDEBUGCANVAS_ATTRIBUTE_Y].asFloat();
+ return new SkDrawPosTextHCommand(text, strlen(text), xpos, y, paint);
+}
+
static const char* gPositioningLabels[] = {
"kDefault_Positioning",
"kHorizontal_Positioning",
« no previous file with comments | « tools/debugger/SkDrawCommand.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698