| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "skia/ext/benchmarking_canvas.h" | 8 #include "skia/ext/benchmarking_canvas.h" |
| 9 #include "third_party/skia/include/core/SkColorFilter.h" | 9 #include "third_party/skia/include/core/SkColorFilter.h" |
| 10 #include "third_party/skia/include/core/SkImageFilter.h" | 10 #include "third_party/skia/include/core/SkImageFilter.h" |
| 11 #include "third_party/skia/include/core/SkTLazy.h" |
| 11 #include "third_party/skia/include/core/SkPicture.h" | 12 #include "third_party/skia/include/core/SkPicture.h" |
| 12 #include "third_party/skia/include/core/SkRegion.h" | 13 #include "third_party/skia/include/core/SkRegion.h" |
| 14 #include "third_party/skia/include/core/SkString.h" |
| 13 #include "third_party/skia/include/core/SkTextBlob.h" | 15 #include "third_party/skia/include/core/SkTextBlob.h" |
| 14 #include "third_party/skia/include/core/SkXfermode.h" | 16 #include "third_party/skia/include/core/SkXfermode.h" |
| 15 | 17 |
| 16 namespace { | 18 namespace { |
| 17 | 19 |
| 18 class FlagsBuilder { | 20 class FlagsBuilder { |
| 19 public: | 21 public: |
| 20 FlagsBuilder(char separator) | 22 FlagsBuilder(char separator) |
| 21 : separator_(separator) {} | 23 : separator_(separator) {} |
| 22 | 24 |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 WARN_UNUSED_RESULT | 401 WARN_UNUSED_RESULT |
| 400 scoped_ptr<base::Value> AsListValue(const T array[], size_t count) { | 402 scoped_ptr<base::Value> AsListValue(const T array[], size_t count) { |
| 401 scoped_ptr<base::ListValue> val(new base::ListValue()); | 403 scoped_ptr<base::ListValue> val(new base::ListValue()); |
| 402 | 404 |
| 403 for (size_t i = 0; i < count; ++i) | 405 for (size_t i = 0; i < count; ++i) |
| 404 val->Append(AsValue(array[i]).release()); | 406 val->Append(AsValue(array[i]).release()); |
| 405 | 407 |
| 406 return val.Pass(); | 408 return val.Pass(); |
| 407 } | 409 } |
| 408 | 410 |
| 411 class OverdrawXfermode : public SkXfermode { |
| 412 public: |
| 413 SkPMColor xferColor(SkPMColor src, SkPMColor dst) const override { |
| 414 // This table encodes the color progression of the overdraw visualization |
| 415 static const SkPMColor gTable[] = { |
| 416 SkPackARGB32(0x00, 0x00, 0x00, 0x00), |
| 417 SkPackARGB32(0xFF, 128, 158, 255), |
| 418 SkPackARGB32(0xFF, 170, 185, 212), |
| 419 SkPackARGB32(0xFF, 213, 195, 170), |
| 420 SkPackARGB32(0xFF, 255, 192, 127), |
| 421 SkPackARGB32(0xFF, 255, 185, 85), |
| 422 SkPackARGB32(0xFF, 255, 165, 42), |
| 423 SkPackARGB32(0xFF, 255, 135, 0), |
| 424 SkPackARGB32(0xFF, 255, 95, 0), |
| 425 SkPackARGB32(0xFF, 255, 50, 0), |
| 426 SkPackARGB32(0xFF, 255, 0, 0) |
| 427 }; |
| 428 |
| 429 size_t idx; |
| 430 if (SkColorGetR(dst) < 64) { // 0 |
| 431 idx = 0; |
| 432 } else if (SkColorGetG(dst) < 25) { // 10 |
| 433 idx = 9; // cap at 9 for upcoming increment |
| 434 } else if ((SkColorGetB(dst) + 21) / 42 > 0) { // 1-6 |
| 435 idx = 7 - (SkColorGetB(dst) + 21) / 42; |
| 436 } else { // 7-9 |
| 437 idx = 10 - (SkColorGetG(dst) + 22) / 45; |
| 438 } |
| 439 |
| 440 ++idx; |
| 441 SkASSERT(idx < SK_ARRAY_COUNT(gTable)); |
| 442 |
| 443 return gTable[idx]; |
| 444 } |
| 445 |
| 446 Factory getFactory() const override { return NULL; } |
| 447 #ifndef SK_IGNORE_TO_STRING |
| 448 void toString(SkString* str) const override { str->set("OverdrawXfermode"); } |
| 449 #endif |
| 450 }; |
| 451 |
| 409 } // namespace | 452 } // namespace |
| 410 | 453 |
| 411 namespace skia { | 454 namespace skia { |
| 412 | 455 |
| 413 class BenchmarkingCanvas::AutoOp { | 456 class BenchmarkingCanvas::AutoOp { |
| 414 public: | 457 public: |
| 415 AutoOp(BenchmarkingCanvas* canvas, const char op_name[], | 458 AutoOp(BenchmarkingCanvas* canvas, const char op_name[], |
| 416 const SkPaint* paint = nullptr) | 459 const SkPaint* paint = nullptr) |
| 417 : canvas_(canvas) | 460 : canvas_(canvas) |
| 418 , op_record_(new base::DictionaryValue()) | 461 , op_record_(new base::DictionaryValue()) |
| 419 , op_params_(new base::ListValue()) { | 462 , op_params_(new base::ListValue()) |
| 463 // AutoOp objects are always scoped within draw call frames, |
| 464 // so the paint is guaranteed to be valid for their lifetime. |
| 465 , paint_(paint) { |
| 420 | 466 |
| 421 DCHECK(canvas); | 467 DCHECK(canvas); |
| 422 DCHECK(op_name); | 468 DCHECK(op_name); |
| 423 | 469 |
| 424 op_record_->SetString("cmd_string", op_name); | 470 op_record_->SetString("cmd_string", op_name); |
| 425 op_record_->Set("info", op_params_); | 471 op_record_->Set("info", op_params_); |
| 426 | 472 |
| 427 if (paint) | 473 if (paint) |
| 428 this->addParam("paint", AsValue(*paint)); | 474 this->addParam("paint", AsValue(*paint)); |
| 429 | 475 |
| 476 if (canvas->flags_ & kOverdrawVisualization_Flag) { |
| 477 DCHECK(canvas->overdraw_xfermode_); |
| 478 |
| 479 paint_ = paint ? filtered_paint_.set(*paint) : filtered_paint_.init(); |
| 480 filtered_paint_.get()->setXfermode(canvas->overdraw_xfermode_.get()); |
| 481 filtered_paint_.get()->setAntiAlias(false); |
| 482 } |
| 483 |
| 430 start_ticks_ = base::TimeTicks::Now(); | 484 start_ticks_ = base::TimeTicks::Now(); |
| 431 } | 485 } |
| 432 | 486 |
| 433 ~AutoOp() { | 487 ~AutoOp() { |
| 434 base::TimeDelta ticks = base::TimeTicks::Now() - start_ticks_; | 488 base::TimeDelta ticks = base::TimeTicks::Now() - start_ticks_; |
| 435 op_record_->SetDouble("cmd_time", ticks.InMillisecondsF()); | 489 op_record_->SetDouble("cmd_time", ticks.InMillisecondsF()); |
| 436 | 490 |
| 437 canvas_->op_records_.Append(op_record_); | 491 canvas_->op_records_.Append(op_record_); |
| 438 } | 492 } |
| 439 | 493 |
| 440 void addParam(const char name[], scoped_ptr<base::Value> value) { | 494 void addParam(const char name[], scoped_ptr<base::Value> value) { |
| 441 scoped_ptr<base::DictionaryValue> param(new base::DictionaryValue()); | 495 scoped_ptr<base::DictionaryValue> param(new base::DictionaryValue()); |
| 442 param->Set(name, value.Pass()); | 496 param->Set(name, value.Pass()); |
| 443 | 497 |
| 444 op_params_->Append(param.release()); | 498 op_params_->Append(param.release()); |
| 445 } | 499 } |
| 446 | 500 |
| 501 const SkPaint* paint() const { return paint_; } |
| 502 |
| 447 private: | 503 private: |
| 448 BenchmarkingCanvas* canvas_; | 504 BenchmarkingCanvas* canvas_; |
| 449 base::DictionaryValue* op_record_; | 505 base::DictionaryValue* op_record_; |
| 450 base::ListValue* op_params_; | 506 base::ListValue* op_params_; |
| 451 base::TimeTicks start_ticks_; | 507 base::TimeTicks start_ticks_; |
| 508 |
| 509 const SkPaint* paint_; |
| 510 SkTLazy<SkPaint> filtered_paint_; |
| 452 }; | 511 }; |
| 453 | 512 |
| 454 BenchmarkingCanvas::BenchmarkingCanvas(SkCanvas* canvas, unsigned flags) | 513 BenchmarkingCanvas::BenchmarkingCanvas(SkCanvas* canvas, unsigned flags) |
| 455 : INHERITED(canvas->imageInfo().width(), | 514 : INHERITED(canvas->imageInfo().width(), |
| 456 canvas->imageInfo().height()) | 515 canvas->imageInfo().height()) |
| 457 , flags_(flags) { | 516 , flags_(flags) { |
| 458 addCanvas(canvas); | 517 addCanvas(canvas); |
| 518 |
| 519 if (flags & kOverdrawVisualization_Flag) |
| 520 overdraw_xfermode_ = AdoptRef(new OverdrawXfermode); |
| 459 } | 521 } |
| 460 | 522 |
| 461 BenchmarkingCanvas::~BenchmarkingCanvas() { | 523 BenchmarkingCanvas::~BenchmarkingCanvas() { |
| 462 } | 524 } |
| 463 | 525 |
| 464 size_t BenchmarkingCanvas::CommandCount() const { | 526 size_t BenchmarkingCanvas::CommandCount() const { |
| 465 return op_records_.GetSize(); | 527 return op_records_.GetSize(); |
| 466 } | 528 } |
| 467 | 529 |
| 468 const base::ListValue& BenchmarkingCanvas::Commands() const { | 530 const base::ListValue& BenchmarkingCanvas::Commands() const { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 486 | 548 |
| 487 INHERITED::willSave(); | 549 INHERITED::willSave(); |
| 488 } | 550 } |
| 489 | 551 |
| 490 SkCanvas::SaveLayerStrategy BenchmarkingCanvas::willSaveLayer(const SkRect* rect
, | 552 SkCanvas::SaveLayerStrategy BenchmarkingCanvas::willSaveLayer(const SkRect* rect
, |
| 491 const SkPaint* pai
nt, | 553 const SkPaint* pai
nt, |
| 492 SaveFlags flags) { | 554 SaveFlags flags) { |
| 493 AutoOp op(this, "SaveLayer", paint); | 555 AutoOp op(this, "SaveLayer", paint); |
| 494 if (rect) | 556 if (rect) |
| 495 op.addParam("bounds", AsValue(*rect)); | 557 op.addParam("bounds", AsValue(*rect)); |
| 496 if (paint) | |
| 497 op.addParam("paint", AsValue(*paint)); | |
| 498 if (flags) | 558 if (flags) |
| 499 op.addParam("flags", AsValue(flags)); | 559 op.addParam("flags", AsValue(flags)); |
| 500 | 560 |
| 501 return INHERITED::willSaveLayer(rect, paint, flags); | 561 return INHERITED::willSaveLayer(rect, op.paint(), flags); |
| 502 } | 562 } |
| 503 | 563 |
| 504 void BenchmarkingCanvas::willRestore() { | 564 void BenchmarkingCanvas::willRestore() { |
| 505 AutoOp op(this, "Restore"); | 565 AutoOp op(this, "Restore"); |
| 506 | 566 |
| 507 INHERITED::willRestore(); | 567 INHERITED::willRestore(); |
| 508 } | 568 } |
| 509 | 569 |
| 510 void BenchmarkingCanvas::didConcat(const SkMatrix& m) { | 570 void BenchmarkingCanvas::didConcat(const SkMatrix& m) { |
| 511 AutoOp op(this, "Concat"); | 571 AutoOp op(this, "Concat"); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 AutoOp op(this, "ClipRegion"); | 619 AutoOp op(this, "ClipRegion"); |
| 560 op.addParam("region", AsValue(region)); | 620 op.addParam("region", AsValue(region)); |
| 561 op.addParam("op", AsValue(region_op)); | 621 op.addParam("op", AsValue(region_op)); |
| 562 | 622 |
| 563 INHERITED::onClipRegion(region, region_op); | 623 INHERITED::onClipRegion(region, region_op); |
| 564 } | 624 } |
| 565 | 625 |
| 566 void BenchmarkingCanvas::onDrawPaint(const SkPaint& paint) { | 626 void BenchmarkingCanvas::onDrawPaint(const SkPaint& paint) { |
| 567 AutoOp op(this, "DrawPaint", &paint); | 627 AutoOp op(this, "DrawPaint", &paint); |
| 568 | 628 |
| 569 INHERITED::onDrawPaint(paint); | 629 INHERITED::onDrawPaint(*op.paint()); |
| 570 } | 630 } |
| 571 | 631 |
| 572 void BenchmarkingCanvas::onDrawPoints(PointMode mode, size_t count, | 632 void BenchmarkingCanvas::onDrawPoints(PointMode mode, size_t count, |
| 573 const SkPoint pts[], const SkPaint& paint)
{ | 633 const SkPoint pts[], const SkPaint& paint)
{ |
| 574 AutoOp op(this, "DrawPoints", &paint); | 634 AutoOp op(this, "DrawPoints", &paint); |
| 575 op.addParam("mode", AsValue(mode)); | 635 op.addParam("mode", AsValue(mode)); |
| 576 op.addParam("points", AsListValue(pts, count)); | 636 op.addParam("points", AsListValue(pts, count)); |
| 577 | 637 |
| 578 INHERITED::onDrawPoints(mode, count, pts, paint); | 638 INHERITED::onDrawPoints(mode, count, pts, *op.paint()); |
| 579 } | 639 } |
| 580 | 640 |
| 581 void BenchmarkingCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) { | 641 void BenchmarkingCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) { |
| 582 AutoOp op(this, "DrawRect", &paint); | 642 AutoOp op(this, "DrawRect", &paint); |
| 583 op.addParam("rect", AsValue(rect)); | 643 op.addParam("rect", AsValue(rect)); |
| 584 | 644 |
| 585 INHERITED::onDrawRect(rect, paint); | 645 INHERITED::onDrawRect(rect, *op.paint()); |
| 586 } | 646 } |
| 587 | 647 |
| 588 void BenchmarkingCanvas::onDrawOval(const SkRect& rect, const SkPaint& paint) { | 648 void BenchmarkingCanvas::onDrawOval(const SkRect& rect, const SkPaint& paint) { |
| 589 AutoOp op(this, "DrawOval", &paint); | 649 AutoOp op(this, "DrawOval", &paint); |
| 590 op.addParam("rect", AsValue(rect)); | 650 op.addParam("rect", AsValue(rect)); |
| 591 | 651 |
| 592 INHERITED::onDrawOval(rect, paint); | 652 INHERITED::onDrawOval(rect, *op.paint()); |
| 593 } | 653 } |
| 594 | 654 |
| 595 void BenchmarkingCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint)
{ | 655 void BenchmarkingCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint)
{ |
| 596 AutoOp op(this, "DrawRRect", &paint); | 656 AutoOp op(this, "DrawRRect", &paint); |
| 597 op.addParam("rrect", AsValue(rrect)); | 657 op.addParam("rrect", AsValue(rrect)); |
| 598 | 658 |
| 599 INHERITED::onDrawRRect(rrect, paint); | 659 INHERITED::onDrawRRect(rrect, *op.paint()); |
| 600 } | 660 } |
| 601 | 661 |
| 602 void BenchmarkingCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner
, | 662 void BenchmarkingCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner
, |
| 603 const SkPaint& paint) { | 663 const SkPaint& paint) { |
| 604 AutoOp op(this, "DrawDRRect", &paint); | 664 AutoOp op(this, "DrawDRRect", &paint); |
| 605 op.addParam("outer", AsValue(outer)); | 665 op.addParam("outer", AsValue(outer)); |
| 606 op.addParam("inner", AsValue(inner)); | 666 op.addParam("inner", AsValue(inner)); |
| 607 | 667 |
| 608 INHERITED::onDrawDRRect(outer, inner, paint); | 668 INHERITED::onDrawDRRect(outer, inner, *op.paint()); |
| 609 } | 669 } |
| 610 | 670 |
| 611 void BenchmarkingCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) { | 671 void BenchmarkingCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) { |
| 612 AutoOp op(this, "DrawPath", &paint); | 672 AutoOp op(this, "DrawPath", &paint); |
| 613 op.addParam("path", AsValue(path)); | 673 op.addParam("path", AsValue(path)); |
| 614 | 674 |
| 615 INHERITED::onDrawPath(path, paint); | 675 INHERITED::onDrawPath(path, *op.paint()); |
| 616 } | 676 } |
| 617 | 677 |
| 618 void BenchmarkingCanvas::onDrawPicture(const SkPicture* picture, | 678 void BenchmarkingCanvas::onDrawPicture(const SkPicture* picture, |
| 619 const SkMatrix* matrix, | 679 const SkMatrix* matrix, |
| 620 const SkPaint* paint) { | 680 const SkPaint* paint) { |
| 621 DCHECK(picture); | 681 DCHECK(picture); |
| 622 AutoOp op(this, "DrawPicture", paint); | 682 AutoOp op(this, "DrawPicture", paint); |
| 623 op.addParam("picture", AsValue(picture)); | 683 op.addParam("picture", AsValue(picture)); |
| 624 if (matrix) | 684 if (matrix) |
| 625 op.addParam("matrix", AsValue(*matrix)); | 685 op.addParam("matrix", AsValue(*matrix)); |
| 626 | 686 |
| 627 INHERITED::drawPicture(picture, matrix, paint); | 687 INHERITED::onDrawPicture(picture, matrix, op.paint()); |
| 628 } | 688 } |
| 629 | 689 |
| 630 void BenchmarkingCanvas::onDrawBitmap(const SkBitmap& bitmap, | 690 void BenchmarkingCanvas::onDrawBitmap(const SkBitmap& bitmap, |
| 631 SkScalar left, | 691 SkScalar left, |
| 632 SkScalar top, | 692 SkScalar top, |
| 633 const SkPaint* paint) { | 693 const SkPaint* paint) { |
| 634 AutoOp op(this, "DrawBitmap", paint); | 694 AutoOp op(this, "DrawBitmap", paint); |
| 635 op.addParam("bitmap", AsValue(bitmap)); | 695 op.addParam("bitmap", AsValue(bitmap)); |
| 636 op.addParam("left", AsValue(left)); | 696 op.addParam("left", AsValue(left)); |
| 637 op.addParam("top", AsValue(top)); | 697 op.addParam("top", AsValue(top)); |
| 638 | 698 |
| 639 INHERITED::onDrawBitmap(bitmap, left, top, paint); | 699 INHERITED::onDrawBitmap(bitmap, left, top, op.paint()); |
| 640 } | 700 } |
| 641 | 701 |
| 642 void BenchmarkingCanvas::onDrawBitmapRect(const SkBitmap& bitmap, | 702 void BenchmarkingCanvas::onDrawBitmapRect(const SkBitmap& bitmap, |
| 643 const SkRect* src, | 703 const SkRect* src, |
| 644 const SkRect& dst, | 704 const SkRect& dst, |
| 645 const SkPaint* paint, | 705 const SkPaint* paint, |
| 646 DrawBitmapRectFlags flags) { | 706 DrawBitmapRectFlags flags) { |
| 647 AutoOp op(this, "DrawBitmapRect", paint); | 707 AutoOp op(this, "DrawBitmapRect", paint); |
| 648 op.addParam("bitmap", AsValue(bitmap)); | 708 op.addParam("bitmap", AsValue(bitmap)); |
| 649 if (src) | 709 if (src) |
| 650 op.addParam("src", AsValue(*src)); | 710 op.addParam("src", AsValue(*src)); |
| 651 op.addParam("dst", AsValue(dst)); | 711 op.addParam("dst", AsValue(dst)); |
| 652 | 712 |
| 653 INHERITED::onDrawBitmapRect(bitmap, src, dst, paint, flags); | 713 INHERITED::onDrawBitmapRect(bitmap, src, dst, op.paint(), flags); |
| 654 } | 714 } |
| 655 | 715 |
| 656 void BenchmarkingCanvas::onDrawImage(const SkImage* image, | 716 void BenchmarkingCanvas::onDrawImage(const SkImage* image, |
| 657 SkScalar left, | 717 SkScalar left, |
| 658 SkScalar top, | 718 SkScalar top, |
| 659 const SkPaint* paint) { | 719 const SkPaint* paint) { |
| 660 DCHECK(image); | 720 DCHECK(image); |
| 661 AutoOp op(this, "DrawImage", paint); | 721 AutoOp op(this, "DrawImage", paint); |
| 662 op.addParam("image", AsValue(*image)); | 722 op.addParam("image", AsValue(*image)); |
| 663 op.addParam("left", AsValue(left)); | 723 op.addParam("left", AsValue(left)); |
| 664 op.addParam("top", AsValue(top)); | 724 op.addParam("top", AsValue(top)); |
| 665 | 725 |
| 666 INHERITED::onDrawImage(image, left, top, paint); | 726 INHERITED::onDrawImage(image, left, top, op.paint()); |
| 667 } | 727 } |
| 668 | 728 |
| 669 void BenchmarkingCanvas::onDrawImageRect(const SkImage* image, const SkRect* src
, | 729 void BenchmarkingCanvas::onDrawImageRect(const SkImage* image, const SkRect* src
, |
| 670 const SkRect& dst, const SkPaint* paint
) { | 730 const SkRect& dst, const SkPaint* paint
) { |
| 671 DCHECK(image); | 731 DCHECK(image); |
| 672 AutoOp op(this, "DrawImageRect", paint); | 732 AutoOp op(this, "DrawImageRect", paint); |
| 673 op.addParam("image", AsValue(*image)); | 733 op.addParam("image", AsValue(*image)); |
| 674 if (src) | 734 if (src) |
| 675 op.addParam("src", AsValue(*src)); | 735 op.addParam("src", AsValue(*src)); |
| 676 op.addParam("dst", AsValue(dst)); | 736 op.addParam("dst", AsValue(dst)); |
| 677 | 737 |
| 678 INHERITED::onDrawImageRect(image, src, dst, paint); | 738 INHERITED::onDrawImageRect(image, src, dst, op.paint()); |
| 679 } | 739 } |
| 680 | 740 |
| 681 void BenchmarkingCanvas::onDrawBitmapNine(const SkBitmap& bitmap, | 741 void BenchmarkingCanvas::onDrawBitmapNine(const SkBitmap& bitmap, |
| 682 const SkIRect& center, | 742 const SkIRect& center, |
| 683 const SkRect& dst, | 743 const SkRect& dst, |
| 684 const SkPaint* paint) { | 744 const SkPaint* paint) { |
| 685 AutoOp op(this, "DrawBitmapNine", paint); | 745 AutoOp op(this, "DrawBitmapNine", paint); |
| 686 op.addParam("bitmap", AsValue(bitmap)); | 746 op.addParam("bitmap", AsValue(bitmap)); |
| 687 op.addParam("center", AsValue(SkRect::Make(center))); | 747 op.addParam("center", AsValue(SkRect::Make(center))); |
| 688 op.addParam("dst", AsValue(dst)); | 748 op.addParam("dst", AsValue(dst)); |
| 689 | 749 |
| 690 INHERITED::onDrawBitmapNine(bitmap, center, dst, paint); | 750 INHERITED::onDrawBitmapNine(bitmap, center, dst, op.paint()); |
| 691 } | 751 } |
| 692 | 752 |
| 693 void BenchmarkingCanvas::onDrawSprite(const SkBitmap& bitmap, int left, int top, | 753 void BenchmarkingCanvas::onDrawSprite(const SkBitmap& bitmap, int left, int top, |
| 694 const SkPaint* paint) { | 754 const SkPaint* paint) { |
| 695 AutoOp op(this, "DrawSprite", paint); | 755 AutoOp op(this, "DrawSprite", paint); |
| 696 op.addParam("bitmap", AsValue(bitmap)); | 756 op.addParam("bitmap", AsValue(bitmap)); |
| 697 op.addParam("left", AsValue(SkIntToScalar(left))); | 757 op.addParam("left", AsValue(SkIntToScalar(left))); |
| 698 op.addParam("top", AsValue(SkIntToScalar(top))); | 758 op.addParam("top", AsValue(SkIntToScalar(top))); |
| 699 | 759 |
| 700 INHERITED::onDrawSprite(bitmap, left, top, paint); | 760 INHERITED::onDrawSprite(bitmap, left, top, op.paint()); |
| 701 } | 761 } |
| 702 | 762 |
| 703 void BenchmarkingCanvas::onDrawText(const void* text, size_t byteLength, | 763 void BenchmarkingCanvas::onDrawText(const void* text, size_t byteLength, |
| 704 SkScalar x, SkScalar y, | 764 SkScalar x, SkScalar y, |
| 705 const SkPaint& paint) { | 765 const SkPaint& paint) { |
| 706 AutoOp op(this, "DrawText", &paint); | 766 AutoOp op(this, "DrawText", &paint); |
| 707 op.addParam("count", AsValue(SkIntToScalar(paint.countText(text, byteLength)))
); | 767 op.addParam("count", AsValue(SkIntToScalar(paint.countText(text, byteLength)))
); |
| 708 op.addParam("x", AsValue(x)); | 768 op.addParam("x", AsValue(x)); |
| 709 op.addParam("y", AsValue(y)); | 769 op.addParam("y", AsValue(y)); |
| 710 | 770 |
| 711 INHERITED::onDrawText(text, byteLength, x, y, paint); | 771 INHERITED::onDrawText(text, byteLength, x, y, *op.paint()); |
| 712 } | 772 } |
| 713 | 773 |
| 714 void BenchmarkingCanvas::onDrawPosText(const void* text, size_t byteLength, | 774 void BenchmarkingCanvas::onDrawPosText(const void* text, size_t byteLength, |
| 715 const SkPoint pos[], const SkPaint& paint
) { | 775 const SkPoint pos[], const SkPaint& paint
) { |
| 716 AutoOp op(this, "DrawPosText", &paint); | 776 AutoOp op(this, "DrawPosText", &paint); |
| 717 | 777 |
| 718 int count = paint.countText(text, byteLength); | 778 int count = paint.countText(text, byteLength); |
| 719 op.addParam("count", AsValue(SkIntToScalar(count))); | 779 op.addParam("count", AsValue(SkIntToScalar(count))); |
| 720 op.addParam("pos", AsListValue(pos, count)); | 780 op.addParam("pos", AsListValue(pos, count)); |
| 721 | 781 |
| 722 INHERITED::onDrawPosText(text, byteLength, pos, paint); | 782 INHERITED::onDrawPosText(text, byteLength, pos, *op.paint()); |
| 723 } | 783 } |
| 724 | 784 |
| 725 void BenchmarkingCanvas::onDrawPosTextH(const void* text, size_t byteLength, | 785 void BenchmarkingCanvas::onDrawPosTextH(const void* text, size_t byteLength, |
| 726 const SkScalar xpos[], SkScalar constY, | 786 const SkScalar xpos[], SkScalar constY, |
| 727 const SkPaint& paint) { | 787 const SkPaint& paint) { |
| 728 AutoOp op(this, "DrawPosTextH", &paint); | 788 AutoOp op(this, "DrawPosTextH", &paint); |
| 729 op.addParam("constY", AsValue(constY)); | 789 op.addParam("constY", AsValue(constY)); |
| 730 | 790 |
| 731 int count = paint.countText(text, byteLength); | 791 int count = paint.countText(text, byteLength); |
| 732 op.addParam("count", AsValue(SkIntToScalar(count))); | 792 op.addParam("count", AsValue(SkIntToScalar(count))); |
| 733 op.addParam("pos", AsListValue(xpos, count)); | 793 op.addParam("pos", AsListValue(xpos, count)); |
| 734 | 794 |
| 735 INHERITED::onDrawPosTextH(text, byteLength, xpos, constY, paint); | 795 INHERITED::onDrawPosTextH(text, byteLength, xpos, constY, *op.paint()); |
| 736 } | 796 } |
| 737 | 797 |
| 738 void BenchmarkingCanvas::onDrawTextOnPath(const void* text, size_t byteLength, | 798 void BenchmarkingCanvas::onDrawTextOnPath(const void* text, size_t byteLength, |
| 739 const SkPath& path, const SkMatrix* ma
trix, | 799 const SkPath& path, const SkMatrix* ma
trix, |
| 740 const SkPaint& paint) { | 800 const SkPaint& paint) { |
| 741 AutoOp op(this, "DrawTextOnPath", &paint); | 801 AutoOp op(this, "DrawTextOnPath", &paint); |
| 742 op.addParam("count", AsValue(SkIntToScalar(paint.countText(text, byteLength)))
); | 802 op.addParam("count", AsValue(SkIntToScalar(paint.countText(text, byteLength)))
); |
| 743 op.addParam("path", AsValue(path)); | 803 op.addParam("path", AsValue(path)); |
| 744 if (matrix) | 804 if (matrix) |
| 745 op.addParam("matrix", AsValue(*matrix)); | 805 op.addParam("matrix", AsValue(*matrix)); |
| 746 | 806 |
| 747 INHERITED::onDrawTextOnPath(text, byteLength, path, matrix, paint); | 807 INHERITED::onDrawTextOnPath(text, byteLength, path, matrix, *op.paint()); |
| 748 } | 808 } |
| 749 | 809 |
| 750 void BenchmarkingCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkSc
alar y, | 810 void BenchmarkingCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkSc
alar y, |
| 751 const SkPaint& paint) { | 811 const SkPaint& paint) { |
| 752 DCHECK(blob); | 812 DCHECK(blob); |
| 753 AutoOp op(this, "DrawTextBlob", &paint); | 813 AutoOp op(this, "DrawTextBlob", &paint); |
| 754 op.addParam("blob", AsValue(*blob)); | 814 op.addParam("blob", AsValue(*blob)); |
| 755 op.addParam("x", AsValue(x)); | 815 op.addParam("x", AsValue(x)); |
| 756 op.addParam("y", AsValue(y)); | 816 op.addParam("y", AsValue(y)); |
| 757 | 817 |
| 758 INHERITED::onDrawTextBlob(blob, x, y, paint); | 818 INHERITED::onDrawTextBlob(blob, x, y, *op.paint()); |
| 759 } | 819 } |
| 760 | 820 |
| 761 } // namespace skia | 821 } // namespace skia |
| OLD | NEW |