| 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/tile_manager.h" | 5 #include "cc/tile_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 | 689 |
| 690 DidTileRasterStateChange(tile, RASTER_STATE); | 690 DidTileRasterStateChange(tile, RASTER_STATE); |
| 691 return resource.Pass(); | 691 return resource.Pass(); |
| 692 } | 692 } |
| 693 | 693 |
| 694 void TileManager::DispatchOneRasterTask(scoped_refptr<Tile> tile) { | 694 void TileManager::DispatchOneRasterTask(scoped_refptr<Tile> tile) { |
| 695 TRACE_EVENT0("cc", "TileManager::DispatchOneRasterTask"); | 695 TRACE_EVENT0("cc", "TileManager::DispatchOneRasterTask"); |
| 696 scoped_ptr<ResourcePool::Resource> resource = PrepareTileForRaster(tile); | 696 scoped_ptr<ResourcePool::Resource> resource = PrepareTileForRaster(tile); |
| 697 ResourceProvider::ResourceId resource_id = resource->id(); | 697 ResourceProvider::ResourceId resource_id = resource->id(); |
| 698 | 698 |
| 699 bool is_pending_now_bin = |
| 700 tile->managed_state().tree_bin[PENDING_TREE] == NOW_BIN; |
| 701 |
| 699 raster_worker_pool_->PostRasterTaskAndReply( | 702 raster_worker_pool_->PostRasterTaskAndReply( |
| 700 tile->picture_pile(), | 703 tile->picture_pile(), |
| 701 base::Bind(&TileManager::PerformRaster, | 704 base::Bind(&TileManager::PerformRaster, |
| 702 resource_pool_->resource_provider()->mapPixelBuffer( | 705 resource_pool_->resource_provider()->mapPixelBuffer( |
| 703 resource_id), | 706 resource_id), |
| 704 tile->content_rect_, | 707 tile->content_rect_, |
| 705 tile->contents_scale(), | 708 tile->contents_scale(), |
| 706 use_cheapness_estimator_), | 709 use_cheapness_estimator_, |
| 710 is_pending_now_bin), |
| 707 base::Bind(&TileManager::OnRasterTaskCompleted, | 711 base::Bind(&TileManager::OnRasterTaskCompleted, |
| 708 base::Unretained(this), | 712 base::Unretained(this), |
| 709 tile, | 713 tile, |
| 710 base::Passed(&resource), | 714 base::Passed(&resource), |
| 711 manage_tiles_call_count_)); | 715 manage_tiles_call_count_)); |
| 712 } | 716 } |
| 713 | 717 |
| 714 void TileManager::PerformOneRaster(Tile* tile) { | 718 void TileManager::PerformOneRaster(Tile* tile) { |
| 715 scoped_ptr<ResourcePool::Resource> resource = PrepareTileForRaster(tile); | 719 scoped_ptr<ResourcePool::Resource> resource = PrepareTileForRaster(tile); |
| 716 ResourceProvider::ResourceId resource_id = resource->id(); | 720 ResourceProvider::ResourceId resource_id = resource->id(); |
| 717 | 721 |
| 722 bool is_pending_now_bin = |
| 723 tile->managed_state().tree_bin[PENDING_TREE] == NOW_BIN; |
| 724 |
| 718 PerformRaster(resource_pool_->resource_provider()->mapPixelBuffer( | 725 PerformRaster(resource_pool_->resource_provider()->mapPixelBuffer( |
| 719 resource_id), | 726 resource_id), |
| 720 tile->content_rect_, | 727 tile->content_rect_, |
| 721 tile->contents_scale(), | 728 tile->contents_scale(), |
| 722 use_cheapness_estimator_, | 729 use_cheapness_estimator_, |
| 730 is_pending_now_bin, |
| 723 tile->picture_pile(), | 731 tile->picture_pile(), |
| 724 &rendering_stats_); | 732 &rendering_stats_); |
| 725 | 733 |
| 726 OnRasterCompleted(tile, resource.Pass(), manage_tiles_call_count_); | 734 OnRasterCompleted(tile, resource.Pass(), manage_tiles_call_count_); |
| 727 } | 735 } |
| 728 | 736 |
| 729 void TileManager::OnRasterCompleted( | 737 void TileManager::OnRasterCompleted( |
| 730 scoped_refptr<Tile> tile, | 738 scoped_refptr<Tile> tile, |
| 731 scoped_ptr<ResourcePool::Resource> resource, | 739 scoped_ptr<ResourcePool::Resource> resource, |
| 732 int manage_tiles_call_count_when_dispatched) { | 740 int manage_tiles_call_count_when_dispatched) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 ++raster_state_count_[mts.raster_state][tree][bin]; | 826 ++raster_state_count_[mts.raster_state][tree][bin]; |
| 819 | 827 |
| 820 mts.tree_bin[tree] = bin; | 828 mts.tree_bin[tree] = bin; |
| 821 } | 829 } |
| 822 | 830 |
| 823 // static | 831 // static |
| 824 void TileManager::PerformRaster(uint8* buffer, | 832 void TileManager::PerformRaster(uint8* buffer, |
| 825 const gfx::Rect& rect, | 833 const gfx::Rect& rect, |
| 826 float contents_scale, | 834 float contents_scale, |
| 827 bool use_cheapness_estimator, | 835 bool use_cheapness_estimator, |
| 836 bool is_pending_now_bin, |
| 828 PicturePileImpl* picture_pile, | 837 PicturePileImpl* picture_pile, |
| 829 RenderingStats* stats) { | 838 RenderingStats* stats) { |
| 830 TRACE_EVENT0("cc", "TileManager::PerformRaster"); | 839 TRACE_EVENT0("cc", "TileManager::PerformRaster"); |
| 831 DCHECK(picture_pile); | 840 DCHECK(picture_pile); |
| 832 DCHECK(buffer); | 841 DCHECK(buffer); |
| 833 SkBitmap bitmap; | 842 SkBitmap bitmap; |
| 834 bitmap.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height()); | 843 bitmap.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height()); |
| 835 bitmap.setPixels(buffer); | 844 bitmap.setPixels(buffer); |
| 836 SkDevice device(bitmap); | 845 SkDevice device(bitmap); |
| 837 SkCanvas canvas(&device); | 846 SkCanvas canvas(&device); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 854 duration.InMilliseconds(), | 863 duration.InMilliseconds(), |
| 855 0, | 864 0, |
| 856 10, | 865 10, |
| 857 10); | 866 10); |
| 858 | 867 |
| 859 if (use_cheapness_estimator) { | 868 if (use_cheapness_estimator) { |
| 860 bool is_predicted_cheap = picture_pile->IsCheapInRect (rect, contents_scal
e); | 869 bool is_predicted_cheap = picture_pile->IsCheapInRect (rect, contents_scal
e); |
| 861 bool is_actually_cheap = duration.InMillisecondsF() <= 1.0f; | 870 bool is_actually_cheap = duration.InMillisecondsF() <= 1.0f; |
| 862 RecordCheapnessPredictorResults(is_predicted_cheap, is_actually_cheap); | 871 RecordCheapnessPredictorResults(is_predicted_cheap, is_actually_cheap); |
| 863 } | 872 } |
| 873 |
| 874 if (is_pending_now_bin) |
| 875 stats->totalRasterizeTimeForNowBinsOnPendingTree += duration; |
| 864 } | 876 } |
| 865 } | 877 } |
| 866 | 878 |
| 867 // static | 879 // static |
| 868 void TileManager::RecordCheapnessPredictorResults(bool is_predicted_cheap, | 880 void TileManager::RecordCheapnessPredictorResults(bool is_predicted_cheap, |
| 869 bool is_actually_cheap) { | 881 bool is_actually_cheap) { |
| 870 if (is_predicted_cheap && !is_actually_cheap) | 882 if (is_predicted_cheap && !is_actually_cheap) |
| 871 UMA_HISTOGRAM_BOOLEAN("Renderer4.CheapPredictorBadlyWrong", true); | 883 UMA_HISTOGRAM_BOOLEAN("Renderer4.CheapPredictorBadlyWrong", true); |
| 872 else if (!is_predicted_cheap && is_actually_cheap) | 884 else if (!is_predicted_cheap && is_actually_cheap) |
| 873 UMA_HISTOGRAM_BOOLEAN("Renderer4.CheapPredictorSafelyWrong", true); | 885 UMA_HISTOGRAM_BOOLEAN("Renderer4.CheapPredictorSafelyWrong", true); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 885 decode_begin_time = base::TimeTicks::Now(); | 897 decode_begin_time = base::TimeTicks::Now(); |
| 886 pixel_ref->Decode(); | 898 pixel_ref->Decode(); |
| 887 if (stats) { | 899 if (stats) { |
| 888 stats->totalDeferredImageDecodeCount++; | 900 stats->totalDeferredImageDecodeCount++; |
| 889 stats->totalDeferredImageDecodeTime += | 901 stats->totalDeferredImageDecodeTime += |
| 890 base::TimeTicks::Now() - decode_begin_time; | 902 base::TimeTicks::Now() - decode_begin_time; |
| 891 } | 903 } |
| 892 } | 904 } |
| 893 | 905 |
| 894 } // namespace cc | 906 } // namespace cc |
| OLD | NEW |