| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "SkDrawCommand.h" | 10 #include "SkDrawCommand.h" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 INSTALL_FACTORY(DrawBitmapRect); | 238 INSTALL_FACTORY(DrawBitmapRect); |
| 239 INSTALL_FACTORY(DrawBitmapNine); | 239 INSTALL_FACTORY(DrawBitmapNine); |
| 240 INSTALL_FACTORY(DrawImage); | 240 INSTALL_FACTORY(DrawImage); |
| 241 INSTALL_FACTORY(DrawImageRect); | 241 INSTALL_FACTORY(DrawImageRect); |
| 242 INSTALL_FACTORY(DrawOval); | 242 INSTALL_FACTORY(DrawOval); |
| 243 INSTALL_FACTORY(DrawPaint); | 243 INSTALL_FACTORY(DrawPaint); |
| 244 INSTALL_FACTORY(DrawPath); | 244 INSTALL_FACTORY(DrawPath); |
| 245 INSTALL_FACTORY(DrawPoints); | 245 INSTALL_FACTORY(DrawPoints); |
| 246 INSTALL_FACTORY(DrawText); | 246 INSTALL_FACTORY(DrawText); |
| 247 INSTALL_FACTORY(DrawPosText); | 247 INSTALL_FACTORY(DrawPosText); |
| 248 INSTALL_FACTORY(DrawPosTextH); |
| 248 INSTALL_FACTORY(DrawTextOnPath); | 249 INSTALL_FACTORY(DrawTextOnPath); |
| 249 INSTALL_FACTORY(DrawTextBlob); | 250 INSTALL_FACTORY(DrawTextBlob); |
| 250 | 251 |
| 251 INSTALL_FACTORY(DrawRect); | 252 INSTALL_FACTORY(DrawRect); |
| 252 INSTALL_FACTORY(DrawRRect); | 253 INSTALL_FACTORY(DrawRRect); |
| 253 INSTALL_FACTORY(DrawDRRect); | 254 INSTALL_FACTORY(DrawDRRect); |
| 254 INSTALL_FACTORY(DrawPatch); | 255 INSTALL_FACTORY(DrawPatch); |
| 255 INSTALL_FACTORY(Save); | 256 INSTALL_FACTORY(Save); |
| 256 INSTALL_FACTORY(SaveLayer); | 257 INSTALL_FACTORY(SaveLayer); |
| 257 INSTALL_FACTORY(SetMatrix); | 258 INSTALL_FACTORY(SetMatrix); |
| (...skipping 2103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2361 | 2362 |
| 2362 void SkDrawPosTextCommand::execute(SkCanvas* canvas) const { | 2363 void SkDrawPosTextCommand::execute(SkCanvas* canvas) const { |
| 2363 canvas->drawPosText(fText, fByteLength, fPos, fPaint); | 2364 canvas->drawPosText(fText, fByteLength, fPos, fPaint); |
| 2364 } | 2365 } |
| 2365 | 2366 |
| 2366 Json::Value SkDrawPosTextCommand::toJSON(UrlDataManager& urlDataManager) const { | 2367 Json::Value SkDrawPosTextCommand::toJSON(UrlDataManager& urlDataManager) const { |
| 2367 Json::Value result = INHERITED::toJSON(urlDataManager); | 2368 Json::Value result = INHERITED::toJSON(urlDataManager); |
| 2368 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, | 2369 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, |
| 2369 ((const char*) fText) + f
ByteLength); | 2370 ((const char*) fText) + f
ByteLength); |
| 2370 Json::Value coords(Json::arrayValue); | 2371 Json::Value coords(Json::arrayValue); |
| 2371 for (size_t i = 0; i < fByteLength; i++) { | 2372 size_t numCoords = fPaint.textToGlyphs(fText, fByteLength, nullptr); |
| 2373 for (size_t i = 0; i < numCoords; i++) { |
| 2372 coords.append(make_json_point(fPos[i])); | 2374 coords.append(make_json_point(fPos[i])); |
| 2373 } | 2375 } |
| 2374 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = coords; | 2376 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = coords; |
| 2375 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2377 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); |
| 2376 return result; | 2378 return result; |
| 2377 } | 2379 } |
| 2378 | 2380 |
| 2379 SkDrawPosTextCommand* SkDrawPosTextCommand::fromJSON(Json::Value& command, | 2381 SkDrawPosTextCommand* SkDrawPosTextCommand::fromJSON(Json::Value& command, |
| 2380 UrlDataManager& urlDataMana
ger) { | 2382 UrlDataManager& urlDataMana
ger) { |
| 2381 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); | 2383 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2409 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); | 2411 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); |
| 2410 fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: ")); | 2412 fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: ")); |
| 2411 fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: ")); | 2413 fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: ")); |
| 2412 fInfo.push(SkObjectParser::PaintToString(paint)); | 2414 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 2413 } | 2415 } |
| 2414 | 2416 |
| 2415 void SkDrawPosTextHCommand::execute(SkCanvas* canvas) const { | 2417 void SkDrawPosTextHCommand::execute(SkCanvas* canvas) const { |
| 2416 canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint); | 2418 canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint); |
| 2417 } | 2419 } |
| 2418 | 2420 |
| 2421 Json::Value SkDrawPosTextHCommand::toJSON(UrlDataManager& urlDataManager) const
{ |
| 2422 Json::Value result = INHERITED::toJSON(urlDataManager); |
| 2423 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, |
| 2424 ((const char*) fText) + f
ByteLength); |
| 2425 result[SKDEBUGCANVAS_ATTRIBUTE_Y] = Json::Value(fConstY); |
| 2426 Json::Value xpos(Json::arrayValue); |
| 2427 size_t numXpos = fPaint.textToGlyphs(fText, fByteLength, nullptr); |
| 2428 for (size_t i = 0; i < numXpos; i++) { |
| 2429 xpos.append(Json::Value(fXpos[i])); |
| 2430 } |
| 2431 result[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS] = xpos; |
| 2432 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); |
| 2433 return result; |
| 2434 } |
| 2435 |
| 2436 SkDrawPosTextHCommand* SkDrawPosTextHCommand::fromJSON(Json::Value& command, |
| 2437 UrlDataManager& urlDataMa
nager) { |
| 2438 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); |
| 2439 SkPaint paint; |
| 2440 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
| 2441 Json::Value jsonXpos = command[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS]; |
| 2442 int count = (int) jsonXpos.size(); |
| 2443 SkScalar* xpos = (SkScalar*) sk_malloc_throw(count * sizeof(SkScalar)); |
| 2444 for (int i = 0; i < count; i++) { |
| 2445 xpos[i] = jsonXpos[i].asFloat(); |
| 2446 } |
| 2447 SkScalar y = command[SKDEBUGCANVAS_ATTRIBUTE_Y].asFloat(); |
| 2448 return new SkDrawPosTextHCommand(text, strlen(text), xpos, y, paint); |
| 2449 } |
| 2450 |
| 2419 static const char* gPositioningLabels[] = { | 2451 static const char* gPositioningLabels[] = { |
| 2420 "kDefault_Positioning", | 2452 "kDefault_Positioning", |
| 2421 "kHorizontal_Positioning", | 2453 "kHorizontal_Positioning", |
| 2422 "kFull_Positioning", | 2454 "kFull_Positioning", |
| 2423 }; | 2455 }; |
| 2424 | 2456 |
| 2425 SkDrawTextBlobCommand::SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x,
SkScalar y, | 2457 SkDrawTextBlobCommand::SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x,
SkScalar y, |
| 2426 const SkPaint& paint) | 2458 const SkPaint& paint) |
| 2427 : INHERITED(kDrawTextBlob_OpType) | 2459 : INHERITED(kDrawTextBlob_OpType) |
| 2428 , fBlob(SkRef(blob)) | 2460 , fBlob(SkRef(blob)) |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3071 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); | 3103 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); |
| 3072 return result; | 3104 return result; |
| 3073 } | 3105 } |
| 3074 | 3106 |
| 3075 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, | 3107 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, |
| 3076 UrlDataManager& urlDataManager)
{ | 3108 UrlDataManager& urlDataManager)
{ |
| 3077 SkMatrix matrix; | 3109 SkMatrix matrix; |
| 3078 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); | 3110 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); |
| 3079 return new SkSetMatrixCommand(matrix); | 3111 return new SkSetMatrixCommand(matrix); |
| 3080 } | 3112 } |
| OLD | NEW |