OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #include "SkDrawCommand.h" | 9 #include "SkDrawCommand.h" |
10 | 10 |
11 #include "SkBlurMaskFilter.h" | 11 #include "SkBlurMaskFilter.h" |
12 #include "SkColorFilter.h" | 12 #include "SkColorFilter.h" |
13 #include "SkDashPathEffect.h" | 13 #include "SkDashPathEffect.h" |
14 #include "SkImageFilter.h" | 14 #include "SkImageFilter.h" |
| 15 #include "SkJsonWriteBuffer.h" |
15 #include "SkMaskFilter.h" | 16 #include "SkMaskFilter.h" |
16 #include "SkObjectParser.h" | 17 #include "SkObjectParser.h" |
17 #include "SkPaintDefaults.h" | 18 #include "SkPaintDefaults.h" |
18 #include "SkPathEffect.h" | 19 #include "SkPathEffect.h" |
19 #include "SkPicture.h" | 20 #include "SkPicture.h" |
20 #include "SkTextBlob.h" | 21 #include "SkTextBlob.h" |
21 #include "SkTextBlobRunIterator.h" | 22 #include "SkTextBlobRunIterator.h" |
22 #include "SkTHash.h" | 23 #include "SkTHash.h" |
23 #include "SkTypeface.h" | 24 #include "SkTypeface.h" |
24 #include "SkValidatingReadBuffer.h" | 25 #include "SkValidatingReadBuffer.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE "textSize" | 57 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE "textSize" |
57 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX "textScaleX" | 58 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX "textScaleX" |
58 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSKEWX "textSkewX" | 59 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSKEWX "textSkewX" |
59 #define SKDEBUGCANVAS_ATTRIBUTE_DASHING "dashing" | 60 #define SKDEBUGCANVAS_ATTRIBUTE_DASHING "dashing" |
60 #define SKDEBUGCANVAS_ATTRIBUTE_INTERVALS "intervals" | 61 #define SKDEBUGCANVAS_ATTRIBUTE_INTERVALS "intervals" |
61 #define SKDEBUGCANVAS_ATTRIBUTE_PHASE "phase" | 62 #define SKDEBUGCANVAS_ATTRIBUTE_PHASE "phase" |
62 #define SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE "fillType" | 63 #define SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE "fillType" |
63 #define SKDEBUGCANVAS_ATTRIBUTE_VERBS "verbs" | 64 #define SKDEBUGCANVAS_ATTRIBUTE_VERBS "verbs" |
64 #define SKDEBUGCANVAS_ATTRIBUTE_NAME "name" | 65 #define SKDEBUGCANVAS_ATTRIBUTE_NAME "name" |
65 #define SKDEBUGCANVAS_ATTRIBUTE_DATA "data" | 66 #define SKDEBUGCANVAS_ATTRIBUTE_DATA "data" |
| 67 #define SKDEBUGCANVAS_ATTRIBUTE_VALUES "values" |
66 #define SKDEBUGCANVAS_ATTRIBUTE_SHADER "shader" | 68 #define SKDEBUGCANVAS_ATTRIBUTE_SHADER "shader" |
67 #define SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT "pathEffect" | 69 #define SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT "pathEffect" |
68 #define SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER "maskFilter" | 70 #define SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER "maskFilter" |
69 #define SKDEBUGCANVAS_ATTRIBUTE_XFERMODE "xfermode" | 71 #define SKDEBUGCANVAS_ATTRIBUTE_XFERMODE "xfermode" |
70 #define SKDEBUGCANVAS_ATTRIBUTE_LOOPER "looper" | 72 #define SKDEBUGCANVAS_ATTRIBUTE_LOOPER "looper" |
71 #define SKDEBUGCANVAS_ATTRIBUTE_BACKDROP "backdrop" | 73 #define SKDEBUGCANVAS_ATTRIBUTE_BACKDROP "backdrop" |
72 #define SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER "colorfilter" | 74 #define SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER "colorfilter" |
73 #define SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER "imagefilter" | 75 #define SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER "imagefilter" |
74 #define SKDEBUGCANVAS_ATTRIBUTE_IMAGE "image" | 76 #define SKDEBUGCANVAS_ATTRIBUTE_IMAGE "image" |
75 #define SKDEBUGCANVAS_ATTRIBUTE_BITMAP "bitmap" | 77 #define SKDEBUGCANVAS_ATTRIBUTE_BITMAP "bitmap" |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 SkPaint p; | 381 SkPaint p; |
380 p.setColor(SK_ColorBLACK); | 382 p.setColor(SK_ColorBLACK); |
381 p.setStyle(SkPaint::kStroke_Style); | 383 p.setStyle(SkPaint::kStroke_Style); |
382 | 384 |
383 canvas->drawDRRect(outer, inner, p); | 385 canvas->drawDRRect(outer, inner, p); |
384 canvas->restore(); | 386 canvas->restore(); |
385 } | 387 } |
386 | 388 |
387 }; | 389 }; |
388 | 390 |
389 static Json::Value make_json_color(const SkColor color) { | 391 Json::Value SkDrawCommand::MakeJsonColor(const SkColor color) { |
390 Json::Value result(Json::arrayValue); | 392 Json::Value result(Json::arrayValue); |
391 result.append(Json::Value(SkColorGetA(color))); | 393 result.append(Json::Value(SkColorGetA(color))); |
392 result.append(Json::Value(SkColorGetR(color))); | 394 result.append(Json::Value(SkColorGetR(color))); |
393 result.append(Json::Value(SkColorGetG(color))); | 395 result.append(Json::Value(SkColorGetG(color))); |
394 result.append(Json::Value(SkColorGetB(color))); | 396 result.append(Json::Value(SkColorGetB(color))); |
395 return result; | 397 return result; |
396 } | 398 } |
397 | 399 |
398 | 400 Json::Value SkDrawCommand::MakeJsonPoint(const SkPoint& point) { |
399 static Json::Value make_json_point(const SkPoint& point) { | |
400 Json::Value result(Json::arrayValue); | 401 Json::Value result(Json::arrayValue); |
401 result.append(Json::Value(point.x())); | 402 result.append(Json::Value(point.x())); |
402 result.append(Json::Value(point.y())); | 403 result.append(Json::Value(point.y())); |
403 return result; | 404 return result; |
404 } | 405 } |
405 | 406 |
406 static Json::Value make_json_point(SkScalar x, SkScalar y) { | 407 Json::Value SkDrawCommand::MakeJsonPoint(SkScalar x, SkScalar y) { |
407 Json::Value result(Json::arrayValue); | 408 Json::Value result(Json::arrayValue); |
408 result.append(Json::Value(x)); | 409 result.append(Json::Value(x)); |
409 result.append(Json::Value(y)); | 410 result.append(Json::Value(y)); |
410 return result; | 411 return result; |
411 } | 412 } |
412 | 413 |
413 static Json::Value make_json_rect(const SkRect& rect) { | 414 Json::Value SkDrawCommand::MakeJsonRect(const SkRect& rect) { |
414 Json::Value result(Json::arrayValue); | 415 Json::Value result(Json::arrayValue); |
415 result.append(Json::Value(rect.left())); | 416 result.append(Json::Value(rect.left())); |
416 result.append(Json::Value(rect.top())); | 417 result.append(Json::Value(rect.top())); |
417 result.append(Json::Value(rect.right())); | 418 result.append(Json::Value(rect.right())); |
418 result.append(Json::Value(rect.bottom())); | 419 result.append(Json::Value(rect.bottom())); |
419 return result; | 420 return result; |
420 } | 421 } |
421 | 422 |
422 Json::Value SkDrawCommand::MakeJsonIRect(const SkIRect& rect) { | 423 Json::Value SkDrawCommand::MakeJsonIRect(const SkIRect& rect) { |
423 Json::Value result(Json::arrayValue); | 424 Json::Value result(Json::arrayValue); |
424 result.append(Json::Value(rect.left())); | 425 result.append(Json::Value(rect.left())); |
425 result.append(Json::Value(rect.top())); | 426 result.append(Json::Value(rect.top())); |
426 result.append(Json::Value(rect.right())); | 427 result.append(Json::Value(rect.right())); |
427 result.append(Json::Value(rect.bottom())); | 428 result.append(Json::Value(rect.bottom())); |
428 return result; | 429 return result; |
429 } | 430 } |
430 | 431 |
431 static Json::Value make_json_rrect(const SkRRect& rrect) { | 432 static Json::Value make_json_rrect(const SkRRect& rrect) { |
432 Json::Value result(Json::arrayValue); | 433 Json::Value result(Json::arrayValue); |
433 result.append(make_json_rect(rrect.rect())); | 434 result.append(SkDrawCommand::MakeJsonRect(rrect.rect())); |
434 result.append(make_json_point(rrect.radii(SkRRect::kUpperLeft_Corner))); | 435 result.append(SkDrawCommand::MakeJsonPoint(rrect.radii(SkRRect::kUpperLeft_C
orner))); |
435 result.append(make_json_point(rrect.radii(SkRRect::kUpperRight_Corner))); | 436 result.append(SkDrawCommand::MakeJsonPoint(rrect.radii(SkRRect::kUpperRight_
Corner))); |
436 result.append(make_json_point(rrect.radii(SkRRect::kLowerRight_Corner))); | 437 result.append(SkDrawCommand::MakeJsonPoint(rrect.radii(SkRRect::kLowerRight_
Corner))); |
437 result.append(make_json_point(rrect.radii(SkRRect::kLowerLeft_Corner))); | 438 result.append(SkDrawCommand::MakeJsonPoint(rrect.radii(SkRRect::kLowerLeft_C
orner))); |
438 return result; | 439 return result; |
439 } | 440 } |
440 | 441 |
441 Json::Value SkDrawCommand::MakeJsonMatrix(const SkMatrix& matrix) { | 442 Json::Value SkDrawCommand::MakeJsonMatrix(const SkMatrix& matrix) { |
442 Json::Value result(Json::arrayValue); | 443 Json::Value result(Json::arrayValue); |
443 Json::Value row1(Json::arrayValue); | 444 Json::Value row1(Json::arrayValue); |
444 row1.append(Json::Value(matrix[0])); | 445 row1.append(Json::Value(matrix[0])); |
445 row1.append(Json::Value(matrix[1])); | 446 row1.append(Json::Value(matrix[1])); |
446 row1.append(Json::Value(matrix[2])); | 447 row1.append(Json::Value(matrix[2])); |
447 result.append(row1); | 448 result.append(row1); |
448 Json::Value row2(Json::arrayValue); | 449 Json::Value row2(Json::arrayValue); |
449 row2.append(Json::Value(matrix[3])); | 450 row2.append(Json::Value(matrix[3])); |
450 row2.append(Json::Value(matrix[4])); | 451 row2.append(Json::Value(matrix[4])); |
451 row2.append(Json::Value(matrix[5])); | 452 row2.append(Json::Value(matrix[5])); |
452 result.append(row2); | 453 result.append(row2); |
453 Json::Value row3(Json::arrayValue); | 454 Json::Value row3(Json::arrayValue); |
454 row3.append(Json::Value(matrix[6])); | 455 row3.append(Json::Value(matrix[6])); |
455 row3.append(Json::Value(matrix[7])); | 456 row3.append(Json::Value(matrix[7])); |
456 row3.append(Json::Value(matrix[8])); | 457 row3.append(Json::Value(matrix[8])); |
457 result.append(row3); | 458 result.append(row3); |
458 return result; | 459 return result; |
459 } | 460 } |
460 | 461 |
461 static Json::Value make_json_path(const SkPath& path) { | 462 Json::Value SkDrawCommand::MakeJsonPath(const SkPath& path) { |
462 Json::Value result(Json::objectValue); | 463 Json::Value result(Json::objectValue); |
463 switch (path.getFillType()) { | 464 switch (path.getFillType()) { |
464 case SkPath::kWinding_FillType: | 465 case SkPath::kWinding_FillType: |
465 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_WI
NDING; | 466 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_WI
NDING; |
466 break; | 467 break; |
467 case SkPath::kEvenOdd_FillType: | 468 case SkPath::kEvenOdd_FillType: |
468 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_EV
ENODD; | 469 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_EV
ENODD; |
469 break; | 470 break; |
470 case SkPath::kInverseWinding_FillType: | 471 case SkPath::kInverseWinding_FillType: |
471 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_IN
VERSEWINDING; | 472 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_IN
VERSEWINDING; |
472 break; | 473 break; |
473 case SkPath::kInverseEvenOdd_FillType: | 474 case SkPath::kInverseEvenOdd_FillType: |
474 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_IN
VERSEEVENODD; | 475 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_IN
VERSEEVENODD; |
475 break; | 476 break; |
476 } | 477 } |
477 Json::Value verbs(Json::arrayValue); | 478 Json::Value verbs(Json::arrayValue); |
478 SkPath::Iter iter(path, false); | 479 SkPath::Iter iter(path, false); |
479 SkPoint pts[4]; | 480 SkPoint pts[4]; |
480 SkPath::Verb verb; | 481 SkPath::Verb verb; |
481 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { | 482 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { |
482 switch (verb) { | 483 switch (verb) { |
483 case SkPath::kLine_Verb: { | 484 case SkPath::kLine_Verb: { |
484 Json::Value line(Json::objectValue); | 485 Json::Value line(Json::objectValue); |
485 line[SKDEBUGCANVAS_VERB_LINE] = make_json_point(pts[1]); | 486 line[SKDEBUGCANVAS_VERB_LINE] = MakeJsonPoint(pts[1]); |
486 verbs.append(line); | 487 verbs.append(line); |
487 break; | 488 break; |
488 } | 489 } |
489 case SkPath::kQuad_Verb: { | 490 case SkPath::kQuad_Verb: { |
490 Json::Value quad(Json::objectValue); | 491 Json::Value quad(Json::objectValue); |
491 Json::Value coords(Json::arrayValue); | 492 Json::Value coords(Json::arrayValue); |
492 coords.append(make_json_point(pts[1])); | 493 coords.append(MakeJsonPoint(pts[1])); |
493 coords.append(make_json_point(pts[2])); | 494 coords.append(MakeJsonPoint(pts[2])); |
494 quad[SKDEBUGCANVAS_VERB_QUAD] = coords; | 495 quad[SKDEBUGCANVAS_VERB_QUAD] = coords; |
495 verbs.append(quad); | 496 verbs.append(quad); |
496 break; | 497 break; |
497 } | 498 } |
498 case SkPath::kCubic_Verb: { | 499 case SkPath::kCubic_Verb: { |
499 Json::Value cubic(Json::objectValue); | 500 Json::Value cubic(Json::objectValue); |
500 Json::Value coords(Json::arrayValue); | 501 Json::Value coords(Json::arrayValue); |
501 coords.append(make_json_point(pts[1])); | 502 coords.append(MakeJsonPoint(pts[1])); |
502 coords.append(make_json_point(pts[2])); | 503 coords.append(MakeJsonPoint(pts[2])); |
503 coords.append(make_json_point(pts[3])); | 504 coords.append(MakeJsonPoint(pts[3])); |
504 cubic[SKDEBUGCANVAS_VERB_CUBIC] = coords; | 505 cubic[SKDEBUGCANVAS_VERB_CUBIC] = coords; |
505 verbs.append(cubic); | 506 verbs.append(cubic); |
506 break; | 507 break; |
507 } | 508 } |
508 case SkPath::kConic_Verb: { | 509 case SkPath::kConic_Verb: { |
509 Json::Value conic(Json::objectValue); | 510 Json::Value conic(Json::objectValue); |
510 Json::Value coords(Json::arrayValue); | 511 Json::Value coords(Json::arrayValue); |
511 coords.append(make_json_point(pts[1])); | 512 coords.append(MakeJsonPoint(pts[1])); |
512 coords.append(make_json_point(pts[2])); | 513 coords.append(MakeJsonPoint(pts[2])); |
513 coords.append(Json::Value(iter.conicWeight())); | 514 coords.append(Json::Value(iter.conicWeight())); |
514 conic[SKDEBUGCANVAS_VERB_CONIC] = coords; | 515 conic[SKDEBUGCANVAS_VERB_CONIC] = coords; |
515 verbs.append(conic); | 516 verbs.append(conic); |
516 break; | 517 break; |
517 } | 518 } |
518 case SkPath::kMove_Verb: { | 519 case SkPath::kMove_Verb: { |
519 Json::Value move(Json::objectValue); | 520 Json::Value move(Json::objectValue); |
520 move[SKDEBUGCANVAS_VERB_MOVE] = make_json_point(pts[0]); | 521 move[SKDEBUGCANVAS_VERB_MOVE] = MakeJsonPoint(pts[0]); |
521 verbs.append(move); | 522 verbs.append(move); |
522 break; | 523 break; |
523 } | 524 } |
524 case SkPath::kClose_Verb: | 525 case SkPath::kClose_Verb: |
525 verbs.append(Json::Value(SKDEBUGCANVAS_VERB_CLOSE)); | 526 verbs.append(Json::Value(SKDEBUGCANVAS_VERB_CLOSE)); |
526 break; | 527 break; |
527 case SkPath::kDone_Verb: | 528 case SkPath::kDone_Verb: |
528 break; | 529 break; |
529 } | 530 } |
530 } | 531 } |
531 result[SKDEBUGCANVAS_ATTRIBUTE_VERBS] = verbs; | 532 result[SKDEBUGCANVAS_ATTRIBUTE_VERBS] = verbs; |
532 return result; | 533 return result; |
533 } | 534 } |
534 | 535 |
535 static Json::Value make_json_region(const SkRegion& region) { | 536 Json::Value SkDrawCommand::MakeJsonRegion(const SkRegion& region) { |
536 return Json::Value("<unimplemented>"); | 537 return Json::Value("<unimplemented>"); |
537 } | 538 } |
538 | 539 |
539 static Json::Value make_json_regionop(SkRegion::Op op) { | 540 static Json::Value make_json_regionop(SkRegion::Op op) { |
540 switch (op) { | 541 switch (op) { |
541 case SkRegion::kDifference_Op: | 542 case SkRegion::kDifference_Op: |
542 return Json::Value(SKDEBUGCANVAS_REGIONOP_DIFFERENCE); | 543 return Json::Value(SKDEBUGCANVAS_REGIONOP_DIFFERENCE); |
543 case SkRegion::kIntersect_Op: | 544 case SkRegion::kIntersect_Op: |
544 return Json::Value(SKDEBUGCANVAS_REGIONOP_INTERSECT); | 545 return Json::Value(SKDEBUGCANVAS_REGIONOP_INTERSECT); |
545 case SkRegion::kUnion_Op: | 546 case SkRegion::kUnion_Op: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 } | 584 } |
584 } | 585 } |
585 | 586 |
586 static void encode_data(const void* bytes, size_t count, const char* contentType
, | 587 static void encode_data(const void* bytes, size_t count, const char* contentType
, |
587 UrlDataManager& urlDataManager, Json::Value* target) { | 588 UrlDataManager& urlDataManager, Json::Value* target) { |
588 SkAutoTUnref<SkData> data(SkData::NewWithCopy(bytes, count)); | 589 SkAutoTUnref<SkData> data(SkData::NewWithCopy(bytes, count)); |
589 SkString url = urlDataManager.addData(data, contentType); | 590 SkString url = urlDataManager.addData(data, contentType); |
590 *target = Json::Value(url.c_str()); | 591 *target = Json::Value(url.c_str()); |
591 } | 592 } |
592 | 593 |
593 static void flatten(const SkFlattenable* flattenable, Json::Value* target, | 594 void SkDrawCommand::flatten(const SkFlattenable* flattenable, Json::Value* targe
t, |
594 UrlDataManager& urlDataManager) { | 595 UrlDataManager& urlDataManager) { |
595 SkWriteBuffer buffer; | 596 SkBinaryWriteBuffer buffer; |
596 flattenable->flatten(buffer); | 597 flattenable->flatten(buffer); |
597 void* data = sk_malloc_throw(buffer.bytesWritten()); | 598 void* data = sk_malloc_throw(buffer.bytesWritten()); |
598 buffer.writeToMemory(data); | 599 buffer.writeToMemory(data); |
599 Json::Value jsonData; | 600 Json::Value jsonData; |
600 encode_data(data, buffer.bytesWritten(), "application/octet-stream", urlData
Manager, &jsonData); | 601 encode_data(data, buffer.bytesWritten(), "application/octet-stream", urlData
Manager, &jsonData); |
601 Json::Value jsonFlattenable; | 602 Json::Value jsonFlattenable; |
602 jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_NAME] = Json::Value(flattenable->get
TypeName()); | 603 jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_NAME] = Json::Value(flattenable->get
TypeName()); |
603 jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_DATA] = jsonData; | 604 jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_DATA] = jsonData; |
| 605 |
| 606 SkJsonWriteBuffer jsonBuffer(&urlDataManager); |
| 607 flattenable->flatten(jsonBuffer); |
| 608 jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_VALUES] = jsonBuffer.getValue(); |
| 609 |
604 (*target) = jsonFlattenable; | 610 (*target) = jsonFlattenable; |
605 sk_free(data); | 611 sk_free(data); |
606 } | 612 } |
607 | 613 |
608 static void write_png_callback(png_structp png_ptr, png_bytep data, png_size_t l
ength) { | 614 static void write_png_callback(png_structp png_ptr, png_bytep data, png_size_t l
ength) { |
609 SkWStream* out = (SkWStream*) png_get_io_ptr(png_ptr); | 615 SkWStream* out = (SkWStream*) png_get_io_ptr(png_ptr); |
610 out->write(data, length); | 616 out->write(data, length); |
611 } | 617 } |
612 | 618 |
613 void SkDrawCommand::WritePNG(const png_bytep rgba, png_uint_32 width, png_uint_3
2 height, | 619 void SkDrawCommand::WritePNG(const png_bytep rgba, png_uint_32 width, png_uint_3
2 height, |
(...skipping 22 matching lines...) Expand all Loading... |
636 } | 642 } |
637 png_set_filter(png, 0, PNG_NO_FILTERS); | 643 png_set_filter(png, 0, PNG_NO_FILTERS); |
638 png_set_rows(png, info_ptr, &rows[0]); | 644 png_set_rows(png, info_ptr, &rows[0]); |
639 png_set_write_fn(png, &out, write_png_callback, NULL); | 645 png_set_write_fn(png, &out, write_png_callback, NULL); |
640 png_write_png(png, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); | 646 png_write_png(png, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); |
641 png_destroy_write_struct(&png, NULL); | 647 png_destroy_write_struct(&png, NULL); |
642 sk_free(rows); | 648 sk_free(rows); |
643 sk_free(pixels); | 649 sk_free(pixels); |
644 } | 650 } |
645 | 651 |
646 static bool SK_WARN_UNUSED_RESULT flatten(const SkImage& image, Json::Value* tar
get, | 652 bool SkDrawCommand::flatten(const SkImage& image, Json::Value* target, |
647 UrlDataManager& urlDataManager) { | 653 UrlDataManager& urlDataManager) { |
648 size_t rowBytes = 4 * image.width(); | 654 size_t rowBytes = 4 * image.width(); |
649 SkAutoFree buffer(sk_malloc_throw(rowBytes * image.height())); | 655 SkAutoFree buffer(sk_malloc_throw(rowBytes * image.height())); |
650 SkImageInfo dstInfo = SkImageInfo::Make(image.width(), image.height(), | 656 SkImageInfo dstInfo = SkImageInfo::Make(image.width(), image.height(), |
651 kN32_SkColorType, kPremul_SkAlphaTyp
e); | 657 kN32_SkColorType, kPremul_SkAlphaTyp
e); |
652 if (!image.readPixels(dstInfo, buffer.get(), rowBytes, 0, 0)) { | 658 if (!image.readPixels(dstInfo, buffer.get(), rowBytes, 0, 0)) { |
653 SkDebugf("readPixels failed\n"); | 659 SkDebugf("readPixels failed\n"); |
654 return false; | 660 return false; |
655 } | 661 } |
656 SkDynamicMemoryWStream out; | 662 SkDynamicMemoryWStream out; |
657 SkDrawCommand::WritePNG((png_bytep) buffer.get(), image.width(), image.heigh
t(), out); | 663 SkDrawCommand::WritePNG((png_bytep) buffer.get(), image.width(), image.heigh
t(), out); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 static sk_sp<SkImage> load_image(const Json::Value& jsonImage, UrlDataManager& u
rlDataManager) { | 814 static sk_sp<SkImage> load_image(const Json::Value& jsonImage, UrlDataManager& u
rlDataManager) { |
809 SkBitmap* bitmap = load_bitmap(jsonImage, urlDataManager); | 815 SkBitmap* bitmap = load_bitmap(jsonImage, urlDataManager); |
810 if (bitmap == nullptr) { | 816 if (bitmap == nullptr) { |
811 return nullptr; | 817 return nullptr; |
812 } | 818 } |
813 auto result = SkImage::MakeFromBitmap(*bitmap); | 819 auto result = SkImage::MakeFromBitmap(*bitmap); |
814 delete bitmap; | 820 delete bitmap; |
815 return result; | 821 return result; |
816 } | 822 } |
817 | 823 |
818 static bool SK_WARN_UNUSED_RESULT flatten(const SkBitmap& bitmap, Json::Value* t
arget, | 824 bool SkDrawCommand::flatten(const SkBitmap& bitmap, Json::Value* target, |
819 UrlDataManager& urlDataManager) { | 825 UrlDataManager& urlDataManager) { |
820 bitmap.lockPixels(); | 826 bitmap.lockPixels(); |
821 sk_sp<SkImage> image(SkImage::MakeFromBitmap(bitmap)); | 827 sk_sp<SkImage> image(SkImage::MakeFromBitmap(bitmap)); |
822 bitmap.unlockPixels(); | 828 bitmap.unlockPixels(); |
823 (*target)[SKDEBUGCANVAS_ATTRIBUTE_COLOR] = Json::Value(color_type_name(bitma
p.colorType())); | 829 (*target)[SKDEBUGCANVAS_ATTRIBUTE_COLOR] = Json::Value(color_type_name(bitma
p.colorType())); |
824 (*target)[SKDEBUGCANVAS_ATTRIBUTE_ALPHA] = Json::Value(alpha_type_name(bitma
p.alphaType())); | 830 (*target)[SKDEBUGCANVAS_ATTRIBUTE_ALPHA] = Json::Value(alpha_type_name(bitma
p.alphaType())); |
825 bool success = flatten(*image, target, urlDataManager); | 831 bool success = flatten(*image, target, urlDataManager); |
826 return success; | 832 return success; |
827 } | 833 } |
828 | 834 |
829 static void apply_paint_color(const SkPaint& paint, Json::Value* target) { | 835 static void apply_paint_color(const SkPaint& paint, Json::Value* target) { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 case SkBlurQuality::kHigh_SkBlurQuality: | 958 case SkBlurQuality::kHigh_SkBlurQuality: |
953 blur[SKDEBUGCANVAS_ATTRIBUTE_QUALITY] = Json::Value( | 959 blur[SKDEBUGCANVAS_ATTRIBUTE_QUALITY] = Json::Value( |
954 SKDEBUGCANVA
S_BLURQUALITY_HIGH); | 960 SKDEBUGCANVA
S_BLURQUALITY_HIGH); |
955 break; | 961 break; |
956 default: | 962 default: |
957 SkASSERT(false); | 963 SkASSERT(false); |
958 } | 964 } |
959 (*target)[SKDEBUGCANVAS_ATTRIBUTE_BLUR] = blur; | 965 (*target)[SKDEBUGCANVAS_ATTRIBUTE_BLUR] = blur; |
960 } else { | 966 } else { |
961 Json::Value jsonMaskFilter; | 967 Json::Value jsonMaskFilter; |
962 flatten(maskFilter, &jsonMaskFilter, urlDataManager); | 968 SkDrawCommand::flatten(maskFilter, &jsonMaskFilter, urlDataManager); |
963 (*target)[SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER] = jsonMaskFilter; | 969 (*target)[SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER] = jsonMaskFilter; |
964 } | 970 } |
965 } | 971 } |
966 } | 972 } |
967 | 973 |
968 static void apply_paint_patheffect(const SkPaint& paint, Json::Value* target, | 974 static void apply_paint_patheffect(const SkPaint& paint, Json::Value* target, |
969 UrlDataManager& urlDataManager) { | 975 UrlDataManager& urlDataManager) { |
970 SkPathEffect* pathEffect = paint.getPathEffect(); | 976 SkPathEffect* pathEffect = paint.getPathEffect(); |
971 if (pathEffect != nullptr) { | 977 if (pathEffect != nullptr) { |
972 SkPathEffect::DashInfo dashInfo; | 978 SkPathEffect::DashInfo dashInfo; |
973 SkPathEffect::DashType dashType = pathEffect->asADash(&dashInfo); | 979 SkPathEffect::DashType dashType = pathEffect->asADash(&dashInfo); |
974 if (dashType == SkPathEffect::kDash_DashType) { | 980 if (dashType == SkPathEffect::kDash_DashType) { |
975 dashInfo.fIntervals = (SkScalar*) sk_malloc_throw(dashInfo.fCount *
sizeof(SkScalar)); | 981 dashInfo.fIntervals = (SkScalar*) sk_malloc_throw(dashInfo.fCount *
sizeof(SkScalar)); |
976 pathEffect->asADash(&dashInfo); | 982 pathEffect->asADash(&dashInfo); |
977 Json::Value dashing(Json::objectValue); | 983 Json::Value dashing(Json::objectValue); |
978 Json::Value intervals(Json::arrayValue); | 984 Json::Value intervals(Json::arrayValue); |
979 for (int32_t i = 0; i < dashInfo.fCount; i++) { | 985 for (int32_t i = 0; i < dashInfo.fCount; i++) { |
980 intervals.append(Json::Value(dashInfo.fIntervals[i])); | 986 intervals.append(Json::Value(dashInfo.fIntervals[i])); |
981 } | 987 } |
982 sk_free(dashInfo.fIntervals); | 988 sk_free(dashInfo.fIntervals); |
983 dashing[SKDEBUGCANVAS_ATTRIBUTE_INTERVALS] = intervals; | 989 dashing[SKDEBUGCANVAS_ATTRIBUTE_INTERVALS] = intervals; |
984 dashing[SKDEBUGCANVAS_ATTRIBUTE_PHASE] = dashInfo.fPhase; | 990 dashing[SKDEBUGCANVAS_ATTRIBUTE_PHASE] = dashInfo.fPhase; |
985 (*target)[SKDEBUGCANVAS_ATTRIBUTE_DASHING] = dashing; | 991 (*target)[SKDEBUGCANVAS_ATTRIBUTE_DASHING] = dashing; |
986 } else { | 992 } else { |
987 Json::Value jsonPathEffect; | 993 Json::Value jsonPathEffect; |
988 flatten(pathEffect, &jsonPathEffect, urlDataManager); | 994 SkDrawCommand::flatten(pathEffect, &jsonPathEffect, urlDataManager); |
989 (*target)[SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT] = jsonPathEffect; | 995 (*target)[SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT] = jsonPathEffect; |
990 } | 996 } |
991 } | 997 } |
992 } | 998 } |
993 | 999 |
994 static void apply_paint_textalign(const SkPaint& paint, Json::Value* target) { | 1000 static void apply_paint_textalign(const SkPaint& paint, Json::Value* target) { |
995 SkPaint::Align textAlign = paint.getTextAlign(); | 1001 SkPaint::Align textAlign = paint.getTextAlign(); |
996 if (textAlign != SkPaint::kLeft_Align) { | 1002 if (textAlign != SkPaint::kLeft_Align) { |
997 switch (textAlign) { | 1003 switch (textAlign) { |
998 case SkPaint::kCenter_Align: { | 1004 case SkPaint::kCenter_Align: { |
(...skipping 25 matching lines...) Expand all Loading... |
1024 sk_free(data); | 1030 sk_free(data); |
1025 (*target)[SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE] = jsonTypeface; | 1031 (*target)[SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE] = jsonTypeface; |
1026 } | 1032 } |
1027 } | 1033 } |
1028 | 1034 |
1029 static void apply_paint_shader(const SkPaint& paint, Json::Value* target, | 1035 static void apply_paint_shader(const SkPaint& paint, Json::Value* target, |
1030 UrlDataManager& urlDataManager) { | 1036 UrlDataManager& urlDataManager) { |
1031 SkFlattenable* shader = paint.getShader(); | 1037 SkFlattenable* shader = paint.getShader(); |
1032 if (shader != nullptr) { | 1038 if (shader != nullptr) { |
1033 Json::Value jsonShader; | 1039 Json::Value jsonShader; |
1034 flatten(shader, &jsonShader, urlDataManager); | 1040 SkDrawCommand::flatten(shader, &jsonShader, urlDataManager); |
1035 (*target)[SKDEBUGCANVAS_ATTRIBUTE_SHADER] = jsonShader; | 1041 (*target)[SKDEBUGCANVAS_ATTRIBUTE_SHADER] = jsonShader; |
1036 } | 1042 } |
1037 } | 1043 } |
1038 | 1044 |
1039 static void apply_paint_xfermode(const SkPaint& paint, Json::Value* target, | 1045 static void apply_paint_xfermode(const SkPaint& paint, Json::Value* target, |
1040 UrlDataManager& urlDataManager) { | 1046 UrlDataManager& urlDataManager) { |
1041 SkFlattenable* xfermode = paint.getXfermode(); | 1047 SkFlattenable* xfermode = paint.getXfermode(); |
1042 if (xfermode != nullptr) { | 1048 if (xfermode != nullptr) { |
1043 Json::Value jsonXfermode; | 1049 Json::Value jsonXfermode; |
1044 flatten(xfermode, &jsonXfermode, urlDataManager); | 1050 SkDrawCommand::flatten(xfermode, &jsonXfermode, urlDataManager); |
1045 (*target)[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE] = jsonXfermode; | 1051 (*target)[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE] = jsonXfermode; |
1046 } | 1052 } |
1047 } | 1053 } |
1048 | 1054 |
1049 static void apply_paint_imagefilter(const SkPaint& paint, Json::Value* target, | 1055 static void apply_paint_imagefilter(const SkPaint& paint, Json::Value* target, |
1050 UrlDataManager& urlDataManager) { | 1056 UrlDataManager& urlDataManager) { |
1051 SkFlattenable* imageFilter = paint.getImageFilter(); | 1057 SkFlattenable* imageFilter = paint.getImageFilter(); |
1052 if (imageFilter != nullptr) { | 1058 if (imageFilter != nullptr) { |
1053 Json::Value jsonImageFilter; | 1059 Json::Value jsonImageFilter; |
1054 flatten(imageFilter, &jsonImageFilter, urlDataManager); | 1060 SkDrawCommand::flatten(imageFilter, &jsonImageFilter, urlDataManager); |
1055 (*target)[SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER] = jsonImageFilter; | 1061 (*target)[SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER] = jsonImageFilter; |
1056 } | 1062 } |
1057 } | 1063 } |
1058 | 1064 |
1059 static void apply_paint_colorfilter(const SkPaint& paint, Json::Value* target, | 1065 static void apply_paint_colorfilter(const SkPaint& paint, Json::Value* target, |
1060 UrlDataManager& urlDataManager) { | 1066 UrlDataManager& urlDataManager) { |
1061 SkFlattenable* colorFilter = paint.getColorFilter(); | 1067 SkFlattenable* colorFilter = paint.getColorFilter(); |
1062 if (colorFilter != nullptr) { | 1068 if (colorFilter != nullptr) { |
1063 Json::Value jsonColorFilter; | 1069 Json::Value jsonColorFilter; |
1064 flatten(colorFilter, &jsonColorFilter, urlDataManager); | 1070 SkDrawCommand::flatten(colorFilter, &jsonColorFilter, urlDataManager); |
1065 (*target)[SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER] = jsonColorFilter; | 1071 (*target)[SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER] = jsonColorFilter; |
1066 } | 1072 } |
1067 } | 1073 } |
1068 | 1074 |
1069 static void apply_paint_looper(const SkPaint& paint, Json::Value* target, | 1075 static void apply_paint_looper(const SkPaint& paint, Json::Value* target, |
1070 UrlDataManager& urlDataManager) { | 1076 UrlDataManager& urlDataManager) { |
1071 SkFlattenable* looper = paint.getLooper(); | 1077 SkFlattenable* looper = paint.getLooper(); |
1072 if (looper != nullptr) { | 1078 if (looper != nullptr) { |
1073 Json::Value jsonLooper; | 1079 Json::Value jsonLooper; |
1074 flatten(looper, &jsonLooper, urlDataManager); | 1080 SkDrawCommand::flatten(looper, &jsonLooper, urlDataManager); |
1075 (*target)[SKDEBUGCANVAS_ATTRIBUTE_LOOPER] = jsonLooper; | 1081 (*target)[SKDEBUGCANVAS_ATTRIBUTE_LOOPER] = jsonLooper; |
1076 } | 1082 } |
1077 } | 1083 } |
1078 | 1084 |
1079 Json::Value make_json_paint(const SkPaint& paint, UrlDataManager& urlDataManager
) { | 1085 Json::Value SkDrawCommand::MakeJsonPaint(const SkPaint& paint, UrlDataManager& u
rlDataManager) { |
1080 Json::Value result(Json::objectValue); | 1086 Json::Value result(Json::objectValue); |
1081 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEWIDTH, paint.getStrokeWi
dth(), 0.0f); | 1087 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEWIDTH, paint.getStrokeWi
dth(), 0.0f); |
1082 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER, paint.getStrokeMi
ter(), | 1088 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER, paint.getStrokeMi
ter(), |
1083 SkPaintDefaults_MiterLimit); | 1089 SkPaintDefaults_MiterLimit); |
1084 store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS, paint.isAntiAlias(),
false); | 1090 store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS, paint.isAntiAlias(),
false); |
1085 store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_DITHER, paint.isDither(), false)
; | 1091 store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_DITHER, paint.isDither(), false)
; |
1086 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE, paint.getTextSize(), | 1092 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE, paint.getTextSize(), |
1087 SkPaintDefaults_TextSize); | 1093 SkPaintDefaults_TextSize); |
1088 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextScale
X(), SK_Scalar1); | 1094 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextScale
X(), SK_Scalar1); |
1089 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextSkewX
(), 0.0f); | 1095 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextSkewX
(), 0.0f); |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1538 fColor = color; | 1544 fColor = color; |
1539 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); | 1545 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); |
1540 } | 1546 } |
1541 | 1547 |
1542 void SkClearCommand::execute(SkCanvas* canvas) const { | 1548 void SkClearCommand::execute(SkCanvas* canvas) const { |
1543 canvas->clear(fColor); | 1549 canvas->clear(fColor); |
1544 } | 1550 } |
1545 | 1551 |
1546 Json::Value SkClearCommand::toJSON(UrlDataManager& urlDataManager) const { | 1552 Json::Value SkClearCommand::toJSON(UrlDataManager& urlDataManager) const { |
1547 Json::Value result = INHERITED::toJSON(urlDataManager); | 1553 Json::Value result = INHERITED::toJSON(urlDataManager); |
1548 result[SKDEBUGCANVAS_ATTRIBUTE_COLOR] = make_json_color(fColor); | 1554 result[SKDEBUGCANVAS_ATTRIBUTE_COLOR] = MakeJsonColor(fColor); |
1549 return result; | 1555 return result; |
1550 } | 1556 } |
1551 | 1557 |
1552 SkClearCommand* SkClearCommand::fromJSON(Json::Value& command, UrlDataManager&
urlDataManager) { | 1558 SkClearCommand* SkClearCommand::fromJSON(Json::Value& command, UrlDataManager&
urlDataManager) { |
1553 Json::Value color = command[SKDEBUGCANVAS_ATTRIBUTE_COLOR]; | 1559 Json::Value color = command[SKDEBUGCANVAS_ATTRIBUTE_COLOR]; |
1554 return new SkClearCommand(get_json_color(color)); | 1560 return new SkClearCommand(get_json_color(color)); |
1555 } | 1561 } |
1556 | 1562 |
1557 SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool d
oAA) | 1563 SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool d
oAA) |
1558 : INHERITED(kClipPath_OpType) { | 1564 : INHERITED(kClipPath_OpType) { |
(...skipping 10 matching lines...) Expand all Loading... |
1569 canvas->clipPath(fPath, fOp, fDoAA); | 1575 canvas->clipPath(fPath, fOp, fDoAA); |
1570 } | 1576 } |
1571 | 1577 |
1572 bool SkClipPathCommand::render(SkCanvas* canvas) const { | 1578 bool SkClipPathCommand::render(SkCanvas* canvas) const { |
1573 render_path(canvas, fPath); | 1579 render_path(canvas, fPath); |
1574 return true; | 1580 return true; |
1575 } | 1581 } |
1576 | 1582 |
1577 Json::Value SkClipPathCommand::toJSON(UrlDataManager& urlDataManager) const { | 1583 Json::Value SkClipPathCommand::toJSON(UrlDataManager& urlDataManager) const { |
1578 Json::Value result = INHERITED::toJSON(urlDataManager); | 1584 Json::Value result = INHERITED::toJSON(urlDataManager); |
1579 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = make_json_path(fPath); | 1585 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = MakeJsonPath(fPath); |
1580 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); | 1586 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); |
1581 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = fDoAA; | 1587 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = fDoAA; |
1582 return result; | 1588 return result; |
1583 } | 1589 } |
1584 | 1590 |
1585 SkClipPathCommand* SkClipPathCommand::fromJSON(Json::Value& command, | 1591 SkClipPathCommand* SkClipPathCommand::fromJSON(Json::Value& command, |
1586 UrlDataManager& urlDataManager) { | 1592 UrlDataManager& urlDataManager) { |
1587 SkPath path; | 1593 SkPath path; |
1588 extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path); | 1594 extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path); |
1589 return new SkClipPathCommand(path, get_json_regionop(command[SKDEBUGCANVAS_A
TTRIBUTE_REGIONOP]), | 1595 return new SkClipPathCommand(path, get_json_regionop(command[SKDEBUGCANVAS_A
TTRIBUTE_REGIONOP]), |
1590 command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBo
ol()); | 1596 command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBo
ol()); |
1591 } | 1597 } |
1592 | 1598 |
1593 SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op
) | 1599 SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op
) |
1594 : INHERITED(kClipRegion_OpType) { | 1600 : INHERITED(kClipRegion_OpType) { |
1595 fRegion = region; | 1601 fRegion = region; |
1596 fOp = op; | 1602 fOp = op; |
1597 | 1603 |
1598 fInfo.push(SkObjectParser::RegionToString(region)); | 1604 fInfo.push(SkObjectParser::RegionToString(region)); |
1599 fInfo.push(SkObjectParser::RegionOpToString(op)); | 1605 fInfo.push(SkObjectParser::RegionOpToString(op)); |
1600 } | 1606 } |
1601 | 1607 |
1602 void SkClipRegionCommand::execute(SkCanvas* canvas) const { | 1608 void SkClipRegionCommand::execute(SkCanvas* canvas) const { |
1603 canvas->clipRegion(fRegion, fOp); | 1609 canvas->clipRegion(fRegion, fOp); |
1604 } | 1610 } |
1605 | 1611 |
1606 Json::Value SkClipRegionCommand::toJSON(UrlDataManager& urlDataManager) const { | 1612 Json::Value SkClipRegionCommand::toJSON(UrlDataManager& urlDataManager) const { |
1607 Json::Value result = INHERITED::toJSON(urlDataManager); | 1613 Json::Value result = INHERITED::toJSON(urlDataManager); |
1608 result[SKDEBUGCANVAS_ATTRIBUTE_REGION] = make_json_region(fRegion); | 1614 result[SKDEBUGCANVAS_ATTRIBUTE_REGION] = MakeJsonRegion(fRegion); |
1609 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); | 1615 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); |
1610 return result; | 1616 return result; |
1611 } | 1617 } |
1612 | 1618 |
1613 SkClipRegionCommand* SkClipRegionCommand::fromJSON(Json::Value& command, | 1619 SkClipRegionCommand* SkClipRegionCommand::fromJSON(Json::Value& command, |
1614 UrlDataManager& urlDataManage
r) { | 1620 UrlDataManager& urlDataManage
r) { |
1615 SkASSERT(false); | 1621 SkASSERT(false); |
1616 return nullptr; | 1622 return nullptr; |
1617 } | 1623 } |
1618 | 1624 |
1619 SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool d
oAA) | 1625 SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool d
oAA) |
1620 : INHERITED(kClipRect_OpType) { | 1626 : INHERITED(kClipRect_OpType) { |
1621 fRect = rect; | 1627 fRect = rect; |
1622 fOp = op; | 1628 fOp = op; |
1623 fDoAA = doAA; | 1629 fDoAA = doAA; |
1624 | 1630 |
1625 fInfo.push(SkObjectParser::RectToString(rect)); | 1631 fInfo.push(SkObjectParser::RectToString(rect)); |
1626 fInfo.push(SkObjectParser::RegionOpToString(op)); | 1632 fInfo.push(SkObjectParser::RegionOpToString(op)); |
1627 fInfo.push(SkObjectParser::BoolToString(doAA)); | 1633 fInfo.push(SkObjectParser::BoolToString(doAA)); |
1628 } | 1634 } |
1629 | 1635 |
1630 void SkClipRectCommand::execute(SkCanvas* canvas) const { | 1636 void SkClipRectCommand::execute(SkCanvas* canvas) const { |
1631 canvas->clipRect(fRect, fOp, fDoAA); | 1637 canvas->clipRect(fRect, fOp, fDoAA); |
1632 } | 1638 } |
1633 | 1639 |
1634 Json::Value SkClipRectCommand::toJSON(UrlDataManager& urlDataManager) const { | 1640 Json::Value SkClipRectCommand::toJSON(UrlDataManager& urlDataManager) const { |
1635 Json::Value result = INHERITED::toJSON(urlDataManager); | 1641 Json::Value result = INHERITED::toJSON(urlDataManager); |
1636 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rect(fRect); | 1642 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fRect); |
1637 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); | 1643 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); |
1638 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = Json::Value(fDoAA); | 1644 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = Json::Value(fDoAA); |
1639 return result; | 1645 return result; |
1640 } | 1646 } |
1641 | 1647 |
1642 SkClipRectCommand* SkClipRectCommand::fromJSON(Json::Value& command, | 1648 SkClipRectCommand* SkClipRectCommand::fromJSON(Json::Value& command, |
1643 UrlDataManager& urlDataManager) { | 1649 UrlDataManager& urlDataManager) { |
1644 SkRect rect; | 1650 SkRect rect; |
1645 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rect); | 1651 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rect); |
1646 return new SkClipRectCommand(rect, get_json_regionop(command[SKDEBUGCANVAS_A
TTRIBUTE_REGIONOP]), | 1652 return new SkClipRectCommand(rect, get_json_regionop(command[SKDEBUGCANVAS_A
TTRIBUTE_REGIONOP]), |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1736 render_bitmap(canvas, fBitmap); | 1742 render_bitmap(canvas, fBitmap); |
1737 return true; | 1743 return true; |
1738 } | 1744 } |
1739 | 1745 |
1740 Json::Value SkDrawBitmapCommand::toJSON(UrlDataManager& urlDataManager) const { | 1746 Json::Value SkDrawBitmapCommand::toJSON(UrlDataManager& urlDataManager) const { |
1741 Json::Value result = INHERITED::toJSON(urlDataManager); | 1747 Json::Value result = INHERITED::toJSON(urlDataManager); |
1742 Json::Value encoded; | 1748 Json::Value encoded; |
1743 if (flatten(fBitmap, &encoded, urlDataManager)) { | 1749 if (flatten(fBitmap, &encoded, urlDataManager)) { |
1744 Json::Value command(Json::objectValue); | 1750 Json::Value command(Json::objectValue); |
1745 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; | 1751 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; |
1746 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(fLeft, fTop); | 1752 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonPoint(fLeft, fTop); |
1747 if (fPaintPtr != nullptr) { | 1753 if (fPaintPtr != nullptr) { |
1748 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr,
urlDataManager); | 1754 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaintPtr, ur
lDataManager); |
1749 } | 1755 } |
1750 } | 1756 } |
1751 return result; | 1757 return result; |
1752 } | 1758 } |
1753 | 1759 |
1754 SkDrawBitmapCommand* SkDrawBitmapCommand::fromJSON(Json::Value& command, | 1760 SkDrawBitmapCommand* SkDrawBitmapCommand::fromJSON(Json::Value& command, |
1755 UrlDataManager& urlDataManage
r) { | 1761 UrlDataManager& urlDataManage
r) { |
1756 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlD
ataManager); | 1762 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlD
ataManager); |
1757 if (bitmap == nullptr) { | 1763 if (bitmap == nullptr) { |
1758 return nullptr; | 1764 return nullptr; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1803 render_bitmap(canvas, fBitmap, &tmp); | 1809 render_bitmap(canvas, fBitmap, &tmp); |
1804 return true; | 1810 return true; |
1805 } | 1811 } |
1806 | 1812 |
1807 Json::Value SkDrawBitmapNineCommand::toJSON(UrlDataManager& urlDataManager) cons
t { | 1813 Json::Value SkDrawBitmapNineCommand::toJSON(UrlDataManager& urlDataManager) cons
t { |
1808 Json::Value result = INHERITED::toJSON(urlDataManager); | 1814 Json::Value result = INHERITED::toJSON(urlDataManager); |
1809 Json::Value encoded; | 1815 Json::Value encoded; |
1810 if (flatten(fBitmap, &encoded, urlDataManager)) { | 1816 if (flatten(fBitmap, &encoded, urlDataManager)) { |
1811 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; | 1817 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; |
1812 result[SKDEBUGCANVAS_ATTRIBUTE_CENTER] = MakeJsonIRect(fCenter); | 1818 result[SKDEBUGCANVAS_ATTRIBUTE_CENTER] = MakeJsonIRect(fCenter); |
1813 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = make_json_rect(fDst); | 1819 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = MakeJsonRect(fDst); |
1814 if (fPaintPtr != nullptr) { | 1820 if (fPaintPtr != nullptr) { |
1815 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr,
urlDataManager); | 1821 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaintPtr, ur
lDataManager); |
1816 } | 1822 } |
1817 } | 1823 } |
1818 return result; | 1824 return result; |
1819 } | 1825 } |
1820 | 1826 |
1821 SkDrawBitmapNineCommand* SkDrawBitmapNineCommand::fromJSON(Json::Value& command, | 1827 SkDrawBitmapNineCommand* SkDrawBitmapNineCommand::fromJSON(Json::Value& command, |
1822 UrlDataManager& urlDa
taManager) { | 1828 UrlDataManager& urlDa
taManager) { |
1823 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlD
ataManager); | 1829 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlD
ataManager); |
1824 if (bitmap == nullptr) { | 1830 if (bitmap == nullptr) { |
1825 return nullptr; | 1831 return nullptr; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 render_bitmap(canvas, fBitmap, this->srcRect()); | 1887 render_bitmap(canvas, fBitmap, this->srcRect()); |
1882 return true; | 1888 return true; |
1883 } | 1889 } |
1884 | 1890 |
1885 Json::Value SkDrawBitmapRectCommand::toJSON(UrlDataManager& urlDataManager) cons
t { | 1891 Json::Value SkDrawBitmapRectCommand::toJSON(UrlDataManager& urlDataManager) cons
t { |
1886 Json::Value result = INHERITED::toJSON(urlDataManager); | 1892 Json::Value result = INHERITED::toJSON(urlDataManager); |
1887 Json::Value encoded; | 1893 Json::Value encoded; |
1888 if (flatten(fBitmap, &encoded, urlDataManager)) { | 1894 if (flatten(fBitmap, &encoded, urlDataManager)) { |
1889 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; | 1895 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; |
1890 if (!fSrc.isEmpty()) { | 1896 if (!fSrc.isEmpty()) { |
1891 result[SKDEBUGCANVAS_ATTRIBUTE_SRC] = make_json_rect(fSrc); | 1897 result[SKDEBUGCANVAS_ATTRIBUTE_SRC] = MakeJsonRect(fSrc); |
1892 } | 1898 } |
1893 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = make_json_rect(fDst); | 1899 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = MakeJsonRect(fDst); |
1894 if (fPaintPtr != nullptr) { | 1900 if (fPaintPtr != nullptr) { |
1895 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr,
urlDataManager); | 1901 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaintPtr, ur
lDataManager); |
1896 } | 1902 } |
1897 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) { | 1903 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) { |
1898 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true); | 1904 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true); |
1899 } | 1905 } |
1900 } | 1906 } |
1901 return result; | 1907 return result; |
1902 } | 1908 } |
1903 | 1909 |
1904 SkDrawBitmapRectCommand* SkDrawBitmapRectCommand::fromJSON(Json::Value& command, | 1910 SkDrawBitmapRectCommand* SkDrawBitmapRectCommand::fromJSON(Json::Value& command, |
1905 UrlDataManager& urlDa
taManager) { | 1911 UrlDataManager& urlDa
taManager) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1971 SkIntToScalar(fImage->hei
ght()))); | 1977 SkIntToScalar(fImage->hei
ght()))); |
1972 this->execute(canvas); | 1978 this->execute(canvas); |
1973 return true; | 1979 return true; |
1974 } | 1980 } |
1975 | 1981 |
1976 Json::Value SkDrawImageCommand::toJSON(UrlDataManager& urlDataManager) const { | 1982 Json::Value SkDrawImageCommand::toJSON(UrlDataManager& urlDataManager) const { |
1977 Json::Value result = INHERITED::toJSON(urlDataManager); | 1983 Json::Value result = INHERITED::toJSON(urlDataManager); |
1978 Json::Value encoded; | 1984 Json::Value encoded; |
1979 if (flatten(*fImage, &encoded, urlDataManager)) { | 1985 if (flatten(*fImage, &encoded, urlDataManager)) { |
1980 result[SKDEBUGCANVAS_ATTRIBUTE_IMAGE] = encoded; | 1986 result[SKDEBUGCANVAS_ATTRIBUTE_IMAGE] = encoded; |
1981 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(fLeft, fTop); | 1987 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonPoint(fLeft, fTop); |
1982 if (fPaint.isValid()) { | 1988 if (fPaint.isValid()) { |
1983 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaint.get(
), urlDataManager); | 1989 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaint.get(),
urlDataManager); |
1984 } | 1990 } |
1985 } | 1991 } |
1986 return result; | 1992 return result; |
1987 } | 1993 } |
1988 | 1994 |
1989 SkDrawImageCommand* SkDrawImageCommand::fromJSON(Json::Value& command, | 1995 SkDrawImageCommand* SkDrawImageCommand::fromJSON(Json::Value& command, |
1990 UrlDataManager& urlDataManager)
{ | 1996 UrlDataManager& urlDataManager)
{ |
1991 sk_sp<SkImage> image = load_image(command[SKDEBUGCANVAS_ATTRIBUTE_IMAGE], ur
lDataManager); | 1997 sk_sp<SkImage> image = load_image(command[SKDEBUGCANVAS_ATTRIBUTE_IMAGE], ur
lDataManager); |
1992 if (image == nullptr) { | 1998 if (image == nullptr) { |
1993 return nullptr; | 1999 return nullptr; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2048 this->execute(canvas); | 2054 this->execute(canvas); |
2049 return true; | 2055 return true; |
2050 } | 2056 } |
2051 | 2057 |
2052 Json::Value SkDrawImageRectCommand::toJSON(UrlDataManager& urlDataManager) const
{ | 2058 Json::Value SkDrawImageRectCommand::toJSON(UrlDataManager& urlDataManager) const
{ |
2053 Json::Value result = INHERITED::toJSON(urlDataManager); | 2059 Json::Value result = INHERITED::toJSON(urlDataManager); |
2054 Json::Value encoded; | 2060 Json::Value encoded; |
2055 if (flatten(*fImage.get(), &encoded, urlDataManager)) { | 2061 if (flatten(*fImage.get(), &encoded, urlDataManager)) { |
2056 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; | 2062 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; |
2057 if (fSrc.isValid()) { | 2063 if (fSrc.isValid()) { |
2058 result[SKDEBUGCANVAS_ATTRIBUTE_SRC] = make_json_rect(*fSrc.get()); | 2064 result[SKDEBUGCANVAS_ATTRIBUTE_SRC] = MakeJsonRect(*fSrc.get()); |
2059 } | 2065 } |
2060 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = make_json_rect(fDst); | 2066 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = MakeJsonRect(fDst); |
2061 if (fPaint.isValid()) { | 2067 if (fPaint.isValid()) { |
2062 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaint.get(
), urlDataManager); | 2068 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaint.get(),
urlDataManager); |
2063 } | 2069 } |
2064 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) { | 2070 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) { |
2065 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true); | 2071 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true); |
2066 } | 2072 } |
2067 } | 2073 } |
2068 return result; | 2074 return result; |
2069 } | 2075 } |
2070 | 2076 |
2071 SkDrawImageRectCommand* SkDrawImageRectCommand::fromJSON(Json::Value& command, | 2077 SkDrawImageRectCommand* SkDrawImageRectCommand::fromJSON(Json::Value& command, |
2072 UrlDataManager& urlData
Manager) { | 2078 UrlDataManager& urlData
Manager) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2131 p.setStyle(SkPaint::kStroke_Style); | 2137 p.setStyle(SkPaint::kStroke_Style); |
2132 | 2138 |
2133 canvas->drawOval(fOval, p); | 2139 canvas->drawOval(fOval, p); |
2134 canvas->restore(); | 2140 canvas->restore(); |
2135 | 2141 |
2136 return true; | 2142 return true; |
2137 } | 2143 } |
2138 | 2144 |
2139 Json::Value SkDrawOvalCommand::toJSON(UrlDataManager& urlDataManager) const { | 2145 Json::Value SkDrawOvalCommand::toJSON(UrlDataManager& urlDataManager) const { |
2140 Json::Value result = INHERITED::toJSON(urlDataManager); | 2146 Json::Value result = INHERITED::toJSON(urlDataManager); |
2141 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rect(fOval); | 2147 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fOval); |
2142 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2148 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager
); |
2143 return result; | 2149 return result; |
2144 } | 2150 } |
2145 | 2151 |
2146 SkDrawOvalCommand* SkDrawOvalCommand::fromJSON(Json::Value& command, | 2152 SkDrawOvalCommand* SkDrawOvalCommand::fromJSON(Json::Value& command, |
2147 UrlDataManager& urlDataManager) { | 2153 UrlDataManager& urlDataManager) { |
2148 SkRect coords; | 2154 SkRect coords; |
2149 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); | 2155 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); |
2150 SkPaint paint; | 2156 SkPaint paint; |
2151 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2157 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2152 return new SkDrawOvalCommand(coords, paint); | 2158 return new SkDrawOvalCommand(coords, paint); |
(...skipping 11 matching lines...) Expand all Loading... |
2164 } | 2170 } |
2165 | 2171 |
2166 bool SkDrawPaintCommand::render(SkCanvas* canvas) const { | 2172 bool SkDrawPaintCommand::render(SkCanvas* canvas) const { |
2167 canvas->clear(0xFFFFFFFF); | 2173 canvas->clear(0xFFFFFFFF); |
2168 canvas->drawPaint(fPaint); | 2174 canvas->drawPaint(fPaint); |
2169 return true; | 2175 return true; |
2170 } | 2176 } |
2171 | 2177 |
2172 Json::Value SkDrawPaintCommand::toJSON(UrlDataManager& urlDataManager) const { | 2178 Json::Value SkDrawPaintCommand::toJSON(UrlDataManager& urlDataManager) const { |
2173 Json::Value result = INHERITED::toJSON(urlDataManager); | 2179 Json::Value result = INHERITED::toJSON(urlDataManager); |
2174 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2180 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager
); |
2175 return result; | 2181 return result; |
2176 } | 2182 } |
2177 | 2183 |
2178 SkDrawPaintCommand* SkDrawPaintCommand::fromJSON(Json::Value& command, | 2184 SkDrawPaintCommand* SkDrawPaintCommand::fromJSON(Json::Value& command, |
2179 UrlDataManager& urlDataManager)
{ | 2185 UrlDataManager& urlDataManager)
{ |
2180 SkPaint paint; | 2186 SkPaint paint; |
2181 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2187 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2182 return new SkDrawPaintCommand(paint); | 2188 return new SkDrawPaintCommand(paint); |
2183 } | 2189 } |
2184 | 2190 |
(...skipping 10 matching lines...) Expand all Loading... |
2195 canvas->drawPath(fPath, fPaint); | 2201 canvas->drawPath(fPath, fPaint); |
2196 } | 2202 } |
2197 | 2203 |
2198 bool SkDrawPathCommand::render(SkCanvas* canvas) const { | 2204 bool SkDrawPathCommand::render(SkCanvas* canvas) const { |
2199 render_path(canvas, fPath); | 2205 render_path(canvas, fPath); |
2200 return true; | 2206 return true; |
2201 } | 2207 } |
2202 | 2208 |
2203 Json::Value SkDrawPathCommand::toJSON(UrlDataManager& urlDataManager) const { | 2209 Json::Value SkDrawPathCommand::toJSON(UrlDataManager& urlDataManager) const { |
2204 Json::Value result = INHERITED::toJSON(urlDataManager); | 2210 Json::Value result = INHERITED::toJSON(urlDataManager); |
2205 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = make_json_path(fPath); | 2211 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = MakeJsonPath(fPath); |
2206 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2212 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager
); |
2207 return result; | 2213 return result; |
2208 } | 2214 } |
2209 | 2215 |
2210 SkDrawPathCommand* SkDrawPathCommand::fromJSON(Json::Value& command, | 2216 SkDrawPathCommand* SkDrawPathCommand::fromJSON(Json::Value& command, |
2211 UrlDataManager& urlDataManager) { | 2217 UrlDataManager& urlDataManager) { |
2212 SkPath path; | 2218 SkPath path; |
2213 extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path); | 2219 extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path); |
2214 SkPaint paint; | 2220 SkPaint paint; |
2215 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2221 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2216 return new SkDrawPathCommand(path, paint); | 2222 return new SkDrawPathCommand(path, paint); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2320 canvas->restore(); | 2326 canvas->restore(); |
2321 | 2327 |
2322 return true; | 2328 return true; |
2323 } | 2329 } |
2324 | 2330 |
2325 Json::Value SkDrawPointsCommand::toJSON(UrlDataManager& urlDataManager) const { | 2331 Json::Value SkDrawPointsCommand::toJSON(UrlDataManager& urlDataManager) const { |
2326 Json::Value result = INHERITED::toJSON(urlDataManager); | 2332 Json::Value result = INHERITED::toJSON(urlDataManager); |
2327 result[SKDEBUGCANVAS_ATTRIBUTE_MODE] = make_json_pointmode(fMode); | 2333 result[SKDEBUGCANVAS_ATTRIBUTE_MODE] = make_json_pointmode(fMode); |
2328 Json::Value points(Json::arrayValue); | 2334 Json::Value points(Json::arrayValue); |
2329 for (size_t i = 0; i < fCount; i++) { | 2335 for (size_t i = 0; i < fCount; i++) { |
2330 points.append(make_json_point(fPts[i])); | 2336 points.append(MakeJsonPoint(fPts[i])); |
2331 } | 2337 } |
2332 result[SKDEBUGCANVAS_ATTRIBUTE_POINTS] = points; | 2338 result[SKDEBUGCANVAS_ATTRIBUTE_POINTS] = points; |
2333 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2339 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager
); |
2334 return result; | 2340 return result; |
2335 } | 2341 } |
2336 | 2342 |
2337 SkDrawPointsCommand* SkDrawPointsCommand::fromJSON(Json::Value& command, | 2343 SkDrawPointsCommand* SkDrawPointsCommand::fromJSON(Json::Value& command, |
2338 UrlDataManager& urlDataManage
r) { | 2344 UrlDataManager& urlDataManage
r) { |
2339 SkCanvas::PointMode mode; | 2345 SkCanvas::PointMode mode; |
2340 const char* jsonMode = command[SKDEBUGCANVAS_ATTRIBUTE_MODE].asCString(); | 2346 const char* jsonMode = command[SKDEBUGCANVAS_ATTRIBUTE_MODE].asCString(); |
2341 if (!strcmp(jsonMode, SKDEBUGCANVAS_POINTMODE_POINTS)) { | 2347 if (!strcmp(jsonMode, SKDEBUGCANVAS_POINTMODE_POINTS)) { |
2342 mode = SkCanvas::kPoints_PointMode; | 2348 mode = SkCanvas::kPoints_PointMode; |
2343 } | 2349 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2388 canvas->drawPosText(fText, fByteLength, fPos, fPaint); | 2394 canvas->drawPosText(fText, fByteLength, fPos, fPaint); |
2389 } | 2395 } |
2390 | 2396 |
2391 Json::Value SkDrawPosTextCommand::toJSON(UrlDataManager& urlDataManager) const { | 2397 Json::Value SkDrawPosTextCommand::toJSON(UrlDataManager& urlDataManager) const { |
2392 Json::Value result = INHERITED::toJSON(urlDataManager); | 2398 Json::Value result = INHERITED::toJSON(urlDataManager); |
2393 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, | 2399 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, |
2394 ((const char*) fText) + f
ByteLength); | 2400 ((const char*) fText) + f
ByteLength); |
2395 Json::Value coords(Json::arrayValue); | 2401 Json::Value coords(Json::arrayValue); |
2396 size_t numCoords = fPaint.textToGlyphs(fText, fByteLength, nullptr); | 2402 size_t numCoords = fPaint.textToGlyphs(fText, fByteLength, nullptr); |
2397 for (size_t i = 0; i < numCoords; i++) { | 2403 for (size_t i = 0; i < numCoords; i++) { |
2398 coords.append(make_json_point(fPos[i])); | 2404 coords.append(MakeJsonPoint(fPos[i])); |
2399 } | 2405 } |
2400 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = coords; | 2406 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = coords; |
2401 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2407 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager
); |
2402 return result; | 2408 return result; |
2403 } | 2409 } |
2404 | 2410 |
2405 SkDrawPosTextCommand* SkDrawPosTextCommand::fromJSON(Json::Value& command, | 2411 SkDrawPosTextCommand* SkDrawPosTextCommand::fromJSON(Json::Value& command, |
2406 UrlDataManager& urlDataMana
ger) { | 2412 UrlDataManager& urlDataMana
ger) { |
2407 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); | 2413 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); |
2408 SkPaint paint; | 2414 SkPaint paint; |
2409 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2415 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2410 Json::Value coords = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; | 2416 Json::Value coords = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; |
2411 int count = (int) coords.size(); | 2417 int count = (int) coords.size(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2446 Json::Value result = INHERITED::toJSON(urlDataManager); | 2452 Json::Value result = INHERITED::toJSON(urlDataManager); |
2447 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, | 2453 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, |
2448 ((const char*) fText) + f
ByteLength); | 2454 ((const char*) fText) + f
ByteLength); |
2449 result[SKDEBUGCANVAS_ATTRIBUTE_Y] = Json::Value(fConstY); | 2455 result[SKDEBUGCANVAS_ATTRIBUTE_Y] = Json::Value(fConstY); |
2450 Json::Value xpos(Json::arrayValue); | 2456 Json::Value xpos(Json::arrayValue); |
2451 size_t numXpos = fPaint.textToGlyphs(fText, fByteLength, nullptr); | 2457 size_t numXpos = fPaint.textToGlyphs(fText, fByteLength, nullptr); |
2452 for (size_t i = 0; i < numXpos; i++) { | 2458 for (size_t i = 0; i < numXpos; i++) { |
2453 xpos.append(Json::Value(fXpos[i])); | 2459 xpos.append(Json::Value(fXpos[i])); |
2454 } | 2460 } |
2455 result[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS] = xpos; | 2461 result[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS] = xpos; |
2456 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2462 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager
); |
2457 return result; | 2463 return result; |
2458 } | 2464 } |
2459 | 2465 |
2460 SkDrawPosTextHCommand* SkDrawPosTextHCommand::fromJSON(Json::Value& command, | 2466 SkDrawPosTextHCommand* SkDrawPosTextHCommand::fromJSON(Json::Value& command, |
2461 UrlDataManager& urlDataMa
nager) { | 2467 UrlDataManager& urlDataMa
nager) { |
2462 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); | 2468 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); |
2463 SkPaint paint; | 2469 SkPaint paint; |
2464 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2470 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2465 Json::Value jsonXpos = command[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS]; | 2471 Json::Value jsonXpos = command[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS]; |
2466 int count = (int) jsonXpos.size(); | 2472 int count = (int) jsonXpos.size(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2541 SkTextBlobRunIterator iter(fBlob.get()); | 2547 SkTextBlobRunIterator iter(fBlob.get()); |
2542 while (!iter.done()) { | 2548 while (!iter.done()) { |
2543 Json::Value run(Json::objectValue); | 2549 Json::Value run(Json::objectValue); |
2544 Json::Value jsonPositions(Json::arrayValue); | 2550 Json::Value jsonPositions(Json::arrayValue); |
2545 Json::Value jsonGlyphs(Json::arrayValue); | 2551 Json::Value jsonGlyphs(Json::arrayValue); |
2546 const SkScalar* iterPositions = iter.pos(); | 2552 const SkScalar* iterPositions = iter.pos(); |
2547 const uint16_t* iterGlyphs = iter.glyphs(); | 2553 const uint16_t* iterGlyphs = iter.glyphs(); |
2548 for (uint32_t i = 0; i < iter.glyphCount(); i++) { | 2554 for (uint32_t i = 0; i < iter.glyphCount(); i++) { |
2549 switch (iter.positioning()) { | 2555 switch (iter.positioning()) { |
2550 case SkTextBlob::kFull_Positioning: | 2556 case SkTextBlob::kFull_Positioning: |
2551 jsonPositions.append(make_json_point(iterPositions[i * 2], | 2557 jsonPositions.append(MakeJsonPoint(iterPositions[i * 2], |
2552 iterPositions[i * 2 + 1
])); | 2558 iterPositions[i * 2 + 1])
); |
2553 break; | 2559 break; |
2554 case SkTextBlob::kHorizontal_Positioning: | 2560 case SkTextBlob::kHorizontal_Positioning: |
2555 jsonPositions.append(Json::Value(iterPositions[i])); | 2561 jsonPositions.append(Json::Value(iterPositions[i])); |
2556 break; | 2562 break; |
2557 case SkTextBlob::kDefault_Positioning: | 2563 case SkTextBlob::kDefault_Positioning: |
2558 break; | 2564 break; |
2559 } | 2565 } |
2560 jsonGlyphs.append(Json::Value(iterGlyphs[i])); | 2566 jsonGlyphs.append(Json::Value(iterGlyphs[i])); |
2561 } | 2567 } |
2562 if (iter.positioning() != SkTextBlob::kDefault_Positioning) { | 2568 if (iter.positioning() != SkTextBlob::kDefault_Positioning) { |
2563 run[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS] = jsonPositions; | 2569 run[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS] = jsonPositions; |
2564 } | 2570 } |
2565 run[SKDEBUGCANVAS_ATTRIBUTE_GLYPHS] = jsonGlyphs; | 2571 run[SKDEBUGCANVAS_ATTRIBUTE_GLYPHS] = jsonGlyphs; |
2566 SkPaint fontPaint; | 2572 SkPaint fontPaint; |
2567 iter.applyFontToPaint(&fontPaint); | 2573 iter.applyFontToPaint(&fontPaint); |
2568 run[SKDEBUGCANVAS_ATTRIBUTE_FONT] = make_json_paint(fontPaint, urlDataMa
nager); | 2574 run[SKDEBUGCANVAS_ATTRIBUTE_FONT] = MakeJsonPaint(fontPaint, urlDataMana
ger); |
2569 run[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(iter.offset()); | 2575 run[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonPoint(iter.offset()); |
2570 runs.append(run); | 2576 runs.append(run); |
2571 iter.next(); | 2577 iter.next(); |
2572 } | 2578 } |
2573 result[SKDEBUGCANVAS_ATTRIBUTE_RUNS] = runs; | 2579 result[SKDEBUGCANVAS_ATTRIBUTE_RUNS] = runs; |
2574 result[SKDEBUGCANVAS_ATTRIBUTE_X] = Json::Value(fXPos); | 2580 result[SKDEBUGCANVAS_ATTRIBUTE_X] = Json::Value(fXPos); |
2575 result[SKDEBUGCANVAS_ATTRIBUTE_Y] = Json::Value(fYPos); | 2581 result[SKDEBUGCANVAS_ATTRIBUTE_Y] = Json::Value(fYPos); |
2576 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2582 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager
); |
2577 return result; | 2583 return result; |
2578 } | 2584 } |
2579 | 2585 |
2580 SkDrawTextBlobCommand* SkDrawTextBlobCommand::fromJSON(Json::Value& command, | 2586 SkDrawTextBlobCommand* SkDrawTextBlobCommand::fromJSON(Json::Value& command, |
2581 UrlDataManager& urlDataMa
nager) { | 2587 UrlDataManager& urlDataMa
nager) { |
2582 SkTextBlobBuilder builder; | 2588 SkTextBlobBuilder builder; |
2583 Json::Value runs = command[SKDEBUGCANVAS_ATTRIBUTE_RUNS]; | 2589 Json::Value runs = command[SKDEBUGCANVAS_ATTRIBUTE_RUNS]; |
2584 for (Json::ArrayIndex i = 0 ; i < runs.size(); i++) { | 2590 for (Json::ArrayIndex i = 0 ; i < runs.size(); i++) { |
2585 Json::Value run = runs[i]; | 2591 Json::Value run = runs[i]; |
2586 SkPaint font; | 2592 SkPaint font; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2649 } | 2655 } |
2650 | 2656 |
2651 void SkDrawPatchCommand::execute(SkCanvas* canvas) const { | 2657 void SkDrawPatchCommand::execute(SkCanvas* canvas) const { |
2652 canvas->drawPatch(fCubics, fColorsPtr, fTexCoordsPtr, fXfermode, fPaint); | 2658 canvas->drawPatch(fCubics, fColorsPtr, fTexCoordsPtr, fXfermode, fPaint); |
2653 } | 2659 } |
2654 | 2660 |
2655 Json::Value SkDrawPatchCommand::toJSON(UrlDataManager& urlDataManager) const { | 2661 Json::Value SkDrawPatchCommand::toJSON(UrlDataManager& urlDataManager) const { |
2656 Json::Value result = INHERITED::toJSON(urlDataManager); | 2662 Json::Value result = INHERITED::toJSON(urlDataManager); |
2657 Json::Value cubics = Json::Value(Json::arrayValue); | 2663 Json::Value cubics = Json::Value(Json::arrayValue); |
2658 for (int i = 0; i < 12; i++) { | 2664 for (int i = 0; i < 12; i++) { |
2659 cubics.append(make_json_point(fCubics[i])); | 2665 cubics.append(MakeJsonPoint(fCubics[i])); |
2660 } | 2666 } |
2661 result[SKDEBUGCANVAS_ATTRIBUTE_CUBICS] = cubics; | 2667 result[SKDEBUGCANVAS_ATTRIBUTE_CUBICS] = cubics; |
2662 if (fColorsPtr != nullptr) { | 2668 if (fColorsPtr != nullptr) { |
2663 Json::Value colors = Json::Value(Json::arrayValue); | 2669 Json::Value colors = Json::Value(Json::arrayValue); |
2664 for (int i = 0; i < 4; i++) { | 2670 for (int i = 0; i < 4; i++) { |
2665 colors.append(make_json_color(fColorsPtr[i])); | 2671 colors.append(MakeJsonColor(fColorsPtr[i])); |
2666 } | 2672 } |
2667 result[SKDEBUGCANVAS_ATTRIBUTE_COLORS] = colors; | 2673 result[SKDEBUGCANVAS_ATTRIBUTE_COLORS] = colors; |
2668 } | 2674 } |
2669 if (fTexCoordsPtr != nullptr) { | 2675 if (fTexCoordsPtr != nullptr) { |
2670 Json::Value texCoords = Json::Value(Json::arrayValue); | 2676 Json::Value texCoords = Json::Value(Json::arrayValue); |
2671 for (int i = 0; i < 4; i++) { | 2677 for (int i = 0; i < 4; i++) { |
2672 texCoords.append(make_json_point(fTexCoords[i])); | 2678 texCoords.append(MakeJsonPoint(fTexCoords[i])); |
2673 } | 2679 } |
2674 result[SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS] = texCoords; | 2680 result[SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS] = texCoords; |
2675 } | 2681 } |
2676 if (fXfermode.get() != nullptr) { | 2682 if (fXfermode.get() != nullptr) { |
2677 Json::Value jsonXfermode; | 2683 Json::Value jsonXfermode; |
2678 flatten(fXfermode, &jsonXfermode, urlDataManager); | 2684 flatten(fXfermode, &jsonXfermode, urlDataManager); |
2679 result[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE] = jsonXfermode; | 2685 result[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE] = jsonXfermode; |
2680 } | 2686 } |
2681 return result; | 2687 return result; |
2682 } | 2688 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2730 fInfo.push(SkObjectParser::RectToString(rect)); | 2736 fInfo.push(SkObjectParser::RectToString(rect)); |
2731 fInfo.push(SkObjectParser::PaintToString(paint)); | 2737 fInfo.push(SkObjectParser::PaintToString(paint)); |
2732 } | 2738 } |
2733 | 2739 |
2734 void SkDrawRectCommand::execute(SkCanvas* canvas) const { | 2740 void SkDrawRectCommand::execute(SkCanvas* canvas) const { |
2735 canvas->drawRect(fRect, fPaint); | 2741 canvas->drawRect(fRect, fPaint); |
2736 } | 2742 } |
2737 | 2743 |
2738 Json::Value SkDrawRectCommand::toJSON(UrlDataManager& urlDataManager) const { | 2744 Json::Value SkDrawRectCommand::toJSON(UrlDataManager& urlDataManager) const { |
2739 Json::Value result = INHERITED::toJSON(urlDataManager); | 2745 Json::Value result = INHERITED::toJSON(urlDataManager); |
2740 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rect(fRect); | 2746 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fRect); |
2741 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2747 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager
); |
2742 return result; | 2748 return result; |
2743 } | 2749 } |
2744 | 2750 |
2745 SkDrawRectCommand* SkDrawRectCommand::fromJSON(Json::Value& command, | 2751 SkDrawRectCommand* SkDrawRectCommand::fromJSON(Json::Value& command, |
2746 UrlDataManager& urlDataManager) { | 2752 UrlDataManager& urlDataManager) { |
2747 SkRect coords; | 2753 SkRect coords; |
2748 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); | 2754 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); |
2749 SkPaint paint; | 2755 SkPaint paint; |
2750 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2756 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2751 return new SkDrawRectCommand(coords, paint); | 2757 return new SkDrawRectCommand(coords, paint); |
(...skipping 13 matching lines...) Expand all Loading... |
2765 } | 2771 } |
2766 | 2772 |
2767 bool SkDrawRRectCommand::render(SkCanvas* canvas) const { | 2773 bool SkDrawRRectCommand::render(SkCanvas* canvas) const { |
2768 render_rrect(canvas, fRRect); | 2774 render_rrect(canvas, fRRect); |
2769 return true; | 2775 return true; |
2770 } | 2776 } |
2771 | 2777 |
2772 Json::Value SkDrawRRectCommand::toJSON(UrlDataManager& urlDataManager) const { | 2778 Json::Value SkDrawRRectCommand::toJSON(UrlDataManager& urlDataManager) const { |
2773 Json::Value result = INHERITED::toJSON(urlDataManager); | 2779 Json::Value result = INHERITED::toJSON(urlDataManager); |
2774 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rrect(fRRect); | 2780 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rrect(fRRect); |
2775 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2781 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager
); |
2776 return result; | 2782 return result; |
2777 } | 2783 } |
2778 | 2784 |
2779 SkDrawRRectCommand* SkDrawRRectCommand::fromJSON(Json::Value& command, | 2785 SkDrawRRectCommand* SkDrawRRectCommand::fromJSON(Json::Value& command, |
2780 UrlDataManager& urlDataManager)
{ | 2786 UrlDataManager& urlDataManager)
{ |
2781 SkRRect coords; | 2787 SkRRect coords; |
2782 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); | 2788 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); |
2783 SkPaint paint; | 2789 SkPaint paint; |
2784 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2790 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2785 return new SkDrawRRectCommand(coords, paint); | 2791 return new SkDrawRRectCommand(coords, paint); |
(...skipping 18 matching lines...) Expand all Loading... |
2804 | 2810 |
2805 bool SkDrawDRRectCommand::render(SkCanvas* canvas) const { | 2811 bool SkDrawDRRectCommand::render(SkCanvas* canvas) const { |
2806 render_drrect(canvas, fOuter, fInner); | 2812 render_drrect(canvas, fOuter, fInner); |
2807 return true; | 2813 return true; |
2808 } | 2814 } |
2809 | 2815 |
2810 Json::Value SkDrawDRRectCommand::toJSON(UrlDataManager& urlDataManager) const { | 2816 Json::Value SkDrawDRRectCommand::toJSON(UrlDataManager& urlDataManager) const { |
2811 Json::Value result = INHERITED::toJSON(urlDataManager); | 2817 Json::Value result = INHERITED::toJSON(urlDataManager); |
2812 result[SKDEBUGCANVAS_ATTRIBUTE_OUTER] = make_json_rrect(fOuter); | 2818 result[SKDEBUGCANVAS_ATTRIBUTE_OUTER] = make_json_rrect(fOuter); |
2813 result[SKDEBUGCANVAS_ATTRIBUTE_INNER] = make_json_rrect(fInner); | 2819 result[SKDEBUGCANVAS_ATTRIBUTE_INNER] = make_json_rrect(fInner); |
2814 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2820 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager
); |
2815 return result; | 2821 return result; |
2816 } | 2822 } |
2817 | 2823 |
2818 SkDrawDRRectCommand* SkDrawDRRectCommand::fromJSON(Json::Value& command, | 2824 SkDrawDRRectCommand* SkDrawDRRectCommand::fromJSON(Json::Value& command, |
2819 UrlDataManager& urlDataManage
r) { | 2825 UrlDataManager& urlDataManage
r) { |
2820 SkRRect outer; | 2826 SkRRect outer; |
2821 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_INNER], &outer); | 2827 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_INNER], &outer); |
2822 SkRRect inner; | 2828 SkRRect inner; |
2823 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_INNER], &inner); | 2829 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_INNER], &inner); |
2824 SkPaint paint; | 2830 SkPaint paint; |
(...skipping 19 matching lines...) Expand all Loading... |
2844 | 2850 |
2845 void SkDrawTextCommand::execute(SkCanvas* canvas) const { | 2851 void SkDrawTextCommand::execute(SkCanvas* canvas) const { |
2846 canvas->drawText(fText, fByteLength, fX, fY, fPaint); | 2852 canvas->drawText(fText, fByteLength, fX, fY, fPaint); |
2847 } | 2853 } |
2848 | 2854 |
2849 Json::Value SkDrawTextCommand::toJSON(UrlDataManager& urlDataManager) const { | 2855 Json::Value SkDrawTextCommand::toJSON(UrlDataManager& urlDataManager) const { |
2850 Json::Value result = INHERITED::toJSON(urlDataManager); | 2856 Json::Value result = INHERITED::toJSON(urlDataManager); |
2851 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, | 2857 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, |
2852 ((const char*) fText) + f
ByteLength); | 2858 ((const char*) fText) + f
ByteLength); |
2853 Json::Value coords(Json::arrayValue); | 2859 Json::Value coords(Json::arrayValue); |
2854 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(fX, fY); | 2860 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonPoint(fX, fY); |
2855 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2861 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager
); |
2856 return result; | 2862 return result; |
2857 } | 2863 } |
2858 | 2864 |
2859 SkDrawTextCommand* SkDrawTextCommand::fromJSON(Json::Value& command, | 2865 SkDrawTextCommand* SkDrawTextCommand::fromJSON(Json::Value& command, |
2860 UrlDataManager& urlDataManager) { | 2866 UrlDataManager& urlDataManager) { |
2861 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); | 2867 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); |
2862 SkPaint paint; | 2868 SkPaint paint; |
2863 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2869 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2864 Json::Value coords = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; | 2870 Json::Value coords = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; |
2865 return new SkDrawTextCommand(text, strlen(text), coords[0].asFloat(), coords
[1].asFloat(), | 2871 return new SkDrawTextCommand(text, strlen(text), coords[0].asFloat(), coords
[1].asFloat(), |
(...skipping 27 matching lines...) Expand all Loading... |
2893 canvas->drawTextOnPath(fText, fByteLength, fPath, | 2899 canvas->drawTextOnPath(fText, fByteLength, fPath, |
2894 fMatrix.isIdentity() ? nullptr : &fMatrix, | 2900 fMatrix.isIdentity() ? nullptr : &fMatrix, |
2895 fPaint); | 2901 fPaint); |
2896 } | 2902 } |
2897 | 2903 |
2898 Json::Value SkDrawTextOnPathCommand::toJSON(UrlDataManager& urlDataManager) cons
t { | 2904 Json::Value SkDrawTextOnPathCommand::toJSON(UrlDataManager& urlDataManager) cons
t { |
2899 Json::Value result = INHERITED::toJSON(urlDataManager); | 2905 Json::Value result = INHERITED::toJSON(urlDataManager); |
2900 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, | 2906 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, |
2901 ((const char*) fText) + f
ByteLength); | 2907 ((const char*) fText) + f
ByteLength); |
2902 Json::Value coords(Json::arrayValue); | 2908 Json::Value coords(Json::arrayValue); |
2903 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = make_json_path(fPath); | 2909 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = MakeJsonPath(fPath); |
2904 if (!fMatrix.isIdentity()) { | 2910 if (!fMatrix.isIdentity()) { |
2905 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); | 2911 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); |
2906 } | 2912 } |
2907 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2913 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager
); |
2908 return result; | 2914 return result; |
2909 } | 2915 } |
2910 | 2916 |
2911 SkDrawTextOnPathCommand* SkDrawTextOnPathCommand::fromJSON(Json::Value& command, | 2917 SkDrawTextOnPathCommand* SkDrawTextOnPathCommand::fromJSON(Json::Value& command, |
2912 UrlDataManager& urlDa
taManager) { | 2918 UrlDataManager& urlDa
taManager) { |
2913 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); | 2919 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); |
2914 SkPaint paint; | 2920 SkPaint paint; |
2915 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2921 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2916 SkPath path; | 2922 SkPath path; |
2917 extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path); | 2923 extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3057 fSaveLayerFlags)); | 3063 fSaveLayerFlags)); |
3058 } | 3064 } |
3059 | 3065 |
3060 void SkSaveLayerCommand::vizExecute(SkCanvas* canvas) const { | 3066 void SkSaveLayerCommand::vizExecute(SkCanvas* canvas) const { |
3061 canvas->save(); | 3067 canvas->save(); |
3062 } | 3068 } |
3063 | 3069 |
3064 Json::Value SkSaveLayerCommand::toJSON(UrlDataManager& urlDataManager) const { | 3070 Json::Value SkSaveLayerCommand::toJSON(UrlDataManager& urlDataManager) const { |
3065 Json::Value result = INHERITED::toJSON(urlDataManager); | 3071 Json::Value result = INHERITED::toJSON(urlDataManager); |
3066 if (!fBounds.isEmpty()) { | 3072 if (!fBounds.isEmpty()) { |
3067 result[SKDEBUGCANVAS_ATTRIBUTE_BOUNDS] = make_json_rect(fBounds); | 3073 result[SKDEBUGCANVAS_ATTRIBUTE_BOUNDS] = MakeJsonRect(fBounds); |
3068 } | 3074 } |
3069 if (fPaintPtr != nullptr) { | 3075 if (fPaintPtr != nullptr) { |
3070 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr, | 3076 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaintPtr, |
3071 urlDataManager); | 3077 urlDataManager); |
3072 } | 3078 } |
3073 if (fBackdrop != nullptr) { | 3079 if (fBackdrop != nullptr) { |
3074 Json::Value jsonBackdrop; | 3080 Json::Value jsonBackdrop; |
3075 flatten(fBackdrop, &jsonBackdrop, urlDataManager); | 3081 flatten(fBackdrop, &jsonBackdrop, urlDataManager); |
3076 result[SKDEBUGCANVAS_ATTRIBUTE_BACKDROP] = jsonBackdrop; | 3082 result[SKDEBUGCANVAS_ATTRIBUTE_BACKDROP] = jsonBackdrop; |
3077 } | 3083 } |
3078 if (fSaveLayerFlags != 0) { | 3084 if (fSaveLayerFlags != 0) { |
3079 SkDebugf("unsupported: saveLayer flags\n"); | 3085 SkDebugf("unsupported: saveLayer flags\n"); |
3080 SkASSERT(false); | 3086 SkASSERT(false); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3127 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); | 3133 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); |
3128 return result; | 3134 return result; |
3129 } | 3135 } |
3130 | 3136 |
3131 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, | 3137 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, |
3132 UrlDataManager& urlDataManager)
{ | 3138 UrlDataManager& urlDataManager)
{ |
3133 SkMatrix matrix; | 3139 SkMatrix matrix; |
3134 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); | 3140 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); |
3135 return new SkSetMatrixCommand(matrix); | 3141 return new SkSetMatrixCommand(matrix); |
3136 } | 3142 } |
OLD | NEW |