Chromium Code Reviews| Index: cc/tile_manager.cc |
| diff --git a/cc/tile_manager.cc b/cc/tile_manager.cc |
| index 580759f7b10521a578edd93fa7cc495a42da1f60..a48f0b51f326545b180ee4014ae90e61496981c0 100644 |
| --- a/cc/tile_manager.cc |
| +++ b/cc/tile_manager.cc |
| @@ -176,7 +176,8 @@ TileManager::TileManager( |
| TileManagerClient* client, |
| ResourceProvider* resource_provider, |
| size_t num_raster_threads, |
| - bool use_cheapness_estimator) |
| + bool use_cheapness_estimator, |
| + bool solid_color_benchmarking) |
| : client_(client), |
| resource_pool_(ResourcePool::Create(resource_provider)), |
| raster_worker_pool_(RasterWorkerPool::Create(this, num_raster_threads)), |
| @@ -188,7 +189,8 @@ TileManager::TileManager( |
| record_rendering_stats_(false), |
| use_cheapness_estimator_(use_cheapness_estimator), |
| allow_cheap_tasks_(true), |
| - did_schedule_cheap_tasks_(false) { |
| + did_schedule_cheap_tasks_(false), |
| + solid_color_benchmarking_(solid_color_benchmarking) { |
| for (int i = 0; i < NUM_STATES; ++i) { |
| for (int j = 0; j < NUM_TREES; ++j) { |
| for (int k = 0; k < NUM_BINS; ++k) |
| @@ -817,6 +819,7 @@ TileManager::RasterTaskMetadata TileManager::GetRasterTaskMetadata( |
| RasterTaskMetadata metadata; |
| const ManagedTileState& mts = tile.managed_state(); |
| metadata.use_cheapness_estimator = use_cheapness_estimator_; |
| + metadata.solid_color_benchmarking = solid_color_benchmarking_; |
| metadata.is_tile_in_pending_tree_now_bin = |
| mts.tree_bin[PENDING_TREE] == NOW_BIN; |
| metadata.tile_resolution = mts.resolution; |
| @@ -939,7 +942,6 @@ void TileManager::RunRasterTask(uint8* buffer, |
| int64 total_pixels_rasterized = 0; |
| picture_pile->Raster(&canvas, rect, contents_scale, |
| &total_pixels_rasterized); |
| - |
| if (stats) { |
| stats->totalPixelsRasterized += total_pixels_rasterized; |
| @@ -957,11 +959,25 @@ void TileManager::RunRasterTask(uint8* buffer, |
| if (metadata.use_cheapness_estimator) { |
| bool is_predicted_cheap = |
| - picture_pile->IsCheapInRect(rect, contents_scale); |
| + picture_pile->IsCheapInRect(rect, contents_scale); |
|
reveman
2013/02/26 23:34:40
nit: 4 space indent here
|
| bool is_actually_cheap = duration.InMillisecondsF() <= 1.0f; |
| RecordCheapnessPredictorResults(is_predicted_cheap, is_actually_cheap); |
| } |
| } |
| + |
| + if (metadata.solid_color_benchmarking) { |
| + SkColor solid_color; |
| + bool is_predicted_solid = |
| + picture_pile->GetColorIfSolidInRect(rect, contents_scale, &solid_color); |
|
reveman
2013/02/26 23:34:40
nit: 4 space indent
|
| + bool is_predicted_transparent = |
| + picture_pile->IsTransparentInRect(rect, contents_scale); |
|
reveman
2013/02/26 23:34:40
nit: 4 space indent
|
| + |
| + RecordSolidColorPredictorResults(buffer, |
| + rect.width() * rect.height(), |
| + is_predicted_solid, |
| + solid_color, |
| + is_predicted_transparent); |
| + } |
| } |
| // static |
| @@ -976,6 +992,56 @@ void TileManager::RecordCheapnessPredictorResults(bool is_predicted_cheap, |
| is_predicted_cheap == is_actually_cheap); |
| } |
| +//static |
|
reveman
2013/02/26 23:34:40
nit: space between // and static
|
| +void TileManager::RecordSolidColorPredictorResults(const uint8* actual_bytes, |
| + size_t pixel_count, |
| + bool is_predicted_solid, |
| + SkColor predicted_color, |
| + bool is_predicted_transparent) { |
|
reveman
2013/02/26 23:34:40
nit: lines should be <= 80 characters long
|
| + CHECK(pixel_count > 0); |
|
reveman
2013/02/26 23:34:40
use CHECK_GT
|
| + |
| + bool is_actually_solid = true; |
| + bool is_transparent = true; |
| + SkColor actual_color = SkColorSetARGB(actual_bytes[3], |
| + actual_bytes[2], |
| + actual_bytes[1], |
| + actual_bytes[0]); |
|
reveman
2013/02/26 23:34:40
is it safe to assume pixels are packed this way? y
|
| + for (int i = (pixel_count-1)*4; i >= 0; i -= 4) { |
|
reveman
2013/02/26 23:34:40
what if stride != width?
|
| + SkColor current_color = SkColorSetARGB(actual_bytes[i+3], |
| + actual_bytes[i+2], |
| + actual_bytes[i+1], |
| + actual_bytes[i]); |
| + if (current_color != actual_color || |
| + SkColorGetA(current_color) != 255) |
| + is_actually_solid = false; |
| + |
| + if (SkColorGetA(current_color) != 0) |
| + is_transparent = false; |
| + } |
| + |
| + if (is_predicted_solid && !is_actually_solid) |
| + UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.WrongActualNotSolid", true); |
| + else if (is_predicted_solid && |
| + is_actually_solid && |
| + predicted_color != actual_color) |
| + UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.WrongColor", true); |
| + else if(!is_predicted_solid && is_actually_solid) |
|
reveman
2013/02/26 23:34:40
nit: space between if and (
|
| + UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.WrongActualSolid", true); |
| + |
| + bool correct_guess = (is_predicted_solid && is_actually_solid && |
| + predicted_color == actual_color) || |
| + (!is_predicted_solid && !is_actually_solid); |
| + UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.Accuracy", correct_guess); |
| + |
| + if (correct_guess) |
| + UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.IsCorrectSolid", |
| + is_predicted_solid); |
| + |
| + if (is_predicted_transparent) |
| + UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.PredictedTransparentIsActually", is_transparent); |
|
reveman
2013/02/26 23:34:40
nit: lines should be <= 80 characters long
|
| + UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.IsActuallyTransparent", is_transparent); |
|
reveman
2013/02/26 23:34:40
nit: lines should be <= 80 characters long
|
| +} |
| + |
| // static |
| void TileManager::RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, |
| RenderingStats* stats) { |