Chromium Code Reviews| 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 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 650 | 650 |
| 651 ResourceProvider::ResourceId resource_id = resource->id(); | 651 ResourceProvider::ResourceId resource_id = resource->id(); |
| 652 | 652 |
| 653 if (use_cheapness_estimator_ && | 653 if (use_cheapness_estimator_ && |
| 654 tile->picture_pile()->IsCheapInRect(tile->content_rect_, | 654 tile->picture_pile()->IsCheapInRect(tile->content_rect_, |
| 655 tile->contents_scale())) { | 655 tile->contents_scale())) { |
| 656 RunRasterTask(resource_pool_->resource_provider()->mapPixelBuffer( | 656 RunRasterTask(resource_pool_->resource_provider()->mapPixelBuffer( |
| 657 resource_id), | 657 resource_id), |
| 658 tile->content_rect_, | 658 tile->content_rect_, |
| 659 tile->contents_scale(), | 659 tile->contents_scale(), |
| 660 use_cheapness_estimator_, | |
| 660 tile->picture_pile(), | 661 tile->picture_pile(), |
| 661 &rendering_stats_); | 662 &rendering_stats_); |
| 662 TileManager::OnRasterTaskCompleted(tile, resource.Pass(), | 663 TileManager::OnRasterTaskCompleted(tile, resource.Pass(), |
| 663 manage_tiles_call_count_); | 664 manage_tiles_call_count_); |
| 664 return; | 665 return; |
| 665 } | 666 } |
| 666 | 667 |
| 667 raster_worker_pool_->PostRasterTaskAndReply( | 668 raster_worker_pool_->PostRasterTaskAndReply( |
| 668 tile->picture_pile(), | 669 tile->picture_pile(), |
| 669 base::Bind(&TileManager::RunRasterTask, | 670 base::Bind(&TileManager::RunRasterTask, |
| 670 resource_pool_->resource_provider()->mapPixelBuffer( | 671 resource_pool_->resource_provider()->mapPixelBuffer( |
| 671 resource_id), | 672 resource_id), |
| 672 tile->content_rect_, | 673 tile->content_rect_, |
| 673 tile->contents_scale()), | 674 tile->contents_scale(), |
| 675 use_cheapness_estimator_), | |
| 674 base::Bind(&TileManager::OnRasterTaskCompletedByWorker, | 676 base::Bind(&TileManager::OnRasterTaskCompletedByWorker, |
| 675 base::Unretained(this), | 677 base::Unretained(this), |
| 676 tile, | 678 tile, |
| 677 base::Passed(&resource), | 679 base::Passed(&resource), |
| 678 manage_tiles_call_count_)); | 680 manage_tiles_call_count_)); |
| 679 } | 681 } |
| 680 | 682 |
| 681 void TileManager::OnRasterTaskCompleted( | 683 void TileManager::OnRasterTaskCompleted( |
| 682 scoped_refptr<Tile> tile, | 684 scoped_refptr<Tile> tile, |
| 683 scoped_ptr<ResourcePool::Resource> resource, | 685 scoped_ptr<ResourcePool::Resource> resource, |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 769 // Increment count for new bin. | 771 // Increment count for new bin. |
| 770 ++raster_state_count_[mts.raster_state][tree][bin]; | 772 ++raster_state_count_[mts.raster_state][tree][bin]; |
| 771 | 773 |
| 772 mts.tree_bin[tree] = bin; | 774 mts.tree_bin[tree] = bin; |
| 773 } | 775 } |
| 774 | 776 |
| 775 // static | 777 // static |
| 776 void TileManager::RunRasterTask(uint8* buffer, | 778 void TileManager::RunRasterTask(uint8* buffer, |
| 777 const gfx::Rect& rect, | 779 const gfx::Rect& rect, |
| 778 float contents_scale, | 780 float contents_scale, |
| 781 bool use_cheapness_estimator, | |
| 779 PicturePileImpl* picture_pile, | 782 PicturePileImpl* picture_pile, |
| 780 RenderingStats* stats) { | 783 RenderingStats* stats) { |
| 781 TRACE_EVENT0("cc", "TileManager::RunRasterTask"); | 784 TRACE_EVENT0("cc", "TileManager::RunRasterTask"); |
| 782 DCHECK(picture_pile); | 785 DCHECK(picture_pile); |
| 783 DCHECK(buffer); | 786 DCHECK(buffer); |
| 784 SkBitmap bitmap; | 787 SkBitmap bitmap; |
| 785 bitmap.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height()); | 788 bitmap.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height()); |
| 786 bitmap.setPixels(buffer); | 789 bitmap.setPixels(buffer); |
| 787 SkDevice device(bitmap); | 790 SkDevice device(bitmap); |
| 788 SkCanvas canvas(&device); | 791 SkCanvas canvas(&device); |
| 789 | 792 |
| 790 base::TimeTicks begin_time; | 793 base::TimeTicks begin_time; |
| 791 if (stats) | 794 if (stats) |
| 792 begin_time = base::TimeTicks::Now(); | 795 begin_time = base::TimeTicks::Now(); |
| 793 | 796 |
| 794 picture_pile->Raster(&canvas, rect, contents_scale, stats); | 797 picture_pile->Raster(&canvas, rect, contents_scale, stats); |
| 795 | 798 |
| 796 if (stats) { | 799 if (stats) { |
| 797 base::TimeTicks end_time = base::TimeTicks::Now(); | 800 base::TimeTicks end_time = base::TimeTicks::Now(); |
| 798 base::TimeDelta duration = end_time - begin_time; | 801 base::TimeDelta duration = end_time - begin_time; |
| 799 stats->totalRasterizeTime += duration; | 802 stats->totalRasterizeTime += duration; |
| 800 UMA_HISTOGRAM_CUSTOM_COUNTS( | 803 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 801 "Renderer4.PictureRasterTimeMS", | 804 "Renderer4.PictureRasterTimeMS", |
| 802 duration.InMilliseconds(), | 805 duration.InMilliseconds(), |
| 803 0, 10, 10 | 806 0, 10, 10 |
| 804 ); | 807 ); |
| 808 | |
| 809 if (use_cheapness_estimator) | |
| 810 RecordCheapnessPredictorCorrectness( | |
| 811 picture_pile->IsCheapInRect (rect, contents_scale), | |
|
nduca
2013/02/05 00:22:26
might pull out the calculation into local vars so
| |
| 812 duration.InMillisecondsF() <= 1.0f | |
| 813 ); | |
| 805 } | 814 } |
| 806 } | 815 } |
| 807 | 816 |
| 808 // static | 817 // static |
| 818 void TileManager::RecordCheapnessPredictorCorrectness( | |
|
nduca
2013/02/05 00:22:26
RecordCheapnessPredictorResults?
| |
| 819 bool is_predicted_cheap, | |
| 820 bool is_actually_cheap) { | |
| 821 | |
| 822 if (is_predicted_cheap) | |
| 823 UMA_HISTOGRAM_BOOLEAN( | |
|
nduca
2013/02/05 00:22:26
i think these two should actually e
if (is_predic
| |
| 824 "Renderer4.CheapPredictorIsCheapAccuracy", | |
| 825 is_actually_cheap | |
| 826 ); | |
| 827 else | |
| 828 UMA_HISTOGRAM_BOOLEAN( | |
| 829 "Renderer4.CheapPredictorIsNotCheapAccuracy", | |
| 830 !is_actually_cheap | |
| 831 ); | |
| 832 | |
|
nduca
2013/02/05 00:22:26
are histograms the right thing to track here? The
| |
| 833 bool is_correct_estimate = false; | |
| 834 if ((is_predicted_cheap && is_actually_cheap) || | |
|
nduca
2013/02/05 00:22:26
isn't this just
is_predicted_cheap == is_actuall
| |
| 835 (!is_predicted_cheap && !is_actually_cheap)) | |
| 836 is_correct_estimate = true; | |
| 837 | |
| 838 UMA_HISTOGRAM_BOOLEAN( | |
| 839 "Renderer4.CheapPredictorOverallAccuracy", | |
|
nduca
2013/02/05 00:22:26
same comment about histograms being the right tool
| |
| 840 is_correct_estimate | |
| 841 ); | |
| 842 } | |
| 843 | |
| 844 // static | |
| 809 void TileManager::RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, | 845 void TileManager::RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, |
| 810 RenderingStats* stats) { | 846 RenderingStats* stats) { |
| 811 TRACE_EVENT0("cc", "TileManager::RunImageDecodeTask"); | 847 TRACE_EVENT0("cc", "TileManager::RunImageDecodeTask"); |
| 812 base::TimeTicks decode_begin_time; | 848 base::TimeTicks decode_begin_time; |
| 813 if (stats) | 849 if (stats) |
| 814 decode_begin_time = base::TimeTicks::Now(); | 850 decode_begin_time = base::TimeTicks::Now(); |
| 815 pixel_ref->Decode(); | 851 pixel_ref->Decode(); |
| 816 if (stats) { | 852 if (stats) { |
| 817 stats->totalDeferredImageDecodeCount++; | 853 stats->totalDeferredImageDecodeCount++; |
| 818 stats->totalDeferredImageDecodeTime += | 854 stats->totalDeferredImageDecodeTime += |
| 819 base::TimeTicks::Now() - decode_begin_time; | 855 base::TimeTicks::Now() - decode_begin_time; |
| 820 } | 856 } |
| 821 } | 857 } |
| 822 | 858 |
| 823 } // namespace cc | 859 } // namespace cc |
| OLD | NEW |