From 8d96434f9b5e6dca2ee4b6417bf7392b3c2a7b70 Mon Sep 17 00:00:00 2001 From: "vollick@chromium.org" Date: Thu, 15 May 2014 18:22:27 +0000 Subject: Remove hit-testing-only RSLL entries As of https://codereview.chromium.org/266913021/ we no longer hit test via the RSLL; we walk the tree instead. This means we can remove the machinery added to allow hidden layers to appear in the RSLL for hit testing purposes. This is essentially a revert of https://codereview.chromium.org/25712004 R=danakj@chromium.org BUG=None Review URL: https://codereview.chromium.org/289973003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270742 0039d316-1c4b-4281-b951-d872f2087c98 --- cc/layers/texture_layer_unittest.cc | 8 --- cc/layers/tiled_layer_impl_unittest.cc | 2 - cc/test/fake_content_layer_impl.cc | 11 +--- cc/test/fake_content_layer_impl.h | 9 --- cc/trees/layer_tree_host.cc | 2 +- cc/trees/layer_tree_host_common.cc | 15 +---- cc/trees/layer_tree_host_impl.cc | 2 +- cc/trees/layer_tree_host_unittest.cc | 35 ----------- cc/trees/layer_tree_impl.h | 3 +- cc/trees/layer_tree_impl_unittest.cc | 104 --------------------------------- cc/trees/occlusion_tracker.cc | 3 - cc/trees/occlusion_tracker_unittest.cc | 39 ------------- 12 files changed, 7 insertions(+), 226 deletions(-) diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc index 97b52f4..be420a5 100644 --- a/cc/layers/texture_layer_unittest.cc +++ b/cc/layers/texture_layer_unittest.cc @@ -924,7 +924,6 @@ TEST_F(TextureLayerImplWithMailboxTest, TestWillDraw) { { scoped_ptr impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1); - impl_layer->SetDrawsContent(true); impl_layer->SetTextureMailbox( test_data_.mailbox1_, SingleReleaseCallback::Create(test_data_.release_mailbox1_)); @@ -934,7 +933,6 @@ TEST_F(TextureLayerImplWithMailboxTest, TestWillDraw) { { scoped_ptr impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1); - impl_layer->SetDrawsContent(true); impl_layer->SetTextureMailbox(TextureMailbox(), scoped_ptr()); EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_HARDWARE)); @@ -944,7 +942,6 @@ TEST_F(TextureLayerImplWithMailboxTest, TestWillDraw) { // Software resource. scoped_ptr impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1); - impl_layer->SetDrawsContent(true); impl_layer->SetTextureMailbox( test_data_.mailbox3_, SingleReleaseCallback::Create(test_data_.release_mailbox3_)); @@ -955,7 +952,6 @@ TEST_F(TextureLayerImplWithMailboxTest, TestWillDraw) { { scoped_ptr impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1); - impl_layer->SetDrawsContent(true); impl_layer->SetTextureMailbox( test_data_.mailbox1_, SingleReleaseCallback::Create(test_data_.release_mailbox1_)); @@ -965,7 +961,6 @@ TEST_F(TextureLayerImplWithMailboxTest, TestWillDraw) { { scoped_ptr impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1); - impl_layer->SetDrawsContent(true); impl_layer->SetTextureMailbox(TextureMailbox(), scoped_ptr()); EXPECT_FALSE(WillDraw(impl_layer.get(), DRAW_MODE_SOFTWARE)); @@ -975,7 +970,6 @@ TEST_F(TextureLayerImplWithMailboxTest, TestWillDraw) { // Software resource. scoped_ptr impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1); - impl_layer->SetDrawsContent(true); impl_layer->SetTextureMailbox( test_data_.mailbox3_, SingleReleaseCallback::Create(test_data_.release_mailbox3_)); @@ -986,7 +980,6 @@ TEST_F(TextureLayerImplWithMailboxTest, TestWillDraw) { { scoped_ptr impl_layer = TextureLayerImpl::Create(host_impl_.active_tree(), 1); - impl_layer->SetDrawsContent(true); impl_layer->SetTextureMailbox( test_data_.mailbox1_, SingleReleaseCallback::Create(test_data_.release_mailbox1_)); @@ -1069,7 +1062,6 @@ TEST_F(TextureLayerImplWithMailboxTest, impl_layer->SetTextureMailbox( test_data_.mailbox1_, SingleReleaseCallback::Create(test_data_.release_mailbox1_)); - impl_layer->SetDrawsContent(true); impl_layer->DidBecomeActive(); EXPECT_TRUE(impl_layer->WillDraw( DRAW_MODE_HARDWARE, host_impl_.active_tree()->resource_provider())); diff --git a/cc/layers/tiled_layer_impl_unittest.cc b/cc/layers/tiled_layer_impl_unittest.cc index 2b18fff..d00fd62 100644 --- a/cc/layers/tiled_layer_impl_unittest.cc +++ b/cc/layers/tiled_layer_impl_unittest.cc @@ -52,8 +52,6 @@ class TiledLayerImplTest : public testing::Test { scoped_ptr layer = CreateLayerNoTiles(tile_size, layer_size, border_texels); - layer->SetDrawsContent(true); - ResourceProvider::ResourceId resource_id = 1; for (int i = 0; i < layer->TilingForTesting()->num_tiles_x(); ++i) { for (int j = 0; j < layer->TilingForTesting()->num_tiles_y(); ++j) { diff --git a/cc/test/fake_content_layer_impl.cc b/cc/test/fake_content_layer_impl.cc index b091d07..7e5a853 100644 --- a/cc/test/fake_content_layer_impl.cc +++ b/cc/test/fake_content_layer_impl.cc @@ -7,9 +7,7 @@ namespace cc { FakeContentLayerImpl::FakeContentLayerImpl(LayerTreeImpl* tree_impl, int id) - : TiledLayerImpl(tree_impl, id), - lost_output_surface_count_(0), - append_quads_count_(0) { + : TiledLayerImpl(tree_impl, id), lost_output_surface_count_(0) { } FakeContentLayerImpl::~FakeContentLayerImpl() {} @@ -28,11 +26,4 @@ void FakeContentLayerImpl::ReleaseResources() { ++lost_output_surface_count_; } -void FakeContentLayerImpl::AppendQuads(QuadSink* quad_sink, - AppendQuadsData* append_quads_data) { - TiledLayerImpl::AppendQuads(quad_sink, append_quads_data); - ++append_quads_count_; -} - - } // namespace cc diff --git a/cc/test/fake_content_layer_impl.h b/cc/test/fake_content_layer_impl.h index 12e7945..4313cad3 100644 --- a/cc/test/fake_content_layer_impl.h +++ b/cc/test/fake_content_layer_impl.h @@ -30,19 +30,10 @@ class FakeContentLayerImpl : public TiledLayerImpl { virtual void ReleaseResources() OVERRIDE; - size_t append_quads_count() const { - return append_quads_count_; - } - void reset_append_quads_count() { append_quads_count_ = 0; } - - virtual void AppendQuads(QuadSink* quad_sink, - AppendQuadsData* append_quads_data) OVERRIDE; - private: explicit FakeContentLayerImpl(LayerTreeImpl* tree_impl, int id); size_t lost_output_surface_count_; - size_t append_quads_count_; }; } // namespace cc diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index e284014..67fe68b 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -1001,7 +1001,7 @@ void LayerTreeHost::PaintLayerContents( if (it.represents_target_render_surface()) { PaintMasksForRenderSurface( *it, queue, did_paint_content, need_more_updates); - } else if (it.represents_itself() && it->DrawsContent()) { + } else if (it.represents_itself()) { DCHECK(!it->paint_properties().bounds.IsEmpty()); *did_paint_content |= it->Update(queue, &occlusion_tracker); *need_more_updates |= it->NeedMoreUpdates(); diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc index a9af3ef..34f4553 100644 --- a/cc/trees/layer_tree_host_common.cc +++ b/cc/trees/layer_tree_host_common.cc @@ -431,10 +431,10 @@ static bool LayerShouldBeSkipped(LayerType* layer, bool layer_is_drawn) { // Layers can be skipped if any of these conditions are met. // - is not drawn due to it or one of its ancestors being hidden (or having // no copy requests). + // - does not draw content. + // - is transparent. // - has empty bounds // - the layer is not double-sided, but its back face is visible. - // - is transparent - // - does not draw content and does not participate in hit testing. // // Some additional conditions need to be computed at a later point after the // recursion is finished. @@ -448,7 +448,7 @@ static bool LayerShouldBeSkipped(LayerType* layer, bool layer_is_drawn) { if (!layer_is_drawn) return true; - if (layer->bounds().IsEmpty()) + if (!layer->DrawsContent() || layer->bounds().IsEmpty()) return true; LayerType* backface_test_layer = layer; @@ -465,13 +465,6 @@ static bool LayerShouldBeSkipped(LayerType* layer, bool layer_is_drawn) { IsLayerBackFaceVisible(backface_test_layer)) return true; - // The layer is visible to events. If it's subject to hit testing, then - // we can't skip it. - bool can_accept_input = !layer->touch_event_handler_region().IsEmpty() || - layer->have_wheel_event_handlers(); - if (!layer->DrawsContent() && !can_accept_input) - return true; - return false; } @@ -507,7 +500,6 @@ static inline bool SubtreeShouldBeSkipped(LayerImpl* layer, // The opacity of a layer always applies to its children (either implicitly // via a render surface or explicitly if the parent preserves 3D), so the // entire subtree can be skipped if this layer is fully transparent. - // TODO(sad): Don't skip layers used for hit testing crbug.com/295295. return !layer->opacity(); } @@ -531,7 +523,6 @@ static inline bool SubtreeShouldBeSkipped(Layer* layer, bool layer_is_drawn) { // In particular, it should not cause the subtree to be skipped. // Similarly, for layers that might animate opacity using an impl-only // animation, their subtree should also not be skipped. - // TODO(sad): Don't skip layers used for hit testing crbug.com/295295. return !layer->opacity() && !layer->OpacityIsAnimating() && !layer->OpacityCanAnimateOnImplThread(); } diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index b51d6f9..eb2ba96 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -825,7 +825,7 @@ DrawResult LayerTreeHostImpl::CalculateRenderPasses( contributing_render_pass, occlusion_tracker, &append_quads_data); - } else if (it.represents_itself() && it->DrawsContent() && + } else if (it.represents_itself() && !it->visible_content_rect().IsEmpty()) { bool occluded = occlusion_tracker.Occluded(it->render_target(), it->visible_content_rect(), diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index 52ac0f6..888b0f6 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -4645,41 +4645,6 @@ class LayerTreeHostTestMemoryLimits : public LayerTreeHostTest { SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostTestMemoryLimits); -class LayerTreeHostTestNoQuadsForEmptyLayer : public LayerTreeHostTest { - protected: - virtual void SetupTree() OVERRIDE { - LayerTreeHostTest::SetupTree(); - root_layer_ = FakeContentLayer::Create(&client_); - root_layer_->SetBounds(gfx::Size(10, 10)); - root_layer_->SetIsDrawable(false); - root_layer_->SetHaveWheelEventHandlers(true); - layer_tree_host()->SetRootLayer(root_layer_); - LayerTreeHostTest::SetupTree(); - } - - virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } - - virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { - FakeContentLayerImpl* layer_impl = - static_cast(impl->RootLayer()); - EXPECT_FALSE(layer_impl->DrawsContent()); - EXPECT_EQ(0u, layer_impl->append_quads_count()); - } - - virtual void DidCommit() OVERRIDE { - // The layer is not drawable, so it should not be updated. - EXPECT_EQ(0u, root_layer_->update_count()); - EndTest(); - } - virtual void AfterTest() OVERRIDE {} - - private: - FakeContentLayerClient client_; - scoped_refptr root_layer_; -}; - -SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoQuadsForEmptyLayer); - } // namespace class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h index 5b740c3..d27e1e4 100644 --- a/cc/trees/layer_tree_impl.h +++ b/cc/trees/layer_tree_impl.h @@ -295,8 +295,7 @@ class CC_EXPORT LayerTreeImpl { // Persisted state for non-impl-side-painting. int scrolling_layer_id_from_previous_tree_; - // List of visible or hit-testable layers for the most recently prepared - // frame. Used for rendering and input event hit testing. + // List of visible layers for the most recently prepared frame. LayerImplList render_surface_layer_list_; bool use_gpu_rasterization_; diff --git a/cc/trees/layer_tree_impl_unittest.cc b/cc/trees/layer_tree_impl_unittest.cc index b27a06e..4a8259e 100644 --- a/cc/trees/layer_tree_impl_unittest.cc +++ b/cc/trees/layer_tree_impl_unittest.cc @@ -1185,110 +1185,6 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { EXPECT_EQ(4, result_layer->id()); } -TEST_F(LayerTreeImplTest, HitTestingForEmptyLayers) { - // Layer 1 - root - scoped_ptr root = LayerImpl::Create(host_impl().active_tree(), 1); - gfx::Transform identity_matrix; - gfx::PointF anchor; - gfx::PointF position; - gfx::Size bounds(100, 100); - SetLayerPropertiesForTesting( - root.get(), identity_matrix, anchor, position, bounds, true, false); - root->SetDrawsContent(true); - - { - // Layer 2 - empty: drawsContent=false - gfx::PointF position(10.f, 10.f); - gfx::Size bounds(30, 30); - scoped_ptr empty_layer = - LayerImpl::Create(host_impl().active_tree(), 2); - SetLayerPropertiesForTesting(empty_layer.get(), - identity_matrix, - anchor, - position, - bounds, - true, - false); - - empty_layer->SetDrawsContent(false); - root->AddChild(empty_layer.Pass()); - } - - { - // Layer 3 - empty, but has touch handler - gfx::PointF position(10.f, 60.f); - gfx::Size bounds(30, 30); - scoped_ptr test_layer = - LayerImpl::Create(host_impl().active_tree(), 3); - SetLayerPropertiesForTesting(test_layer.get(), - identity_matrix, - anchor, - position, - bounds, - true, - false); - - test_layer->SetDrawsContent(false); - Region touch_handler_region(gfx::Rect(10, 10, 10, 10)); - test_layer->SetTouchEventHandlerRegion(touch_handler_region); - root->AddChild(test_layer.Pass()); - } - - { - // Layer 4 - empty, but has mousewheel handler - gfx::PointF position(60.f, 60.f); - gfx::Size bounds(30, 30); - scoped_ptr test_layer = - LayerImpl::Create(host_impl().active_tree(), 4); - SetLayerPropertiesForTesting(test_layer.get(), - identity_matrix, - anchor, - position, - bounds, - true, - false); - - test_layer->SetDrawsContent(false); - test_layer->SetHaveWheelEventHandlers(true); - root->AddChild(test_layer.Pass()); - } - - host_impl().SetViewportSize(root->bounds()); - host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); - - // Verify that the root layer and empty layers with touch/wheel handlers - // (but not the empty layer without a touch handler) are in the RSSL. - ASSERT_EQ(1u, RenderSurfaceLayerList().size()); - EXPECT_EQ(1, RenderSurfaceLayerList()[0]->id()); - ASSERT_EQ(3u, root_layer()->render_surface()->layer_list().size()); - EXPECT_EQ(1, root_layer()->render_surface()->layer_list().at(0)->id()); - EXPECT_EQ(3, root_layer()->render_surface()->layer_list().at(1)->id()); - EXPECT_EQ(4, root_layer()->render_surface()->layer_list().at(2)->id()); - - // Hit testing for a point inside the empty no-handlers layer should return - // the root layer. - gfx::Point test_point = gfx::Point(15, 15); - LayerImpl* result_layer = - host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); - ASSERT_TRUE(result_layer); - EXPECT_EQ(1, result_layer->id()); - - // Hit testing for a point inside the touch handler layer should return it. - test_point = gfx::Point(15, 75); - result_layer = - host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); - ASSERT_TRUE(result_layer); - EXPECT_EQ(3, result_layer->id()); - - // Hit testing for a point inside the mousewheel layer should return it. - test_point = gfx::Point(75, 75); - result_layer = - host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); - ASSERT_TRUE(result_layer); - EXPECT_EQ(4, result_layer->id()); -} - TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSingleLayer) { scoped_ptr root = LayerImpl::Create(host_impl().active_tree(), 12345); diff --git a/cc/trees/occlusion_tracker.cc b/cc/trees/occlusion_tracker.cc index 94125be..ceb2d14 100644 --- a/cc/trees/occlusion_tracker.cc +++ b/cc/trees/occlusion_tracker.cc @@ -404,9 +404,6 @@ void OcclusionTracker::MarkOccludedBehindLayer( if (stack_.empty()) return; - if (!layer->DrawsContent()) - return; - if (!LayerOpacityKnown(layer) || layer->draw_opacity() < 1) return; diff --git a/cc/trees/occlusion_tracker_unittest.cc b/cc/trees/occlusion_tracker_unittest.cc index 8f083f5..4687dab 100644 --- a/cc/trees/occlusion_tracker_unittest.cc +++ b/cc/trees/occlusion_tracker_unittest.cc @@ -328,14 +328,6 @@ template class OcclusionTrackerTest : public testing::Test { Types::TestLayerIterator::Begin(render_surface_layer_list_.get()); } - void SetDrawsContent(LayerImpl* layer_impl, bool draws_content) { - layer_impl->SetDrawsContent(draws_content); - } - - void SetDrawsContent(Layer* layer, bool draws_content) { - layer->SetIsDrawable(draws_content); - } - void EnterLayer(typename Types::LayerType* layer, typename Types::OcclusionTrackerType* occlusion) { ASSERT_EQ(layer, *layer_iterator_); @@ -3565,36 +3557,5 @@ class OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude) -template -class OcclusionTrackerTestEmptyEventLayerDoesNotOcclude - : public OcclusionTrackerTest { - protected: - explicit OcclusionTrackerTestEmptyEventLayerDoesNotOcclude( - bool opaque_layers) - : OcclusionTrackerTest(opaque_layers) {} - void RunMyTest() { - typename Types::ContentLayerType* root = this->CreateRoot( - this->identity_matrix, gfx::Point(), gfx::Size(400, 400)); - typename Types::ContentLayerType* empty_layer = this->CreateDrawingLayer( - root, this->identity_matrix, gfx::Point(), gfx::Size(200, 200), true); - this->SetDrawsContent(empty_layer, false); - empty_layer->SetTouchEventHandlerRegion(gfx::Rect(10, 10, 10, 10)); - - this->CalcDrawEtc(root); - - TestOcclusionTrackerWithClip occlusion( - gfx::Rect(0, 0, 1000, 1000)); - - this->VisitLayer(empty_layer, &occlusion); - - EXPECT_EQ(gfx::Rect().ToString(), - occlusion.occlusion_from_outside_target().ToString()); - EXPECT_EQ(gfx::Rect().ToString(), - occlusion.occlusion_from_inside_target().ToString()); - } -}; - -ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestEmptyEventLayerDoesNotOcclude) - } // namespace } // namespace cc -- cgit v1.1