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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 state->Set("resolution", TileResolutionAsValue(resolution).release()); | 169 state->Set("resolution", TileResolutionAsValue(resolution).release()); |
170 state->Set("time_to_needed_in_seconds", MathUtil::asValueSafely(time_to_needed _in_seconds).release()); | 170 state->Set("time_to_needed_in_seconds", MathUtil::asValueSafely(time_to_needed _in_seconds).release()); |
171 state->Set("distance_to_visible_in_pixels", MathUtil::asValueSafely(distance_t o_visible_in_pixels).release()); | 171 state->Set("distance_to_visible_in_pixels", MathUtil::asValueSafely(distance_t o_visible_in_pixels).release()); |
172 return state.PassAs<base::Value>(); | 172 return state.PassAs<base::Value>(); |
173 } | 173 } |
174 | 174 |
175 TileManager::TileManager( | 175 TileManager::TileManager( |
176 TileManagerClient* client, | 176 TileManagerClient* client, |
177 ResourceProvider* resource_provider, | 177 ResourceProvider* resource_provider, |
178 size_t num_raster_threads, | 178 size_t num_raster_threads, |
179 bool use_cheapness_estimator) | 179 bool use_cheapness_estimator, |
180 bool solid_color_benchmarking) | |
180 : client_(client), | 181 : client_(client), |
181 resource_pool_(ResourcePool::Create(resource_provider)), | 182 resource_pool_(ResourcePool::Create(resource_provider)), |
182 raster_worker_pool_(RasterWorkerPool::Create(this, num_raster_threads)), | 183 raster_worker_pool_(RasterWorkerPool::Create(this, num_raster_threads)), |
183 manage_tiles_pending_(false), | 184 manage_tiles_pending_(false), |
184 manage_tiles_call_count_(0), | 185 manage_tiles_call_count_(0), |
185 bytes_pending_upload_(0), | 186 bytes_pending_upload_(0), |
186 has_performed_uploads_since_last_flush_(false), | 187 has_performed_uploads_since_last_flush_(false), |
187 ever_exceeded_memory_budget_(false), | 188 ever_exceeded_memory_budget_(false), |
188 record_rendering_stats_(false), | 189 record_rendering_stats_(false), |
189 use_cheapness_estimator_(use_cheapness_estimator), | 190 use_cheapness_estimator_(use_cheapness_estimator), |
190 allow_cheap_tasks_(true), | 191 allow_cheap_tasks_(true), |
191 did_schedule_cheap_tasks_(false) { | 192 did_schedule_cheap_tasks_(false), |
193 solid_color_benchmarking_(solid_color_benchmarking) { | |
192 for (int i = 0; i < NUM_STATES; ++i) { | 194 for (int i = 0; i < NUM_STATES; ++i) { |
193 for (int j = 0; j < NUM_TREES; ++j) { | 195 for (int j = 0; j < NUM_TREES; ++j) { |
194 for (int k = 0; k < NUM_BINS; ++k) | 196 for (int k = 0; k < NUM_BINS; ++k) |
195 raster_state_count_[i][j][k] = 0; | 197 raster_state_count_[i][j][k] = 0; |
196 } | 198 } |
197 } | 199 } |
198 } | 200 } |
199 | 201 |
200 TileManager::~TileManager() { | 202 TileManager::~TileManager() { |
201 // Reset global state and manage. This should cause | 203 // Reset global state and manage. This should cause |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
810 base::Passed(&resource), | 812 base::Passed(&resource), |
811 manage_tiles_call_count_)); | 813 manage_tiles_call_count_)); |
812 did_schedule_cheap_tasks_ |= is_cheap; | 814 did_schedule_cheap_tasks_ |= is_cheap; |
813 } | 815 } |
814 | 816 |
815 TileManager::RasterTaskMetadata TileManager::GetRasterTaskMetadata( | 817 TileManager::RasterTaskMetadata TileManager::GetRasterTaskMetadata( |
816 const Tile& tile) const { | 818 const Tile& tile) const { |
817 RasterTaskMetadata metadata; | 819 RasterTaskMetadata metadata; |
818 const ManagedTileState& mts = tile.managed_state(); | 820 const ManagedTileState& mts = tile.managed_state(); |
819 metadata.use_cheapness_estimator = use_cheapness_estimator_; | 821 metadata.use_cheapness_estimator = use_cheapness_estimator_; |
822 metadata.solid_color_benchmarking = solid_color_benchmarking_; | |
820 metadata.is_tile_in_pending_tree_now_bin = | 823 metadata.is_tile_in_pending_tree_now_bin = |
821 mts.tree_bin[PENDING_TREE] == NOW_BIN; | 824 mts.tree_bin[PENDING_TREE] == NOW_BIN; |
822 metadata.tile_resolution = mts.resolution; | 825 metadata.tile_resolution = mts.resolution; |
823 return metadata; | 826 return metadata; |
824 } | 827 } |
825 | 828 |
826 void TileManager::OnRasterTaskCompleted( | 829 void TileManager::OnRasterTaskCompleted( |
827 scoped_refptr<Tile> tile, | 830 scoped_refptr<Tile> tile, |
828 scoped_ptr<ResourcePool::Resource> resource, | 831 scoped_ptr<ResourcePool::Resource> resource, |
829 int manage_tiles_call_count_when_dispatched) { | 832 int manage_tiles_call_count_when_dispatched) { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
932 SkDevice device(bitmap); | 935 SkDevice device(bitmap); |
933 SkCanvas canvas(&device); | 936 SkCanvas canvas(&device); |
934 | 937 |
935 base::TimeTicks begin_time; | 938 base::TimeTicks begin_time; |
936 if (stats) | 939 if (stats) |
937 begin_time = base::TimeTicks::HighResNow(); | 940 begin_time = base::TimeTicks::HighResNow(); |
938 | 941 |
939 int64 total_pixels_rasterized = 0; | 942 int64 total_pixels_rasterized = 0; |
940 picture_pile->Raster(&canvas, rect, contents_scale, | 943 picture_pile->Raster(&canvas, rect, contents_scale, |
941 &total_pixels_rasterized); | 944 &total_pixels_rasterized); |
942 | |
943 if (stats) { | 945 if (stats) { |
944 stats->totalPixelsRasterized += total_pixels_rasterized; | 946 stats->totalPixelsRasterized += total_pixels_rasterized; |
945 | 947 |
946 base::TimeTicks end_time = base::TimeTicks::HighResNow(); | 948 base::TimeTicks end_time = base::TimeTicks::HighResNow(); |
947 base::TimeDelta duration = end_time - begin_time; | 949 base::TimeDelta duration = end_time - begin_time; |
948 stats->totalRasterizeTime += duration; | 950 stats->totalRasterizeTime += duration; |
949 if (metadata.is_tile_in_pending_tree_now_bin) | 951 if (metadata.is_tile_in_pending_tree_now_bin) |
950 stats->totalRasterizeTimeForNowBinsOnPendingTree += duration; | 952 stats->totalRasterizeTimeForNowBinsOnPendingTree += duration; |
951 | 953 |
952 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.PictureRasterTimeMS", | 954 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.PictureRasterTimeMS", |
953 duration.InMilliseconds(), | 955 duration.InMilliseconds(), |
954 0, | 956 0, |
955 10, | 957 10, |
956 10); | 958 10); |
957 | 959 |
958 if (metadata.use_cheapness_estimator) { | 960 if (metadata.use_cheapness_estimator) { |
959 bool is_predicted_cheap = | 961 bool is_predicted_cheap = |
960 picture_pile->IsCheapInRect(rect, contents_scale); | 962 picture_pile->IsCheapInRect(rect, contents_scale); |
reveman
2013/02/26 23:34:40
nit: 4 space indent here
| |
961 bool is_actually_cheap = duration.InMillisecondsF() <= 1.0f; | 963 bool is_actually_cheap = duration.InMillisecondsF() <= 1.0f; |
962 RecordCheapnessPredictorResults(is_predicted_cheap, is_actually_cheap); | 964 RecordCheapnessPredictorResults(is_predicted_cheap, is_actually_cheap); |
963 } | 965 } |
964 } | 966 } |
967 | |
968 if (metadata.solid_color_benchmarking) { | |
969 SkColor solid_color; | |
970 bool is_predicted_solid = | |
971 picture_pile->GetColorIfSolidInRect(rect, contents_scale, &solid_color); | |
reveman
2013/02/26 23:34:40
nit: 4 space indent
| |
972 bool is_predicted_transparent = | |
973 picture_pile->IsTransparentInRect(rect, contents_scale); | |
reveman
2013/02/26 23:34:40
nit: 4 space indent
| |
974 | |
975 RecordSolidColorPredictorResults(buffer, | |
976 rect.width() * rect.height(), | |
977 is_predicted_solid, | |
978 solid_color, | |
979 is_predicted_transparent); | |
980 } | |
965 } | 981 } |
966 | 982 |
967 // static | 983 // static |
968 void TileManager::RecordCheapnessPredictorResults(bool is_predicted_cheap, | 984 void TileManager::RecordCheapnessPredictorResults(bool is_predicted_cheap, |
969 bool is_actually_cheap) { | 985 bool is_actually_cheap) { |
970 if (is_predicted_cheap && !is_actually_cheap) | 986 if (is_predicted_cheap && !is_actually_cheap) |
971 UMA_HISTOGRAM_BOOLEAN("Renderer4.CheapPredictorBadlyWrong", true); | 987 UMA_HISTOGRAM_BOOLEAN("Renderer4.CheapPredictorBadlyWrong", true); |
972 else if (!is_predicted_cheap && is_actually_cheap) | 988 else if (!is_predicted_cheap && is_actually_cheap) |
973 UMA_HISTOGRAM_BOOLEAN("Renderer4.CheapPredictorSafelyWrong", true); | 989 UMA_HISTOGRAM_BOOLEAN("Renderer4.CheapPredictorSafelyWrong", true); |
974 | 990 |
975 UMA_HISTOGRAM_BOOLEAN("Renderer4.CheapPredictorAccuracy", | 991 UMA_HISTOGRAM_BOOLEAN("Renderer4.CheapPredictorAccuracy", |
976 is_predicted_cheap == is_actually_cheap); | 992 is_predicted_cheap == is_actually_cheap); |
977 } | 993 } |
978 | 994 |
995 //static | |
reveman
2013/02/26 23:34:40
nit: space between // and static
| |
996 void TileManager::RecordSolidColorPredictorResults(const uint8* actual_bytes, | |
997 size_t pixel_count, | |
998 bool is_predicted_solid, | |
999 SkColor predicted_color, | |
1000 bool is_predicted_transparent ) { | |
reveman
2013/02/26 23:34:40
nit: lines should be <= 80 characters long
| |
1001 CHECK(pixel_count > 0); | |
reveman
2013/02/26 23:34:40
use CHECK_GT
| |
1002 | |
1003 bool is_actually_solid = true; | |
1004 bool is_transparent = true; | |
1005 SkColor actual_color = SkColorSetARGB(actual_bytes[3], | |
1006 actual_bytes[2], | |
1007 actual_bytes[1], | |
1008 actual_bytes[0]); | |
reveman
2013/02/26 23:34:40
is it safe to assume pixels are packed this way? y
| |
1009 for (int i = (pixel_count-1)*4; i >= 0; i -= 4) { | |
reveman
2013/02/26 23:34:40
what if stride != width?
| |
1010 SkColor current_color = SkColorSetARGB(actual_bytes[i+3], | |
1011 actual_bytes[i+2], | |
1012 actual_bytes[i+1], | |
1013 actual_bytes[i]); | |
1014 if (current_color != actual_color || | |
1015 SkColorGetA(current_color) != 255) | |
1016 is_actually_solid = false; | |
1017 | |
1018 if (SkColorGetA(current_color) != 0) | |
1019 is_transparent = false; | |
1020 } | |
1021 | |
1022 if (is_predicted_solid && !is_actually_solid) | |
1023 UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.WrongActualNotSolid", true); | |
1024 else if (is_predicted_solid && | |
1025 is_actually_solid && | |
1026 predicted_color != actual_color) | |
1027 UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.WrongColor", true); | |
1028 else if(!is_predicted_solid && is_actually_solid) | |
reveman
2013/02/26 23:34:40
nit: space between if and (
| |
1029 UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.WrongActualSolid", true); | |
1030 | |
1031 bool correct_guess = (is_predicted_solid && is_actually_solid && | |
1032 predicted_color == actual_color) || | |
1033 (!is_predicted_solid && !is_actually_solid); | |
1034 UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.Accuracy", correct_guess); | |
1035 | |
1036 if (correct_guess) | |
1037 UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.IsCorrectSolid", | |
1038 is_predicted_solid); | |
1039 | |
1040 if (is_predicted_transparent) | |
1041 UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.PredictedTransparentIsActual ly", is_transparent); | |
reveman
2013/02/26 23:34:40
nit: lines should be <= 80 characters long
| |
1042 UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.IsActuallyTransparent", is_tra nsparent); | |
reveman
2013/02/26 23:34:40
nit: lines should be <= 80 characters long
| |
1043 } | |
1044 | |
979 // static | 1045 // static |
980 void TileManager::RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, | 1046 void TileManager::RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, |
981 RenderingStats* stats) { | 1047 RenderingStats* stats) { |
982 TRACE_EVENT0("cc", "TileManager::RunImageDecodeTask"); | 1048 TRACE_EVENT0("cc", "TileManager::RunImageDecodeTask"); |
983 base::TimeTicks decode_begin_time; | 1049 base::TimeTicks decode_begin_time; |
984 if (stats) | 1050 if (stats) |
985 decode_begin_time = base::TimeTicks::HighResNow(); | 1051 decode_begin_time = base::TimeTicks::HighResNow(); |
986 pixel_ref->Decode(); | 1052 pixel_ref->Decode(); |
987 if (stats) { | 1053 if (stats) { |
988 stats->totalDeferredImageDecodeCount++; | 1054 stats->totalDeferredImageDecodeCount++; |
989 stats->totalDeferredImageDecodeTime += | 1055 stats->totalDeferredImageDecodeTime += |
990 base::TimeTicks::HighResNow() - decode_begin_time; | 1056 base::TimeTicks::HighResNow() - decode_begin_time; |
991 } | 1057 } |
992 } | 1058 } |
993 | 1059 |
994 } // namespace cc | 1060 } // namespace cc |
OLD | NEW |