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

Unified Diff: cc/tiles/tile_manager.cc

Issue 1531013004: cc: Do solid color analysis before scheduling tiles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test updated. Created 4 years, 11 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
« no previous file with comments | « cc/tiles/tile_manager.h ('k') | cc/tiles/tile_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tiles/tile_manager.cc
diff --git a/cc/tiles/tile_manager.cc b/cc/tiles/tile_manager.cc
index 400fff20646bf77374fab31801f7181d207551f6..da09aa731b057e35647c8aa86bf0271fa225ad2b 100644
--- a/cc/tiles/tile_manager.cc
+++ b/cc/tiles/tile_manager.cc
@@ -55,10 +55,7 @@ class RasterTaskImpl : public RasterTask {
uint64_t previous_content_id,
uint64_t resource_content_id,
int source_frame_number,
- bool analyze_picture,
- const base::Callback<
- void(const DisplayListRasterSource::SolidColorAnalysis&,
- bool)>& reply,
+ const base::Callback<void(bool)>& reply,
ImageDecodeTask::Vector* dependencies)
: RasterTask(dependencies),
resource_(resource),
@@ -74,7 +71,6 @@ class RasterTaskImpl : public RasterTask {
previous_content_id_(previous_content_id),
resource_content_id_(resource_content_id),
source_frame_number_(source_frame_number),
- analyze_picture_(analyze_picture),
reply_(reply) {}
// Overridden from Task:
@@ -85,12 +81,6 @@ class RasterTaskImpl : public RasterTask {
DCHECK(raster_source_.get());
DCHECK(raster_buffer_);
- if (analyze_picture_) {
- Analyze(raster_source_.get());
- if (analysis_.is_solid_color)
- return;
- }
-
Raster(raster_source_.get());
}
@@ -102,25 +92,13 @@ class RasterTaskImpl : public RasterTask {
}
void CompleteOnOriginThread(TileTaskClient* client) override {
client->ReleaseBufferForRaster(std::move(raster_buffer_));
- reply_.Run(analysis_, !HasFinishedRunning());
+ reply_.Run(!HasFinishedRunning());
}
protected:
~RasterTaskImpl() override { DCHECK(!raster_buffer_); }
private:
- void Analyze(const DisplayListRasterSource* raster_source) {
- frame_viewer_instrumentation::ScopedAnalyzeTask analyze_task(
- tile_, tile_resolution_, source_frame_number_, layer_id_);
-
- DCHECK(raster_source);
-
- raster_source->PerformSolidColorAnalysis(content_rect_, contents_scale_,
- &analysis_);
- // Clear the flag if we're not using the estimator.
- analysis_.is_solid_color &= kUseColorEstimator;
- }
-
void Raster(const DisplayListRasterSource* raster_source) {
frame_viewer_instrumentation::ScopedRasterTask raster_task(
tile_, tile_resolution_, source_frame_number_, layer_id_);
@@ -136,7 +114,6 @@ class RasterTaskImpl : public RasterTask {
}
const Resource* resource_;
- DisplayListRasterSource::SolidColorAnalysis analysis_;
scoped_refptr<DisplayListRasterSource> raster_source_;
gfx::Rect content_rect_;
gfx::Rect invalid_content_rect_;
@@ -149,9 +126,7 @@ class RasterTaskImpl : public RasterTask {
uint64_t previous_content_id_;
uint64_t resource_content_id_;
int source_frame_number_;
- bool analyze_picture_;
- const base::Callback<void(const DisplayListRasterSource::SolidColorAnalysis&,
- bool)> reply_;
+ const base::Callback<void(bool)> reply_;
scoped_ptr<RasterBuffer> raster_buffer_;
DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl);
@@ -593,6 +568,23 @@ void TileManager::AssignGpuMemoryToTiles(
break;
}
+ if (tile->use_picture_analysis() && kUseColorEstimator) {
+ // We analyze for solid color here, to decide to continue
+ // or drop the tile for scheduling and raster.
+ // TODO(sohanjg): Check if we could use a shared analysis
+ // canvas which is reset between tiles.
+ SkColor color = SK_ColorTRANSPARENT;
+ bool is_solid_color =
+ prioritized_tile.raster_source()->PerformSolidColorAnalysis(
+ tile->content_rect(), tile->contents_scale(), &color);
+ if (is_solid_color) {
+ tile->draw_info().set_solid_color(color);
+ tile->draw_info().set_was_ever_ready_to_draw();
+ client_->NotifyTileStateChanged(tile);
+ continue;
+ }
+ }
+
// We won't be able to schedule this tile, so break out early.
if (tiles_that_need_to_be_rasterized->size() >=
scheduled_raster_task_limit) {
@@ -826,7 +818,6 @@ scoped_refptr<RasterTask> TileManager::CreateRasterTask(
prioritized_tile.priority().resolution, tile->layer_id(),
prepare_tiles_count_, static_cast<const void*>(tile), tile->id(),
tile->invalidated_id(), resource_content_id, tile->source_frame_number(),
- tile->use_picture_analysis(),
base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this),
tile->id(), resource),
&decode_tasks));
@@ -835,11 +826,11 @@ scoped_refptr<RasterTask> TileManager::CreateRasterTask(
void TileManager::OnRasterTaskCompleted(
Tile::Id tile_id,
Resource* resource,
- const DisplayListRasterSource::SolidColorAnalysis& analysis,
bool was_canceled) {
DCHECK(tiles_.find(tile_id) != tiles_.end());
Tile* tile = tiles_[tile_id];
+ TileDrawInfo& draw_info = tile->draw_info();
DCHECK(tile->raster_task_.get());
orphan_tasks_.push_back(tile->raster_task_);
tile->raster_task_ = nullptr;
@@ -854,32 +845,12 @@ void TileManager::OnRasterTaskCompleted(
return;
}
- UpdateTileDrawInfo(tile, resource, analysis);
-}
-
-void TileManager::UpdateTileDrawInfo(
- Tile* tile,
- Resource* resource,
- const DisplayListRasterSource::SolidColorAnalysis& analysis) {
- TileDrawInfo& draw_info = tile->draw_info();
-
++flush_stats_.completed_count;
- if (analysis.is_solid_color) {
- draw_info.set_solid_color(analysis.solid_color);
- if (resource) {
- // TODO(ericrk): If more partial raster work is done in the future, it may
- // be worth returning the resource to the pool with its previous ID (not
- // currently tracked). crrev.com/1370333002/#ps40001 has a possible method
- // of achieving this.
- resource_pool_->ReleaseResource(resource, 0 /* content_id */);
- }
- } else {
- DCHECK(resource);
- draw_info.set_use_resource();
- draw_info.resource_ = resource;
- draw_info.contents_swizzled_ = DetermineResourceRequiresSwizzle(tile);
- }
+ draw_info.set_use_resource();
+ draw_info.resource_ = resource;
+ draw_info.contents_swizzled_ = DetermineResourceRequiresSwizzle(tile);
+
DCHECK(draw_info.IsReadyToDraw());
draw_info.set_was_ever_ready_to_draw();
« no previous file with comments | « cc/tiles/tile_manager.h ('k') | cc/tiles/tile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698