| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "cc/resources/tile_manager.h" | 5 #include "cc/resources/tile_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "cc/debug/devtools_instrumentation.h" | 14 #include "cc/debug/devtools_instrumentation.h" |
| 15 #include "cc/debug/traced_value.h" | 15 #include "cc/debug/traced_value.h" |
| 16 #include "cc/resources/image_raster_worker_pool.h" | 16 #include "cc/resources/image_raster_worker_pool.h" |
| 17 #include "cc/resources/pixel_buffer_raster_worker_pool.h" | 17 #include "cc/resources/pixel_buffer_raster_worker_pool.h" |
| 18 #include "cc/resources/tile.h" | 18 #include "cc/resources/tile.h" |
| 19 #include "skia/ext/paint_simplifier.h" |
| 19 #include "third_party/skia/include/core/SkCanvas.h" | 20 #include "third_party/skia/include/core/SkCanvas.h" |
| 20 #include "ui/gfx/rect_conversions.h" | 21 #include "ui/gfx/rect_conversions.h" |
| 21 | 22 |
| 22 namespace cc { | 23 namespace cc { |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 27 class DisableLCDTextFilter : public SkDrawFilter { |
| 28 public: |
| 29 // SkDrawFilter interface. |
| 30 virtual bool filter(SkPaint* paint, SkDrawFilter::Type type) OVERRIDE { |
| 31 if (type != SkDrawFilter::kText_Type) |
| 32 return true; |
| 33 |
| 34 paint->setLCDRenderText(false); |
| 35 return true; |
| 36 } |
| 37 }; |
| 38 |
| 26 // Determine bin based on three categories of tiles: things we need now, | 39 // Determine bin based on three categories of tiles: things we need now, |
| 27 // things we need soon, and eventually. | 40 // things we need soon, and eventually. |
| 28 inline TileManagerBin BinFromTilePriority(const TilePriority& prio) { | 41 inline TileManagerBin BinFromTilePriority(const TilePriority& prio) { |
| 29 // The amount of time for which we want to have prepainting coverage. | 42 // The amount of time for which we want to have prepainting coverage. |
| 30 const float kPrepaintingWindowTimeSeconds = 1.0f; | 43 const float kPrepaintingWindowTimeSeconds = 1.0f; |
| 31 const float kBackflingGuardDistancePixels = 314.0f; | 44 const float kBackflingGuardDistancePixels = 314.0f; |
| 32 | 45 |
| 33 if (prio.time_to_visible_in_seconds == 0) | 46 if (prio.time_to_visible_in_seconds == 0) |
| 34 return NOW_BIN; | 47 return NOW_BIN; |
| 35 | 48 |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 } | 399 } |
| 387 | 400 |
| 388 void TileManager::AddRequiredTileForActivation(Tile* tile) { | 401 void TileManager::AddRequiredTileForActivation(Tile* tile) { |
| 389 DCHECK(std::find(tiles_that_need_to_be_initialized_for_activation_.begin(), | 402 DCHECK(std::find(tiles_that_need_to_be_initialized_for_activation_.begin(), |
| 390 tiles_that_need_to_be_initialized_for_activation_.end(), | 403 tiles_that_need_to_be_initialized_for_activation_.end(), |
| 391 tile) == | 404 tile) == |
| 392 tiles_that_need_to_be_initialized_for_activation_.end()); | 405 tiles_that_need_to_be_initialized_for_activation_.end()); |
| 393 tiles_that_need_to_be_initialized_for_activation_.insert(tile); | 406 tiles_that_need_to_be_initialized_for_activation_.insert(tile); |
| 394 } | 407 } |
| 395 | 408 |
| 409 unsigned TileManager::DetermineRasterFlags(const Tile* tile) const { |
| 410 DCHECK(tile); |
| 411 DCHECK(tile->picture_pile()); |
| 412 |
| 413 unsigned raster_flags = 0; |
| 414 if (tile->picture_pile()->can_use_lcd_text()) |
| 415 raster_flags |= USE_LCD_TEXT; |
| 416 |
| 417 if (tile->managed_state().resolution != LOW_RESOLUTION) |
| 418 raster_flags |= USE_HIGH_QUALITY; |
| 419 return raster_flags; |
| 420 } |
| 421 |
| 396 void TileManager::AssignGpuMemoryToTiles() { | 422 void TileManager::AssignGpuMemoryToTiles() { |
| 397 TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles"); | 423 TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles"); |
| 398 | 424 |
| 399 // Now give memory out to the tiles until we're out, and build | 425 // Now give memory out to the tiles until we're out, and build |
| 400 // the needs-to-be-rasterized queue. | 426 // the needs-to-be-rasterized queue. |
| 401 tiles_that_need_to_be_rasterized_.clear(); | 427 tiles_that_need_to_be_rasterized_.clear(); |
| 402 tiles_that_need_to_be_initialized_for_activation_.clear(); | 428 tiles_that_need_to_be_initialized_for_activation_.clear(); |
| 403 | 429 |
| 404 size_t bytes_releasable = 0; | 430 size_t bytes_releasable = 0; |
| 405 for (TileVector::const_iterator it = tiles_.begin(); | 431 for (TileVector::const_iterator it = tiles_.begin(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 FreeResourcesForTile(tile); | 465 FreeResourcesForTile(tile); |
| 440 continue; | 466 continue; |
| 441 } | 467 } |
| 442 | 468 |
| 443 size_t tile_bytes = 0; | 469 size_t tile_bytes = 0; |
| 444 | 470 |
| 445 // It costs to maintain a resource. | 471 // It costs to maintain a resource. |
| 446 if (tile_version.resource_) | 472 if (tile_version.resource_) |
| 447 tile_bytes += tile->bytes_consumed_if_allocated(); | 473 tile_bytes += tile->bytes_consumed_if_allocated(); |
| 448 | 474 |
| 475 unsigned current_raster_flags = tile_version.raster_flags_; |
| 476 unsigned required_raster_flags = DetermineRasterFlags(tile); |
| 477 |
| 449 // It will cost to allocate a resource. | 478 // It will cost to allocate a resource. |
| 450 // Note that this is separate from the above condition, | 479 if (mts.raster_task.is_null() && |
| 451 // so that it's clear why we're adding memory. | 480 (!tile_version.resource_ || |
| 452 if (!tile_version.resource_ && mts.raster_task.is_null()) | 481 (current_raster_flags != required_raster_flags))) { |
| 453 tile_bytes += tile->bytes_consumed_if_allocated(); | 482 tile_bytes += tile->bytes_consumed_if_allocated(); |
| 483 } |
| 454 | 484 |
| 455 // Tile is OOM. | 485 // Tile is OOM. |
| 456 if (tile_bytes > bytes_left) { | 486 if (tile_bytes > bytes_left) { |
| 457 tile->tile_version().set_rasterize_on_demand(); | 487 tile->tile_version().set_rasterize_on_demand(); |
| 458 if (mts.tree_bin[PENDING_TREE] == NOW_BIN) { | 488 if (mts.tree_bin[PENDING_TREE] == NOW_BIN) { |
| 459 tiles_requiring_memory_but_oomed.push_back(tile); | 489 tiles_requiring_memory_but_oomed.push_back(tile); |
| 460 bytes_oom_in_now_bin_on_pending_tree += tile_bytes; | 490 bytes_oom_in_now_bin_on_pending_tree += tile_bytes; |
| 461 } | 491 } |
| 462 FreeResourcesForTile(tile); | 492 FreeResourcesForTile(tile); |
| 463 higher_priority_tile_oomed = true; | 493 higher_priority_tile_oomed = true; |
| 464 continue; | 494 continue; |
| 465 } | 495 } |
| 466 | 496 |
| 467 tile_version.set_use_resource(); | 497 tile_version.set_use_resource(); |
| 468 bytes_left -= tile_bytes; | 498 bytes_left -= tile_bytes; |
| 469 | 499 |
| 470 // Tile shouldn't be rasterized if we've failed to assign | 500 // Tile shouldn't be rasterized if we've failed to assign |
| 471 // gpu memory to a higher priority tile. This is important for | 501 // gpu memory to a higher priority tile. This is important for |
| 472 // two reasons: | 502 // two reasons: |
| 473 // 1. Tile size should not impact raster priority. | 503 // 1. Tile size should not impact raster priority. |
| 474 // 2. Tile with unreleasable memory could otherwise incorrectly | 504 // 2. Tile with unreleasable memory could otherwise incorrectly |
| 475 // be added as it's not affected by |bytes_allocatable|. | 505 // be added as it's not affected by |bytes_allocatable|. |
| 476 if (higher_priority_tile_oomed) | 506 if (higher_priority_tile_oomed) |
| 477 continue; | 507 continue; |
| 478 | 508 |
| 479 if (!tile_version.resource_) | 509 if (!tile_version.resource_ || |
| 510 (current_raster_flags != required_raster_flags)) { |
| 480 tiles_that_need_to_be_rasterized_.push_back(tile); | 511 tiles_that_need_to_be_rasterized_.push_back(tile); |
| 512 } |
| 481 | 513 |
| 482 if (!tile_version.resource_ && tile->required_for_activation()) | 514 if (!tile_version.resource_ && tile->required_for_activation()) |
| 483 AddRequiredTileForActivation(tile); | 515 AddRequiredTileForActivation(tile); |
| 484 } | 516 } |
| 485 | 517 |
| 486 // In OOM situation, we iterate tiles_, remove the memory for active tree | 518 // In OOM situation, we iterate tiles_, remove the memory for active tree |
| 487 // and not the now bin. And give them to bytes_oom_in_now_bin_on_pending_tree | 519 // and not the now bin. And give them to bytes_oom_in_now_bin_on_pending_tree |
| 488 if (!tiles_requiring_memory_but_oomed.empty()) { | 520 if (!tiles_requiring_memory_but_oomed.empty()) { |
| 489 size_t bytes_freed = 0; | 521 size_t bytes_freed = 0; |
| 490 for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 522 for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 | 586 |
| 555 // Build a new task queue containing all task currently needed. Tasks | 587 // Build a new task queue containing all task currently needed. Tasks |
| 556 // are added in order of priority, highest priority task first. | 588 // are added in order of priority, highest priority task first. |
| 557 for (TileVector::iterator it = tiles_that_need_to_be_rasterized_.begin(); | 589 for (TileVector::iterator it = tiles_that_need_to_be_rasterized_.begin(); |
| 558 it != tiles_that_need_to_be_rasterized_.end(); | 590 it != tiles_that_need_to_be_rasterized_.end(); |
| 559 ++it) { | 591 ++it) { |
| 560 Tile* tile = *it; | 592 Tile* tile = *it; |
| 561 ManagedTileState& mts = tile->managed_state(); | 593 ManagedTileState& mts = tile->managed_state(); |
| 562 | 594 |
| 563 DCHECK(tile->tile_version().requires_resource()); | 595 DCHECK(tile->tile_version().requires_resource()); |
| 564 DCHECK(!tile->tile_version().resource_); | 596 DCHECK(!tile->tile_version().resource_ || |
| 597 (tile->tile_version().raster_flags_ != DetermineRasterFlags(tile))); |
| 565 | 598 |
| 566 // Create raster task for this tile if necessary. | 599 // Create raster task for this tile if necessary. |
| 567 if (mts.raster_task.is_null()) | 600 if (mts.raster_task.is_null()) |
| 568 mts.raster_task = CreateRasterTask(tile); | 601 mts.raster_task = CreateRasterTask(tile); |
| 569 | 602 |
| 570 // Finally append raster task. | 603 // Finally append raster task. |
| 571 tasks.Append(mts.raster_task); | 604 tasks.Append(mts.raster_task); |
| 572 } | 605 } |
| 573 | 606 |
| 574 // Schedule running of |tasks|. This replaces any previously | 607 // Schedule running of |tasks|. This replaces any previously |
| (...skipping 28 matching lines...) Expand all Loading... |
| 603 TileManager::RasterTaskMetadata TileManager::GetRasterTaskMetadata( | 636 TileManager::RasterTaskMetadata TileManager::GetRasterTaskMetadata( |
| 604 const Tile& tile) const { | 637 const Tile& tile) const { |
| 605 RasterTaskMetadata metadata; | 638 RasterTaskMetadata metadata; |
| 606 const ManagedTileState& mts = tile.managed_state(); | 639 const ManagedTileState& mts = tile.managed_state(); |
| 607 metadata.is_tile_in_pending_tree_now_bin = | 640 metadata.is_tile_in_pending_tree_now_bin = |
| 608 mts.tree_bin[PENDING_TREE] == NOW_BIN; | 641 mts.tree_bin[PENDING_TREE] == NOW_BIN; |
| 609 metadata.tile_resolution = mts.resolution; | 642 metadata.tile_resolution = mts.resolution; |
| 610 metadata.layer_id = tile.layer_id(); | 643 metadata.layer_id = tile.layer_id(); |
| 611 metadata.tile_id = &tile; | 644 metadata.tile_id = &tile; |
| 612 metadata.source_frame_number = tile.source_frame_number(); | 645 metadata.source_frame_number = tile.source_frame_number(); |
| 646 metadata.raster_flags = DetermineRasterFlags(&tile); |
| 613 return metadata; | 647 return metadata; |
| 614 } | 648 } |
| 615 | 649 |
| 616 RasterWorkerPool::RasterTask TileManager::CreateRasterTask(Tile* tile) { | 650 RasterWorkerPool::RasterTask TileManager::CreateRasterTask(Tile* tile) { |
| 617 TRACE_EVENT0("cc", "TileManager::CreateRasterTask"); | 651 TRACE_EVENT0("cc", "TileManager::CreateRasterTask"); |
| 618 | 652 |
| 619 scoped_ptr<ResourcePool::Resource> resource = | 653 scoped_ptr<ResourcePool::Resource> resource = |
| 620 resource_pool_->AcquireResource( | 654 resource_pool_->AcquireResource( |
| 621 tile->tile_size_.size(), | 655 tile->tile_size_.size(), |
| 622 tile->tile_version().resource_format_); | 656 tile->tile_version().resource_format_); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 648 continue; | 682 continue; |
| 649 } | 683 } |
| 650 | 684 |
| 651 // Create and append new image decode task for this pixel ref. | 685 // Create and append new image decode task for this pixel ref. |
| 652 RasterWorkerPool::Task decode_task = CreateImageDecodeTask( | 686 RasterWorkerPool::Task decode_task = CreateImageDecodeTask( |
| 653 tile, pixel_ref); | 687 tile, pixel_ref); |
| 654 decode_tasks.Insert(decode_task); | 688 decode_tasks.Insert(decode_task); |
| 655 pending_decode_tasks_[id] = decode_task; | 689 pending_decode_tasks_[id] = decode_task; |
| 656 } | 690 } |
| 657 | 691 |
| 692 RasterTaskMetadata metadata = GetRasterTaskMetadata(*tile); |
| 658 return RasterWorkerPool::RasterTask( | 693 return RasterWorkerPool::RasterTask( |
| 659 tile->picture_pile(), | 694 tile->picture_pile(), |
| 660 const_resource, | 695 const_resource, |
| 661 base::Bind(&TileManager::RunAnalyzeAndRasterTask, | 696 base::Bind(&TileManager::RunAnalyzeAndRasterTask, |
| 662 base::Bind(&TileManager::RunAnalyzeTask, | 697 base::Bind(&TileManager::RunAnalyzeTask, |
| 663 analysis, | 698 analysis, |
| 664 tile->content_rect(), | 699 tile->content_rect(), |
| 665 tile->contents_scale(), | 700 tile->contents_scale(), |
| 666 use_color_estimator_, | 701 use_color_estimator_, |
| 667 GetRasterTaskMetadata(*tile), | 702 metadata, |
| 668 rendering_stats_instrumentation_), | 703 rendering_stats_instrumentation_), |
| 669 base::Bind(&TileManager::RunRasterTask, | 704 base::Bind(&TileManager::RunRasterTask, |
| 670 analysis, | 705 analysis, |
| 671 tile->content_rect(), | 706 tile->content_rect(), |
| 672 tile->contents_scale(), | 707 tile->contents_scale(), |
| 673 GetRasterTaskMetadata(*tile), | 708 metadata, |
| 674 rendering_stats_instrumentation_)), | 709 rendering_stats_instrumentation_)), |
| 675 base::Bind(&TileManager::OnRasterTaskCompleted, | 710 base::Bind(&TileManager::OnRasterTaskCompleted, |
| 676 base::Unretained(this), | 711 base::Unretained(this), |
| 677 make_scoped_refptr(tile), | 712 make_scoped_refptr(tile), |
| 678 base::Passed(&resource), | 713 base::Passed(&resource), |
| 679 base::Owned(analysis)), | 714 base::Owned(analysis), |
| 715 metadata.raster_flags), |
| 680 &decode_tasks); | 716 &decode_tasks); |
| 681 } | 717 } |
| 682 | 718 |
| 683 void TileManager::OnRasterTaskCompleted( | 719 void TileManager::OnRasterTaskCompleted( |
| 684 scoped_refptr<Tile> tile, | 720 scoped_refptr<Tile> tile, |
| 685 scoped_ptr<ResourcePool::Resource> resource, | 721 scoped_ptr<ResourcePool::Resource> resource, |
| 686 PicturePileImpl::Analysis* analysis, | 722 PicturePileImpl::Analysis* analysis, |
| 723 unsigned raster_flags, |
| 687 bool was_canceled) { | 724 bool was_canceled) { |
| 688 TRACE_EVENT1("cc", "TileManager::OnRasterTaskCompleted", | 725 TRACE_EVENT1("cc", "TileManager::OnRasterTaskCompleted", |
| 689 "was_canceled", was_canceled); | 726 "was_canceled", was_canceled); |
| 690 | 727 |
| 691 ManagedTileState& mts = tile->managed_state(); | 728 ManagedTileState& mts = tile->managed_state(); |
| 692 DCHECK(!mts.raster_task.is_null()); | 729 DCHECK(!mts.raster_task.is_null()); |
| 693 mts.raster_task.Reset(); | 730 mts.raster_task.Reset(); |
| 694 | 731 |
| 695 if (was_canceled) { | 732 if (was_canceled) { |
| 696 resource_pool_->ReleaseResource(resource.Pass()); | 733 resource_pool_->ReleaseResource(resource.Pass()); |
| 697 return; | 734 return; |
| 698 } | 735 } |
| 699 | 736 |
| 737 if (tile->tile_version().resource_) { |
| 738 resource_pool_->ReleaseResource(tile->tile_version().resource_.Pass()); |
| 739 DCHECK(tile->tile_version().raster_flags_ != raster_flags); |
| 740 tile->tile_version().raster_flags_ = 0; |
| 741 } |
| 742 |
| 700 mts.picture_pile_analysis = *analysis; | 743 mts.picture_pile_analysis = *analysis; |
| 701 mts.picture_pile_analyzed = true; | 744 mts.picture_pile_analyzed = true; |
| 702 | 745 |
| 703 if (analysis->is_solid_color) { | 746 if (analysis->is_solid_color) { |
| 704 tile->tile_version().set_solid_color(analysis->solid_color); | 747 tile->tile_version().set_solid_color(analysis->solid_color); |
| 705 resource_pool_->ReleaseResource(resource.Pass()); | 748 resource_pool_->ReleaseResource(resource.Pass()); |
| 706 } else { | 749 } else { |
| 707 tile->tile_version().resource_ = resource.Pass(); | 750 tile->tile_version().resource_ = resource.Pass(); |
| 751 tile->tile_version().raster_flags_ = raster_flags; |
| 708 } | 752 } |
| 709 | 753 |
| 710 DidFinishTileInitialization(tile.get()); | 754 DidFinishTileInitialization(tile.get()); |
| 711 } | 755 } |
| 712 | 756 |
| 713 void TileManager::DidFinishTileInitialization(Tile* tile) { | 757 void TileManager::DidFinishTileInitialization(Tile* tile) { |
| 714 if (tile->priority(ACTIVE_TREE).distance_to_visible_in_pixels == 0) | 758 if (tile->priority(ACTIVE_TREE).distance_to_visible_in_pixels == 0) |
| 715 did_initialize_visible_tile_ = true; | 759 did_initialize_visible_tile_ = true; |
| 716 if (tile->required_for_activation()) { | 760 if (tile->required_for_activation()) { |
| 717 // It's possible that a tile required for activation is not in this list | 761 // It's possible that a tile required for activation is not in this list |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 analysis->is_solid_color &= use_color_estimator; | 827 analysis->is_solid_color &= use_color_estimator; |
| 784 } | 828 } |
| 785 | 829 |
| 786 scoped_ptr<base::Value> TileManager::RasterTaskMetadata::AsValue() const { | 830 scoped_ptr<base::Value> TileManager::RasterTaskMetadata::AsValue() const { |
| 787 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); | 831 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); |
| 788 res->Set("tile_id", TracedValue::CreateIDRef(tile_id).release()); | 832 res->Set("tile_id", TracedValue::CreateIDRef(tile_id).release()); |
| 789 res->SetBoolean("is_tile_in_pending_tree_now_bin", | 833 res->SetBoolean("is_tile_in_pending_tree_now_bin", |
| 790 is_tile_in_pending_tree_now_bin); | 834 is_tile_in_pending_tree_now_bin); |
| 791 res->Set("resolution", TileResolutionAsValue(tile_resolution).release()); | 835 res->Set("resolution", TileResolutionAsValue(tile_resolution).release()); |
| 792 res->SetInteger("source_frame_number", source_frame_number); | 836 res->SetInteger("source_frame_number", source_frame_number); |
| 837 res->SetInteger("raster_flags", raster_flags); |
| 793 return res.PassAs<base::Value>(); | 838 return res.PassAs<base::Value>(); |
| 794 } | 839 } |
| 795 | 840 |
| 796 // static | 841 // static |
| 797 bool TileManager::RunRasterTask( | 842 bool TileManager::RunRasterTask( |
| 798 PicturePileImpl::Analysis* analysis, | 843 PicturePileImpl::Analysis* analysis, |
| 799 gfx::Rect rect, | 844 gfx::Rect rect, |
| 800 float contents_scale, | 845 float contents_scale, |
| 801 const RasterTaskMetadata& metadata, | 846 const RasterTaskMetadata& metadata, |
| 802 RenderingStatsInstrumentation* stats_instrumentation, | 847 RenderingStatsInstrumentation* stats_instrumentation, |
| 803 SkDevice* device, | 848 SkDevice* device, |
| 804 PicturePileImpl* picture_pile) { | 849 PicturePileImpl* picture_pile) { |
| 805 TRACE_EVENT1( | 850 TRACE_EVENT1( |
| 806 "cc", "TileManager::RunRasterTask", | 851 "cc", "TileManager::RunRasterTask", |
| 807 "metadata", TracedValue::FromValue(metadata.AsValue().release())); | 852 "metadata", TracedValue::FromValue(metadata.AsValue().release())); |
| 808 devtools_instrumentation::ScopedLayerTask raster_task( | 853 devtools_instrumentation::ScopedLayerTask raster_task( |
| 809 devtools_instrumentation::kRasterTask, metadata.layer_id); | 854 devtools_instrumentation::kRasterTask, metadata.layer_id); |
| 810 | 855 |
| 811 DCHECK(picture_pile); | 856 DCHECK(picture_pile); |
| 812 DCHECK(analysis); | 857 DCHECK(analysis); |
| 813 DCHECK(device); | 858 DCHECK(device); |
| 814 | 859 |
| 815 if (analysis->is_solid_color) | 860 if (analysis->is_solid_color) |
| 816 return false; | 861 return false; |
| 817 | 862 |
| 818 SkCanvas canvas(device); | 863 SkCanvas canvas(device); |
| 819 | 864 |
| 865 skia::RefPtr<SkDrawFilter> draw_filter; |
| 866 if ((metadata.raster_flags & USE_HIGH_QUALITY) == 0) |
| 867 draw_filter = skia::AdoptRef(new skia::PaintSimplifier); |
| 868 else if ((metadata.raster_flags & USE_LCD_TEXT) == 0) |
| 869 draw_filter = skia::AdoptRef(new DisableLCDTextFilter); |
| 870 |
| 871 canvas.setDrawFilter(draw_filter.get()); |
| 872 |
| 820 if (stats_instrumentation->record_rendering_stats()) { | 873 if (stats_instrumentation->record_rendering_stats()) { |
| 821 PicturePileImpl::RasterStats raster_stats; | 874 PicturePileImpl::RasterStats raster_stats; |
| 822 picture_pile->RasterToBitmap(&canvas, rect, contents_scale, &raster_stats); | 875 picture_pile->RasterToBitmap(&canvas, rect, contents_scale, &raster_stats); |
| 823 stats_instrumentation->AddRaster( | 876 stats_instrumentation->AddRaster( |
| 824 raster_stats.total_rasterize_time, | 877 raster_stats.total_rasterize_time, |
| 825 raster_stats.best_rasterize_time, | 878 raster_stats.best_rasterize_time, |
| 826 raster_stats.total_pixels_rasterized, | 879 raster_stats.total_pixels_rasterized, |
| 827 metadata.is_tile_in_pending_tree_now_bin); | 880 metadata.is_tile_in_pending_tree_now_bin); |
| 828 | 881 |
| 829 HISTOGRAM_CUSTOM_COUNTS( | 882 HISTOGRAM_CUSTOM_COUNTS( |
| 830 "Renderer4.PictureRasterTimeUS", | 883 "Renderer4.PictureRasterTimeUS", |
| 831 raster_stats.total_rasterize_time.InMicroseconds(), | 884 raster_stats.total_rasterize_time.InMicroseconds(), |
| 832 0, | 885 0, |
| 833 100000, | 886 100000, |
| 834 100); | 887 100); |
| 835 } else { | 888 } else { |
| 836 picture_pile->RasterToBitmap(&canvas, rect, contents_scale, NULL); | 889 picture_pile->RasterToBitmap(&canvas, rect, contents_scale, NULL); |
| 837 } | 890 } |
| 838 | 891 |
| 839 return true; | 892 return true; |
| 840 } | 893 } |
| 841 | 894 |
| 842 } // namespace cc | 895 } // namespace cc |
| OLD | NEW |