Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1135)

Unified Diff: cc/tile_manager.cc

Issue 12316084: cc: Consolidate the analysis_canvas operations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed unittest Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/tile_manager.cc
diff --git a/cc/tile_manager.cc b/cc/tile_manager.cc
index 580759f7b10521a578edd93fa7cc495a42da1f60..5bb5542649b964f278a69e4048e1de03963587b2 100644
--- a/cc/tile_manager.cc
+++ b/cc/tile_manager.cc
@@ -176,7 +176,9 @@ TileManager::TileManager(
TileManagerClient* client,
ResourceProvider* resource_provider,
size_t num_raster_threads,
- bool use_cheapness_estimator)
+ bool use_cheapness_estimator,
+ bool use_color_estimator,
+ bool prediction_benchmarking)
: client_(client),
resource_pool_(ResourcePool::Create(resource_provider)),
raster_worker_pool_(RasterWorkerPool::Create(this, num_raster_threads)),
@@ -187,8 +189,10 @@ TileManager::TileManager(
ever_exceeded_memory_budget_(false),
record_rendering_stats_(false),
use_cheapness_estimator_(use_cheapness_estimator),
+ use_color_estimator_(use_color_estimator),
allow_cheap_tasks_(true),
- did_schedule_cheap_tasks_(false) {
+ did_schedule_cheap_tasks_(false),
+ prediction_benchmarking_(prediction_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)
@@ -370,11 +374,30 @@ void TileManager::ManageTiles() {
for (int i = 0; i < NUM_BIN_PRIORITIES; ++i)
mts.bin[i] = bin_map[mts.bin[i]];
- if (tile->priority(ACTIVE_TREE).is_live ||
- tile->priority(PENDING_TREE).is_live ||
- tile->managed_state().resource ||
+ if (tile->managed_state().resource ||
tile->managed_state().resource_is_being_initialized) {
live_or_allocated_tiles_.push_back(tile);
+ } else if (tile->priority(ACTIVE_TREE).is_live ||
+ tile->priority(PENDING_TREE).is_live) {
+ bool is_cheap = use_cheapness_estimator_ &&
+ tile->picture_pile()->IsCheapInRect(tile->content_rect(),
+ tile->contents_scale());
+ tile->set_cheap(is_cheap);
+ if (use_color_estimator_) {
+ SkColor color;
+ bool is_solid_color = tile->picture_pile()->GetColorIfSolidInRect(
+ tile->content_rect(),
+ tile->contents_scale(),
+ &color);
+ if (is_solid_color)
+ tile->set_solid_color(color);
+
+ bool is_transparent = tile->picture_pile()->IsTransparentInRect(
+ tile->content_rect(),
+ tile->contents_scale());
+ tile->set_transparent(is_transparent);
+ }
+ live_or_allocated_tiles_.push_back(tile);
}
}
TRACE_COUNTER_ID1("cc", "LiveOrAllocatedTileCount", this,
@@ -578,6 +601,8 @@ void TileManager::AssignGpuMemoryToTiles() {
for (TileVector::iterator it = live_or_allocated_tiles_.begin();
it != live_or_allocated_tiles_.end(); ++it) {
Tile* tile = *it;
+ if (tile->is_solid_color() || tile->is_transparent())
+ continue;
if (!tile->managed_state().can_be_freed)
unreleasable_bytes += tile->bytes_consumed_if_allocated();
if (tile->managed_state().raster_state == WAITING_FOR_RASTER_STATE)
@@ -589,6 +614,9 @@ void TileManager::AssignGpuMemoryToTiles() {
size_t bytes_left = bytes_allocatable;
for (TileVector::iterator it = live_or_allocated_tiles_.begin(); it != live_or_allocated_tiles_.end(); ++it) {
Tile* tile = *it;
+ if (tile->is_solid_color() || tile->is_transparent())
+ continue;
+
size_t tile_bytes = tile->bytes_consumed_if_allocated();
ManagedTileState& managed_tile_state = tile->managed_state();
if (!managed_tile_state.can_be_freed)
@@ -793,12 +821,9 @@ void TileManager::DispatchOneRasterTask(scoped_refptr<Tile> tile) {
uint8* buffer =
resource_pool_->resource_provider()->mapPixelBuffer(resource_id);
- bool is_cheap = use_cheapness_estimator_ && allow_cheap_tasks_ &&
- tile->picture_pile()->IsCheapInRect(tile->content_rect_,
Tom Hudson 2013/02/27 14:49:36 We've lost the guarantee that this is called here,
- tile->contents_scale());
raster_worker_pool_->PostRasterTaskAndReply(
tile->picture_pile(),
- is_cheap,
+ allow_cheap_tasks_ && tile->is_cheap(),
base::Bind(&TileManager::RunRasterTask,
buffer,
tile->content_rect(),
@@ -809,14 +834,14 @@ void TileManager::DispatchOneRasterTask(scoped_refptr<Tile> tile) {
tile,
base::Passed(&resource),
manage_tiles_call_count_));
- did_schedule_cheap_tasks_ |= is_cheap;
+ did_schedule_cheap_tasks_ |= (allow_cheap_tasks_ && tile->is_cheap());
}
TileManager::RasterTaskMetadata TileManager::GetRasterTaskMetadata(
const Tile& tile) const {
RasterTaskMetadata metadata;
const ManagedTileState& mts = tile.managed_state();
- metadata.use_cheapness_estimator = use_cheapness_estimator_;
+ metadata.prediction_benchmarking = prediction_benchmarking_;
metadata.is_tile_in_pending_tree_now_bin =
mts.tree_bin[PENDING_TREE] == NOW_BIN;
metadata.tile_resolution = mts.resolution;
@@ -939,7 +964,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;
@@ -955,11 +979,24 @@ void TileManager::RunRasterTask(uint8* buffer,
10,
10);
- if (metadata.use_cheapness_estimator) {
+ if (metadata.prediction_benchmarking) {
bool is_predicted_cheap =
picture_pile->IsCheapInRect(rect, contents_scale);
bool is_actually_cheap = duration.InMillisecondsF() <= 1.0f;
RecordCheapnessPredictorResults(is_predicted_cheap, is_actually_cheap);
+
+ SkColor solid_color;
+ bool is_predicted_solid =
+ picture_pile->GetColorIfSolidInRect(rect, contents_scale, &solid_color);
+ bool is_predicted_transparent =
+ picture_pile->IsTransparentInRect(rect, contents_scale);
+
+ RecordSolidColorPredictorResults(
+ reinterpret_cast<SkColor*>(bitmap.getPixels()),
+ bitmap.getSize() / bitmap.bytesPerPixel(),
+ is_predicted_solid,
+ solid_color,
+ is_predicted_transparent);
}
}
}
@@ -977,6 +1014,55 @@ void TileManager::RecordCheapnessPredictorResults(bool is_predicted_cheap,
}
// static
+void TileManager::RecordSolidColorPredictorResults(
+ const SkColor* actual_colors,
+ size_t color_count,
+ bool is_predicted_solid,
+ SkColor predicted_color,
+ bool is_predicted_transparent) {
+ DCHECK_GT(color_count, 0);
+
+ bool is_actually_solid = true;
+ bool is_transparent = true;
+
+ SkColor actual_color = *actual_colors;
+ for (int i = 0; i < color_count; ++i) {
+ SkColor current_color = actual_colors[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)
+ 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);
+ UMA_HISTOGRAM_BOOLEAN("Renderer4.ColorPredictor.IsActuallyTransparent",
+ is_transparent);
+}
+
+// static
void TileManager::RunImageDecodeTask(skia::LazyPixelRef* pixel_ref,
RenderingStats* stats) {
TRACE_EVENT0("cc", "TileManager::RunImageDecodeTask");

Powered by Google App Engine
This is Rietveld 408576698