Cherry-pick with modification: cc: PictureLayerImpl with empty bounds should not have tiles

Cherry-pick of Chromium

Removed changes to add new test to avoid gyp/mk churn.

BUG: 11288267

Original description:

If a PictureLayer bounds is set to from non-empty to empty,
PictureLayer::Update is skipped so the picture pile is not
updated. In this case, the PictureLayerImpl should not have

Change-Id: Ib022c99a34d2933dd2aba37bffd616fa114eaf42
diff --git a/cc/layers/ b/cc/layers/
index 889e2fb..c84ade3 100644
--- a/cc/layers/
+++ b/cc/layers/
@@ -41,6 +41,18 @@
   // This should be first so others can use it.
+  if (layer_impl->bounds().IsEmpty()) {
+    // Update may not get called for an empty layer, so resize here instead.
+    // Using layer_impl because either bounds() or paint_properties().bounds
+    // may disagree and either one could have been pushed to layer_impl.
+    pile_->Resize(layer_impl->bounds());
+    pile_->UpdateRecordedRegion();
+  }
+  if (DrawsContent()) {
+    DCHECK(paint_properties().bounds == pile_->size());
+  }
   // Unlike other properties, invalidation must always be set on layer_impl.