summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjbedley@chromium.org <jbedley@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-23 22:17:11 +0000
committerjbedley@chromium.org <jbedley@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-23 22:17:11 +0000
commit562b7ad53bc7f66f97dd2fa757103cd607154306 (patch)
tree56370a0daea4c915e8a10f24a8c3257f939c6f27
parent413defe90cbe4fecc20afcfaf726caf6ca7beafa (diff)
downloadchromium_src-562b7ad53bc7f66f97dd2fa757103cd607154306.zip
chromium_src-562b7ad53bc7f66f97dd2fa757103cd607154306.tar.gz
chromium_src-562b7ad53bc7f66f97dd2fa757103cd607154306.tar.bz2
Skip occluded tiles during rasterization.
This causes the LayerRasterTileIterator to skip occluded tiles by tracking the occlusion for each layer and then determining whether each tile is occluded or not. The occlusion information is stored on the tile. Another CL will be created to store the occlusion information on the TilePriority instead so that the same tile can have different occlusion on each tree. This patch depends on https://codereview.chromium.org/246673005 or similar changes that cause the raster iterator to be used. BUG=178971 Review URL: https://codereview.chromium.org/316093002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279195 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/layers/layer_impl.h3
-rw-r--r--cc/layers/picture_image_layer_impl_unittest.cc2
-rw-r--r--cc/layers/picture_layer_impl.cc39
-rw-r--r--cc/layers/picture_layer_impl.h6
-rw-r--r--cc/layers/picture_layer_impl_unittest.cc305
-rw-r--r--cc/resources/picture_layer_tiling.cc19
-rw-r--r--cc/resources/picture_layer_tiling.h14
-rw-r--r--cc/resources/picture_layer_tiling_perftest.cc20
-rw-r--r--cc/resources/picture_layer_tiling_unittest.cc133
-rw-r--r--cc/resources/tile.cc1
-rw-r--r--cc/resources/tile.h4
-rw-r--r--cc/resources/tile_manager_perftest.cc2
-rw-r--r--cc/resources/tile_manager_unittest.cc64
-rw-r--r--cc/trees/layer_tree_impl.cc27
-rw-r--r--cc/trees/layer_tree_settings.cc3
-rw-r--r--cc/trees/layer_tree_settings.h1
16 files changed, 564 insertions, 79 deletions
diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h
index 6632060..5e29a1c 100644
--- a/cc/layers/layer_impl.h
+++ b/cc/layers/layer_impl.h
@@ -190,7 +190,8 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
virtual RenderPass::Id FirstContributingRenderPassId() const;
virtual RenderPass::Id NextContributingRenderPassId(RenderPass::Id id) const;
- virtual void UpdateTiles() {}
+ virtual void UpdateTiles(
+ const OcclusionTracker<LayerImpl>* occlusion_tracker) {}
virtual void NotifyTileStateChanged(const Tile* tile) {}
virtual ScrollbarLayerImplBase* ToScrollbarLayer();
diff --git a/cc/layers/picture_image_layer_impl_unittest.cc b/cc/layers/picture_image_layer_impl_unittest.cc
index 9dfdf0a..456c6ee 100644
--- a/cc/layers/picture_image_layer_impl_unittest.cc
+++ b/cc/layers/picture_image_layer_impl_unittest.cc
@@ -84,7 +84,7 @@ class PictureImageLayerImplTest : public testing::Test {
maximum_animation_contents_scale;
layer->draw_properties().screen_space_transform_is_animating =
animating_transform_to_screen;
- layer->UpdateTiles();
+ layer->UpdateTiles(NULL);
}
protected:
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc
index b058e2b..3694e7c 100644
--- a/cc/layers/picture_layer_impl.cc
+++ b/cc/layers/picture_layer_impl.cc
@@ -393,11 +393,18 @@ void PictureLayerImpl::AppendQuads(
CleanUpTilingsOnActiveLayer(seen_tilings);
}
-void PictureLayerImpl::UpdateTiles() {
+void PictureLayerImpl::UpdateTiles(
+ const OcclusionTracker<LayerImpl>* occlusion_tracker) {
TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTiles");
DoPostCommitInitializationIfNeeded();
+ // TODO(danakj): We should always get an occlusion tracker when we are using
+ // occlusion, so update this check when we don't use a pending tree in the
+ // browser compositor.
+ DCHECK(!occlusion_tracker ||
+ layer_tree_impl()->settings().use_occlusion_for_tile_prioritization);
+
if (layer_tree_impl()->device_viewport_valid_for_tile_management()) {
visible_rect_for_tile_priority_ = visible_content_rect();
viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize();
@@ -435,13 +442,14 @@ void PictureLayerImpl::UpdateTiles() {
// non-updated tree which will then be updated immediately afterwards.
should_update_tile_priorities_ = true;
- UpdateTilePriorities();
+ UpdateTilePriorities(occlusion_tracker);
if (layer_tree_impl()->IsPendingTree())
MarkVisibleResourcesAsRequired();
}
-void PictureLayerImpl::UpdateTilePriorities() {
+void PictureLayerImpl::UpdateTilePriorities(
+ const OcclusionTracker<LayerImpl>* occlusion_tracker) {
TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities");
double current_frame_time_in_seconds =
@@ -483,7 +491,10 @@ void PictureLayerImpl::UpdateTilePriorities() {
tilings_->tiling_at(i)->UpdateTilePriorities(tree,
visible_layer_rect,
MaximumTilingContentsScale(),
- current_frame_time_in_seconds);
+ current_frame_time_in_seconds,
+ occlusion_tracker,
+ render_target(),
+ draw_transform());
}
// Tile priorities were modified.
@@ -714,7 +725,11 @@ void PictureLayerImpl::SyncTiling(
// we can create tiles for this tiling immediately.
if (!layer_tree_impl()->needs_update_draw_properties() &&
should_update_tile_priorities_) {
- UpdateTilePriorities();
+ // TODO(danakj): Add a DCHECK() that we are not using occlusion tracking
+ // when we stop using the pending tree in the browser compositor. If we want
+ // to support occlusion tracking here, we need to dirty the draw properties
+ // or save occlusion as a draw property.
+ UpdateTilePriorities(NULL);
}
}
@@ -877,6 +892,10 @@ bool PictureLayerImpl::MarkVisibleTilesAsRequired(
if (!tile)
continue;
+ // If the tile is occluded, don't mark it as required for activation.
+ if (tile->is_occluded())
+ continue;
+
// If the missing region doesn't cover it, this tile is fully
// covered by acceptable tiles at other scales.
if (!missing_region.Intersects(iter.geometry_rect()))
@@ -1451,7 +1470,8 @@ PictureLayerImpl::LayerRasterTileIterator::LayerRasterTileIterator(
IteratorType index = stages_[current_stage_].iterator_type;
TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type;
- if (!iterators_[index] || iterators_[index].get_type() != tile_type)
+ if (!iterators_[index] || iterators_[index].get_type() != tile_type ||
+ (*iterators_[index])->is_occluded())
++(*this);
}
@@ -1471,6 +1491,10 @@ operator++() {
if (iterators_[index])
++iterators_[index];
+ while (iterators_[index] && iterators_[index].get_type() == tile_type &&
+ (*iterators_[index])->is_occluded())
+ ++iterators_[index];
+
if (iterators_[index] && iterators_[index].get_type() == tile_type)
return *this;
@@ -1481,7 +1505,8 @@ operator++() {
index = stages_[current_stage_].iterator_type;
tile_type = stages_[current_stage_].tile_type;
- if (iterators_[index] && iterators_[index].get_type() == tile_type)
+ if (iterators_[index] && iterators_[index].get_type() == tile_type &&
+ !(*iterators_[index])->is_occluded())
break;
++current_stage_;
}
diff --git a/cc/layers/picture_layer_impl.h b/cc/layers/picture_layer_impl.h
index b9db60f..e8eba29 100644
--- a/cc/layers/picture_layer_impl.h
+++ b/cc/layers/picture_layer_impl.h
@@ -91,7 +91,8 @@ class CC_EXPORT PictureLayerImpl
virtual void AppendQuads(RenderPass* render_pass,
const OcclusionTracker<LayerImpl>& occlusion_tracker,
AppendQuadsData* append_quads_data) OVERRIDE;
- virtual void UpdateTiles() OVERRIDE;
+ virtual void UpdateTiles(
+ const OcclusionTracker<LayerImpl>* occlusion_tracker) OVERRIDE;
virtual void NotifyTileStateChanged(const Tile* tile) OVERRIDE;
virtual void DidBecomeActive() OVERRIDE;
virtual void DidBeginTracing() OVERRIDE;
@@ -139,7 +140,8 @@ class CC_EXPORT PictureLayerImpl
void RemoveAllTilings();
void SyncFromActiveLayer(const PictureLayerImpl* other);
void AddTilingsForRasterScale();
- void UpdateTilePriorities();
+ void UpdateTilePriorities(
+ const OcclusionTracker<LayerImpl>* occlusion_tracker);
virtual bool ShouldAdjustRasterScale() const;
virtual void RecalculateRasterScales();
void CleanUpTilingsOnActiveLayer(
diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc
index 97ebf54..f6fc3ef 100644
--- a/cc/layers/picture_layer_impl_unittest.cc
+++ b/cc/layers/picture_layer_impl_unittest.cc
@@ -153,7 +153,7 @@ class PictureLayerImplTest : public testing::Test {
maximum_animation_contents_scale;
layer->draw_properties().screen_space_transform_is_animating =
animating_transform_to_screen;
- layer->UpdateTiles();
+ layer->UpdateTiles(NULL);
}
static void VerifyAllTilesExistAndHavePile(
const PictureLayerTiling* tiling,
@@ -326,7 +326,7 @@ TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) {
transform, viewport, viewport, valid_for_tile_management);
active_layer_->draw_properties().visible_content_rect = viewport;
active_layer_->draw_properties().screen_space_transform = transform;
- active_layer_->UpdateTiles();
+ active_layer_->UpdateTiles(NULL);
gfx::Rect visible_rect_for_tile_priority =
active_layer_->visible_rect_for_tile_priority();
@@ -348,7 +348,7 @@ TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) {
active_layer_->draw_properties().screen_space_transform = transform;
host_impl_.SetExternalDrawConstraints(
transform, viewport, viewport, valid_for_tile_management);
- active_layer_->UpdateTiles();
+ active_layer_->UpdateTiles(NULL);
EXPECT_RECT_EQ(visible_rect_for_tile_priority,
active_layer_->visible_rect_for_tile_priority());
@@ -364,7 +364,7 @@ TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) {
valid_for_tile_management = true;
host_impl_.SetExternalDrawConstraints(
transform, viewport, viewport, valid_for_tile_management);
- active_layer_->UpdateTiles();
+ active_layer_->UpdateTiles(NULL);
EXPECT_FALSE(visible_rect_for_tile_priority ==
active_layer_->visible_rect_for_tile_priority());
@@ -401,7 +401,7 @@ TEST_F(PictureLayerImplTest, InvalidViewportAfterReleaseResources) {
EXPECT_TRUE(active_layer_->HighResTiling());
size_t num_tilings = active_layer_->num_tilings();
- active_layer_->UpdateTiles();
+ active_layer_->UpdateTiles(NULL);
pending_layer_->AddTiling(0.5f);
EXPECT_EQ(num_tilings + 1, active_layer_->num_tilings());
}
@@ -2419,7 +2419,7 @@ TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) {
transform, viewport, viewport, valid_for_tile_management);
active_layer_->draw_properties().visible_content_rect = viewport;
active_layer_->draw_properties().screen_space_transform = transform;
- active_layer_->UpdateTiles();
+ active_layer_->UpdateTiles(NULL);
gfx::Rect visible_rect_for_tile_priority =
active_layer_->visible_rect_for_tile_priority();
@@ -2441,7 +2441,7 @@ TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) {
active_layer_->draw_properties().screen_space_transform = transform;
host_impl_.SetExternalDrawConstraints(
transform, viewport, viewport, valid_for_tile_management);
- active_layer_->UpdateTiles();
+ active_layer_->UpdateTiles(NULL);
EXPECT_RECT_EQ(visible_rect_for_tile_priority,
active_layer_->visible_rect_for_tile_priority());
@@ -2457,7 +2457,7 @@ TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) {
valid_for_tile_management = true;
host_impl_.SetExternalDrawConstraints(
transform, viewport, viewport, valid_for_tile_management);
- active_layer_->UpdateTiles();
+ active_layer_->UpdateTiles(NULL);
EXPECT_FALSE(visible_rect_for_tile_priority ==
active_layer_->visible_rect_for_tile_priority());
@@ -2494,7 +2494,7 @@ TEST_F(NoLowResPictureLayerImplTest, InvalidViewportAfterReleaseResources) {
EXPECT_TRUE(active_layer_->HighResTiling());
size_t num_tilings = active_layer_->num_tilings();
- active_layer_->UpdateTiles();
+ active_layer_->UpdateTiles(NULL);
pending_layer_->AddTiling(0.5f);
EXPECT_EQ(num_tilings + 1, active_layer_->num_tilings());
}
@@ -2807,5 +2807,292 @@ TEST_F(PictureLayerImplTest, UpdateTilesForMasksWithNoVisibleContent) {
EXPECT_NE(0u, pending_mask_content->num_tilings());
}
+class OcclusionTrackingSettings : public ImplSidePaintingSettings {
+ public:
+ OcclusionTrackingSettings() { use_occlusion_for_tile_prioritization = true; }
+};
+
+class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest {
+ public:
+ OcclusionTrackingPictureLayerImplTest()
+ : PictureLayerImplTest(OcclusionTrackingSettings()) {}
+};
+
+TEST_F(OcclusionTrackingPictureLayerImplTest,
+ OccludedTilesSkippedDuringRasterization) {
+ gfx::Size tile_size(102, 102);
+ gfx::Size layer_bounds(1000, 1000);
+ gfx::Size viewport_size(500, 500);
+ gfx::Point occluding_layer_position(310, 0);
+
+ scoped_refptr<FakePicturePileImpl> pending_pile =
+ FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
+ SetupPendingTree(pending_pile);
+ pending_layer_->set_fixed_tile_size(tile_size);
+
+ host_impl_.SetViewportSize(viewport_size);
+ host_impl_.pending_tree()->UpdateDrawProperties();
+
+ // No occlusion.
+ int unoccluded_tile_count = 0;
+ for (PictureLayerImpl::LayerRasterTileIterator it =
+ PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false);
+ it;
+ ++it) {
+ Tile* tile = *it;
+
+ // Occluded tiles should not be iterated over.
+ EXPECT_FALSE(tile->is_occluded());
+
+ // Some tiles may not be visible (i.e. outside the viewport). The rest are
+ // visible and at least partially unoccluded, verified by the above expect.
+ bool tile_is_visible =
+ tile->content_rect().Intersects(pending_layer_->visible_content_rect());
+ if (tile_is_visible)
+ unoccluded_tile_count++;
+ }
+ EXPECT_EQ(unoccluded_tile_count, 25 + 4);
+
+ // Partial occlusion.
+ pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1));
+ LayerImpl* layer1 = pending_layer_->children()[0];
+ layer1->SetBounds(layer_bounds);
+ layer1->SetContentBounds(layer_bounds);
+ layer1->SetDrawsContent(true);
+ layer1->SetContentsOpaque(true);
+ layer1->SetPosition(occluding_layer_position);
+
+ host_impl_.pending_tree()->UpdateDrawProperties();
+
+ unoccluded_tile_count = 0;
+ for (PictureLayerImpl::LayerRasterTileIterator it =
+ PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false);
+ it;
+ ++it) {
+ Tile* tile = *it;
+
+ EXPECT_FALSE(tile->is_occluded());
+
+ bool tile_is_visible =
+ tile->content_rect().Intersects(pending_layer_->visible_content_rect());
+ if (tile_is_visible)
+ unoccluded_tile_count++;
+ }
+ EXPECT_EQ(unoccluded_tile_count, 20 + 2);
+
+ // Full occlusion.
+ layer1->SetPosition(gfx::Point(0, 0));
+
+ host_impl_.pending_tree()->UpdateDrawProperties();
+
+ unoccluded_tile_count = 0;
+ for (PictureLayerImpl::LayerRasterTileIterator it =
+ PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false);
+ it;
+ ++it) {
+ Tile* tile = *it;
+
+ EXPECT_FALSE(tile->is_occluded());
+
+ bool tile_is_visible =
+ tile->content_rect().Intersects(pending_layer_->visible_content_rect());
+ if (tile_is_visible)
+ unoccluded_tile_count++;
+ }
+ EXPECT_EQ(unoccluded_tile_count, 0);
+}
+
+TEST_F(OcclusionTrackingPictureLayerImplTest,
+ OccludedTilesNotMarkedAsRequired) {
+ gfx::Size tile_size(102, 102);
+ gfx::Size layer_bounds(1000, 1000);
+ gfx::Size viewport_size(500, 500);
+ gfx::Point occluding_layer_position(310, 0);
+
+ scoped_refptr<FakePicturePileImpl> pending_pile =
+ FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
+ SetupPendingTree(pending_pile);
+ pending_layer_->set_fixed_tile_size(tile_size);
+
+ host_impl_.SetViewportSize(viewport_size);
+ host_impl_.pending_tree()->UpdateDrawProperties();
+
+ // No occlusion.
+ int occluded_tile_count = 0;
+ for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
+ PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
+
+ occluded_tile_count = 0;
+ for (PictureLayerTiling::CoverageIterator iter(
+ tiling,
+ pending_layer_->contents_scale_x(),
+ gfx::Rect(layer_bounds));
+ iter;
+ ++iter) {
+ if (!*iter)
+ continue;
+ const Tile* tile = *iter;
+
+ // Fully occluded tiles are not required for activation.
+ if (tile->is_occluded()) {
+ EXPECT_FALSE(tile->required_for_activation());
+ occluded_tile_count++;
+ }
+ }
+ EXPECT_EQ(occluded_tile_count, 0);
+ }
+
+ // Partial occlusion.
+ pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1));
+ LayerImpl* layer1 = pending_layer_->children()[0];
+ layer1->SetBounds(layer_bounds);
+ layer1->SetContentBounds(layer_bounds);
+ layer1->SetDrawsContent(true);
+ layer1->SetContentsOpaque(true);
+ layer1->SetPosition(occluding_layer_position);
+
+ host_impl_.pending_tree()->UpdateDrawProperties();
+
+ for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
+ PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
+
+ occluded_tile_count = 0;
+ for (PictureLayerTiling::CoverageIterator iter(
+ tiling,
+ pending_layer_->contents_scale_x(),
+ gfx::Rect(layer_bounds));
+ iter;
+ ++iter) {
+ if (!*iter)
+ continue;
+ const Tile* tile = *iter;
+
+ if (tile->is_occluded()) {
+ EXPECT_FALSE(tile->required_for_activation());
+ occluded_tile_count++;
+ }
+ }
+ switch (i) {
+ case 0:
+ EXPECT_EQ(occluded_tile_count, 5);
+ break;
+ case 1:
+ EXPECT_EQ(occluded_tile_count, 2);
+ break;
+ default:
+ NOTREACHED();
+ }
+ }
+
+ // Full occlusion.
+ layer1->SetPosition(gfx::PointF(0, 0));
+
+ host_impl_.pending_tree()->UpdateDrawProperties();
+
+ for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
+ PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
+
+ occluded_tile_count = 0;
+ for (PictureLayerTiling::CoverageIterator iter(
+ tiling,
+ pending_layer_->contents_scale_x(),
+ gfx::Rect(layer_bounds));
+ iter;
+ ++iter) {
+ if (!*iter)
+ continue;
+ const Tile* tile = *iter;
+
+ if (tile->is_occluded()) {
+ EXPECT_FALSE(tile->required_for_activation());
+ occluded_tile_count++;
+ }
+ }
+ switch (i) {
+ case 0:
+ EXPECT_EQ(occluded_tile_count, 25);
+ break;
+ case 1:
+ EXPECT_EQ(occluded_tile_count, 4);
+ break;
+ default:
+ NOTREACHED();
+ }
+ }
+}
+
+TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForDifferentScales) {
+ gfx::Size tile_size(102, 102);
+ gfx::Size layer_bounds(1000, 1000);
+ gfx::Size viewport_size(500, 500);
+ gfx::Point occluding_layer_position(310, 0);
+
+ scoped_refptr<FakePicturePileImpl> pending_pile =
+ FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
+ SetupPendingTree(pending_pile);
+ pending_layer_->set_fixed_tile_size(tile_size);
+
+ ASSERT_TRUE(pending_layer_->CanHaveTilings());
+
+ float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
+
+ std::vector<PictureLayerTiling*> tilings;
+ tilings.push_back(pending_layer_->AddTiling(low_res_factor));
+ tilings.push_back(pending_layer_->AddTiling(0.3f));
+ tilings.push_back(pending_layer_->AddTiling(0.7f));
+ tilings.push_back(pending_layer_->AddTiling(1.0f));
+ tilings.push_back(pending_layer_->AddTiling(2.0f));
+
+ pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1));
+ LayerImpl* layer1 = pending_layer_->children()[0];
+ layer1->SetBounds(layer_bounds);
+ layer1->SetContentBounds(layer_bounds);
+ layer1->SetDrawsContent(true);
+ layer1->SetContentsOpaque(true);
+ layer1->SetPosition(occluding_layer_position);
+
+ host_impl_.SetViewportSize(viewport_size);
+ host_impl_.pending_tree()->UpdateDrawProperties();
+
+ int tiling_count = 0;
+ int occluded_tile_count = 0;
+ for (std::vector<PictureLayerTiling*>::iterator tiling_iterator =
+ tilings.begin();
+ tiling_iterator != tilings.end();
+ ++tiling_iterator) {
+ std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting();
+
+ occluded_tile_count = 0;
+ for (size_t i = 0; i < tiles.size(); ++i) {
+ if (tiles[i]->is_occluded()) {
+ gfx::Rect scaled_content_rect = ScaleToEnclosingRect(
+ tiles[i]->content_rect(), 1.0f / tiles[i]->contents_scale());
+ EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x());
+ occluded_tile_count++;
+ }
+ }
+ switch (tiling_count) {
+ case 0:
+ case 1:
+ EXPECT_EQ(occluded_tile_count, 2);
+ break;
+ case 2:
+ EXPECT_EQ(occluded_tile_count, 4);
+ break;
+ case 3:
+ EXPECT_EQ(occluded_tile_count, 5);
+ break;
+ case 4:
+ EXPECT_EQ(occluded_tile_count, 30);
+ break;
+ default:
+ NOTREACHED();
+ }
+
+ tiling_count++;
+ }
+
+ EXPECT_EQ(tiling_count, 5);
+}
} // namespace
} // namespace cc
diff --git a/cc/resources/picture_layer_tiling.cc b/cc/resources/picture_layer_tiling.cc
index 5a41951..33e9038 100644
--- a/cc/resources/picture_layer_tiling.cc
+++ b/cc/resources/picture_layer_tiling.cc
@@ -12,6 +12,7 @@
#include "cc/base/math_util.h"
#include "cc/resources/tile.h"
#include "cc/resources/tile_priority.h"
+#include "cc/trees/occlusion_tracker.h"
#include "ui/gfx/point_conversions.h"
#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/safe_integer_conversions.h"
@@ -419,7 +420,10 @@ void PictureLayerTiling::UpdateTilePriorities(
WhichTree tree,
const gfx::Rect& visible_layer_rect,
float layer_contents_scale,
- double current_frame_time_in_seconds) {
+ double current_frame_time_in_seconds,
+ const OcclusionTracker<LayerImpl>* occlusion_tracker,
+ const LayerImpl* render_target,
+ const gfx::Transform& draw_transform) {
if (!NeedsUpdateForFrameAtTime(current_frame_time_in_seconds)) {
// This should never be zero for the purposes of has_ever_been_updated().
DCHECK_NE(current_frame_time_in_seconds, 0.0);
@@ -479,6 +483,19 @@ void PictureLayerTiling::UpdateTilePriorities(
Tile* tile = find->second.get();
tile->SetPriority(tree, now_priority);
+
+ // Set whether tile is occluded or not.
+ bool is_occluded = false;
+ if (occlusion_tracker) {
+ gfx::Rect tile_query_rect = ScaleToEnclosingRect(
+ IntersectRects(tile->content_rect(), visible_rect_in_content_space),
+ 1.0f / contents_scale_);
+ // TODO(vmpstr): Remove render_target and draw_transform from the
+ // parameters so they can be hidden from the tiling.
+ is_occluded = occlusion_tracker->Occluded(
+ render_target, tile_query_rect, draw_transform);
+ }
+ tile->set_is_occluded(is_occluded);
}
// Assign soon priority to skewport tiles.
diff --git a/cc/resources/picture_layer_tiling.h b/cc/resources/picture_layer_tiling.h
index fc7505c..df58618 100644
--- a/cc/resources/picture_layer_tiling.h
+++ b/cc/resources/picture_layer_tiling.h
@@ -20,6 +20,8 @@
namespace cc {
+template <typename LayerType>
+class OcclusionTracker;
class PictureLayerTiling;
class CC_EXPORT PictureLayerTilingClient {
@@ -206,10 +208,14 @@ class CC_EXPORT PictureLayerTiling {
void Reset();
- void UpdateTilePriorities(WhichTree tree,
- const gfx::Rect& visible_layer_rect,
- float layer_contents_scale,
- double current_frame_time_in_seconds);
+ void UpdateTilePriorities(
+ WhichTree tree,
+ const gfx::Rect& visible_layer_rect,
+ float layer_contents_scale,
+ double current_frame_time_in_seconds,
+ const OcclusionTracker<LayerImpl>* occlusion_tracker,
+ const LayerImpl* render_target,
+ const gfx::Transform& draw_transform);
// Copies the src_tree priority into the dst_tree priority for all tiles.
// The src_tree priority is reset to the lowest priority possible. This
diff --git a/cc/resources/picture_layer_tiling_perftest.cc b/cc/resources/picture_layer_tiling_perftest.cc
index 1e698b9..e956d17b 100644
--- a/cc/resources/picture_layer_tiling_perftest.cc
+++ b/cc/resources/picture_layer_tiling_perftest.cc
@@ -53,8 +53,13 @@ class PictureLayerTilingPerfTest : public testing::Test {
timer_.Reset();
do {
- picture_layer_tiling_->UpdateTilePriorities(
- ACTIVE_TREE, viewport_rect, 1.f, timer_.NumLaps() + 1);
+ picture_layer_tiling_->UpdateTilePriorities(ACTIVE_TREE,
+ viewport_rect,
+ 1.f,
+ timer_.NumLaps() + 1,
+ NULL,
+ NULL,
+ gfx::Transform());
timer_.NextLap();
} while (!timer_.HasTimeLimitExpired());
@@ -78,8 +83,13 @@ class PictureLayerTilingPerfTest : public testing::Test {
timer_.Reset();
do {
- picture_layer_tiling_->UpdateTilePriorities(
- ACTIVE_TREE, viewport_rect, 1.f, timer_.NumLaps() + 1);
+ picture_layer_tiling_->UpdateTilePriorities(ACTIVE_TREE,
+ viewport_rect,
+ 1.f,
+ timer_.NumLaps() + 1,
+ NULL,
+ NULL,
+ gfx::Transform());
viewport_rect = gfx::Rect(viewport_rect.x() + xoffsets[offsetIndex],
viewport_rect.y() + yoffsets[offsetIndex],
@@ -108,7 +118,7 @@ class PictureLayerTilingPerfTest : public testing::Test {
picture_layer_tiling_ =
PictureLayerTiling::Create(1, bounds, &picture_layer_tiling_client_);
picture_layer_tiling_->UpdateTilePriorities(
- ACTIVE_TREE, viewport, 1.0f, 1.0);
+ ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform());
timer_.Reset();
do {
diff --git a/cc/resources/picture_layer_tiling_unittest.cc b/cc/resources/picture_layer_tiling_unittest.cc
index bfdd6fc..9743a82 100644
--- a/cc/resources/picture_layer_tiling_unittest.cc
+++ b/cc/resources/picture_layer_tiling_unittest.cc
@@ -43,7 +43,10 @@ static void UpdateAllTilePriorities(PictureLayerTilingSet* set,
set->tiling_at(i)->UpdateTilePriorities(tree,
visible_layer_rect,
layer_contents_scale,
- current_frame_time_in_seconds);
+ current_frame_time_in_seconds,
+ NULL,
+ NULL,
+ gfx::Transform());
}
}
@@ -315,7 +318,8 @@ TEST(PictureLayerTilingTest, SkewportLimits) {
client.SetTileSize(gfx::Size(100, 100));
tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client);
- tiling->UpdateTilePriorities(ACTIVE_TREE, viewport, 1.f, 1.0);
+ tiling->UpdateTilePriorities(
+ ACTIVE_TREE, viewport, 1.f, 1.0, NULL, NULL, gfx::Transform());
// Move viewport down 50 pixels in 0.5 seconds.
gfx::Rect down_skewport =
@@ -380,7 +384,8 @@ TEST(PictureLayerTilingTest, ComputeSkewport) {
client.SetTileSize(gfx::Size(100, 100));
tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client);
- tiling->UpdateTilePriorities(ACTIVE_TREE, viewport, 1.f, 1.0);
+ tiling->UpdateTilePriorities(
+ ACTIVE_TREE, viewport, 1.f, 1.0, NULL, NULL, gfx::Transform());
// Move viewport down 50 pixels in 0.5 seconds.
gfx::Rect down_skewport =
@@ -446,7 +451,8 @@ TEST(PictureLayerTilingTest, ViewportDistanceWithScale) {
gfx::Rect viewport_in_content_space =
gfx::ToEnclosedRect(gfx::ScaleRect(viewport, 0.25f));
- tiling->UpdateTilePriorities(ACTIVE_TREE, viewport, 1.f, 1.0);
+ tiling->UpdateTilePriorities(
+ ACTIVE_TREE, viewport, 1.f, 1.0, NULL, NULL, gfx::Transform());
gfx::Rect soon_rect = viewport;
soon_rect.Inset(-312.f, -312.f, -312.f, -312.f);
@@ -529,7 +535,8 @@ TEST(PictureLayerTilingTest, ViewportDistanceWithScale) {
EXPECT_EQ(25, skewport.width());
EXPECT_EQ(35, skewport.height());
- tiling->UpdateTilePriorities(ACTIVE_TREE, viewport, 1.f, 2.0);
+ tiling->UpdateTilePriorities(
+ ACTIVE_TREE, viewport, 1.f, 2.0, NULL, NULL, gfx::Transform());
have_now = false;
have_eventually = false;
@@ -579,7 +586,8 @@ TEST(PictureLayerTilingTest, ViewportDistanceWithScale) {
EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible);
// Change the underlying layer scale.
- tiling->UpdateTilePriorities(ACTIVE_TREE, viewport, 2.0f, 3.0);
+ tiling->UpdateTilePriorities(
+ ACTIVE_TREE, viewport, 2.0f, 3.0, NULL, NULL, gfx::Transform());
priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE);
EXPECT_FLOAT_EQ(34.f, priority.distance_to_visible);
@@ -822,7 +830,8 @@ TEST(PictureLayerTilingTest, TilingRasterTileIteratorStaticViewport) {
client.SetTileSize(gfx::Size(30, 30));
tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client);
- tiling->UpdateTilePriorities(ACTIVE_TREE, viewport, 1.0f, 1.0);
+ tiling->UpdateTilePriorities(
+ ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform());
PictureLayerTiling::TilingRasterTileIterator empty_iterator;
EXPECT_FALSE(empty_iterator);
@@ -929,8 +938,10 @@ TEST(PictureLayerTilingTest, TilingRasterTileIteratorMovingViewport) {
client.SetTileSize(gfx::Size(30, 30));
tiling = TestablePictureLayerTiling::Create(1.f, layer_bounds, &client);
- tiling->UpdateTilePriorities(ACTIVE_TREE, viewport, 1.0f, 1.0);
- tiling->UpdateTilePriorities(ACTIVE_TREE, moved_viewport, 1.0f, 2.0);
+ tiling->UpdateTilePriorities(
+ ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform());
+ tiling->UpdateTilePriorities(
+ ACTIVE_TREE, moved_viewport, 1.0f, 2.0, NULL, NULL, gfx::Transform());
gfx::Rect soon_rect = moved_viewport;
soon_rect.Inset(-312.f, -312.f, -312.f, -312.f);
@@ -1002,7 +1013,8 @@ TEST(PictureLayerTilingTest, TilingEvictionTileIteratorStaticViewport) {
client.SetTileSize(gfx::Size(30, 30));
tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client);
- tiling->UpdateTilePriorities(ACTIVE_TREE, viewport, 1.0f, 1.0);
+ tiling->UpdateTilePriorities(
+ ACTIVE_TREE, viewport, 1.0f, 1.0, NULL, NULL, gfx::Transform());
PictureLayerTiling::TilingRasterTileIterator empty_iterator;
EXPECT_FALSE(empty_iterator);
@@ -1056,14 +1068,20 @@ TEST_F(PictureLayerTilingIteratorTest, TilesExist) {
ACTIVE_TREE,
gfx::Rect(layer_bounds), // visible content rect
1.f, // current contents scale
- 1.0); // current frame time
+ 1.0, // current frame time
+ NULL, // occlusion tracker
+ NULL, // render target
+ gfx::Transform()); // draw transform
VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, true));
// Make the viewport rect empty. All tiles are killed and become zombies.
tiling_->UpdateTilePriorities(ACTIVE_TREE,
- gfx::Rect(), // visible content rect
- 1.f, // current contents scale
- 2.0); // current frame time
+ gfx::Rect(), // visible content rect
+ 1.f, // current contents scale
+ 2.0, // current frame time
+ NULL, // occlusion tracker
+ NULL, // render target
+ gfx::Transform()); // draw transform
VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false));
}
@@ -1079,14 +1097,20 @@ TEST_F(PictureLayerTilingIteratorTest, TilesExistGiantViewport) {
ACTIVE_TREE,
gfx::Rect(layer_bounds), // visible content rect
1.f, // current contents scale
- 1.0); // current frame time
+ 1.0, // current frame time
+ NULL, // occlusion tracker
+ NULL, // render target
+ gfx::Transform()); // draw transform
VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, true));
// If the visible content rect is empty, it should still have live tiles.
tiling_->UpdateTilePriorities(ACTIVE_TREE,
- giant_rect, // visible content rect
- 1.f, // current contents scale
- 2.0); // current frame time
+ giant_rect, // visible content rect
+ 1.f, // current contents scale
+ 2.0, // current frame time
+ NULL, // occlusion tracker
+ NULL, // render target
+ gfx::Transform()); // draw transform
VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, true));
}
@@ -1102,9 +1126,12 @@ TEST_F(PictureLayerTilingIteratorTest, TilesExistOutsideViewport) {
EXPECT_FALSE(viewport_rect.Intersects(gfx::Rect(layer_bounds)));
tiling_->UpdateTilePriorities(ACTIVE_TREE,
- viewport_rect, // visible content rect
- 1.f, // current contents scale
- 1.0); // current frame time
+ viewport_rect, // visible content rect
+ 1.f, // current contents scale
+ 1.0, // current frame time
+ NULL, // occlusion tracker
+ NULL, // render target
+ gfx::Transform()); // draw transform
VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, true));
}
@@ -1130,9 +1157,12 @@ TEST_F(PictureLayerTilingIteratorTest,
set_max_tiles_for_interest_area(1);
tiling_->UpdateTilePriorities(ACTIVE_TREE,
- visible_rect, // visible content rect
- 1.f, // current contents scale
- 1.0); // current frame time
+ visible_rect, // visible content rect
+ 1.f, // current contents scale
+ 1.0, // current frame time
+ NULL, // occlusion tracker
+ NULL, // render target
+ gfx::Transform()); // draw transform
VerifyTiles(1.f,
gfx::Rect(layer_bounds),
base::Bind(&TilesIntersectingRectExist, visible_rect, true));
@@ -1157,7 +1187,10 @@ TEST_F(PictureLayerTilingIteratorTest,
ACTIVE_TREE,
gfx::Rect(layer_bounds), // visible content rect
1.f, // current contents scale
- 1.0); // current frame time
+ 1.0, // current frame time
+ NULL, // occlusion tracker
+ NULL, // render target
+ gfx::Transform()); // draw transform
int num_tiles = 0;
VerifyTiles(1.f,
@@ -1246,7 +1279,10 @@ TEST(UpdateTilePrioritiesTest, VisibleTiles) {
tiling->UpdateTilePriorities(ACTIVE_TREE,
viewport_in_layer_space,
current_layer_contents_scale,
- current_frame_time_in_seconds);
+ current_frame_time_in_seconds,
+ NULL, // occlusion tracker
+ NULL, // render target
+ gfx::Transform()); // draw transform
ASSERT_TRUE(tiling->TileAt(0, 0));
ASSERT_TRUE(tiling->TileAt(0, 1));
@@ -1299,7 +1335,10 @@ TEST(UpdateTilePrioritiesTest, OffscreenTiles) {
tiling->UpdateTilePriorities(ACTIVE_TREE,
viewport_in_layer_space,
current_layer_contents_scale,
- current_frame_time_in_seconds);
+ current_frame_time_in_seconds,
+ NULL, // occlusion tracker
+ NULL, // render target
+ gfx::Transform()); // draw transform
ASSERT_TRUE(tiling->TileAt(0, 0));
ASSERT_TRUE(tiling->TileAt(0, 1));
@@ -1362,7 +1401,10 @@ TEST(UpdateTilePrioritiesTest, PartiallyOffscreenLayer) {
tiling->UpdateTilePriorities(ACTIVE_TREE,
viewport_in_layer_space,
current_layer_contents_scale,
- current_frame_time_in_seconds);
+ current_frame_time_in_seconds,
+ NULL, // occlusion tracker
+ NULL, // render target
+ gfx::Transform()); // draw transform
ASSERT_TRUE(tiling->TileAt(0, 0));
ASSERT_TRUE(tiling->TileAt(0, 1));
@@ -1419,7 +1461,10 @@ TEST(UpdateTilePrioritiesTest, PartiallyOffscreenRotatedLayer) {
tiling->UpdateTilePriorities(ACTIVE_TREE,
viewport_in_layer_space,
current_layer_contents_scale,
- current_frame_time_in_seconds);
+ current_frame_time_in_seconds,
+ NULL, // occlusion tracker
+ NULL, // render target
+ gfx::Transform()); // draw transform
ASSERT_TRUE(tiling->TileAt(0, 0));
ASSERT_TRUE(tiling->TileAt(0, 1));
@@ -1500,7 +1545,10 @@ TEST(UpdateTilePrioritiesTest, PerspectiveLayer) {
tiling->UpdateTilePriorities(ACTIVE_TREE,
viewport_in_layer_space,
current_layer_contents_scale,
- current_frame_time_in_seconds);
+ current_frame_time_in_seconds,
+ NULL, // occlusion tracker
+ NULL, // render target
+ gfx::Transform()); // draw transform
ASSERT_TRUE(tiling->TileAt(0, 0));
ASSERT_TRUE(tiling->TileAt(0, 1));
@@ -1591,7 +1639,10 @@ TEST(UpdateTilePrioritiesTest, PerspectiveLayerClippedByW) {
tiling->UpdateTilePriorities(ACTIVE_TREE,
viewport_in_layer_space,
current_layer_contents_scale,
- current_frame_time_in_seconds);
+ current_frame_time_in_seconds,
+ NULL, // occlusion tracker
+ NULL, // render target
+ gfx::Transform()); // draw transform
ASSERT_TRUE(tiling->TileAt(0, 0));
ASSERT_TRUE(tiling->TileAt(0, 1));
@@ -1653,13 +1704,19 @@ TEST(UpdateTilePrioritiesTest, BasicMotion) {
tiling->UpdateTilePriorities(ACTIVE_TREE,
viewport_in_layer_space,
last_layer_contents_scale,
- last_frame_time_in_seconds);
+ last_frame_time_in_seconds,
+ NULL, // occlusion tracker
+ NULL, // render target
+ gfx::Transform()); // draw transform
// current frame
tiling->UpdateTilePriorities(ACTIVE_TREE,
viewport_in_layer_space,
current_layer_contents_scale,
- current_frame_time_in_seconds);
+ current_frame_time_in_seconds,
+ NULL, // occlusion tracker
+ NULL, // render target
+ gfx::Transform()); // draw transform
ASSERT_TRUE(tiling->TileAt(0, 0));
ASSERT_TRUE(tiling->TileAt(0, 1));
@@ -1728,13 +1785,19 @@ TEST(UpdateTilePrioritiesTest, RotationMotion) {
tiling->UpdateTilePriorities(ACTIVE_TREE,
viewport_in_layer_space,
last_layer_contents_scale,
- last_frame_time_in_seconds);
+ last_frame_time_in_seconds,
+ NULL, // occlusion tracker
+ NULL, // render target
+ gfx::Transform()); // draw transform
// current frame
tiling->UpdateTilePriorities(ACTIVE_TREE,
viewport_in_layer_space,
current_layer_contents_scale,
- current_frame_time_in_seconds);
+ current_frame_time_in_seconds,
+ NULL, // occlusion tracker
+ NULL, // render target
+ gfx::Transform()); // draw transform
ASSERT_TRUE(tiling->TileAt(0, 0));
ASSERT_TRUE(tiling->TileAt(0, 1));
diff --git a/cc/resources/tile.cc b/cc/resources/tile.cc
index d59dc02..781d008 100644
--- a/cc/resources/tile.cc
+++ b/cc/resources/tile.cc
@@ -30,6 +30,7 @@ Tile::Tile(TileManager* tile_manager,
content_rect_(content_rect),
contents_scale_(contents_scale),
opaque_rect_(opaque_rect),
+ is_occluded_(false),
layer_id_(layer_id),
source_frame_number_(source_frame_number),
flags_(flags),
diff --git a/cc/resources/tile.h b/cc/resources/tile.h
index 69ef56f..29acf80 100644
--- a/cc/resources/tile.h
+++ b/cc/resources/tile.h
@@ -128,6 +128,9 @@ class CC_EXPORT Tile : public RefCountedManaged<Tile> {
return managed_state_.tile_versions[mode];
}
+ void set_is_occluded(bool is_occluded) { is_occluded_ = is_occluded; }
+ bool is_occluded() const { return is_occluded_; }
+
private:
friend class TileManager;
friend class PrioritizedTileSet;
@@ -157,6 +160,7 @@ class CC_EXPORT Tile : public RefCountedManaged<Tile> {
gfx::Rect content_rect_;
float contents_scale_;
gfx::Rect opaque_rect_;
+ bool is_occluded_;
TilePriority priority_[NUM_TREES];
ManagedTileState managed_state_;
diff --git a/cc/resources/tile_manager_perftest.cc b/cc/resources/tile_manager_perftest.cc
index cc54fbb..e17c661 100644
--- a/cc/resources/tile_manager_perftest.cc
+++ b/cc/resources/tile_manager_perftest.cc
@@ -277,7 +277,7 @@ class TileManagerPerfTest : public testing::Test {
do {
host_impl_.UpdateCurrentFrameTime();
for (unsigned i = 0; i < layers.size(); ++i)
- layers[i]->UpdateTiles();
+ layers[i]->UpdateTiles(NULL);
GlobalStateThatImpactsTilePriority global_state(GlobalStateForTest());
tile_manager()->ManageTiles(global_state);
diff --git a/cc/resources/tile_manager_unittest.cc b/cc/resources/tile_manager_unittest.cc
index f894c4f..024ca20 100644
--- a/cc/resources/tile_manager_unittest.cc
+++ b/cc/resources/tile_manager_unittest.cc
@@ -638,13 +638,37 @@ TEST_F(TileManagerTileIteratorTest, RasterTileIterator) {
// Renew all of the tile priorities.
gfx::Rect viewport(50, 50, 100, 100);
pending_layer_->HighResTiling()->UpdateTilePriorities(
- PENDING_TREE, viewport, 1.0f, 1.0);
+ PENDING_TREE,
+ viewport,
+ 1.0f,
+ 1.0,
+ NULL,
+ pending_layer_->render_target(),
+ pending_layer_->draw_transform());
pending_layer_->LowResTiling()->UpdateTilePriorities(
- PENDING_TREE, viewport, 1.0f, 1.0);
+ PENDING_TREE,
+ viewport,
+ 1.0f,
+ 1.0,
+ NULL,
+ pending_layer_->render_target(),
+ pending_layer_->draw_transform());
active_layer_->HighResTiling()->UpdateTilePriorities(
- ACTIVE_TREE, viewport, 1.0f, 1.0);
+ ACTIVE_TREE,
+ viewport,
+ 1.0f,
+ 1.0,
+ NULL,
+ active_layer_->render_target(),
+ active_layer_->draw_transform());
active_layer_->LowResTiling()->UpdateTilePriorities(
- ACTIVE_TREE, viewport, 1.0f, 1.0);
+ ACTIVE_TREE,
+ viewport,
+ 1.0f,
+ 1.0,
+ NULL,
+ active_layer_->render_target(),
+ active_layer_->draw_transform());
// Populate all tiles directly from the tilings.
all_tiles.clear();
@@ -815,13 +839,37 @@ TEST_F(TileManagerTileIteratorTest, EvictionTileIterator) {
// Renew all of the tile priorities.
gfx::Rect viewport(50, 50, 100, 100);
pending_layer_->HighResTiling()->UpdateTilePriorities(
- PENDING_TREE, viewport, 1.0f, 1.0);
+ PENDING_TREE,
+ viewport,
+ 1.0f,
+ 1.0,
+ NULL,
+ pending_layer_->render_target(),
+ pending_layer_->draw_transform());
pending_layer_->LowResTiling()->UpdateTilePriorities(
- PENDING_TREE, viewport, 1.0f, 1.0);
+ PENDING_TREE,
+ viewport,
+ 1.0f,
+ 1.0,
+ NULL,
+ pending_layer_->render_target(),
+ pending_layer_->draw_transform());
active_layer_->HighResTiling()->UpdateTilePriorities(
- ACTIVE_TREE, viewport, 1.0f, 1.0);
+ ACTIVE_TREE,
+ viewport,
+ 1.0f,
+ 1.0,
+ NULL,
+ active_layer_->render_target(),
+ active_layer_->draw_transform());
active_layer_->LowResTiling()->UpdateTilePriorities(
- ACTIVE_TREE, viewport, 1.0f, 1.0);
+ ACTIVE_TREE,
+ viewport,
+ 1.0f,
+ 1.0,
+ NULL,
+ active_layer_->render_target(),
+ active_layer_->draw_transform());
// Populate all tiles directly from the tilings.
all_tiles.clear();
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index d5ec804..dccdf8c 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -24,6 +24,7 @@
#include "cc/resources/ui_resource_request.h"
#include "cc/trees/layer_tree_host_common.h"
#include "cc/trees/layer_tree_host_impl.h"
+#include "cc/trees/occlusion_tracker.h"
#include "ui/gfx/point_conversions.h"
#include "ui/gfx/size_conversions.h"
#include "ui/gfx/vector2d_conversions.h"
@@ -486,6 +487,14 @@ bool LayerTreeImpl::UpdateDrawProperties() {
IsActiveTree(),
"SourceFrameNumber",
source_frame_number_);
+ scoped_ptr<OcclusionTracker<LayerImpl> > occlusion_tracker;
+ if (settings().use_occlusion_for_tile_prioritization) {
+ occlusion_tracker.reset(new OcclusionTracker<LayerImpl>(
+ root_layer()->render_surface()->content_rect()));
+ occlusion_tracker->set_minimum_tracking_size(
+ settings().minimum_occlusion_tracking_size);
+ }
+
// LayerIterator is used here instead of CallFunctionForSubtree to only
// UpdateTilePriorities on layers that will be visible (and thus have valid
// draw properties) and not because any ordering is required.
@@ -495,17 +504,27 @@ bool LayerTreeImpl::UpdateDrawProperties() {
LayerIteratorType::Begin(&render_surface_layer_list_);
it != end;
++it) {
+ if (occlusion_tracker)
+ occlusion_tracker->EnterLayer(it);
+
LayerImpl* layer = *it;
if (it.represents_itself())
- layer->UpdateTiles();
+ layer->UpdateTiles(occlusion_tracker.get());
- if (!it.represents_contributing_render_surface())
+ if (!it.represents_contributing_render_surface()) {
+ if (occlusion_tracker)
+ occlusion_tracker->LeaveLayer(it);
continue;
+ }
if (layer->mask_layer())
- layer->mask_layer()->UpdateTiles();
+ layer->mask_layer()->UpdateTiles(occlusion_tracker.get());
if (layer->replica_layer() && layer->replica_layer()->mask_layer())
- layer->replica_layer()->mask_layer()->UpdateTiles();
+ layer->replica_layer()->mask_layer()->UpdateTiles(
+ occlusion_tracker.get());
+
+ if (occlusion_tracker)
+ occlusion_tracker->LeaveLayer(it);
}
}
diff --git a/cc/trees/layer_tree_settings.cc b/cc/trees/layer_tree_settings.cc
index 629b4e2..4b56d7c 100644
--- a/cc/trees/layer_tree_settings.cc
+++ b/cc/trees/layer_tree_settings.cc
@@ -63,7 +63,8 @@ LayerTreeSettings::LayerTreeSettings()
ignore_root_layer_flings(false),
use_rgba_4444_textures(false),
touch_hit_testing(true),
- texture_id_allocation_chunk_size(64) {
+ texture_id_allocation_chunk_size(64),
+ use_occlusion_for_tile_prioritization(false) {
}
LayerTreeSettings::~LayerTreeSettings() {}
diff --git a/cc/trees/layer_tree_settings.h b/cc/trees/layer_tree_settings.h
index 8192b3d..21d72c9 100644
--- a/cc/trees/layer_tree_settings.h
+++ b/cc/trees/layer_tree_settings.h
@@ -79,6 +79,7 @@ class CC_EXPORT LayerTreeSettings {
bool use_rgba_4444_textures;
bool touch_hit_testing;
size_t texture_id_allocation_chunk_size;
+ bool use_occlusion_for_tile_prioritization;
LayerTreeDebugState initial_debug_state;
};