summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorepenner@chromium.org <epenner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-24 13:51:19 +0000
committerepenner@chromium.org <epenner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-24 13:51:19 +0000
commit1bcced2a88a693aef5351ba98b8945b4d6417b14 (patch)
tree39475f99f148a9729956aa7d8593561686513cdc /cc
parent83daccedacc8669a90d0d942bcce2df1ce018263 (diff)
downloadchromium_src-1bcced2a88a693aef5351ba98b8945b4d6417b14.zip
chromium_src-1bcced2a88a693aef5351ba98b8945b4d6417b14.tar.gz
chromium_src-1bcced2a88a693aef5351ba98b8945b4d6417b14.tar.bz2
CC: Fix raster-on-demand (due to stale sort order).
Tile sort order dirty bit didn't respect tree priority changes. This patch only updates GlobalState on ManageTiles, to ensure the state is consistent with tile sorting. BUG=295331 NOTRY=true Review URL: https://chromiumcodereview.appspot.com/24269016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224994 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/resources/tile_manager.cc23
-rw-r--r--cc/resources/tile_manager.h7
-rw-r--r--cc/resources/tile_manager_perftest.cc9
-rw-r--r--cc/resources/tile_manager_unittest.cc58
-rw-r--r--cc/resources/tile_priority.h11
-rw-r--r--cc/test/fake_tile_manager.cc4
-rw-r--r--cc/test/fake_tile_manager.h3
-rw-r--r--cc/trees/layer_tree_host_impl.cc26
-rw-r--r--cc/trees/layer_tree_host_impl.h2
9 files changed, 77 insertions, 66 deletions
diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc
index b8cbdca..42e4a4d 100644
--- a/cc/resources/tile_manager.cc
+++ b/cc/resources/tile_manager.cc
@@ -182,15 +182,6 @@ TileManager::~TileManager() {
DCHECK_EQ(0u, resources_releasable_);
}
-void TileManager::SetGlobalState(
- const GlobalStateThatImpactsTilePriority& global_state) {
- global_state_ = global_state;
- resource_pool_->SetResourceUsageLimits(
- global_state_.memory_limit_in_bytes,
- global_state_.unused_memory_limit_in_bytes,
- global_state_.num_resources_limit);
-}
-
void TileManager::RegisterTile(Tile* tile) {
DCHECK(!tile->required_for_activation());
DCHECK(tiles_.find(tile->id()) == tiles_.end());
@@ -221,7 +212,7 @@ void TileManager::DidChangeTilePriority(Tile* tile) {
}
bool TileManager::ShouldForceTasksRequiredForActivationToComplete() const {
- return GlobalState().tree_priority != SMOOTHNESS_TAKES_PRIORITY;
+ return global_state_.tree_priority != SMOOTHNESS_TAKES_PRIORITY;
}
PrioritizedTileSet* TileManager::GetPrioritizedTileSet() {
@@ -406,9 +397,19 @@ void TileManager::GetTilesWithAssignedBins(PrioritizedTileSet* tiles) {
}
}
-void TileManager::ManageTiles() {
+void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) {
TRACE_EVENT0("cc", "TileManager::ManageTiles");
+ // Update internal state.
+ if (state != global_state_) {
+ prioritized_tiles_dirty_ = true;
+ resource_pool_->SetResourceUsageLimits(
+ global_state_.memory_limit_in_bytes,
+ global_state_.unused_memory_limit_in_bytes,
+ global_state_.num_resources_limit);
+ }
+ global_state_ = state;
+
// We need to call CheckForCompletedTasks() once in-between each call
// to ScheduleTasks() to prevent canceled tasks from being scheduled.
if (!did_check_for_completed_tasks_since_last_schedule_tasks_) {
diff --git a/cc/resources/tile_manager.h b/cc/resources/tile_manager.h
index 3f262bc..360bdca 100644
--- a/cc/resources/tile_manager.h
+++ b/cc/resources/tile_manager.h
@@ -56,12 +56,7 @@ class CC_EXPORT TileManager : public RasterWorkerPoolClient {
size_t max_transfer_buffer_usage_bytes);
virtual ~TileManager();
- const GlobalStateThatImpactsTilePriority& GlobalState() const {
- return global_state_;
- }
- void SetGlobalState(const GlobalStateThatImpactsTilePriority& state);
-
- void ManageTiles();
+ void ManageTiles(const GlobalStateThatImpactsTilePriority& state);
// Returns true when visible tiles have been initialized.
bool UpdateVisibleTiles();
diff --git a/cc/resources/tile_manager_perftest.cc b/cc/resources/tile_manager_perftest.cc
index 99d16a1..ce70eaf 100644
--- a/cc/resources/tile_manager_perftest.cc
+++ b/cc/resources/tile_manager_perftest.cc
@@ -43,7 +43,10 @@ class TileManagerPerfTest : public testing::Test {
ResourceProvider::Create(output_surface_.get(), 0, false);
tile_manager_ = make_scoped_ptr(
new FakeTileManager(&tile_manager_client_, resource_provider_.get()));
+ picture_pile_ = FakePicturePileImpl::CreatePile();
+ }
+ GlobalStateThatImpactsTilePriority GlobalStateForTest() {
GlobalStateThatImpactsTilePriority state;
gfx::Size tile_size = settings_.default_tile_size;
state.memory_limit_in_bytes =
@@ -52,9 +55,7 @@ class TileManagerPerfTest : public testing::Test {
state.num_resources_limit = 10000;
state.memory_limit_policy = ALLOW_ANYTHING;
state.tree_priority = SMOOTHNESS_TAKES_PRIORITY;
-
- tile_manager_->SetGlobalState(state);
- picture_pile_ = FakePicturePileImpl::CreatePile();
+ return state;
}
virtual void TearDown() OVERRIDE {
@@ -151,7 +152,7 @@ class TileManagerPerfTest : public testing::Test {
}
}
- tile_manager_->ManageTiles();
+ tile_manager_->ManageTiles(GlobalStateForTest());
tile_manager_->CheckForCompletedTasks();
timer_.NextLap();
} while (!timer_.HasTimeLimitExpired());
diff --git a/cc/resources/tile_manager_unittest.cc b/cc/resources/tile_manager_unittest.cc
index 0274914..bc78695a 100644
--- a/cc/resources/tile_manager_unittest.cc
+++ b/cc/resources/tile_manager_unittest.cc
@@ -49,7 +49,8 @@ class TileManagerTest : public testing::TestWithParam<bool> {
state.memory_limit_policy = memory_limit_policy;
state.tree_priority = tree_priority;
- tile_manager_->SetGlobalState(state);
+ global_state_ = state;
+ tile_manager_->ManageTiles(state);
picture_pile_ = FakePicturePileImpl::CreatePile();
}
@@ -62,7 +63,7 @@ class TileManagerTest : public testing::TestWithParam<bool> {
state.memory_limit_policy = memory_limit_policy_;
state.num_resources_limit = 100;
state.tree_priority = tree_priority;
- tile_manager_->SetGlobalState(state);
+ global_state_ = state;
}
virtual void TearDown() OVERRIDE {
@@ -130,6 +131,9 @@ class TileManagerTest : public testing::TestWithParam<bool> {
return has_lcd_count;
}
+ protected:
+ GlobalStateThatImpactsTilePriority global_state_;
+
private:
FakeTileManagerClient tile_manager_client_;
LayerTreeSettings settings_;
@@ -154,7 +158,7 @@ TEST_P(TileManagerTest, EnoughMemoryAllowAnything) {
3, TilePriorityForSoonBin(), TilePriorityForSoonBin());
TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority());
- tile_manager()->AssignMemoryToTiles();
+ tile_manager()->AssignMemoryToTiles(global_state_);
EXPECT_EQ(3, AssignedMemoryCount(active_now));
EXPECT_EQ(3, AssignedMemoryCount(pending_now));
@@ -175,7 +179,7 @@ TEST_P(TileManagerTest, EnoughMemoryAllowPrepaintOnly) {
3, TilePriorityForSoonBin(), TilePriorityForSoonBin());
TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority());
- tile_manager()->AssignMemoryToTiles();
+ tile_manager()->AssignMemoryToTiles(global_state_);
EXPECT_EQ(3, AssignedMemoryCount(active_now));
EXPECT_EQ(3, AssignedMemoryCount(pending_now));
@@ -196,7 +200,7 @@ TEST_P(TileManagerTest, EnoughMemoryAllowAbsoluteMinimum) {
3, TilePriorityForSoonBin(), TilePriorityForSoonBin());
TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority());
- tile_manager()->AssignMemoryToTiles();
+ tile_manager()->AssignMemoryToTiles(global_state_);
EXPECT_EQ(3, AssignedMemoryCount(active_now));
EXPECT_EQ(3, AssignedMemoryCount(pending_now));
@@ -217,7 +221,7 @@ TEST_P(TileManagerTest, EnoughMemoryAllowNothing) {
3, TilePriorityForSoonBin(), TilePriorityForSoonBin());
TileVector never_bin = CreateTiles(1, TilePriority(), TilePriority());
- tile_manager()->AssignMemoryToTiles();
+ tile_manager()->AssignMemoryToTiles(global_state_);
EXPECT_EQ(0, AssignedMemoryCount(active_now));
EXPECT_EQ(0, AssignedMemoryCount(pending_now));
@@ -237,13 +241,13 @@ TEST_P(TileManagerTest, PartialOOMMemoryToPending) {
TileVector pending_tree_tiles =
CreateTiles(5, TilePriority(), TilePriorityRequiredForActivation());
- tile_manager()->AssignMemoryToTiles();
+ tile_manager()->AssignMemoryToTiles(global_state_);
EXPECT_EQ(5, AssignedMemoryCount(active_tree_tiles));
EXPECT_EQ(3, AssignedMemoryCount(pending_tree_tiles));
SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES);
- tile_manager()->AssignMemoryToTiles();
+ tile_manager()->AssignMemoryToTiles(global_state_);
EXPECT_EQ(3, AssignedMemoryCount(active_tree_tiles));
EXPECT_EQ(5, AssignedMemoryCount(pending_tree_tiles));
@@ -260,7 +264,7 @@ TEST_P(TileManagerTest, PartialOOMMemoryToActive) {
TileVector pending_tree_tiles =
CreateTiles(5, TilePriority(), TilePriorityForNowBin());
- tile_manager()->AssignMemoryToTiles();
+ tile_manager()->AssignMemoryToTiles(global_state_);
EXPECT_EQ(5, AssignedMemoryCount(active_tree_tiles));
EXPECT_EQ(3, AssignedMemoryCount(pending_tree_tiles));
@@ -278,13 +282,13 @@ TEST_P(TileManagerTest, TotalOOMMemoryToPending) {
TileVector pending_tree_tiles =
CreateTiles(5, TilePriority(), TilePriorityRequiredForActivation());
- tile_manager()->AssignMemoryToTiles();
+ tile_manager()->AssignMemoryToTiles(global_state_);
EXPECT_EQ(4, AssignedMemoryCount(active_tree_tiles));
EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles));
SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES);
- tile_manager()->AssignMemoryToTiles();
+ tile_manager()->AssignMemoryToTiles(global_state_);
EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles));
EXPECT_EQ(4, AssignedMemoryCount(pending_tree_tiles));
@@ -302,13 +306,13 @@ TEST_P(TileManagerTest, TotalOOMActiveSoonMemoryToPending) {
TileVector pending_tree_tiles =
CreateTiles(5, TilePriority(), TilePriorityRequiredForActivation());
- tile_manager()->AssignMemoryToTiles();
+ tile_manager()->AssignMemoryToTiles(global_state_);
EXPECT_EQ(4, AssignedMemoryCount(active_tree_tiles));
EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles));
SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES);
- tile_manager()->AssignMemoryToTiles();
+ tile_manager()->AssignMemoryToTiles(global_state_);
EXPECT_EQ(0, AssignedMemoryCount(active_tree_tiles));
EXPECT_EQ(4, AssignedMemoryCount(pending_tree_tiles));
@@ -325,7 +329,7 @@ TEST_P(TileManagerTest, TotalOOMMemoryToActive) {
TileVector pending_tree_tiles =
CreateTiles(5, TilePriority(), TilePriorityForNowBin());
- tile_manager()->AssignMemoryToTiles();
+ tile_manager()->AssignMemoryToTiles(global_state_);
EXPECT_EQ(4, AssignedMemoryCount(active_tree_tiles));
EXPECT_EQ(0, AssignedMemoryCount(pending_tree_tiles));
@@ -340,7 +344,7 @@ TEST_P(TileManagerTest, RasterAsLCD) {
TileVector pending_tree_tiles =
CreateTiles(5, TilePriority(), TilePriorityForNowBin());
- tile_manager()->ManageTiles();
+ tile_manager()->ManageTiles(global_state_);
EXPECT_EQ(5, TilesWithLCDCount(active_tree_tiles));
EXPECT_EQ(5, TilesWithLCDCount(pending_tree_tiles));
@@ -364,7 +368,7 @@ TEST_P(TileManagerTest, RasterAsNoLCD) {
(*it)->set_can_use_lcd_text(false);
}
- tile_manager()->ManageTiles();
+ tile_manager()->ManageTiles(global_state_);
EXPECT_EQ(0, TilesWithLCDCount(active_tree_tiles));
EXPECT_EQ(0, TilesWithLCDCount(pending_tree_tiles));
@@ -377,7 +381,7 @@ TEST_P(TileManagerTest, ReRasterAsNoLCD) {
TileVector pending_tree_tiles =
CreateTiles(5, TilePriority(), TilePriorityForNowBin());
- tile_manager()->ManageTiles();
+ tile_manager()->ManageTiles(global_state_);
EXPECT_EQ(5, TilesWithLCDCount(active_tree_tiles));
EXPECT_EQ(5, TilesWithLCDCount(pending_tree_tiles));
@@ -393,7 +397,7 @@ TEST_P(TileManagerTest, ReRasterAsNoLCD) {
(*it)->set_can_use_lcd_text(false);
}
- tile_manager()->ManageTiles();
+ tile_manager()->ManageTiles(global_state_);
EXPECT_EQ(0, TilesWithLCDCount(active_tree_tiles));
EXPECT_EQ(0, TilesWithLCDCount(pending_tree_tiles));
@@ -406,7 +410,7 @@ TEST_P(TileManagerTest, NoTextDontReRasterAsNoLCD) {
TileVector pending_tree_tiles =
CreateTiles(5, TilePriority(), TilePriorityForNowBin());
- tile_manager()->ManageTiles();
+ tile_manager()->ManageTiles(global_state_);
EXPECT_EQ(5, TilesWithLCDCount(active_tree_tiles));
EXPECT_EQ(5, TilesWithLCDCount(pending_tree_tiles));
@@ -430,7 +434,7 @@ TEST_P(TileManagerTest, NoTextDontReRasterAsNoLCD) {
EXPECT_TRUE((*it)->IsReadyToDraw());
}
- tile_manager()->ManageTiles();
+ tile_manager()->ManageTiles(global_state_);
EXPECT_EQ(5, TilesWithLCDCount(active_tree_tiles));
EXPECT_EQ(5, TilesWithLCDCount(pending_tree_tiles));
@@ -443,7 +447,7 @@ TEST_P(TileManagerTest, TextReRasterAsNoLCD) {
TileVector pending_tree_tiles =
CreateTiles(5, TilePriority(), TilePriorityForNowBin());
- tile_manager()->ManageTiles();
+ tile_manager()->ManageTiles(global_state_);
EXPECT_EQ(5, TilesWithLCDCount(active_tree_tiles));
EXPECT_EQ(5, TilesWithLCDCount(pending_tree_tiles));
@@ -472,7 +476,7 @@ TEST_P(TileManagerTest, TextReRasterAsNoLCD) {
EXPECT_TRUE((*it)->IsReadyToDraw());
}
- tile_manager()->ManageTiles();
+ tile_manager()->ManageTiles(global_state_);
EXPECT_EQ(0, TilesWithLCDCount(active_tree_tiles));
EXPECT_EQ(0, TilesWithLCDCount(pending_tree_tiles));
@@ -488,14 +492,13 @@ TEST_P(TileManagerTest, RespectMemoryLimit) {
size_t memory_allocated_bytes;
size_t memory_used_bytes;
- tile_manager()->ManageTiles();
+ tile_manager()->ManageTiles(global_state_);
tile_manager()->GetMemoryStats(&memory_required_bytes,
&memory_nice_to_have_bytes,
&memory_allocated_bytes,
&memory_used_bytes);
// Allocated bytes should never be more than the memory limit.
- EXPECT_LE(memory_allocated_bytes,
- tile_manager()->GlobalState().memory_limit_in_bytes);
+ EXPECT_LE(memory_allocated_bytes, global_state_.memory_limit_in_bytes);
// Finish raster of large tiles.
tile_manager()->UpdateVisibleTiles();
@@ -510,14 +513,13 @@ TEST_P(TileManagerTest, RespectMemoryLimit) {
TileVector small_tiles = CreateTilesWithSize(
5, TilePriorityForNowBin(), TilePriority(), gfx::Size(128, 128));
- tile_manager()->ManageTiles();
+ tile_manager()->ManageTiles(global_state_);
tile_manager()->GetMemoryStats(&memory_required_bytes,
&memory_nice_to_have_bytes,
&memory_allocated_bytes,
&memory_used_bytes);
// Allocated bytes should never be more than the memory limit.
- EXPECT_LE(memory_allocated_bytes,
- tile_manager()->GlobalState().memory_limit_in_bytes);
+ EXPECT_LE(memory_allocated_bytes, global_state_.memory_limit_in_bytes);
}
// If true, the max tile limit should be applied as bytes; if false,
diff --git a/cc/resources/tile_priority.h b/cc/resources/tile_priority.h
index e613dd7..914b565b 100644
--- a/cc/resources/tile_priority.h
+++ b/cc/resources/tile_priority.h
@@ -172,6 +172,17 @@ class GlobalStateThatImpactsTilePriority {
TreePriority tree_priority;
+ bool operator==(const GlobalStateThatImpactsTilePriority& other) const {
+ return memory_limit_policy == other.memory_limit_policy
+ && memory_limit_in_bytes == other.memory_limit_in_bytes
+ && unused_memory_limit_in_bytes == other.unused_memory_limit_in_bytes
+ && num_resources_limit == other.num_resources_limit
+ && tree_priority == other.tree_priority;
+ }
+ bool operator!=(const GlobalStateThatImpactsTilePriority& other) const {
+ return !(*this == other);
+ }
+
scoped_ptr<base::Value> AsValue() const;
};
diff --git a/cc/test/fake_tile_manager.cc b/cc/test/fake_tile_manager.cc
index d8b53aa..87dad04 100644
--- a/cc/test/fake_tile_manager.cc
+++ b/cc/test/fake_tile_manager.cc
@@ -62,10 +62,12 @@ FakeTileManager::FakeTileManager(TileManagerClient* client,
FakeTileManager::~FakeTileManager() {}
-void FakeTileManager::AssignMemoryToTiles() {
+void FakeTileManager::AssignMemoryToTiles(
+ const GlobalStateThatImpactsTilePriority& state) {
tiles_for_raster.clear();
all_tiles.Clear();
+ ManageTiles(state);
GetTilesWithAssignedBins(&all_tiles);
AssignGpuMemoryToTiles(&all_tiles, &tiles_for_raster);
}
diff --git a/cc/test/fake_tile_manager.h b/cc/test/fake_tile_manager.h
index 6a5b6ac..b2fa495 100644
--- a/cc/test/fake_tile_manager.h
+++ b/cc/test/fake_tile_manager.h
@@ -19,7 +19,8 @@ class FakeTileManager : public TileManager {
ResourceProvider* resource_provider);
bool HasBeenAssignedMemory(Tile* tile);
- void AssignMemoryToTiles();
+ void AssignMemoryToTiles(
+ const GlobalStateThatImpactsTilePriority& state);
void CheckForCompletedTasks();
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 1901219..59e307b 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -364,7 +364,7 @@ void LayerTreeHostImpl::ManageTiles() {
return;
tile_priorities_dirty_ = false;
- tile_manager_->ManageTiles();
+ tile_manager_->ManageTiles(global_tile_state_);
size_t memory_required_bytes;
size_t memory_nice_to_have_bytes;
@@ -1128,23 +1128,22 @@ void LayerTreeHostImpl::UpdateTileManagerMemoryPolicy(
if (!tile_manager_)
return;
- GlobalStateThatImpactsTilePriority new_state(tile_manager_->GlobalState());
- new_state.memory_limit_in_bytes = visible_ ?
- policy.bytes_limit_when_visible :
- policy.bytes_limit_when_not_visible;
// TODO(reveman): We should avoid keeping around unused resources if
// possible. crbug.com/224475
- new_state.unused_memory_limit_in_bytes = static_cast<size_t>(
- (static_cast<int64>(new_state.memory_limit_in_bytes) *
+ global_tile_state_.memory_limit_in_bytes =
+ visible_ ?
+ policy.bytes_limit_when_visible :
+ policy.bytes_limit_when_not_visible;
+ global_tile_state_.unused_memory_limit_in_bytes = static_cast<size_t>(
+ (static_cast<int64>(global_tile_state_.memory_limit_in_bytes) *
settings_.max_unused_resource_memory_percentage) / 100);
- new_state.memory_limit_policy =
+ global_tile_state_.memory_limit_policy =
ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy(
visible_ ?
policy.priority_cutoff_when_visible :
policy.priority_cutoff_when_not_visible);
- new_state.num_resources_limit = policy.num_resources_limit;
+ global_tile_state_.num_resources_limit = policy.num_resources_limit;
- tile_manager_->SetGlobalState(new_state);
DidModifyTilePriorities();
}
@@ -2567,12 +2566,9 @@ void LayerTreeHostImpl::SetTreePriority(TreePriority priority) {
if (!tile_manager_)
return;
- GlobalStateThatImpactsTilePriority new_state(tile_manager_->GlobalState());
- if (new_state.tree_priority == priority)
+ if (global_tile_state_.tree_priority == priority)
return;
-
- new_state.tree_priority = priority;
- tile_manager_->SetGlobalState(new_state);
+ global_tile_state_.tree_priority = priority;
DidModifyTilePriorities();
}
diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h
index 4121812..17dc747 100644
--- a/cc/trees/layer_tree_host_impl.h
+++ b/cc/trees/layer_tree_host_impl.h
@@ -507,6 +507,8 @@ class CC_EXPORT LayerTreeHostImpl
scoped_ptr<TileManager> tile_manager_;
scoped_ptr<Renderer> renderer_;
+ GlobalStateThatImpactsTilePriority global_tile_state_;
+
// Tree currently being drawn.
scoped_ptr<LayerTreeImpl> active_tree_;