cc: Fix resource eviction with impl-side painting.

When evicting resources with impl-side painting we need wait until
the active tree is without evicted resources before we can draw.

This moves the ContentsTexturesPurged state from LTHI to the LTI
and makes LTHI::canDraw() return false when the active LTI has
ContentsTexturesPurged set. The result is no change in behavior
when we only have one tree, while with impl-side painting when
we have two trees, canDraw() will not return true until the new
tree without ContentsTexturesPurged set has been activated.

BUG=170157


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177532 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/cc/layer_tree_impl.cc b/cc/layer_tree_impl.cc
index 769639a4..ad22981 100644
--- a/cc/layer_tree_impl.cc
+++ b/cc/layer_tree_impl.cc
@@ -19,7 +19,8 @@
     , currently_scrolling_layer_(0)
     , background_color_(0)
     , has_transparent_background_(false)
-    , scrolling_layer_id_from_previous_tree_(0) {
+    , scrolling_layer_id_from_previous_tree_(0)
+    , contents_textures_purged_(false) {
 }
 
 LayerTreeImpl::~LayerTreeImpl() {
@@ -215,6 +216,20 @@
     DidBecomeActiveRecursive(RootLayer());
 }
 
+bool LayerTreeImpl::ContentsTexturesPurged() const {
+  return contents_textures_purged_;
+}
+
+void LayerTreeImpl::SetContentsTexturesPurged() {
+  contents_textures_purged_ = true;
+  layer_tree_host_impl_->OnCanDrawStateChangedForTree(this);
+}
+
+void LayerTreeImpl::ResetContentsTexturesPurged() {
+  contents_textures_purged_ = false;
+  layer_tree_host_impl_->OnCanDrawStateChangedForTree(this);
+}
+
 const LayerTreeSettings& LayerTreeImpl::settings() const {
   return layer_tree_host_impl_->settings();
 }