Support single-threaded impl-side painting

This makes the synchronous composite path support impl-side painting.
This initial version is intended for converting layout tests, as a real
version for the browser would commit to the active tree directly.

This path is currently not used anywhere (it DCHECKed) and the only
consumer after this patch is a unittest to verify that it works.

Depends on https://codereview.chromium.org/672673003/ so that
WaitForTasksRunningToComplete includes all visible tiles.

Depends on https://codereview.chromium.org/668123003/ for correctness,
as zero copy and masks aren't supported quite yet.

[email protected],[email protected],[email protected]
BUG=381919

Review URL: https://codereview.chromium.org/667793004

Cr-Commit-Position: refs/heads/master@{#301966}
diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc
index 344dfb97..1af657a3 100644
--- a/cc/trees/single_thread_proxy.cc
+++ b/cc/trees/single_thread_proxy.cc
@@ -467,8 +467,6 @@
 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) {
   TRACE_EVENT0("cc", "SingleThreadProxy::CompositeImmediately");
   DCHECK(Proxy::IsMainThread());
-  DCHECK(!layer_tree_host_impl_->settings().impl_side_painting)
-      << "Impl-side painting and synchronous compositing are not supported.";
   base::AutoReset<bool> inside_composite(&inside_synchronous_composite_, true);
 
   if (layer_tree_host_->output_surface_lost()) {
@@ -493,6 +491,13 @@
 
   {
     DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this));
+    if (layer_tree_host_impl_->settings().impl_side_painting) {
+      layer_tree_host_impl_->ActivateSyncTree();
+      layer_tree_host_impl_->active_tree()->UpdateDrawProperties();
+      layer_tree_host_impl_->ManageTiles();
+      layer_tree_host_impl_->SynchronouslyInitializeAllTiles();
+    }
+
     LayerTreeHostImpl::FrameData frame;
     DoComposite(frame_begin_time, &frame);