summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorawoloszyn@chromium.org <awoloszyn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-11 17:39:54 +0000
committerawoloszyn@chromium.org <awoloszyn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-11 17:41:20 +0000
commitad63b2ffb295d0de395b83faeff6125475f0f5c4 (patch)
tree1d867e1db456fd4bb95f5e0a202e7005d5f6ae85 /cc
parent6ebf79234c9c16a3611a05f481e845433ddd7271 (diff)
downloadchromium_src-ad63b2ffb295d0de395b83faeff6125475f0f5c4.zip
chromium_src-ad63b2ffb295d0de395b83faeff6125475f0f5c4.tar.gz
chromium_src-ad63b2ffb295d0de395b83faeff6125475f0f5c4.tar.bz2
Keeping track of descendants that draw content instead of recalcualting
This is a required for removing Render Surface creation from CalcDrawProps. BUG=386788 Review URL: https://codereview.chromium.org/373113003 Cr-Commit-Position: refs/heads/master@{#288740} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288740 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/BUILD.gn1
-rw-r--r--cc/cc_tests.gyp1
-rw-r--r--cc/layers/content_layer.cc9
-rw-r--r--cc/layers/content_layer.h5
-rw-r--r--cc/layers/delegated_renderer_layer.cc4
-rw-r--r--cc/layers/delegated_renderer_layer.h1
-rw-r--r--cc/layers/delegated_renderer_layer_impl_unittest.cc4
-rw-r--r--cc/layers/delegated_renderer_layer_unittest.cc78
-rw-r--r--cc/layers/draw_properties.h4
-rw-r--r--cc/layers/heads_up_display_layer.cc9
-rw-r--r--cc/layers/heads_up_display_layer.h2
-rw-r--r--cc/layers/image_layer.cc9
-rw-r--r--cc/layers/image_layer.h4
-rw-r--r--cc/layers/io_surface_layer.cc5
-rw-r--r--cc/layers/io_surface_layer.h2
-rw-r--r--cc/layers/layer.cc54
-rw-r--r--cc/layers/layer.h19
-rw-r--r--cc/layers/layer_impl.cc13
-rw-r--r--cc/layers/layer_impl.h4
-rw-r--r--cc/layers/layer_impl_unittest.cc2
-rw-r--r--cc/layers/picture_image_layer.cc5
-rw-r--r--cc/layers/picture_image_layer.h4
-rw-r--r--cc/layers/picture_layer.cc13
-rw-r--r--cc/layers/picture_layer.h4
-rw-r--r--cc/layers/surface_layer.cc5
-rw-r--r--cc/layers/surface_layer.h2
-rw-r--r--cc/layers/texture_layer.cc6
-rw-r--r--cc/layers/texture_layer.h2
-rw-r--r--cc/layers/tiled_layer.cc15
-rw-r--r--cc/layers/tiled_layer.h3
-rw-r--r--cc/layers/ui_resource_layer.cc15
-rw-r--r--cc/layers/ui_resource_layer.h4
-rw-r--r--cc/test/fake_delegated_renderer_layer_impl.h1
-rw-r--r--cc/test/fake_layer_tree_host_impl.cc22
-rw-r--r--cc/test/fake_layer_tree_host_impl.h3
-rw-r--r--cc/trees/damage_tracker_unittest.cc1
-rw-r--r--cc/trees/layer_tree_host_common.cc18
-rw-r--r--cc/trees/layer_tree_host_common_unittest.cc1
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc4
-rw-r--r--cc/trees/layer_tree_host_unittest.cc56
-rw-r--r--cc/trees/layer_tree_impl_unittest.cc50
-rw-r--r--cc/trees/occlusion_tracker_unittest.cc7
42 files changed, 372 insertions, 99 deletions
diff --git a/cc/BUILD.gn b/cc/BUILD.gn
index aabbdf6..0688868 100644
--- a/cc/BUILD.gn
+++ b/cc/BUILD.gn
@@ -654,6 +654,7 @@ test("cc_unittests") {
"layers/delegated_frame_provider_unittest.cc",
"layers/delegated_frame_resource_collection_unittest.cc",
"layers/delegated_renderer_layer_impl_unittest.cc",
+ "layers/delegated_renderer_layer_unittest.cc",
"layers/heads_up_display_unittest.cc",
"layers/heads_up_display_layer_impl_unittest.cc",
"layers/io_surface_layer_impl_unittest.cc",
diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp
index 18d38f9..cf68c66 100644
--- a/cc/cc_tests.gyp
+++ b/cc/cc_tests.gyp
@@ -30,6 +30,7 @@
'layers/delegated_frame_provider_unittest.cc',
'layers/delegated_frame_resource_collection_unittest.cc',
'layers/delegated_renderer_layer_impl_unittest.cc',
+ 'layers/delegated_renderer_layer_unittest.cc',
'layers/heads_up_display_unittest.cc',
'layers/heads_up_display_layer_impl_unittest.cc',
'layers/io_surface_layer_impl_unittest.cc',
diff --git a/cc/layers/content_layer.cc b/cc/layers/content_layer.cc
index d720501..c1eec73 100644
--- a/cc/layers/content_layer.cc
+++ b/cc/layers/content_layer.cc
@@ -45,8 +45,13 @@ ContentLayer::ContentLayer(ContentLayerClient* client)
ContentLayer::~ContentLayer() {}
-bool ContentLayer::DrawsContent() const {
- return TiledLayer::DrawsContent() && client_;
+void ContentLayer::ClearClient() {
+ client_ = NULL;
+ UpdateDrawsContent(HasDrawableContent());
+}
+
+bool ContentLayer::HasDrawableContent() const {
+ return client_ && TiledLayer::HasDrawableContent();
}
void ContentLayer::SetLayerTreeHost(LayerTreeHost* host) {
diff --git a/cc/layers/content_layer.h b/cc/layers/content_layer.h
index 9bef22b..c440c6f 100644
--- a/cc/layers/content_layer.h
+++ b/cc/layers/content_layer.h
@@ -38,9 +38,8 @@ class CC_EXPORT ContentLayer : public TiledLayer {
public:
static scoped_refptr<ContentLayer> Create(ContentLayerClient* client);
- void ClearClient() { client_ = NULL; }
+ void ClearClient();
- virtual bool DrawsContent() const OVERRIDE;
virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) OVERRIDE;
virtual void SetTexturePriorities(const PriorityCalculator& priority_calc)
OVERRIDE;
@@ -60,6 +59,8 @@ class CC_EXPORT ContentLayer : public TiledLayer {
explicit ContentLayer(ContentLayerClient* client);
virtual ~ContentLayer();
+ virtual bool HasDrawableContent() const OVERRIDE;
+
// TiledLayer implementation.
virtual LayerUpdater* Updater() const OVERRIDE;
diff --git a/cc/layers/delegated_renderer_layer.cc b/cc/layers/delegated_renderer_layer.cc
index c472061..2dd1234 100644
--- a/cc/layers/delegated_renderer_layer.cc
+++ b/cc/layers/delegated_renderer_layer.cc
@@ -98,4 +98,8 @@ bool DelegatedRendererLayer::Update(ResourceUpdateQueue* queue,
return true;
}
+bool DelegatedRendererLayer::HasDelegatedContent() const {
+ return true;
+}
+
} // namespace cc
diff --git a/cc/layers/delegated_renderer_layer.h b/cc/layers/delegated_renderer_layer.h
index 3bc0aa8..0e4b958 100644
--- a/cc/layers/delegated_renderer_layer.h
+++ b/cc/layers/delegated_renderer_layer.h
@@ -32,6 +32,7 @@ class CC_EXPORT DelegatedRendererLayer : public Layer {
// Called by the DelegatedFrameProvider when a new frame is available to be
// picked up.
void ProviderHasNewFrame();
+ virtual bool HasDelegatedContent() const OVERRIDE;
protected:
DelegatedRendererLayer(
diff --git a/cc/layers/delegated_renderer_layer_impl_unittest.cc b/cc/layers/delegated_renderer_layer_impl_unittest.cc
index 18336d1..94050ae 100644
--- a/cc/layers/delegated_renderer_layer_impl_unittest.cc
+++ b/cc/layers/delegated_renderer_layer_impl_unittest.cc
@@ -311,6 +311,8 @@ TEST_F(DelegatedRendererLayerImplTestSimple, DoesOwnARenderSurfaceForOpacity) {
delegated_renderer_layer_->SetOpacity(0.5f);
LayerTreeHostImpl::FrameData frame;
+ FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(
+ host_impl_->active_tree()->root_layer());
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
// This test case has quads from multiple layers in the delegated renderer, so
@@ -329,6 +331,8 @@ TEST_F(DelegatedRendererLayerImplTestSimple,
delegated_renderer_layer_->SetTransform(rotation);
LayerTreeHostImpl::FrameData frame;
+ FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(
+ host_impl_->active_tree()->root_layer());
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
// This test case has quads from multiple layers in the delegated renderer, so
diff --git a/cc/layers/delegated_renderer_layer_unittest.cc b/cc/layers/delegated_renderer_layer_unittest.cc
new file mode 100644
index 0000000..b997a26
--- /dev/null
+++ b/cc/layers/delegated_renderer_layer_unittest.cc
@@ -0,0 +1,78 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/layers/delegated_renderer_layer.h"
+
+#include "cc/layers/delegated_frame_provider.h"
+#include "cc/layers/delegated_frame_resource_collection.h"
+#include "cc/layers/solid_color_layer.h"
+#include "cc/output/delegated_frame_data.h"
+#include "cc/test/fake_delegated_renderer_layer.h"
+#include "cc/test/fake_layer_tree_host.h"
+#include "cc/test/fake_proxy.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace cc {
+namespace {
+
+class DelegatedRendererLayerTest : public testing::Test {
+ public:
+ DelegatedRendererLayerTest() : proxy_() {
+ LayerTreeSettings settings;
+ settings.minimum_occlusion_tracking_size = gfx::Size();
+
+ host_impl_ = FakeLayerTreeHost::Create(settings);
+ host_impl_->SetViewportSize(gfx::Size(10, 10));
+ }
+
+ protected:
+ FakeProxy proxy_;
+ TestSharedBitmapManager shared_bitmap_manager_;
+ scoped_ptr<LayerTreeHost> host_impl_;
+};
+
+class DelegatedRendererLayerTestSimple : public DelegatedRendererLayerTest {
+ public:
+ DelegatedRendererLayerTestSimple() : DelegatedRendererLayerTest() {
+ scoped_ptr<RenderPass> root_pass(RenderPass::Create());
+ root_pass->SetNew(RenderPass::Id(1, 1),
+ gfx::Rect(1, 1),
+ gfx::Rect(1, 1),
+ gfx::Transform());
+ scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
+ frame_data->render_pass_list.push_back(root_pass.Pass());
+ resources_ = new DelegatedFrameResourceCollection;
+ provider_ = new DelegatedFrameProvider(resources_, frame_data.Pass());
+ root_layer_ = SolidColorLayer::Create();
+ layer_before_ = SolidColorLayer::Create();
+ delegated_renderer_layer_ = FakeDelegatedRendererLayer::Create(provider_);
+ }
+
+ protected:
+ scoped_refptr<Layer> root_layer_;
+ scoped_refptr<Layer> layer_before_;
+ scoped_refptr<DelegatedRendererLayer> delegated_renderer_layer_;
+ scoped_refptr<DelegatedFrameResourceCollection> resources_;
+ scoped_refptr<DelegatedFrameProvider> provider_;
+};
+
+TEST_F(DelegatedRendererLayerTestSimple, DelegatedManyDescendants) {
+ EXPECT_EQ(0, root_layer_->NumDescendantsThatDrawContent());
+ root_layer_->AddChild(layer_before_);
+ EXPECT_EQ(0, root_layer_->NumDescendantsThatDrawContent());
+ layer_before_->SetIsDrawable(true);
+ EXPECT_EQ(1, root_layer_->NumDescendantsThatDrawContent());
+ EXPECT_EQ(0, layer_before_->NumDescendantsThatDrawContent());
+ layer_before_->AddChild(delegated_renderer_layer_);
+ EXPECT_EQ(0, layer_before_->NumDescendantsThatDrawContent());
+ EXPECT_EQ(0, delegated_renderer_layer_->NumDescendantsThatDrawContent());
+ EXPECT_EQ(1, root_layer_->NumDescendantsThatDrawContent());
+ delegated_renderer_layer_->SetIsDrawable(true);
+ EXPECT_EQ(1000, delegated_renderer_layer_->NumDescendantsThatDrawContent());
+ EXPECT_EQ(1001, layer_before_->NumDescendantsThatDrawContent());
+ EXPECT_EQ(1002, root_layer_->NumDescendantsThatDrawContent());
+}
+
+} // namespace
+} // namespace cc
diff --git a/cc/layers/draw_properties.h b/cc/layers/draw_properties.h
index a0bfc2a..4bbce72 100644
--- a/cc/layers/draw_properties.h
+++ b/cc/layers/draw_properties.h
@@ -26,7 +26,6 @@ struct CC_EXPORT DrawProperties {
render_target(NULL),
contents_scale_x(1.f),
contents_scale_y(1.f),
- num_descendants_that_draw_content(0),
num_unclipped_descendants(0),
layer_or_descendant_has_copy_request(false),
layer_or_descendant_has_input_handler(false),
@@ -96,9 +95,6 @@ struct CC_EXPORT DrawProperties {
float contents_scale_y;
gfx::Size content_bounds;
- // Does not include this layer itself, only its children and descendants.
- int num_descendants_that_draw_content;
-
// Number of descendants with a clip parent that is our ancestor. NB - this
// does not include our clip children because they are clipped by us.
int num_unclipped_descendants;
diff --git a/cc/layers/heads_up_display_layer.cc b/cc/layers/heads_up_display_layer.cc
index ca63471..6adf8d0 100644
--- a/cc/layers/heads_up_display_layer.cc
+++ b/cc/layers/heads_up_display_layer.cc
@@ -16,7 +16,10 @@ scoped_refptr<HeadsUpDisplayLayer> HeadsUpDisplayLayer::Create() {
return make_scoped_refptr(new HeadsUpDisplayLayer());
}
-HeadsUpDisplayLayer::HeadsUpDisplayLayer() {}
+HeadsUpDisplayLayer::HeadsUpDisplayLayer() {
+ SetIsDrawable(true);
+ UpdateDrawsContent(HasDrawableContent());
+}
HeadsUpDisplayLayer::~HeadsUpDisplayLayer() {}
@@ -47,7 +50,9 @@ void HeadsUpDisplayLayer::PrepareForCalculateDrawProperties(
SetTransform(matrix);
}
-bool HeadsUpDisplayLayer::DrawsContent() const { return true; }
+bool HeadsUpDisplayLayer::HasDrawableContent() const {
+ return true;
+}
scoped_ptr<LayerImpl> HeadsUpDisplayLayer::CreateLayerImpl(
LayerTreeImpl* tree_impl) {
diff --git a/cc/layers/heads_up_display_layer.h b/cc/layers/heads_up_display_layer.h
index 4750faf..12d6aef 100644
--- a/cc/layers/heads_up_display_layer.h
+++ b/cc/layers/heads_up_display_layer.h
@@ -20,13 +20,13 @@ class CC_EXPORT HeadsUpDisplayLayer : public ContentsScalingLayer {
void PrepareForCalculateDrawProperties(
const gfx::Size& device_viewport, float device_scale_factor);
- virtual bool DrawsContent() const OVERRIDE;
virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
OVERRIDE;
protected:
HeadsUpDisplayLayer();
+ virtual bool HasDrawableContent() const OVERRIDE;
private:
virtual ~HeadsUpDisplayLayer();
diff --git a/cc/layers/image_layer.cc b/cc/layers/image_layer.cc
index edcf1dc..67e620c 100644
--- a/cc/layers/image_layer.cc
+++ b/cc/layers/image_layer.cc
@@ -30,9 +30,14 @@ void ImageLayer::SetBitmap(const SkBitmap& bitmap) {
return;
bitmap_ = bitmap;
+ UpdateDrawsContent(HasDrawableContent());
SetNeedsDisplay();
}
+bool ImageLayer::HasDrawableContent() const {
+ return !bitmap_.isNull() && TiledLayer::HasDrawableContent();
+}
+
void ImageLayer::SetTexturePriorities(const PriorityCalculator& priority_calc) {
// Update the tile data before creating all the layer's tiles.
UpdateTileSizeAndTilingOption();
@@ -73,10 +78,6 @@ void ImageLayer::CalculateContentsScale(float ideal_contents_scale,
*content_bounds = gfx::Size(bitmap_.width(), bitmap_.height());
}
-bool ImageLayer::DrawsContent() const {
- return !bitmap_.isNull() && TiledLayer::DrawsContent();
-}
-
void ImageLayer::OnOutputSurfaceCreated() {
SetTextureFormat(
layer_tree_host()->GetRendererCapabilities().best_texture_format);
diff --git a/cc/layers/image_layer.h b/cc/layers/image_layer.h
index a3cee58..63d467a 100644
--- a/cc/layers/image_layer.h
+++ b/cc/layers/image_layer.h
@@ -19,7 +19,6 @@ class CC_EXPORT ImageLayer : public TiledLayer {
static scoped_refptr<ImageLayer> Create();
// Layer implementation.
- virtual bool DrawsContent() const OVERRIDE;
virtual void SetTexturePriorities(const PriorityCalculator& priority_calc)
OVERRIDE;
virtual bool Update(ResourceUpdateQueue* queue,
@@ -32,6 +31,9 @@ class CC_EXPORT ImageLayer : public TiledLayer {
void SetBitmap(const SkBitmap& image);
+ protected:
+ virtual bool HasDrawableContent() const OVERRIDE;
+
private:
ImageLayer();
virtual ~ImageLayer();
diff --git a/cc/layers/io_surface_layer.cc b/cc/layers/io_surface_layer.cc
index 98d3dfe..0682aee 100644
--- a/cc/layers/io_surface_layer.cc
+++ b/cc/layers/io_surface_layer.cc
@@ -20,6 +20,7 @@ void IOSurfaceLayer::SetIOSurfaceProperties(uint32_t io_surface_id,
const gfx::Size& size) {
io_surface_id_ = io_surface_id;
io_surface_size_ = size;
+ UpdateDrawsContent(HasDrawableContent());
SetNeedsCommit();
}
@@ -28,8 +29,8 @@ scoped_ptr<LayerImpl> IOSurfaceLayer::CreateLayerImpl(
return IOSurfaceLayerImpl::Create(tree_impl, layer_id_).PassAs<LayerImpl>();
}
-bool IOSurfaceLayer::DrawsContent() const {
- return io_surface_id_ && Layer::DrawsContent();
+bool IOSurfaceLayer::HasDrawableContent() const {
+ return io_surface_id_ && Layer::HasDrawableContent();
}
void IOSurfaceLayer::PushPropertiesTo(LayerImpl* layer) {
diff --git a/cc/layers/io_surface_layer.h b/cc/layers/io_surface_layer.h
index 80e5b69..ad06e7f 100644
--- a/cc/layers/io_surface_layer.h
+++ b/cc/layers/io_surface_layer.h
@@ -18,12 +18,12 @@ class CC_EXPORT IOSurfaceLayer : public Layer {
virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
OVERRIDE;
- virtual bool DrawsContent() const OVERRIDE;
virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
virtual bool Update(ResourceUpdateQueue* queue,
const OcclusionTracker<Layer>* occlusion) OVERRIDE;
protected:
+ virtual bool HasDrawableContent() const OVERRIDE;
IOSurfaceLayer();
private:
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index 2367e52..737a261 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -47,6 +47,7 @@ Layer::Layer()
parent_(NULL),
layer_tree_host_(NULL),
scroll_clip_layer_id_(INVALID_ID),
+ num_descendants_that_draw_content_(0),
should_scroll_on_main_thread_(false),
have_wheel_event_handlers_(false),
have_scroll_event_handlers_(false),
@@ -55,6 +56,7 @@ Layer::Layer()
is_root_for_isolated_group_(false),
is_container_for_fixed_position_layers_(false),
is_drawable_(false),
+ draws_content_(false),
hide_layer_and_subtree_(false),
masks_to_bounds_(false),
contents_opaque_(false),
@@ -250,6 +252,8 @@ void Layer::InsertChild(scoped_refptr<Layer> child, size_t index) {
index = std::min(index, children_.size());
children_.insert(children_.begin() + index, child);
+ AddDrawableDescendants(child->NumDescendantsThatDrawContent() +
+ (child->DrawsContent() ? 1 : 0));
SetNeedsFullTreeSync();
}
@@ -280,6 +284,8 @@ void Layer::RemoveChildOrDependent(Layer* child) {
continue;
child->SetParent(NULL);
+ AddDrawableDescendants(-child->NumDescendantsThatDrawContent() -
+ (child->DrawsContent() ? 1 : 0));
children_.erase(iter);
SetNeedsFullTreeSync();
return;
@@ -775,7 +781,7 @@ void Layer::SetIsDrawable(bool is_drawable) {
return;
is_drawable_ = is_drawable;
- SetNeedsCommit();
+ UpdateDrawsContent(HasDrawableContent());
}
void Layer::SetHideLayerAndSubtree(bool hide) {
@@ -898,6 +904,7 @@ void Layer::PushPropertiesTo(LayerImpl* layer) {
layer->SetTransformAndInvertibility(transform_, transform_is_invertible_);
DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly()));
layer->Set3dSortingContextId(sorting_context_id_);
+ layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_);
layer->SetScrollClipLayer(scroll_clip_layer_id_);
layer->set_user_scrollable_horizontal(user_scrollable_horizontal_);
@@ -1004,9 +1011,38 @@ scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) {
}
bool Layer::DrawsContent() const {
+ return draws_content_;
+}
+
+bool Layer::HasDrawableContent() const {
return is_drawable_;
}
+void Layer::UpdateDrawsContent(bool has_drawable_content) {
+ bool draws_content = has_drawable_content;
+ DCHECK(is_drawable_ || !has_drawable_content);
+ if (draws_content == draws_content_)
+ return;
+
+ if (HasDelegatedContent()) {
+ // Layers with delegated content need to be treated as if they have as
+ // many children as the number of layers they own delegated quads for.
+ // Since we don't know this number right now, we choose one that acts like
+ // infinity for our purposes.
+ AddDrawableDescendants(draws_content ? 1000 : -1000);
+ }
+
+ if (parent())
+ parent()->AddDrawableDescendants(draws_content ? 1 : -1);
+
+ draws_content_ = draws_content;
+ SetNeedsCommit();
+}
+
+int Layer::NumDescendantsThatDrawContent() const {
+ return num_descendants_that_draw_content_;
+}
+
void Layer::SavePaintProperties() {
DCHECK(layer_tree_host_);
@@ -1187,7 +1223,23 @@ void Layer::RemoveFromClipTree() {
clip_parent_ = NULL;
}
+void Layer::AddDrawableDescendants(int num) {
+ DCHECK_GE(num_descendants_that_draw_content_, 0);
+ DCHECK_GE(num_descendants_that_draw_content_ + num, 0);
+ if (num == 0)
+ return;
+ num_descendants_that_draw_content_ += num;
+ SetNeedsCommit();
+ if (parent())
+ parent()->AddDrawableDescendants(num);
+}
+
void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) {
benchmark->RunOnLayer(this);
}
+
+bool Layer::HasDelegatedContent() const {
+ return false;
+}
+
} // namespace cc
diff --git a/cc/layers/layer.h b/cc/layers/layer.h
index 822b16d..dfbbdf7b 100644
--- a/cc/layers/layer.h
+++ b/cc/layers/layer.h
@@ -331,7 +331,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>,
virtual void SetLayerTreeHost(LayerTreeHost* host);
- bool HasDelegatedContent() const { return false; }
+ virtual bool HasDelegatedContent() const;
bool HasContributingDelegatedRenderPasses() const { return false; }
void SetIsDrawable(bool is_drawable);
@@ -350,8 +350,13 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>,
(mask_layer_.get() || replica_layer_->mask_layer_.get());
}
- // These methods typically need to be overwritten by derived classes.
+ int NumDescendantsThatDrawContent() const;
+
+ // This is only virtual for tests.
+ // TODO(awoloszyn): Remove this once we no longer need it for tests
virtual bool DrawsContent() const;
+
+ // This methods typically need to be overwritten by derived classes.
virtual void SavePaintProperties();
// Returns true iff any resources were updated that need to be committed.
virtual bool Update(ResourceUpdateQueue* queue,
@@ -482,6 +487,14 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>,
// unused resources on the impl thread are returned before commit completes.
void SetNextCommitWaitsForActivation();
+ // Will recalculate whether the layer draws content and set draws_content_
+ // appropriately.
+ void UpdateDrawsContent(bool has_drawable_content);
+ virtual bool HasDrawableContent() const;
+
+ // Called when the layer's number of drawable descendants changes.
+ void AddDrawableDescendants(int num);
+
void AddDependentNeedsPushProperties();
void RemoveDependentNeedsPushProperties();
bool parent_should_know_need_push_properties() const {
@@ -575,6 +588,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>,
// transformed relative to this layer, defines the maximum scroll offset for
// this layer.
int scroll_clip_layer_id_;
+ int num_descendants_that_draw_content_;
bool should_scroll_on_main_thread_ : 1;
bool have_wheel_event_handlers_ : 1;
bool have_scroll_event_handlers_ : 1;
@@ -583,6 +597,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>,
bool is_root_for_isolated_group_ : 1;
bool is_container_for_fixed_position_layers_ : 1;
bool is_drawable_ : 1;
+ bool draws_content_ : 1;
bool hide_layer_and_subtree_ : 1;
bool masks_to_bounds_ : 1;
bool contents_opaque_ : 1;
diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc
index bd9a2d7..e6e60f5 100644
--- a/cc/layers/layer_impl.cc
+++ b/cc/layers/layer_impl.cc
@@ -64,6 +64,7 @@ LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id)
background_color_(0),
opacity_(1.0),
blend_mode_(SkXfermode::kSrcOver_Mode),
+ num_descendants_that_draw_content_(0),
draw_depth_(0.f),
needs_push_properties_(false),
num_dependents_need_push_properties_(0),
@@ -176,6 +177,13 @@ void LayerImpl::SetScrollChildren(std::set<LayerImpl*>* children) {
SetNeedsPushProperties();
}
+void LayerImpl::SetNumDescendantsThatDrawContent(int num_descendants) {
+ if (num_descendants_that_draw_content_ == num_descendants)
+ return;
+ num_descendants_that_draw_content_ = num_descendants;
+ SetNeedsPushProperties();
+}
+
void LayerImpl::SetClipParent(LayerImpl* ancestor) {
if (clip_parent_ == ancestor)
return;
@@ -532,6 +540,7 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) {
scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta());
layer->SetSentScrollDelta(gfx::Vector2d());
layer->Set3dSortingContextId(sorting_context_id_);
+ layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_);
LayerImpl* scroll_parent = NULL;
if (scroll_parent_) {
@@ -1521,6 +1530,10 @@ void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) {
benchmark->RunOnLayer(this);
}
+int LayerImpl::NumDescendantsThatDrawContent() const {
+ return num_descendants_that_draw_content_;
+}
+
void LayerImpl::NotifyAnimationFinished(
base::TimeTicks monotonic_time,
Animation::TargetProperty target_property) {
diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h
index c1ce9df..b09cb3f 100644
--- a/cc/layers/layer_impl.h
+++ b/cc/layers/layer_impl.h
@@ -140,6 +140,7 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
return scroll_children_.get();
}
+ void SetNumDescendantsThatDrawContent(int num_descendants);
void SetClipParent(LayerImpl* ancestor);
LayerImpl* clip_parent() {
@@ -211,6 +212,7 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
void SetDrawsContent(bool draws_content);
bool DrawsContent() const { return draws_content_; }
+ int NumDescendantsThatDrawContent() const;
void SetHideLayerAndSubtree(bool hide);
bool hide_layer_and_subtree() const { return hide_layer_and_subtree_; }
@@ -650,6 +652,8 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
gfx::Vector2d sent_scroll_delta_;
gfx::Vector2dF last_scroll_offset_;
+ int num_descendants_that_draw_content_;
+
// The global depth value of the center of the layer. This value is used
// to sort layers from back to front.
float draw_depth_;
diff --git a/cc/layers/layer_impl_unittest.cc b/cc/layers/layer_impl_unittest.cc
index 39469c1..c5cac8d 100644
--- a/cc/layers/layer_impl_unittest.cc
+++ b/cc/layers/layer_impl_unittest.cc
@@ -200,6 +200,8 @@ TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) {
root->SetClipParent(clip_parent.get()));
EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
root->SetClipChildren(clip_children));
+ EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
+ root->SetNumDescendantsThatDrawContent(10));
// After setting all these properties already, setting to the exact same
// values again should not cause any change.
diff --git a/cc/layers/picture_image_layer.cc b/cc/layers/picture_image_layer.cc
index a65ac8c..8f24aaf 100644
--- a/cc/layers/picture_image_layer.cc
+++ b/cc/layers/picture_image_layer.cc
@@ -24,8 +24,8 @@ scoped_ptr<LayerImpl> PictureImageLayer::CreateLayerImpl(
return PictureImageLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>();
}
-bool PictureImageLayer::DrawsContent() const {
- return !bitmap_.isNull() && PictureLayer::DrawsContent();
+bool PictureImageLayer::HasDrawableContent() const {
+ return !bitmap_.isNull() && PictureLayer::HasDrawableContent();
}
void PictureImageLayer::SetBitmap(const SkBitmap& bitmap) {
@@ -37,6 +37,7 @@ void PictureImageLayer::SetBitmap(const SkBitmap& bitmap) {
return;
bitmap_ = bitmap;
+ UpdateDrawsContent(HasDrawableContent());
SetNeedsDisplay();
}
diff --git a/cc/layers/picture_image_layer.h b/cc/layers/picture_image_layer.h
index 69b89d1..0b3e32c 100644
--- a/cc/layers/picture_image_layer.h
+++ b/cc/layers/picture_image_layer.h
@@ -22,7 +22,6 @@ class CC_EXPORT PictureImageLayer : public PictureLayer, ContentLayerClient {
// Layer implementation.
virtual scoped_ptr<LayerImpl> CreateLayerImpl(
LayerTreeImpl* tree_impl) OVERRIDE;
- virtual bool DrawsContent() const OVERRIDE;
// ContentLayerClient implementation.
virtual void PaintContents(
@@ -33,6 +32,9 @@ class CC_EXPORT PictureImageLayer : public PictureLayer, ContentLayerClient {
virtual void DidChangeLayerCanUseLCDText() OVERRIDE {}
virtual bool FillsBoundsCompletely() const OVERRIDE;
+ protected:
+ virtual bool HasDrawableContent() const OVERRIDE;
+
private:
PictureImageLayer();
virtual ~PictureImageLayer();
diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc
index b9f265a..d2e29b6 100644
--- a/cc/layers/picture_layer.cc
+++ b/cc/layers/picture_layer.cc
@@ -28,10 +28,6 @@ PictureLayer::PictureLayer(ContentLayerClient* client)
PictureLayer::~PictureLayer() {
}
-bool PictureLayer::DrawsContent() const {
- return Layer::DrawsContent() && client_;
-}
-
scoped_ptr<LayerImpl> PictureLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) {
return PictureLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>();
}
@@ -200,6 +196,15 @@ bool PictureLayer::IsSuitableForGpuRasterization() const {
return pile_->is_suitable_for_gpu_rasterization();
}
+void PictureLayer::ClearClient() {
+ client_ = NULL;
+ UpdateDrawsContent(HasDrawableContent());
+}
+
+bool PictureLayer::HasDrawableContent() const {
+ return client_ && Layer::HasDrawableContent();
+}
+
void PictureLayer::RunMicroBenchmark(MicroBenchmark* benchmark) {
benchmark->RunOnLayer(this);
}
diff --git a/cc/layers/picture_layer.h b/cc/layers/picture_layer.h
index 406ffad..80bb4d8 100644
--- a/cc/layers/picture_layer.h
+++ b/cc/layers/picture_layer.h
@@ -21,10 +21,9 @@ class CC_EXPORT PictureLayer : public Layer {
public:
static scoped_refptr<PictureLayer> Create(ContentLayerClient* client);
- void ClearClient() { client_ = NULL; }
+ void ClearClient();
// Layer interface.
- virtual bool DrawsContent() const OVERRIDE;
virtual scoped_ptr<LayerImpl> CreateLayerImpl(
LayerTreeImpl* tree_impl) OVERRIDE;
virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE;
@@ -49,6 +48,7 @@ class CC_EXPORT PictureLayer : public Layer {
explicit PictureLayer(ContentLayerClient* client);
virtual ~PictureLayer();
+ virtual bool HasDrawableContent() const OVERRIDE;
void UpdateCanUseLCDText();
private:
diff --git a/cc/layers/surface_layer.cc b/cc/layers/surface_layer.cc
index f345b74..3ca179f 100644
--- a/cc/layers/surface_layer.cc
+++ b/cc/layers/surface_layer.cc
@@ -19,6 +19,7 @@ SurfaceLayer::~SurfaceLayer() {}
void SurfaceLayer::SetSurfaceId(SurfaceId surface_id) {
surface_id_ = surface_id;
+ UpdateDrawsContent(HasDrawableContent());
SetNeedsPushProperties();
}
@@ -26,8 +27,8 @@ scoped_ptr<LayerImpl> SurfaceLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) {
return SurfaceLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>();
}
-bool SurfaceLayer::DrawsContent() const {
- return !surface_id_.is_null() && Layer::DrawsContent();
+bool SurfaceLayer::HasDrawableContent() const {
+ return !surface_id_.is_null() && Layer::HasDrawableContent();
}
void SurfaceLayer::PushPropertiesTo(LayerImpl* layer) {
diff --git a/cc/layers/surface_layer.h b/cc/layers/surface_layer.h
index cf150ab..d58d47d 100644
--- a/cc/layers/surface_layer.h
+++ b/cc/layers/surface_layer.h
@@ -22,11 +22,11 @@ class CC_EXPORT SurfaceLayer : public Layer {
// Layer overrides.
virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
OVERRIDE;
- virtual bool DrawsContent() const OVERRIDE;
virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
protected:
SurfaceLayer();
+ virtual bool HasDrawableContent() const OVERRIDE;
private:
virtual ~SurfaceLayer();
diff --git a/cc/layers/texture_layer.cc b/cc/layers/texture_layer.cc
index 05391fe..5d386ca 100644
--- a/cc/layers/texture_layer.cc
+++ b/cc/layers/texture_layer.cc
@@ -45,6 +45,7 @@ void TextureLayer::ClearClient() {
layer_tree_host()->StopRateLimiter();
client_ = NULL;
ClearTexture();
+ UpdateDrawsContent(HasDrawableContent());
}
void TextureLayer::ClearTexture() {
@@ -136,6 +137,7 @@ void TextureLayer::SetTextureMailboxInternal(
else
SetNeedsPushProperties();
+ UpdateDrawsContent(HasDrawableContent());
// The active frame needs to be replaced and the mailbox returned before the
// commit is called complete.
SetNextCommitWaitsForActivation();
@@ -198,8 +200,8 @@ void TextureLayer::SetLayerTreeHost(LayerTreeHost* host) {
Layer::SetLayerTreeHost(host);
}
-bool TextureLayer::DrawsContent() const {
- return (client_ || holder_ref_) && Layer::DrawsContent();
+bool TextureLayer::HasDrawableContent() const {
+ return (client_ || holder_ref_) && Layer::HasDrawableContent();
}
bool TextureLayer::Update(ResourceUpdateQueue* queue,
diff --git a/cc/layers/texture_layer.h b/cc/layers/texture_layer.h
index aa2ed56..fb25da6 100644
--- a/cc/layers/texture_layer.h
+++ b/cc/layers/texture_layer.h
@@ -134,7 +134,6 @@ class CC_EXPORT TextureLayer : public Layer {
virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect) OVERRIDE;
virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) OVERRIDE;
- virtual bool DrawsContent() const OVERRIDE;
virtual bool Update(ResourceUpdateQueue* queue,
const OcclusionTracker<Layer>* occlusion) OVERRIDE;
virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
@@ -143,6 +142,7 @@ class CC_EXPORT TextureLayer : public Layer {
protected:
explicit TextureLayer(TextureLayerClient* client);
virtual ~TextureLayer();
+ virtual bool HasDrawableContent() const OVERRIDE;
private:
void SetTextureMailboxInternal(
diff --git a/cc/layers/tiled_layer.cc b/cc/layers/tiled_layer.cc
index 6656405..c1937e4 100644
--- a/cc/layers/tiled_layer.cc
+++ b/cc/layers/tiled_layer.cc
@@ -154,27 +154,26 @@ void TiledLayer::UpdateBounds() {
for (Region::Iterator new_rects(new_region); new_rects.has_rect();
new_rects.next())
InvalidateContentRect(new_rects.rect());
+ UpdateDrawsContent(HasDrawableContent());
}
void TiledLayer::SetTileSize(const gfx::Size& size) {
tiler_->SetTileSize(size);
+ UpdateDrawsContent(HasDrawableContent());
}
void TiledLayer::SetBorderTexelOption(
LayerTilingData::BorderTexelOption border_texel_option) {
tiler_->SetBorderTexelOption(border_texel_option);
+ UpdateDrawsContent(HasDrawableContent());
}
-bool TiledLayer::DrawsContent() const {
- if (!ContentsScalingLayer::DrawsContent())
- return false;
-
+bool TiledLayer::HasDrawableContent() const {
bool has_more_than_one_tile =
- tiler_->num_tiles_x() > 1 || tiler_->num_tiles_y() > 1;
- if (tiling_option_ == NEVER_TILE && has_more_than_one_tile)
- return false;
+ (tiler_->num_tiles_x() > 1) || (tiler_->num_tiles_y() > 1);
- return true;
+ return !(tiling_option_ == NEVER_TILE && has_more_than_one_tile) &&
+ ContentsScalingLayer::HasDrawableContent();
}
void TiledLayer::ReduceMemoryUsage() {
diff --git a/cc/layers/tiled_layer.h b/cc/layers/tiled_layer.h
index e272497..4a83e45 100644
--- a/cc/layers/tiled_layer.h
+++ b/cc/layers/tiled_layer.h
@@ -27,7 +27,6 @@ class CC_EXPORT TiledLayer : public ContentsScalingLayer {
// Layer implementation.
virtual void SetIsMask(bool is_mask) OVERRIDE;
virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
- virtual bool DrawsContent() const OVERRIDE;
virtual void ReduceMemoryUsage() OVERRIDE;
virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect) OVERRIDE;
virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) OVERRIDE;
@@ -68,6 +67,8 @@ class CC_EXPORT TiledLayer : public ContentsScalingLayer {
bool SkipsDraw() const { return skips_draw_; }
+ virtual bool HasDrawableContent() const OVERRIDE;
+
// Virtual for testing
virtual PrioritizedResourceManager* ResourceManager();
const LayerTilingData* TilerForTesting() const { return tiler_.get(); }
diff --git a/cc/layers/ui_resource_layer.cc b/cc/layers/ui_resource_layer.cc
index b26ebaa..59fbe83 100644
--- a/cc/layers/ui_resource_layer.cc
+++ b/cc/layers/ui_resource_layer.cc
@@ -113,11 +113,11 @@ void UIResourceLayer::SetLayerTreeHost(LayerTreeHost* host) {
void UIResourceLayer::RecreateUIResourceHolder() {
ui_resource_holder_.reset();
- if (!layer_tree_host() || bitmap_.empty())
- return;
-
- ui_resource_holder_ =
- ScopedUIResourceHolder::Create(layer_tree_host(), bitmap_);
+ if (layer_tree_host() && !bitmap_.empty()) {
+ ui_resource_holder_ =
+ ScopedUIResourceHolder::Create(layer_tree_host(), bitmap_);
+ }
+ UpdateDrawsContent(HasDrawableContent());
}
void UIResourceLayer::SetBitmap(const SkBitmap& skbitmap) {
@@ -137,12 +137,13 @@ void UIResourceLayer::SetUIResourceId(UIResourceId resource_id) {
ui_resource_holder_.reset();
}
+ UpdateDrawsContent(HasDrawableContent());
SetNeedsCommit();
}
-bool UIResourceLayer::DrawsContent() const {
+bool UIResourceLayer::HasDrawableContent() const {
return ui_resource_holder_ && ui_resource_holder_->id() &&
- Layer::DrawsContent();
+ Layer::HasDrawableContent();
}
void UIResourceLayer::PushPropertiesTo(LayerImpl* layer) {
diff --git a/cc/layers/ui_resource_layer.h b/cc/layers/ui_resource_layer.h
index d99c073..8e278a9 100644
--- a/cc/layers/ui_resource_layer.h
+++ b/cc/layers/ui_resource_layer.h
@@ -20,8 +20,6 @@ class CC_EXPORT UIResourceLayer : public Layer {
public:
static scoped_refptr<UIResourceLayer> Create();
- virtual bool DrawsContent() const OVERRIDE;
-
virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE;
@@ -51,6 +49,8 @@ class CC_EXPORT UIResourceLayer : public Layer {
UIResourceLayer();
virtual ~UIResourceLayer();
+ virtual bool HasDrawableContent() const OVERRIDE;
+
scoped_ptr<UIResourceHolder> ui_resource_holder_;
SkBitmap bitmap_;
diff --git a/cc/test/fake_delegated_renderer_layer_impl.h b/cc/test/fake_delegated_renderer_layer_impl.h
index 157f5d6..f909d24 100644
--- a/cc/test/fake_delegated_renderer_layer_impl.h
+++ b/cc/test/fake_delegated_renderer_layer_impl.h
@@ -28,7 +28,6 @@ class FakeDelegatedRendererLayerImpl : public DelegatedRendererLayerImpl {
void SetFrameDataForRenderPasses(float device_scale_factor,
RenderPassList* pass_list);
-
protected:
FakeDelegatedRendererLayerImpl(LayerTreeImpl* tree_impl, int id);
};
diff --git a/cc/test/fake_layer_tree_host_impl.cc b/cc/test/fake_layer_tree_host_impl.cc
index 84f75e0..0505bbd 100644
--- a/cc/test/fake_layer_tree_host_impl.cc
+++ b/cc/test/fake_layer_tree_host_impl.cc
@@ -62,4 +62,26 @@ void FakeLayerTreeHostImpl::SetCurrentFrameTimeTicks(
current_frame_time_ticks_ = current_frame_time_ticks;
}
+int FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(LayerImpl* layer) {
+ int num_children_that_draw_content = 0;
+ for (size_t i = 0; i < layer->children().size(); ++i) {
+ num_children_that_draw_content +=
+ RecursiveUpdateNumChildren(layer->children()[i]);
+ }
+ if (layer->DrawsContent() && layer->HasDelegatedContent())
+ num_children_that_draw_content += 1000;
+ layer->SetNumDescendantsThatDrawContent(num_children_that_draw_content);
+ return num_children_that_draw_content + (layer->DrawsContent() ? 1 : 0);
+}
+
+void FakeLayerTreeHostImpl::UpdateNumChildrenAndDrawPropertiesForActiveTree() {
+ UpdateNumChildrenAndDrawProperties(active_tree());
+}
+
+void FakeLayerTreeHostImpl::UpdateNumChildrenAndDrawProperties(
+ LayerTreeImpl* layerTree) {
+ RecursiveUpdateNumChildren(layerTree->root_layer());
+ layerTree->UpdateDrawProperties();
+}
+
} // namespace cc
diff --git a/cc/test/fake_layer_tree_host_impl.h b/cc/test/fake_layer_tree_host_impl.h
index 38957a8..0d0014c 100644
--- a/cc/test/fake_layer_tree_host_impl.h
+++ b/cc/test/fake_layer_tree_host_impl.h
@@ -30,6 +30,9 @@ class FakeLayerTreeHostImpl : public LayerTreeHostImpl {
virtual base::TimeTicks CurrentFrameTimeTicks() OVERRIDE;
void SetCurrentFrameTimeTicks(base::TimeTicks current_frame_time_ticks);
+ void UpdateNumChildrenAndDrawPropertiesForActiveTree();
+ static void UpdateNumChildrenAndDrawProperties(LayerTreeImpl* layerTree);
+ static int RecursiveUpdateNumChildren(LayerImpl* layer);
using LayerTreeHostImpl::ActivateSyncTree;
using LayerTreeHostImpl::manage_tiles_needed;
diff --git a/cc/trees/damage_tracker_unittest.cc b/cc/trees/damage_tracker_unittest.cc
index 169eea4..b6a4409 100644
--- a/cc/trees/damage_tracker_unittest.cc
+++ b/cc/trees/damage_tracker_unittest.cc
@@ -30,6 +30,7 @@ void ExecuteCalculateDrawProperties(LayerImpl* root,
ASSERT_TRUE(root->render_surface());
ASSERT_FALSE(render_surface_layer_list->size());
+ FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root);
LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
root, root->bounds(), render_surface_layer_list);
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc
index 51fb080..840a32b 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -583,7 +583,7 @@ static bool SubtreeShouldRenderToSeparateSurface(
}
int num_descendants_that_draw_content =
- layer->draw_properties().num_descendants_that_draw_content;
+ layer->NumDescendantsThatDrawContent();
// If the layer flattens its subtree, but it is treated as a 3D object by its
// parent (i.e. parent participates in a 3D rendering context).
@@ -1207,8 +1207,6 @@ template <typename LayerType>
static void PreCalculateMetaInformation(
LayerType* layer,
PreCalculateMetaInformationRecursiveData* recursive_data) {
- bool has_delegated_content = layer->HasDelegatedContent();
- int num_descendants_that_draw_content = 0;
layer->draw_properties().sorted_for_recursion = false;
layer->draw_properties().has_child_with_a_scroll_parent = false;
@@ -1219,14 +1217,6 @@ static void PreCalculateMetaInformation(
return;
}
- if (has_delegated_content) {
- // Layers with delegated content need to be treated as if they have as
- // many children as the number of layers they own delegated quads for.
- // Since we don't know this number right now, we choose one that acts like
- // infinity for our purposes.
- num_descendants_that_draw_content = 1000;
- }
-
if (layer->clip_parent())
recursive_data->num_unclipped_descendants++;
@@ -1237,10 +1227,6 @@ static void PreCalculateMetaInformation(
PreCalculateMetaInformationRecursiveData data_for_child;
PreCalculateMetaInformation(child_layer, &data_for_child);
- num_descendants_that_draw_content += child_layer->DrawsContent() ? 1 : 0;
- num_descendants_that_draw_content +=
- child_layer->draw_properties().num_descendants_that_draw_content;
-
if (child_layer->scroll_parent())
layer->draw_properties().has_child_with_a_scroll_parent = true;
recursive_data->Merge(data_for_child);
@@ -1259,8 +1245,6 @@ static void PreCalculateMetaInformation(
layer->have_wheel_event_handlers())
recursive_data->layer_or_descendant_has_input_handler = true;
- layer->draw_properties().num_descendants_that_draw_content =
- num_descendants_that_draw_content;
layer->draw_properties().num_unclipped_descendants =
recursive_data->num_unclipped_descendants;
layer->draw_properties().layer_or_descendant_has_copy_request =
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index 6429e81..66b63a5 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -6945,6 +6945,7 @@ TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) {
{
LayerImplList render_surface_layer_list;
+ FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root.get());
LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
root.get(), root->bounds(), &render_surface_layer_list);
inputs.can_render_to_separate_surface = true;
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index fe2a234..92166b9 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -1845,6 +1845,8 @@ TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) {
EXPECT_FALSE(layer2->did_draw_called());
LayerTreeHostImpl::FrameData frame;
+ FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(
+ host_impl_->active_tree()->root_layer());
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
@@ -3678,6 +3680,8 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
layer2->SetExpectation(false, false);
layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
+ FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(
+ host_impl_->active_tree()->root_layer());
EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
EXPECT_TRUE(layer1->quads_appended());
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index 94383da..2ddee12 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -2996,6 +2996,8 @@ class PushPropertiesCountingLayer : public Layer {
PassAs<LayerImpl>();
}
+ void SetDrawsContent(bool draws_content) { SetIsDrawable(draws_content); }
+
size_t push_properties_count() const { return push_properties_count_; }
void reset_push_properties_count() { push_properties_count_ = 0; }
@@ -3007,7 +3009,6 @@ class PushPropertiesCountingLayer : public Layer {
PushPropertiesCountingLayer()
: push_properties_count_(0), persist_needs_push_properties_(false) {
SetBounds(gfx::Size(1, 1));
- SetIsDrawable(true);
}
virtual ~PushPropertiesCountingLayer() {}
@@ -3464,6 +3465,59 @@ class LayerTreeHostTestPropertyChangesDuringUpdateArePushed
MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed);
+class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest {
+ protected:
+ virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
+
+ virtual void SetupTree() OVERRIDE {
+ root_ = PushPropertiesCountingLayer::Create();
+ child_ = PushPropertiesCountingLayer::Create();
+ root_->AddChild(child_);
+
+ layer_tree_host()->SetRootLayer(root_);
+ LayerTreeHostTest::SetupTree();
+ }
+
+ virtual void DidCommitAndDrawFrame() OVERRIDE {
+ switch (layer_tree_host()->source_frame_number()) {
+ case 0:
+ break;
+ case 1: {
+ // During update, the ignore_set_needs_commit_ bit is set to true to
+ // avoid causing a second commit to be scheduled. If a property change
+ // is made during this, however, it needs to be pushed in the upcoming
+ // commit.
+ EXPECT_FALSE(root_->needs_push_properties());
+ EXPECT_FALSE(child_->needs_push_properties());
+ EXPECT_EQ(0, root_->NumDescendantsThatDrawContent());
+ root_->reset_push_properties_count();
+ child_->reset_push_properties_count();
+ child_->SetDrawsContent(true);
+ EXPECT_EQ(1, root_->NumDescendantsThatDrawContent());
+ EXPECT_EQ(0u, root_->push_properties_count());
+ EXPECT_EQ(0u, child_->push_properties_count());
+ EXPECT_TRUE(root_->needs_push_properties());
+ EXPECT_TRUE(child_->needs_push_properties());
+ break;
+ }
+ case 2:
+ EXPECT_EQ(1u, root_->push_properties_count());
+ EXPECT_EQ(1u, child_->push_properties_count());
+ EXPECT_FALSE(root_->needs_push_properties());
+ EXPECT_FALSE(child_->needs_push_properties());
+ EndTest();
+ break;
+ }
+ }
+
+ virtual void AfterTest() OVERRIDE {}
+
+ scoped_refptr<PushPropertiesCountingLayer> root_;
+ scoped_refptr<PushPropertiesCountingLayer> child_;
+};
+
+MULTI_THREAD_TEST_F(LayerTreeHostTestSetDrawableCausesCommit);
+
class LayerTreeHostTestCasePushPropertiesThreeGrandChildren
: public LayerTreeHostTest {
protected:
diff --git a/cc/trees/layer_tree_impl_unittest.cc b/cc/trees/layer_tree_impl_unittest.cc
index d215349..7c917e0 100644
--- a/cc/trees/layer_tree_impl_unittest.cc
+++ b/cc/trees/layer_tree_impl_unittest.cc
@@ -62,7 +62,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSingleLayer) {
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
@@ -128,7 +128,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) {
host_impl().SetViewportSize(hud_bounds);
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
@@ -186,7 +186,7 @@ TEST_F(LayerTreeImplTest, HitTestingForUninvertibleTransform) {
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size());
@@ -252,7 +252,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSinglePositionedLayer) {
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
@@ -308,7 +308,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSingleRotatedLayer) {
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
@@ -377,7 +377,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) {
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
@@ -457,7 +457,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSingleLayerWithScaledContents) {
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
// The visible content rect for test_layer is actually 100x100, even though
@@ -548,7 +548,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSimpleClippedLayer) {
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
@@ -673,7 +673,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultiClippedRotatedLayer) {
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
// The grand_child is expected to create a render surface because it
@@ -796,7 +796,7 @@ TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) {
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
@@ -904,7 +904,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) {
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_TRUE(child1);
@@ -1052,7 +1052,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) {
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_TRUE(child1);
@@ -1170,7 +1170,7 @@ TEST_F(LayerTreeImplTest, HitTestingRespectsClipParents) {
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
gfx::Point test_point = gfx::Point(12, 52);
LayerImpl* result_layer =
@@ -1245,7 +1245,7 @@ TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) {
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
gfx::Point test_point = gfx::Point(12, 52);
LayerImpl* result_layer =
@@ -1338,7 +1338,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) {
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_TRUE(child1);
@@ -1428,7 +1428,7 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSingleLayer) {
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
@@ -1517,7 +1517,7 @@ TEST_F(LayerTreeImplTest,
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
@@ -1595,7 +1595,7 @@ TEST_F(LayerTreeImplTest,
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
@@ -1691,7 +1691,7 @@ TEST_F(LayerTreeImplTest,
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
// The visible content rect for test_layer is actually 100x100, even though
@@ -1800,7 +1800,7 @@ TEST_F(LayerTreeImplTest,
page_scale_factor, page_scale_factor, page_scale_factor);
host_impl().active_tree()->SetRootLayer(root.Pass());
host_impl().active_tree()->SetViewportLayersFromIds(1, 1, Layer::INVALID_ID);
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
// The visible content rect for test_layer is actually 100x100, even though
@@ -1930,7 +1930,7 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) {
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
@@ -2028,7 +2028,7 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) {
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
@@ -2090,7 +2090,7 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) {
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
@@ -2191,7 +2191,7 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForPartialOccludedLayers) {
host_impl().SetViewportSize(root->bounds());
host_impl().active_tree()->SetRootLayer(root.Pass());
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
@@ -2286,7 +2286,7 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForScaledLayers) {
page_scale_factor, page_scale_factor, page_scale_factor);
host_impl().active_tree()->SetRootLayer(root.Pass());
host_impl().active_tree()->SetViewportLayersFromIds(1, 1, Layer::INVALID_ID);
- host_impl().active_tree()->UpdateDrawProperties();
+ host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
diff --git a/cc/trees/occlusion_tracker_unittest.cc b/cc/trees/occlusion_tracker_unittest.cc
index 1a6529b..e6464a2 100644
--- a/cc/trees/occlusion_tracker_unittest.cc
+++ b/cc/trees/occlusion_tracker_unittest.cc
@@ -133,6 +133,8 @@ struct OcclusionTrackerTestMainThreadTypes {
}
static void DestroyLayer(LayerPtrType* layer) { *layer = NULL; }
+
+ static void RecursiveUpdateNumChildren(LayerType* layerType) {}
};
struct OcclusionTrackerTestImplThreadTypes {
@@ -162,6 +164,10 @@ struct OcclusionTrackerTestImplThreadTypes {
}
static void DestroyLayer(LayerPtrType* layer) { layer->reset(); }
+
+ static void RecursiveUpdateNumChildren(LayerType* layer) {
+ FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(layer);
+ }
};
int OcclusionTrackerTestImplThreadTypes::next_layer_impl_id = 1;
@@ -304,6 +310,7 @@ template <typename Types> class OcclusionTrackerTest : public testing::Test {
DCHECK(root == root_.get());
DCHECK(!root->render_surface());
+ Types::RecursiveUpdateNumChildren(root);
LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
root, root->bounds(), &render_surface_layer_list_impl_);
inputs.can_adjust_raster_scales = true;