summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorvmpstr@chromium.org <vmpstr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-13 19:34:10 +0000
committervmpstr@chromium.org <vmpstr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-13 19:34:10 +0000
commitda9c84a3699e85b4c32c817313dd4652c5ecbab8 (patch)
treed9172ee4283d94732a7ed8cca85e1461d205423d /cc
parentceea12202cd521eb7c11ec76842a3de65f54b883 (diff)
downloadchromium_src-da9c84a3699e85b4c32c817313dd4652c5ecbab8.zip
chromium_src-da9c84a3699e85b4c32c817313dd4652c5ecbab8.tar.gz
chromium_src-da9c84a3699e85b4c32c817313dd4652c5ecbab8.tar.bz2
cc: Remove analysis from tile manager
Analysis is only used by the raster task. It's the part that fills in the analysis, and it's also the part that consumes it. I think it makes sense moving it deeper in, instead of allocating it early and passing it around. BUG=248765 Review URL: https://chromiumcodereview.appspot.com/16341005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206134 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/resources/managed_tile_state.cc14
-rw-r--r--cc/resources/managed_tile_state.h8
-rw-r--r--cc/resources/picture_layer_tiling.cc5
-rw-r--r--cc/resources/raster_worker_pool.cc20
-rw-r--r--cc/resources/raster_worker_pool.h4
-rw-r--r--cc/resources/raster_worker_pool_unittest.cc3
-rw-r--r--cc/resources/tile.h4
-rw-r--r--cc/resources/tile_manager.cc15
-rw-r--r--cc/resources/tile_manager.h2
9 files changed, 35 insertions, 40 deletions
diff --git a/cc/resources/managed_tile_state.cc b/cc/resources/managed_tile_state.cc
index a319cf7..1b2c2d0 100644
--- a/cc/resources/managed_tile_state.cc
+++ b/cc/resources/managed_tile_state.cc
@@ -12,7 +12,6 @@ namespace cc {
ManagedTileState::ManagedTileState()
: raster_mode(LOW_QUALITY_RASTER_MODE),
- picture_pile_analyzed(false),
gpu_memmgr_stats_bin(NEVER_BIN),
resolution(NON_IDEAL_RESOLUTION),
required_for_activation(false),
@@ -26,6 +25,7 @@ ManagedTileState::ManagedTileState()
ManagedTileState::TileVersion::TileVersion()
: mode_(RESOURCE_MODE),
+ has_text_(false),
resource_id_(0),
resource_format_(GL_RGBA),
forced_upload_(false) {
@@ -71,11 +71,13 @@ scoped_ptr<base::Value> ManagedTileState::AsValue() const {
state->Set("distance_to_visible_in_pixels",
MathUtil::AsValueSafely(distance_to_visible_in_pixels).release());
state->SetBoolean("required_for_activation", required_for_activation);
- state->SetBoolean("is_picture_pile_analyzed", picture_pile_analyzed);
- state->SetBoolean("is_solid_color", picture_pile_analysis.is_solid_color);
- state->SetBoolean("is_transparent",
- picture_pile_analysis.is_solid_color &&
- !SkColorGetA(picture_pile_analysis.solid_color));
+ state->SetBoolean(
+ "is_solid_color",
+ tile_versions[raster_mode].mode_ == TileVersion::SOLID_COLOR_MODE);
+ state->SetBoolean(
+ "is_transparent",
+ tile_versions[raster_mode].mode_ == TileVersion::SOLID_COLOR_MODE &&
+ !SkColorGetA(tile_versions[raster_mode].solid_color_));
return state.PassAs<base::Value>();
}
diff --git a/cc/resources/managed_tile_state.h b/cc/resources/managed_tile_state.h
index 371f129..200997b 100644
--- a/cc/resources/managed_tile_state.h
+++ b/cc/resources/managed_tile_state.h
@@ -90,6 +90,10 @@ class CC_EXPORT ManagedTileState {
resource_id_ = 0;
}
+ void set_has_text(bool has_text) {
+ has_text_ = has_text;
+ }
+
void set_rasterize_on_demand() {
mode_ = PICTURE_PILE_MODE;
resource_id_ = 0;
@@ -97,6 +101,7 @@ class CC_EXPORT ManagedTileState {
Mode mode_;
SkColor solid_color_;
+ bool has_text_;
// TODO(reveman): Eliminate the need for |resource_id_|
// and |resource_format_| and | forced_upload_| by re-factoring
@@ -119,9 +124,6 @@ class CC_EXPORT ManagedTileState {
TileVersion tile_versions[NUM_RASTER_MODES];
RasterMode raster_mode;
- bool picture_pile_analyzed;
- PicturePileImpl::Analysis picture_pile_analysis;
-
// Ephemeral state, valid only during TileManager::ManageTiles.
bool is_in_never_bin_on_both_trees() const {
return bin[HIGH_PRIORITY_BIN] == NEVER_BIN &&
diff --git a/cc/resources/picture_layer_tiling.cc b/cc/resources/picture_layer_tiling.cc
index 6589f2a..a93e6566 100644
--- a/cc/resources/picture_layer_tiling.cc
+++ b/cc/resources/picture_layer_tiling.cc
@@ -17,7 +17,10 @@
namespace cc {
bool PictureLayerTilingClient::TileHasText(Tile* tile) {
- return tile->has_text();
+ RasterMode raster_mode = HIGH_QUALITY_RASTER_MODE;
+ if (!tile->IsReadyToDraw(&raster_mode))
+ return false;
+ return tile->has_text(raster_mode);
}
scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create(
diff --git a/cc/resources/raster_worker_pool.cc b/cc/resources/raster_worker_pool.cc
index e7f1ceb..4ac3b2e 100644
--- a/cc/resources/raster_worker_pool.cc
+++ b/cc/resources/raster_worker_pool.cc
@@ -69,7 +69,6 @@ class RootWorkerPoolTaskImpl : public internal::WorkerPoolTask {
class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask {
public:
RasterWorkerPoolTaskImpl(const Resource* resource,
- PicturePileImpl::Analysis* analysis,
PicturePileImpl* picture_pile,
gfx::Rect content_rect,
float contents_scale,
@@ -80,7 +79,6 @@ class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask {
const RasterWorkerPool::RasterTask::Reply& reply,
internal::WorkerPoolTask::TaskVector* dependencies)
: internal::RasterWorkerPoolTask(resource, dependencies),
- analysis_(analysis),
picture_pile_(picture_pile),
content_rect_(content_rect),
contents_scale_(contents_scale),
@@ -97,7 +95,6 @@ class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask {
TracedValue::FromValue(metadata_.AsValue().release()));
DCHECK(picture_pile_);
- DCHECK(analysis_);
DCHECK(rendering_stats_);
PicturePileImpl* picture_clone =
@@ -106,17 +103,17 @@ class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask {
DCHECK(picture_clone);
base::TimeTicks start_time = rendering_stats_->StartRecording();
- picture_clone->AnalyzeInRect(content_rect_, contents_scale_, analysis_);
+ picture_clone->AnalyzeInRect(content_rect_, contents_scale_, &analysis_);
base::TimeDelta duration = rendering_stats_->EndRecording(start_time);
// Record the solid color prediction.
UMA_HISTOGRAM_BOOLEAN("Renderer4.SolidColorTilesAnalyzed",
- analysis_->is_solid_color);
+ analysis_.is_solid_color);
rendering_stats_->AddTileAnalysisResult(duration,
- analysis_->is_solid_color);
+ analysis_.is_solid_color);
// Clear the flag if we're not using the estimator.
- analysis_->is_solid_color &= use_color_estimator_;
+ analysis_.is_solid_color &= use_color_estimator_;
}
bool RunRasterOnThread(SkDevice* device, unsigned thread_index) {
@@ -127,10 +124,9 @@ class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask {
devtools_instrumentation::kRasterTask, metadata_.layer_id);
DCHECK(picture_pile_);
- DCHECK(analysis_);
DCHECK(device);
- if (analysis_->is_solid_color)
+ if (analysis_.is_solid_color)
return false;
PicturePileImpl* picture_clone =
@@ -184,14 +180,14 @@ class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask {
return RunRasterOnThread(device, thread_index);
}
virtual void DispatchCompletionCallback() OVERRIDE {
- reply_.Run(!HasFinishedRunning());
+ reply_.Run(analysis_, !HasFinishedRunning());
}
protected:
virtual ~RasterWorkerPoolTaskImpl() {}
private:
- PicturePileImpl::Analysis* analysis_;
+ PicturePileImpl::Analysis analysis_;
scoped_refptr<PicturePileImpl> picture_pile_;
gfx::Rect content_rect_;
float contents_scale_;
@@ -373,7 +369,6 @@ void RasterWorkerPool::Shutdown() {
RasterWorkerPool::RasterTask RasterWorkerPool::CreateRasterTask(
const Resource* resource,
- PicturePileImpl::Analysis* analysis,
PicturePileImpl* picture_pile,
gfx::Rect content_rect,
float contents_scale,
@@ -384,7 +379,6 @@ RasterWorkerPool::RasterTask RasterWorkerPool::CreateRasterTask(
const RasterTask::Reply& reply,
Task::Set& dependencies) {
return RasterTask(new RasterWorkerPoolTaskImpl(resource,
- analysis,
picture_pile,
content_rect,
contents_scale,
diff --git a/cc/resources/raster_worker_pool.h b/cc/resources/raster_worker_pool.h
index ce68e75..ca14274 100644
--- a/cc/resources/raster_worker_pool.h
+++ b/cc/resources/raster_worker_pool.h
@@ -143,7 +143,8 @@ class CC_EXPORT RasterWorkerPool : public WorkerPool {
class CC_EXPORT RasterTask {
public:
- typedef base::Callback<void(bool was_canceled)> Reply;
+ typedef base::Callback<void(const PicturePileImpl::Analysis& analysis,
+ bool was_canceled)> Reply;
class CC_EXPORT Queue {
public:
@@ -182,7 +183,6 @@ class CC_EXPORT RasterWorkerPool : public WorkerPool {
// TODO(vmpstr): Try to elimiate some variables.
static RasterTask CreateRasterTask(
const Resource* resource,
- PicturePileImpl::Analysis* analysis,
PicturePileImpl* picture_pile,
gfx::Rect content_rect,
float contents_scale,
diff --git a/cc/resources/raster_worker_pool_unittest.cc b/cc/resources/raster_worker_pool_unittest.cc
index 7f49443..136488b 100644
--- a/cc/resources/raster_worker_pool_unittest.cc
+++ b/cc/resources/raster_worker_pool_unittest.cc
@@ -29,7 +29,7 @@ class TestRasterTaskImpl : public internal::RasterWorkerPoolTask {
return true;
}
virtual void DispatchCompletionCallback() OVERRIDE {
- reply_.Run(!HasFinishedRunning());
+ reply_.Run(PicturePileImpl::Analysis(), !HasFinishedRunning());
}
protected:
@@ -172,6 +172,7 @@ class BasicRasterWorkerPoolTest : public RasterWorkerPoolTest {
void OnTaskCompleted(scoped_ptr<ScopedResource> resource,
unsigned id,
+ const PicturePileImpl::Analysis& analysis,
bool was_canceled) {
on_task_completed_ids_.push_back(id);
if (on_task_completed_ids_.size() == 2)
diff --git a/cc/resources/tile.h b/cc/resources/tile.h
index 8b4e304..2cd4997 100644
--- a/cc/resources/tile.h
+++ b/cc/resources/tile.h
@@ -82,8 +82,8 @@ class CC_EXPORT Tile : public base::RefCounted<Tile> {
}
gfx::Rect opaque_rect() const { return opaque_rect_; }
- bool has_text() const {
- return managed_state_.picture_pile_analysis.has_text;
+ bool has_text(RasterMode mode) const {
+ return managed_state_.tile_versions[mode].has_text_;
}
float contents_scale() const { return contents_scale_; }
diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc
index fdd2e70..f3319af 100644
--- a/cc/resources/tile_manager.cc
+++ b/cc/resources/tile_manager.cc
@@ -700,9 +700,6 @@ RasterWorkerPool::RasterTask TileManager::CreateRasterTask(
mts.tile_versions[mts.raster_mode].resource_id_ = resource->id();
mts.tile_versions[mts.raster_mode].resource_format_ = texture_format_;
- // TODO(vmpstr): Move analysis into RasterTask.
- PicturePileImpl::Analysis* analysis = new PicturePileImpl::Analysis;
-
// Create and queue all image decode tasks that this tile depends on.
RasterWorkerPool::Task::Set decode_tasks;
for (PicturePileImpl::PixelRefIterator iter(tile->content_rect(),
@@ -739,7 +736,6 @@ RasterWorkerPool::RasterTask TileManager::CreateRasterTask(
RasterTaskMetadata metadata = GetRasterTaskMetadata(*tile);
return RasterWorkerPool::CreateRasterTask(
const_resource,
- analysis,
tile->picture_pile(),
tile->content_rect(),
tile->contents_scale(),
@@ -751,7 +747,6 @@ RasterWorkerPool::RasterTask TileManager::CreateRasterTask(
base::Unretained(this),
make_scoped_refptr(tile),
base::Passed(&resource),
- base::Owned(analysis),
mts.raster_mode),
decode_tasks);
}
@@ -759,8 +754,8 @@ RasterWorkerPool::RasterTask TileManager::CreateRasterTask(
void TileManager::OnRasterTaskCompleted(
scoped_refptr<Tile> tile,
scoped_ptr<ResourcePool::Resource> resource,
- PicturePileImpl::Analysis* analysis,
RasterMode raster_mode,
+ const PicturePileImpl::Analysis& analysis,
bool was_canceled) {
TRACE_EVENT1("cc", "TileManager::OnRasterTaskCompleted",
"was_canceled", was_canceled);
@@ -777,11 +772,9 @@ void TileManager::OnRasterTaskCompleted(
return;
}
- mts.picture_pile_analysis = *analysis;
- mts.picture_pile_analyzed = true;
-
- if (analysis->is_solid_color) {
- tile_version.set_solid_color(analysis->solid_color);
+ tile_version.set_has_text(analysis.has_text);
+ if (analysis.is_solid_color) {
+ tile_version.set_solid_color(analysis.solid_color);
resource_pool_->ReleaseResource(resource.Pass());
} else {
tile_version.resource_ = resource.Pass();
diff --git a/cc/resources/tile_manager.h b/cc/resources/tile_manager.h
index 7ae8d68..7c22814 100644
--- a/cc/resources/tile_manager.h
+++ b/cc/resources/tile_manager.h
@@ -120,8 +120,8 @@ class CC_EXPORT TileManager {
void OnRasterTaskCompleted(
scoped_refptr<Tile> tile,
scoped_ptr<ResourcePool::Resource> resource,
- PicturePileImpl::Analysis* analysis,
RasterMode raster_mode,
+ const PicturePileImpl::Analysis& analysis,
bool was_canceled);
void AssignBinsToTiles();