summaryrefslogtreecommitdiffstats
path: root/cc/layers
diff options
context:
space:
mode:
authorvollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-19 19:13:22 +0000
committervollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-19 19:13:22 +0000
commit44d8e84c39855ae33772d3fa6ce35d6a5a936932 (patch)
treebc19a43d9962f50cbf047fad71aaac106ef502ce /cc/layers
parent03d7bea45a3d5dca915fd437e3b2625453aaf95a (diff)
downloadchromium_src-44d8e84c39855ae33772d3fa6ce35d6a5a936932.zip
chromium_src-44d8e84c39855ae33772d3fa6ce35d6a5a936932.tar.gz
chromium_src-44d8e84c39855ae33772d3fa6ce35d6a5a936932.tar.bz2
Only allocate temporary layer lists when sorting contributions.
Previously, I'd constructed temporary layer lists to hold the layer list contributions from children when I visited them out of order in CalcDrawProps. Unfortunately ~RenderSurfaceLayerList frees all the surfaces, so when the temporary lists were destroyed, the surfaces would be nuked. To work around this, I don't pass temporary lists to children, I just sort the "real" lists after the recursion. When doing this sorting I allocate a LayerList for Layers and a LayerImplList for LayerImpls. The types got a bit unwieldy when doing this, so I also put some handy typedefs in Layer and LayerImpl. This lets us cut down on the number of template parameters we use in LTHC. TEST=LayerTreeHostCommonTest.OutOfOrderClippingRequiresRSLLSorting R=danakj@chromium.org BUG=309381 Review URL: https://codereview.chromium.org/29653002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229619 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layers')
-rw-r--r--cc/layers/draw_properties.h4
-rw-r--r--cc/layers/layer.h12
-rw-r--r--cc/layers/layer_impl.h10
-rw-r--r--cc/layers/layer_lists.cc7
-rw-r--r--cc/layers/layer_lists.h2
5 files changed, 25 insertions, 10 deletions
diff --git a/cc/layers/draw_properties.h b/cc/layers/draw_properties.h
index b81bec7..990b4c97 100644
--- a/cc/layers/draw_properties.h
+++ b/cc/layers/draw_properties.h
@@ -13,7 +13,7 @@ namespace cc {
// Container for properties that layers need to compute before they can be
// drawn.
-template <typename LayerType, typename RenderSurfaceType>
+template <typename LayerType>
struct CC_EXPORT DrawProperties {
DrawProperties()
: opacity(0.f),
@@ -70,7 +70,7 @@ struct CC_EXPORT DrawProperties {
LayerType* render_target;
// The surface that this layer and its subtree would contribute to.
- scoped_ptr<RenderSurfaceType> render_surface;
+ scoped_ptr<typename LayerType::RenderSurfaceType> render_surface;
// This rect is in the layer's content space.
gfx::Rect visible_content_rect;
diff --git a/cc/layers/layer.h b/cc/layers/layer.h
index 6f391ac..e1bed9b 100644
--- a/cc/layers/layer.h
+++ b/cc/layers/layer.h
@@ -60,6 +60,10 @@ struct AnimationEvent;
class CC_EXPORT Layer : public base::RefCounted<Layer>,
public LayerAnimationValueObserver {
public:
+ typedef RenderSurfaceLayerList RenderSurfaceListType;
+ typedef LayerList LayerListType;
+ typedef RenderSurface RenderSurfaceType;
+
enum LayerIdLabels {
INVALID_ID = -1,
};
@@ -185,10 +189,8 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>,
return clip_children_.get();
}
- DrawProperties<Layer, RenderSurface>& draw_properties() {
- return draw_properties_;
- }
- const DrawProperties<Layer, RenderSurface>& draw_properties() const {
+ DrawProperties<Layer>& draw_properties() { return draw_properties_; }
+ const DrawProperties<Layer>& draw_properties() const {
return draw_properties_;
}
@@ -579,7 +581,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>,
base::Closure did_scroll_callback_;
- DrawProperties<Layer, RenderSurface> draw_properties_;
+ DrawProperties<Layer> draw_properties_;
PaintProperties paint_properties_;
diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h
index 6513b32..2048840 100644
--- a/cc/layers/layer_impl.h
+++ b/cc/layers/layer_impl.h
@@ -59,6 +59,10 @@ enum DrawMode {
class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
public:
+ typedef LayerImplList RenderSurfaceListType;
+ typedef LayerImplList LayerListType;
+ typedef RenderSurfaceImpl RenderSurfaceType;
+
static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) {
return make_scoped_ptr(new LayerImpl(tree_impl, id));
}
@@ -267,10 +271,10 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
void CreateRenderSurface();
void ClearRenderSurface();
- DrawProperties<LayerImpl, RenderSurfaceImpl>& draw_properties() {
+ DrawProperties<LayerImpl>& draw_properties() {
return draw_properties_;
}
- const DrawProperties<LayerImpl, RenderSurfaceImpl>& draw_properties() const {
+ const DrawProperties<LayerImpl>& draw_properties() const {
return draw_properties_;
}
@@ -613,7 +617,7 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
// Group of properties that need to be computed based on the layer tree
// hierarchy before layers can be drawn.
- DrawProperties<LayerImpl, RenderSurfaceImpl> draw_properties_;
+ DrawProperties<LayerImpl> draw_properties_;
DISALLOW_COPY_AND_ASSIGN(LayerImpl);
};
diff --git a/cc/layers/layer_lists.cc b/cc/layers/layer_lists.cc
index 89cd498..fda1a1c 100644
--- a/cc/layers/layer_lists.cc
+++ b/cc/layers/layer_lists.cc
@@ -35,6 +35,13 @@ size_t RenderSurfaceLayerList::size() const {
return list_.size();
}
+scoped_refptr<Layer>& RenderSurfaceLayerList::operator[](size_t i) {
+ return list_[i];
+}
+const scoped_refptr<Layer>& RenderSurfaceLayerList::operator[](size_t i) const {
+ return list_[i];
+}
+
LayerList::iterator RenderSurfaceLayerList::begin() {
return list_.begin();
}
diff --git a/cc/layers/layer_lists.h b/cc/layers/layer_lists.h
index 24a9c3c..01a7966 100644
--- a/cc/layers/layer_lists.h
+++ b/cc/layers/layer_lists.h
@@ -31,6 +31,8 @@ class CC_EXPORT RenderSurfaceLayerList {
Layer* back();
size_t size() const;
bool empty() const { return size() == 0u; }
+ scoped_refptr<Layer>& operator[](size_t i);
+ const scoped_refptr<Layer>& operator[](size_t i) const;
LayerList::iterator begin();
LayerList::iterator end();
LayerList::const_iterator begin() const;