Chromium Code Reviews| 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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 template<typename T> | 400 template<typename T> |
| 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 |
|
robertphillips
2015/03/11 14:07:47
// Comment maybe ?
// This filter works by ...
f(malita)
2015/03/11 14:45:48
Switched back to the color-table approach.
| |
| 411 class OverdrawXfermode : public SkXfermode { | |
| 412 public: | |
| 413 SkPMColor xferColor(SkPMColor, SkPMColor dst) const override { | |
| 414 // Interpolate between kStartColor & kEndColor, | |
| 415 // adding kRate weight for each overdraw. | |
| 416 const SkPMColor kStartColor = SkPackARGB32(0xFF, 0x80, 0x80, 0xFF); | |
| 417 const SkPMColor kEndColor = SkPackARGB32(0xFF, 0xFF, 0, 0); | |
| 418 const float kRate = 0.1f; | |
| 419 | |
| 420 float weight = 0.f; | |
| 421 if (SkGetPackedR32(dst) >= SkGetPackedR16(kStartColor)) { | |
| 422 weight = (float)(SkGetPackedR32(dst) - SkGetPackedR32(kStartColor)) / | |
| 423 (SkGetPackedR32(kEndColor) - SkGetPackedR32(kStartColor)); | |
| 424 weight = std::min(weight + kRate, 1.f); | |
| 425 } | |
| 426 | |
| 427 return SkFourByteInterp(kEndColor, kStartColor, | |
| 428 SkScalarRoundToInt(weight * 255)); | |
| 429 } | |
| 430 | |
| 431 Factory getFactory() const override { return NULL; } | |
| 432 #ifndef SK_IGNORE_TO_STRING | |
| 433 void toString(SkString* str) const override { str->set("OverdrawXfermode"); } | |
| 434 #endif | |
| 435 | |
| 436 private: | |
| 437 typedef SkXfermode INHERITED; | |
| 438 }; | |
| 439 | |
| 409 } // namespace | 440 } // namespace |
| 410 | 441 |
| 411 namespace skia { | 442 namespace skia { |
| 412 | 443 |
| 413 class BenchmarkingCanvas::AutoOp { | 444 class BenchmarkingCanvas::AutoOp { |
| 414 public: | 445 public: |
| 415 AutoOp(BenchmarkingCanvas* canvas, const char op_name[], | 446 AutoOp(BenchmarkingCanvas* canvas, const char op_name[], |
| 416 const SkPaint* paint = nullptr) | 447 const SkPaint* paint = nullptr) |
| 417 : canvas_(canvas) | 448 : canvas_(canvas) |
| 418 , op_record_(new base::DictionaryValue()) | 449 , op_record_(new base::DictionaryValue()) |
| 419 , op_params_(new base::ListValue()) { | 450 , op_params_(new base::ListValue()) |
|
robertphillips
2015/03/11 14:07:47
What guarantees is the caller providing regarding
f(malita)
2015/03/11 14:45:48
AutoOp objects are always scoped within a given dr
| |
| 451 , paint_(paint) { | |
| 420 | 452 |
| 421 DCHECK(canvas); | 453 DCHECK(canvas); |
| 422 DCHECK(op_name); | 454 DCHECK(op_name); |
| 423 | 455 |
| 424 op_record_->SetString("cmd_string", op_name); | 456 op_record_->SetString("cmd_string", op_name); |
| 425 op_record_->Set("info", op_params_); | 457 op_record_->Set("info", op_params_); |
| 426 | 458 |
| 427 if (paint) | 459 if (paint) { |
| 428 this->addParam("paint", AsValue(*paint)); | 460 this->addParam("paint", AsValue(*paint)); |
| 429 | 461 |
|
robertphillips
2015/03/11 14:07:47
I think even if the op has no paint you need to cr
f(malita)
2015/03/11 14:45:48
Good catch, done.
| |
| 462 if (canvas->flags_ & kOverdrawVisualization_Flag) { | |
| 463 DCHECK(canvas->overdraw_xfermode_); | |
| 464 paint_ = filtered_paint_.set(*paint); | |
| 465 filtered_paint_.get()->setXfermode(canvas->overdraw_xfermode_.get()); | |
|
robertphillips
2015/03/11 14:07:47
Should disable AA in here too.
f(malita)
2015/03/11 14:45:49
Done.
| |
| 466 } | |
| 467 } | |
| 468 | |
| 430 start_ticks_ = base::TimeTicks::Now(); | 469 start_ticks_ = base::TimeTicks::Now(); |
| 431 } | 470 } |
| 432 | 471 |
| 433 ~AutoOp() { | 472 ~AutoOp() { |
| 434 base::TimeDelta ticks = base::TimeTicks::Now() - start_ticks_; | 473 base::TimeDelta ticks = base::TimeTicks::Now() - start_ticks_; |
| 435 op_record_->SetDouble("cmd_time", ticks.InMillisecondsF()); | 474 op_record_->SetDouble("cmd_time", ticks.InMillisecondsF()); |
| 436 | 475 |
| 437 canvas_->op_records_.Append(op_record_); | 476 canvas_->op_records_.Append(op_record_); |
| 438 } | 477 } |
| 439 | 478 |
| 440 void addParam(const char name[], scoped_ptr<base::Value> value) { | 479 void addParam(const char name[], scoped_ptr<base::Value> value) { |
| 441 scoped_ptr<base::DictionaryValue> param(new base::DictionaryValue()); | 480 scoped_ptr<base::DictionaryValue> param(new base::DictionaryValue()); |
| 442 param->Set(name, value.Pass()); | 481 param->Set(name, value.Pass()); |
| 443 | 482 |
| 444 op_params_->Append(param.release()); | 483 op_params_->Append(param.release()); |
| 445 } | 484 } |
| 446 | 485 |
| 486 const SkPaint* paint() const { return paint_; } | |
| 487 | |
| 447 private: | 488 private: |
| 448 BenchmarkingCanvas* canvas_; | 489 BenchmarkingCanvas* canvas_; |
| 449 base::DictionaryValue* op_record_; | 490 base::DictionaryValue* op_record_; |
| 450 base::ListValue* op_params_; | 491 base::ListValue* op_params_; |
| 451 base::TimeTicks start_ticks_; | 492 base::TimeTicks start_ticks_; |
| 493 | |
| 494 const SkPaint* paint_; | |
| 495 SkTLazy<SkPaint> filtered_paint_; | |
| 452 }; | 496 }; |
| 453 | 497 |
| 454 BenchmarkingCanvas::BenchmarkingCanvas(SkCanvas* canvas, unsigned flags) | 498 BenchmarkingCanvas::BenchmarkingCanvas(SkCanvas* canvas, unsigned flags) |
| 455 : INHERITED(canvas->imageInfo().width(), | 499 : INHERITED(canvas->imageInfo().width(), |
| 456 canvas->imageInfo().height()) | 500 canvas->imageInfo().height()) |
| 457 , flags_(flags) { | 501 , flags_(flags) { |
| 458 addCanvas(canvas); | 502 addCanvas(canvas); |
| 503 | |
| 504 if (flags & kOverdrawVisualization_Flag) | |
| 505 overdraw_xfermode_ = AdoptRef(new OverdrawXfermode); | |
| 459 } | 506 } |
| 460 | 507 |
| 461 BenchmarkingCanvas::~BenchmarkingCanvas() { | 508 BenchmarkingCanvas::~BenchmarkingCanvas() { |
| 462 } | 509 } |
| 463 | 510 |
| 464 size_t BenchmarkingCanvas::CommandCount() const { | 511 size_t BenchmarkingCanvas::CommandCount() const { |
| 465 return op_records_.GetSize(); | 512 return op_records_.GetSize(); |
| 466 } | 513 } |
| 467 | 514 |
| 468 const base::ListValue& BenchmarkingCanvas::Commands() const { | 515 const base::ListValue& BenchmarkingCanvas::Commands() const { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 486 | 533 |
| 487 INHERITED::willSave(); | 534 INHERITED::willSave(); |
| 488 } | 535 } |
| 489 | 536 |
| 490 SkCanvas::SaveLayerStrategy BenchmarkingCanvas::willSaveLayer(const SkRect* rect , | 537 SkCanvas::SaveLayerStrategy BenchmarkingCanvas::willSaveLayer(const SkRect* rect , |
| 491 const SkPaint* pai nt, | 538 const SkPaint* pai nt, |
| 492 SaveFlags flags) { | 539 SaveFlags flags) { |
| 493 AutoOp op(this, "SaveLayer", paint); | 540 AutoOp op(this, "SaveLayer", paint); |
| 494 if (rect) | 541 if (rect) |
| 495 op.addParam("bounds", AsValue(*rect)); | 542 op.addParam("bounds", AsValue(*rect)); |
| 496 if (paint) | |
| 497 op.addParam("paint", AsValue(*paint)); | |
| 498 if (flags) | 543 if (flags) |
| 499 op.addParam("flags", AsValue(flags)); | 544 op.addParam("flags", AsValue(flags)); |
| 500 | 545 |
| 501 return INHERITED::willSaveLayer(rect, paint, flags); | 546 return INHERITED::willSaveLayer(rect, op.paint(), flags); |
| 502 } | 547 } |
| 503 | 548 |
| 504 void BenchmarkingCanvas::willRestore() { | 549 void BenchmarkingCanvas::willRestore() { |
| 505 AutoOp op(this, "Restore"); | 550 AutoOp op(this, "Restore"); |
| 506 | 551 |
| 507 INHERITED::willRestore(); | 552 INHERITED::willRestore(); |
| 508 } | 553 } |
| 509 | 554 |
| 510 void BenchmarkingCanvas::didConcat(const SkMatrix& m) { | 555 void BenchmarkingCanvas::didConcat(const SkMatrix& m) { |
| 511 AutoOp op(this, "Concat"); | 556 AutoOp op(this, "Concat"); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 559 AutoOp op(this, "ClipRegion"); | 604 AutoOp op(this, "ClipRegion"); |
| 560 op.addParam("region", AsValue(region)); | 605 op.addParam("region", AsValue(region)); |
| 561 op.addParam("op", AsValue(region_op)); | 606 op.addParam("op", AsValue(region_op)); |
| 562 | 607 |
| 563 INHERITED::onClipRegion(region, region_op); | 608 INHERITED::onClipRegion(region, region_op); |
| 564 } | 609 } |
| 565 | 610 |
| 566 void BenchmarkingCanvas::onDrawPaint(const SkPaint& paint) { | 611 void BenchmarkingCanvas::onDrawPaint(const SkPaint& paint) { |
| 567 AutoOp op(this, "DrawPaint", &paint); | 612 AutoOp op(this, "DrawPaint", &paint); |
| 568 | 613 |
| 569 INHERITED::onDrawPaint(paint); | 614 INHERITED::onDrawPaint(*op.paint()); |
| 570 } | 615 } |
| 571 | 616 |
| 572 void BenchmarkingCanvas::onDrawPoints(PointMode mode, size_t count, | 617 void BenchmarkingCanvas::onDrawPoints(PointMode mode, size_t count, |
| 573 const SkPoint pts[], const SkPaint& paint) { | 618 const SkPoint pts[], const SkPaint& paint) { |
| 574 AutoOp op(this, "DrawPoints", &paint); | 619 AutoOp op(this, "DrawPoints", &paint); |
| 575 op.addParam("mode", AsValue(mode)); | 620 op.addParam("mode", AsValue(mode)); |
| 576 op.addParam("points", AsListValue(pts, count)); | 621 op.addParam("points", AsListValue(pts, count)); |
| 577 | 622 |
| 578 INHERITED::onDrawPoints(mode, count, pts, paint); | 623 INHERITED::onDrawPoints(mode, count, pts, *op.paint()); |
| 579 } | 624 } |
| 580 | 625 |
| 581 void BenchmarkingCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) { | 626 void BenchmarkingCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) { |
| 582 AutoOp op(this, "DrawRect", &paint); | 627 AutoOp op(this, "DrawRect", &paint); |
| 583 op.addParam("rect", AsValue(rect)); | 628 op.addParam("rect", AsValue(rect)); |
| 584 | 629 |
| 585 INHERITED::onDrawRect(rect, paint); | 630 INHERITED::onDrawRect(rect, *op.paint()); |
| 586 } | 631 } |
| 587 | 632 |
| 588 void BenchmarkingCanvas::onDrawOval(const SkRect& rect, const SkPaint& paint) { | 633 void BenchmarkingCanvas::onDrawOval(const SkRect& rect, const SkPaint& paint) { |
| 589 AutoOp op(this, "DrawOval", &paint); | 634 AutoOp op(this, "DrawOval", &paint); |
| 590 op.addParam("rect", AsValue(rect)); | 635 op.addParam("rect", AsValue(rect)); |
| 591 | 636 |
| 592 INHERITED::onDrawOval(rect, paint); | 637 INHERITED::onDrawOval(rect, *op.paint()); |
| 593 } | 638 } |
| 594 | 639 |
| 595 void BenchmarkingCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) { | 640 void BenchmarkingCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) { |
| 596 AutoOp op(this, "DrawRRect", &paint); | 641 AutoOp op(this, "DrawRRect", &paint); |
| 597 op.addParam("rrect", AsValue(rrect)); | 642 op.addParam("rrect", AsValue(rrect)); |
| 598 | 643 |
| 599 INHERITED::onDrawRRect(rrect, paint); | 644 INHERITED::onDrawRRect(rrect, *op.paint()); |
| 600 } | 645 } |
| 601 | 646 |
| 602 void BenchmarkingCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner , | 647 void BenchmarkingCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner , |
| 603 const SkPaint& paint) { | 648 const SkPaint& paint) { |
| 604 AutoOp op(this, "DrawDRRect", &paint); | 649 AutoOp op(this, "DrawDRRect", &paint); |
| 605 op.addParam("outer", AsValue(outer)); | 650 op.addParam("outer", AsValue(outer)); |
| 606 op.addParam("inner", AsValue(inner)); | 651 op.addParam("inner", AsValue(inner)); |
| 607 | 652 |
| 608 INHERITED::onDrawDRRect(outer, inner, paint); | 653 INHERITED::onDrawDRRect(outer, inner, *op.paint()); |
| 609 } | 654 } |
| 610 | 655 |
| 611 void BenchmarkingCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) { | 656 void BenchmarkingCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) { |
| 612 AutoOp op(this, "DrawPath", &paint); | 657 AutoOp op(this, "DrawPath", &paint); |
| 613 op.addParam("path", AsValue(path)); | 658 op.addParam("path", AsValue(path)); |
| 614 | 659 |
| 615 INHERITED::onDrawPath(path, paint); | 660 INHERITED::onDrawPath(path, *op.paint()); |
| 616 } | 661 } |
| 617 | 662 |
| 618 void BenchmarkingCanvas::onDrawPicture(const SkPicture* picture, | 663 void BenchmarkingCanvas::onDrawPicture(const SkPicture* picture, |
| 619 const SkMatrix* matrix, | 664 const SkMatrix* matrix, |
| 620 const SkPaint* paint) { | 665 const SkPaint* paint) { |
| 621 DCHECK(picture); | 666 DCHECK(picture); |
| 622 AutoOp op(this, "DrawPicture", paint); | 667 AutoOp op(this, "DrawPicture", paint); |
| 623 op.addParam("picture", AsValue(picture)); | 668 op.addParam("picture", AsValue(picture)); |
| 624 if (matrix) | 669 if (matrix) |
| 625 op.addParam("matrix", AsValue(*matrix)); | 670 op.addParam("matrix", AsValue(*matrix)); |
| 626 | 671 |
| 627 INHERITED::onDrawPicture(picture, matrix, paint); | 672 INHERITED::onDrawPicture(picture, matrix, op.paint()); |
| 628 } | 673 } |
| 629 | 674 |
| 630 void BenchmarkingCanvas::onDrawBitmap(const SkBitmap& bitmap, | 675 void BenchmarkingCanvas::onDrawBitmap(const SkBitmap& bitmap, |
| 631 SkScalar left, | 676 SkScalar left, |
| 632 SkScalar top, | 677 SkScalar top, |
| 633 const SkPaint* paint) { | 678 const SkPaint* paint) { |
| 634 AutoOp op(this, "DrawBitmap", paint); | 679 AutoOp op(this, "DrawBitmap", paint); |
| 635 op.addParam("bitmap", AsValue(bitmap)); | 680 op.addParam("bitmap", AsValue(bitmap)); |
| 636 op.addParam("left", AsValue(left)); | 681 op.addParam("left", AsValue(left)); |
| 637 op.addParam("top", AsValue(top)); | 682 op.addParam("top", AsValue(top)); |
| 638 | 683 |
| 639 INHERITED::onDrawBitmap(bitmap, left, top, paint); | 684 INHERITED::onDrawBitmap(bitmap, left, top, op.paint()); |
| 640 } | 685 } |
| 641 | 686 |
| 642 void BenchmarkingCanvas::onDrawBitmapRect(const SkBitmap& bitmap, | 687 void BenchmarkingCanvas::onDrawBitmapRect(const SkBitmap& bitmap, |
| 643 const SkRect* src, | 688 const SkRect* src, |
| 644 const SkRect& dst, | 689 const SkRect& dst, |
| 645 const SkPaint* paint, | 690 const SkPaint* paint, |
| 646 DrawBitmapRectFlags flags) { | 691 DrawBitmapRectFlags flags) { |
| 647 AutoOp op(this, "DrawBitmapRect", paint); | 692 AutoOp op(this, "DrawBitmapRect", paint); |
| 648 op.addParam("bitmap", AsValue(bitmap)); | 693 op.addParam("bitmap", AsValue(bitmap)); |
| 649 if (src) | 694 if (src) |
| 650 op.addParam("src", AsValue(*src)); | 695 op.addParam("src", AsValue(*src)); |
| 651 op.addParam("dst", AsValue(dst)); | 696 op.addParam("dst", AsValue(dst)); |
| 652 | 697 |
| 653 INHERITED::onDrawBitmapRect(bitmap, src, dst, paint, flags); | 698 INHERITED::onDrawBitmapRect(bitmap, src, dst, op.paint(), flags); |
| 654 } | 699 } |
| 655 | 700 |
| 656 void BenchmarkingCanvas::onDrawImage(const SkImage* image, | 701 void BenchmarkingCanvas::onDrawImage(const SkImage* image, |
| 657 SkScalar left, | 702 SkScalar left, |
| 658 SkScalar top, | 703 SkScalar top, |
| 659 const SkPaint* paint) { | 704 const SkPaint* paint) { |
| 660 DCHECK(image); | 705 DCHECK(image); |
| 661 AutoOp op(this, "DrawImage", paint); | 706 AutoOp op(this, "DrawImage", paint); |
| 662 op.addParam("image", AsValue(*image)); | 707 op.addParam("image", AsValue(*image)); |
| 663 op.addParam("left", AsValue(left)); | 708 op.addParam("left", AsValue(left)); |
| 664 op.addParam("top", AsValue(top)); | 709 op.addParam("top", AsValue(top)); |
| 665 | 710 |
| 666 INHERITED::onDrawImage(image, left, top, paint); | 711 INHERITED::onDrawImage(image, left, top, op.paint()); |
| 667 } | 712 } |
| 668 | 713 |
| 669 void BenchmarkingCanvas::onDrawImageRect(const SkImage* image, const SkRect* src , | 714 void BenchmarkingCanvas::onDrawImageRect(const SkImage* image, const SkRect* src , |
| 670 const SkRect& dst, const SkPaint* paint ) { | 715 const SkRect& dst, const SkPaint* paint ) { |
| 671 DCHECK(image); | 716 DCHECK(image); |
| 672 AutoOp op(this, "DrawImageRect", paint); | 717 AutoOp op(this, "DrawImageRect", paint); |
| 673 op.addParam("image", AsValue(*image)); | 718 op.addParam("image", AsValue(*image)); |
| 674 if (src) | 719 if (src) |
| 675 op.addParam("src", AsValue(*src)); | 720 op.addParam("src", AsValue(*src)); |
| 676 op.addParam("dst", AsValue(dst)); | 721 op.addParam("dst", AsValue(dst)); |
| 677 | 722 |
| 678 INHERITED::onDrawImageRect(image, src, dst, paint); | 723 INHERITED::onDrawImageRect(image, src, dst, op.paint()); |
| 679 } | 724 } |
| 680 | 725 |
| 681 void BenchmarkingCanvas::onDrawBitmapNine(const SkBitmap& bitmap, | 726 void BenchmarkingCanvas::onDrawBitmapNine(const SkBitmap& bitmap, |
| 682 const SkIRect& center, | 727 const SkIRect& center, |
| 683 const SkRect& dst, | 728 const SkRect& dst, |
| 684 const SkPaint* paint) { | 729 const SkPaint* paint) { |
| 685 AutoOp op(this, "DrawBitmapNine", paint); | 730 AutoOp op(this, "DrawBitmapNine", paint); |
| 686 op.addParam("bitmap", AsValue(bitmap)); | 731 op.addParam("bitmap", AsValue(bitmap)); |
| 687 op.addParam("center", AsValue(SkRect::Make(center))); | 732 op.addParam("center", AsValue(SkRect::Make(center))); |
| 688 op.addParam("dst", AsValue(dst)); | 733 op.addParam("dst", AsValue(dst)); |
| 689 | 734 |
| 690 INHERITED::onDrawBitmapNine(bitmap, center, dst, paint); | 735 INHERITED::onDrawBitmapNine(bitmap, center, dst, op.paint()); |
| 691 } | 736 } |
| 692 | 737 |
| 693 void BenchmarkingCanvas::onDrawSprite(const SkBitmap& bitmap, int left, int top, | 738 void BenchmarkingCanvas::onDrawSprite(const SkBitmap& bitmap, int left, int top, |
| 694 const SkPaint* paint) { | 739 const SkPaint* paint) { |
| 695 AutoOp op(this, "DrawSprite", paint); | 740 AutoOp op(this, "DrawSprite", paint); |
| 696 op.addParam("bitmap", AsValue(bitmap)); | 741 op.addParam("bitmap", AsValue(bitmap)); |
| 697 op.addParam("left", AsValue(SkIntToScalar(left))); | 742 op.addParam("left", AsValue(SkIntToScalar(left))); |
| 698 op.addParam("top", AsValue(SkIntToScalar(top))); | 743 op.addParam("top", AsValue(SkIntToScalar(top))); |
| 699 | 744 |
| 700 INHERITED::onDrawSprite(bitmap, left, top, paint); | 745 INHERITED::onDrawSprite(bitmap, left, top, op.paint()); |
| 701 } | 746 } |
| 702 | 747 |
| 703 void BenchmarkingCanvas::onDrawText(const void* text, size_t byteLength, | 748 void BenchmarkingCanvas::onDrawText(const void* text, size_t byteLength, |
| 704 SkScalar x, SkScalar y, | 749 SkScalar x, SkScalar y, |
| 705 const SkPaint& paint) { | 750 const SkPaint& paint) { |
| 706 AutoOp op(this, "DrawText", &paint); | 751 AutoOp op(this, "DrawText", &paint); |
| 707 op.addParam("count", AsValue(SkIntToScalar(paint.countText(text, byteLength))) ); | 752 op.addParam("count", AsValue(SkIntToScalar(paint.countText(text, byteLength))) ); |
| 708 op.addParam("x", AsValue(x)); | 753 op.addParam("x", AsValue(x)); |
| 709 op.addParam("y", AsValue(y)); | 754 op.addParam("y", AsValue(y)); |
| 710 | 755 |
| 711 INHERITED::onDrawText(text, byteLength, x, y, paint); | 756 INHERITED::onDrawText(text, byteLength, x, y, *op.paint()); |
| 712 } | 757 } |
| 713 | 758 |
| 714 void BenchmarkingCanvas::onDrawPosText(const void* text, size_t byteLength, | 759 void BenchmarkingCanvas::onDrawPosText(const void* text, size_t byteLength, |
| 715 const SkPoint pos[], const SkPaint& paint ) { | 760 const SkPoint pos[], const SkPaint& paint ) { |
| 716 AutoOp op(this, "DrawPosText", &paint); | 761 AutoOp op(this, "DrawPosText", &paint); |
| 717 | 762 |
| 718 int count = paint.countText(text, byteLength); | 763 int count = paint.countText(text, byteLength); |
| 719 op.addParam("count", AsValue(SkIntToScalar(count))); | 764 op.addParam("count", AsValue(SkIntToScalar(count))); |
| 720 op.addParam("pos", AsListValue(pos, count)); | 765 op.addParam("pos", AsListValue(pos, count)); |
| 721 | 766 |
| 722 INHERITED::onDrawPosText(text, byteLength, pos, paint); | 767 INHERITED::onDrawPosText(text, byteLength, pos, *op.paint()); |
| 723 } | 768 } |
| 724 | 769 |
| 725 void BenchmarkingCanvas::onDrawPosTextH(const void* text, size_t byteLength, | 770 void BenchmarkingCanvas::onDrawPosTextH(const void* text, size_t byteLength, |
| 726 const SkScalar xpos[], SkScalar constY, | 771 const SkScalar xpos[], SkScalar constY, |
| 727 const SkPaint& paint) { | 772 const SkPaint& paint) { |
| 728 AutoOp op(this, "DrawPosTextH", &paint); | 773 AutoOp op(this, "DrawPosTextH", &paint); |
| 729 op.addParam("constY", AsValue(constY)); | 774 op.addParam("constY", AsValue(constY)); |
| 730 | 775 |
| 731 int count = paint.countText(text, byteLength); | 776 int count = paint.countText(text, byteLength); |
| 732 op.addParam("count", AsValue(SkIntToScalar(count))); | 777 op.addParam("count", AsValue(SkIntToScalar(count))); |
| 733 op.addParam("pos", AsListValue(xpos, count)); | 778 op.addParam("pos", AsListValue(xpos, count)); |
| 734 | 779 |
| 735 INHERITED::onDrawPosTextH(text, byteLength, xpos, constY, paint); | 780 INHERITED::onDrawPosTextH(text, byteLength, xpos, constY, *op.paint()); |
| 736 } | 781 } |
| 737 | 782 |
| 738 void BenchmarkingCanvas::onDrawTextOnPath(const void* text, size_t byteLength, | 783 void BenchmarkingCanvas::onDrawTextOnPath(const void* text, size_t byteLength, |
| 739 const SkPath& path, const SkMatrix* ma trix, | 784 const SkPath& path, const SkMatrix* ma trix, |
| 740 const SkPaint& paint) { | 785 const SkPaint& paint) { |
| 741 AutoOp op(this, "DrawTextOnPath", &paint); | 786 AutoOp op(this, "DrawTextOnPath", &paint); |
| 742 op.addParam("count", AsValue(SkIntToScalar(paint.countText(text, byteLength))) ); | 787 op.addParam("count", AsValue(SkIntToScalar(paint.countText(text, byteLength))) ); |
| 743 op.addParam("path", AsValue(path)); | 788 op.addParam("path", AsValue(path)); |
| 744 if (matrix) | 789 if (matrix) |
| 745 op.addParam("matrix", AsValue(*matrix)); | 790 op.addParam("matrix", AsValue(*matrix)); |
| 746 | 791 |
| 747 INHERITED::onDrawTextOnPath(text, byteLength, path, matrix, paint); | 792 INHERITED::onDrawTextOnPath(text, byteLength, path, matrix, *op.paint()); |
| 748 } | 793 } |
| 749 | 794 |
| 750 void BenchmarkingCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkSc alar y, | 795 void BenchmarkingCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkSc alar y, |
| 751 const SkPaint& paint) { | 796 const SkPaint& paint) { |
| 752 DCHECK(blob); | 797 DCHECK(blob); |
| 753 AutoOp op(this, "DrawTextBlob", &paint); | 798 AutoOp op(this, "DrawTextBlob", &paint); |
| 754 op.addParam("blob", AsValue(*blob)); | 799 op.addParam("blob", AsValue(*blob)); |
| 755 op.addParam("x", AsValue(x)); | 800 op.addParam("x", AsValue(x)); |
| 756 op.addParam("y", AsValue(y)); | 801 op.addParam("y", AsValue(y)); |
| 757 | 802 |
| 758 INHERITED::onDrawTextBlob(blob, x, y, paint); | 803 INHERITED::onDrawTextBlob(blob, x, y, *op.paint()); |
| 759 } | 804 } |
| 760 | 805 |
| 761 } // namespace skia | 806 } // namespace skia |
| OLD | NEW |