cc: Move updateDrawProperties to LayerTreeImpl

This moves updateDrawProperties and render surface layer list to LayerTreeImpl.
As a bonus, accessing the RSLL before updateDrawProperties is called now
asserts.

[email protected]
BUG=155209


Review URL: https://chromiumcodereview.appspot.com/11640035

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174197 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/cc/layer_tree_impl.cc b/cc/layer_tree_impl.cc
index de4bfa16..949cf84 100644
--- a/cc/layer_tree_impl.cc
+++ b/cc/layer_tree_impl.cc
@@ -4,6 +4,7 @@
 
 #include "cc/layer_tree_impl.h"
 
+#include "base/debug/trace_event.h"
 #include "cc/layer_tree_host_common.h"
 #include "cc/layer_tree_host_impl.h"
 #include "ui/gfx/vector2d_conversions.h"
@@ -64,6 +65,8 @@
     currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0;
   currently_scrolling_layer_ = NULL;
 
+  render_surface_layer_list_.clear();
+  SetNeedsUpdateDrawProperties();
   return root_layer_.Pass();
 }
 
@@ -106,6 +109,49 @@
   root_scroll_layer()->setMaxScrollOffset(gfx::ToFlooredVector2d(max_scroll));
 }
 
+void LayerTreeImpl::UpdateDrawProperties() {
+  render_surface_layer_list_.clear();
+  if (!RootLayer())
+    return;
+
+  if (root_scroll_layer()) {
+    root_scroll_layer()->setImplTransform(
+        layer_tree_host_impl_->implTransform());
+  }
+
+  {
+    TRACE_EVENT0("cc", "LayerTreeImpl::UpdateDrawProperties");
+    LayerTreeHostCommon::calculateDrawProperties(
+        RootLayer(),
+        device_viewport_size(),
+        device_scale_factor(),
+        pinch_zoom_viewport().pageScaleFactor(),
+        layer_tree_host_impl_->rendererCapabilities().maxTextureSize,
+        settings().canUseLCDText,
+        render_surface_layer_list_);
+  }
+}
+
+static void ClearRenderSurfacesOnLayerImplRecursive(LayerImpl* current)
+{
+    DCHECK(current);
+    for (size_t i = 0; i < current->children().size(); ++i)
+        ClearRenderSurfacesOnLayerImplRecursive(current->children()[i]);
+    current->clearRenderSurface();
+}
+
+void LayerTreeImpl::ClearRenderSurfaces() {
+  ClearRenderSurfacesOnLayerImplRecursive(RootLayer());
+  render_surface_layer_list_.clear();
+  SetNeedsUpdateDrawProperties();
+}
+
+const LayerTreeImpl::LayerList& LayerTreeImpl::RenderSurfaceLayerList() const {
+  // If this assert triggers, then the list is dirty.
+  DCHECK(!layer_tree_host_impl_->needsUpdateDrawProperties());
+  return render_surface_layer_list_;
+}
+
 gfx::Size LayerTreeImpl::ContentSize() const {
   // TODO(aelias): Hardcoding the first child here is weird. Think of
   // a cleaner way to get the contentBounds on the Impl side.