cc: Clean up LayerTreeHostImplTest init and add check for lost context
I wanted to add a DCHECK() that we call
LayerTreeHostImpl::DidLoseOutputSurface always before destroying
and recreating the ResourceProvider etc.
This failed not on any context loss tests, but rather on a bunch
of LayerTreeHostImplTests (mostly) that were re-initializing the
renderer by hand.
So, instead of having these tests poke the LayerTreeHostImpl in
a weird way, I cleaned up the way the tests create and initialize
the LayerTreeHostImpl.
Test-only change, no new tests.
R=enne, jamesr
BUG=313790
Review URL: https://codereview.chromium.org/93183002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237739 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 060b25c..21d71cf 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -254,6 +254,9 @@
rendering_stats_instrumentation_(rendering_stats_instrumentation),
micro_benchmark_controller_(this),
need_to_update_visible_tiles_before_draw_(false),
+#ifndef NDEBUG
+ did_lose_called_(false),
+#endif
shared_bitmap_manager_(manager) {
DCHECK(proxy_->IsImplThread());
DidVisibilityChange(this, visible_);
@@ -1461,6 +1464,9 @@
// important) in production. We should adjust the test to not need this.
if (renderer_)
client_->DidLoseOutputSurfaceOnImplThread();
+#ifndef NDEBUG
+ did_lose_called_ = true;
+#endif
}
void LayerTreeHostImpl::Readback(void* pixels,
@@ -1695,6 +1701,10 @@
bool LayerTreeHostImpl::InitializeRenderer(
scoped_ptr<OutputSurface> output_surface) {
+#ifndef NDEBUG
+ DCHECK(!renderer_ || did_lose_called_);
+#endif
+
// Since we will create a new resource provider, we cannot continue to use
// the old resources (i.e. render_surfaces and texture IDs). Clear them
// before we destroy the old resource provider.