summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-08 22:43:26 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-08 22:43:26 +0000
commitc9addd1a9ec9bd14e242268b4a7e368e4bd377d3 (patch)
treeaea96e5929800059075e2268d850e8f12285dd11 /cc
parent384cc73aee79d33baa743398c583adba702ce5e6 (diff)
downloadchromium_src-c9addd1a9ec9bd14e242268b4a7e368e4bd377d3.zip
chromium_src-c9addd1a9ec9bd14e242268b4a7e368e4bd377d3.tar.gz
chromium_src-c9addd1a9ec9bd14e242268b4a7e368e4bd377d3.tar.bz2
Rely on lost context callbacks intead of polling
The compositor is notified of a lost context event through the ContextProvider's lost context callback. We also had various pieces of code that expilcitly polled the context to see if it was still alive and attempted to fail faster if the context was lost. This logic is not really necessary, however, since on a lost context the callback will always be invoked sooner or later and these early exit + recover paths add significantly complexity to the compositor and the context bindings. This strips out code that polls for a lost context inside cc and instead performs recovery on the lost context callback. This also stops attempting to make the compositor's context current before making calls. Since we use the object-oriented C++ bindings to talk to the context implementation, there's no need to update the current context pointer in TLS in order to issue GL calls. Ganesh still uses the TLS pointer for its bindings so we do have an entry point to make that context current when necessary. BUG=181120 Review URL: https://codereview.chromium.org/107193003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239415 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/output/context_provider.h1
-rw-r--r--cc/output/delegating_renderer.cc6
-rw-r--r--cc/output/gl_renderer.cc36
-rw-r--r--cc/output/gl_renderer.h4
-rw-r--r--cc/output/gl_renderer_unittest.cc22
-rw-r--r--cc/output/output_surface_unittest.cc5
-rw-r--r--cc/resources/resource_provider.cc23
-rw-r--r--cc/test/test_context_provider.cc6
-rw-r--r--cc/test/test_context_provider.h1
-rw-r--r--cc/test/test_web_graphics_context_3d.cc12
-rw-r--r--cc/test/test_web_graphics_context_3d.h8
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc46
-rw-r--r--cc/trees/layer_tree_host_unittest_context.cc385
13 files changed, 60 insertions, 495 deletions
diff --git a/cc/output/context_provider.h b/cc/output/context_provider.h
index d615d17..ef46d09 100644
--- a/cc/output/context_provider.h
+++ b/cc/output/context_provider.h
@@ -33,6 +33,7 @@ class ContextProvider : public base::RefCountedThreadSafe<ContextProvider> {
virtual gpu::gles2::GLES2Interface* ContextGL() = 0;
virtual gpu::ContextSupport* ContextSupport() = 0;
virtual class GrContext* GrContext() = 0;
+ virtual void MakeGrContextCurrent() = 0;
struct Capabilities {
bool egl_image_external : 1;
diff --git a/cc/output/delegating_renderer.cc b/cc/output/delegating_renderer.cc
index 51cb946..9532cc3 100644
--- a/cc/output/delegating_renderer.cc
+++ b/cc/output/delegating_renderer.cc
@@ -67,12 +67,6 @@ bool DelegatingRenderer::Initialize() {
return true;
}
- WebGraphicsContext3D* context3d =
- output_surface_->context_provider()->Context3d();
-
- if (!context3d->makeContextCurrent())
- return false;
-
const ContextProvider::Capabilities& caps =
output_surface_->context_provider()->ContextCapabilities();
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index 15cb3a2..a910cb3 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -156,8 +156,7 @@ scoped_ptr<GLRenderer> GLRenderer::Create(
resource_provider,
texture_mailbox_deleter,
highp_threshold_min));
- if (!renderer->Initialize())
- return scoped_ptr<GLRenderer>();
+ renderer->Initialize();
return renderer.Pass();
}
@@ -187,10 +186,7 @@ GLRenderer::GLRenderer(RendererClient* client,
DCHECK(context_support_);
}
-bool GLRenderer::Initialize() {
- if (!context_->makeContextCurrent())
- return false;
-
+void GLRenderer::Initialize() {
ContextProvider::Capabilities context_caps =
output_surface_->context_provider()->ContextCapabilities();
@@ -219,12 +215,10 @@ bool GLRenderer::Initialize() {
capabilities_.using_discard_framebuffer =
context_caps.discard_framebuffer;
- if (!InitializeSharedObjects())
- return false;
+ InitializeSharedObjects();
// Make sure the viewport and context gets initialized, even if it is to zero.
ViewportChanged();
- return true;
}
GLRenderer::~GLRenderer() {
@@ -325,9 +319,6 @@ void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) {
TRACE_EVENT0("cc", "GLRenderer::DrawLayers");
- MakeContextCurrent();
-
- // TODO(enne): Do we need to reinitialize all of this state per frame?
ReinitializeGLState();
}
@@ -482,7 +473,7 @@ static SkBitmap ApplyImageFilter(GLRenderer* renderer,
renderer->resource_provider()->Flush();
// Make sure skia uses the correct GL context.
- offscreen_contexts->Context3d()->makeContextCurrent();
+ offscreen_contexts->MakeGrContextCurrent();
// Wrap the source texture in a Ganesh platform texture.
GrBackendTextureDesc backend_texture_description;
@@ -541,9 +532,6 @@ static SkBitmap ApplyImageFilter(GLRenderer* renderer,
// visible in the compositor's context.
offscreen_contexts->Context3d()->flush();
- // Use the compositor's GL context again.
- renderer->Context()->makeContextCurrent();
-
return device.accessBitmap(false);
}
@@ -589,7 +577,7 @@ static SkBitmap ApplyBlendModeWithBackdrop(
renderer->resource_provider()->Flush();
// Make sure skia uses the correct GL context.
- offscreen_contexts->Context3d()->makeContextCurrent();
+ offscreen_contexts->MakeGrContextCurrent();
// Wrap the source texture in a Ganesh platform texture.
GrBackendTextureDesc backend_texture_description;
@@ -658,9 +646,6 @@ static SkBitmap ApplyBlendModeWithBackdrop(
// visible in the compositor's context.
offscreen_contexts->Context3d()->flush();
- // Use the compositor's GL context again.
- renderer->Context()->makeContextCurrent();
-
return device.accessBitmap(false);
}
@@ -2360,8 +2345,6 @@ void GLRenderer::DoGetFramebufferPixels(
bool is_async = !cleanup_callback.is_null();
- MakeContextCurrent();
-
bool do_workaround = NeedsIOSurfaceReadbackWorkaround();
unsigned temporary_texture = 0;
@@ -2633,19 +2616,14 @@ void GLRenderer::SetDrawViewport(gfx::Rect window_space_viewport) {
window_space_viewport.height()));
}
-bool GLRenderer::MakeContextCurrent() { return context_->makeContextCurrent(); }
-
-bool GLRenderer::InitializeSharedObjects() {
+void GLRenderer::InitializeSharedObjects() {
TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects");
- MakeContextCurrent();
// Create an FBO for doing offscreen rendering.
GLC(context_, offscreen_framebuffer_id_ = context_->createFramebuffer());
shared_geometry_ = make_scoped_ptr(
new GeometryBinding(context_, QuadVertexRect()));
-
- return true;
}
const GLRenderer::TileCheckerboardProgram*
@@ -3012,8 +2990,6 @@ GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) {
}
void GLRenderer::CleanupSharedObjects() {
- MakeContextCurrent();
-
shared_geometry_.reset();
for (int i = 0; i < NumTexCoordPrecisions; ++i) {
diff --git a/cc/output/gl_renderer.h b/cc/output/gl_renderer.h
index decb7d0..c1daec9 100644
--- a/cc/output/gl_renderer.h
+++ b/cc/output/gl_renderer.h
@@ -90,7 +90,7 @@ class CC_EXPORT GLRenderer : public DirectRenderer {
int highp_threshold_min);
bool IsBackbufferDiscarded() const { return is_backbuffer_discarded_; }
- bool Initialize();
+ void Initialize();
void InitializeGrContext();
const gfx::QuadF& SharedGeometryQuad() const { return shared_geometry_quad_; }
@@ -199,7 +199,7 @@ class CC_EXPORT GLRenderer : public DirectRenderer {
bool MakeContextCurrent();
- bool InitializeSharedObjects();
+ void InitializeSharedObjects();
void CleanupSharedObjects();
typedef base::Callback<void(scoped_ptr<CopyOutputRequest> copy_request,
diff --git a/cc/output/gl_renderer_unittest.cc b/cc/output/gl_renderer_unittest.cc
index eb05784..a83809d 100644
--- a/cc/output/gl_renderer_unittest.cc
+++ b/cc/output/gl_renderer_unittest.cc
@@ -579,7 +579,7 @@ TEST(GLRendererTest2, InitializationDoesNotMakeSynchronousCalls) {
output_surface.get(),
resource_provider.get());
- EXPECT_TRUE(renderer.Initialize());
+ renderer.Initialize();
}
class LoseContextOnFirstGetContext : public TestWebGraphicsContext3D {
@@ -652,7 +652,7 @@ TEST(GLRendererTest2, OpaqueBackground) {
renderer_client.root_render_pass()->has_transparent_background = false;
- EXPECT_TRUE(renderer.Initialize());
+ renderer.Initialize();
// On DEBUG builds, render passes with opaque background clear to blue to
// easily see regions that were not drawn on the screen.
@@ -690,7 +690,7 @@ TEST(GLRendererTest2, TransparentBackground) {
renderer_client.root_render_pass()->has_transparent_background = true;
- EXPECT_TRUE(renderer.Initialize());
+ renderer.Initialize();
EXPECT_CALL(*context, discardFramebufferEXT(GL_FRAMEBUFFER, 1, _))
.Times(1);
@@ -720,7 +720,7 @@ TEST(GLRendererTest2, OffscreenOutputSurface) {
output_surface.get(),
resource_provider.get());
- EXPECT_TRUE(renderer.Initialize());
+ renderer.Initialize();
EXPECT_CALL(*context, discardFramebufferEXT(GL_FRAMEBUFFER, _, _))
.With(Args<2, 1>(ElementsAre(GL_COLOR_ATTACHMENT0)))
@@ -800,7 +800,7 @@ TEST(GLRendererTest2, VisibilityChangeIsLastCall) {
output_surface.get(),
resource_provider.get());
- EXPECT_TRUE(renderer.Initialize());
+ renderer.Initialize();
// Ensure that the call to SetSurfaceVisible is the last call issue to the
// GPU process, after glFlush is called, and after the RendererClient's
@@ -862,7 +862,7 @@ TEST(GLRendererTest2, ActiveTextureState) {
// During initialization we are allowed to set any texture parameters.
EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber());
- EXPECT_TRUE(renderer.Initialize());
+ renderer.Initialize();
cc::RenderPass::Id id(1, 1);
scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
@@ -948,7 +948,7 @@ TEST(GLRendererTest2, ShouldClearRootRenderPass) {
&settings,
output_surface.get(),
resource_provider.get());
- EXPECT_TRUE(renderer.Initialize());
+ renderer.Initialize();
gfx::Rect viewport_rect(renderer_client.DeviceViewport());
ScopedPtrVector<RenderPass>& render_passes =
@@ -1034,7 +1034,7 @@ TEST(GLRendererTest2, ScissorTestWhenClearing) {
&settings,
output_surface.get(),
resource_provider.get());
- EXPECT_TRUE(renderer.Initialize());
+ renderer.Initialize();
EXPECT_FALSE(renderer.Capabilities().using_partial_swap);
gfx::Rect viewport_rect(renderer_client.DeviceViewport());
@@ -1123,7 +1123,7 @@ TEST(GLRendererTest2, NoDiscardOnPartialUpdates) {
&settings,
output_surface.get(),
resource_provider.get());
- EXPECT_TRUE(renderer.Initialize());
+ renderer.Initialize();
EXPECT_TRUE(renderer.Capabilities().using_partial_swap);
gfx::Rect viewport_rect(renderer_client.DeviceViewport());
@@ -1301,7 +1301,7 @@ TEST(GLRendererTest2, ScissorAndViewportWithinNonreshapableSurface) {
&settings,
output_surface.get(),
resource_provider.get());
- EXPECT_TRUE(renderer.Initialize());
+ renderer.Initialize();
EXPECT_FALSE(renderer.Capabilities().using_partial_swap);
gfx::Rect viewport_rect(renderer_client.DeviceViewport().size());
@@ -1648,7 +1648,7 @@ class MockOutputSurfaceTest : public testing::Test, public FakeRendererClient {
renderer_.reset(new FakeRendererGL(
this, &settings_, &output_surface_, resource_provider_.get()));
- EXPECT_TRUE(renderer_->Initialize());
+ renderer_->Initialize();
}
void SwapBuffers() { renderer_->SwapBuffers(CompositorFrameMetadata()); }
diff --git a/cc/output/output_surface_unittest.cc b/cc/output/output_surface_unittest.cc
index 64dfa9d..85d586a 100644
--- a/cc/output/output_surface_unittest.cc
+++ b/cc/output/output_surface_unittest.cc
@@ -153,7 +153,7 @@ TEST(OutputSurfaceTest, ClientPointerIndicatesBindToClientFailure) {
TestContextProvider::Create();
// Lose the context so BindToClient fails.
- context_provider->UnboundTestContext3d()->set_times_make_current_succeeds(0);
+ context_provider->UnboundTestContext3d()->set_context_lost(true);
TestOutputSurface output_surface(context_provider);
EXPECT_FALSE(output_surface.HasClient());
@@ -209,8 +209,7 @@ TEST_F(OutputSurfaceTestInitializeNewContext3d, Success) {
TEST_F(OutputSurfaceTestInitializeNewContext3d, Context3dMakeCurrentFails) {
BindOutputSurface();
- context_provider_->UnboundTestContext3d()
- ->set_times_make_current_succeeds(0);
+ context_provider_->UnboundTestContext3d()->set_context_lost(true);
InitializeNewContextExpectFail();
}
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index a725b4f..3f90129 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -926,12 +926,6 @@ bool ResourceProvider::InitializeGL() {
DCHECK(!texture_id_allocator_);
DCHECK(!buffer_id_allocator_);
- WebGraphicsContext3D* context3d = Context3d();
- DCHECK(context3d);
-
- if (!context3d->makeContextCurrent())
- return false;
-
default_resource_type_ = GLTexture;
const ContextProvider::Capabilities& caps =
@@ -942,8 +936,12 @@ bool ResourceProvider::InitializeGL() {
use_texture_usage_hint_ = caps.texture_usage;
use_compressed_texture_etc1_ = caps.texture_format_etc1;
+ WebGraphicsContext3D* context3d = Context3d();
+ DCHECK(context3d);
+
texture_uploader_ = TextureUploader::Create(context3d);
max_texture_size_ = 0; // Context expects cleared value.
+
GLC(context3d, context3d->getIntegerv(GL_MAX_TEXTURE_SIZE,
&max_texture_size_));
best_texture_format_ = PlatformColor::BestTextureFormat(use_bgra);
@@ -966,7 +964,6 @@ void ResourceProvider::CleanUpGLIfNeeded() {
}
DCHECK(context3d);
- context3d->makeContextCurrent();
texture_uploader_.reset();
texture_id_allocator_.reset();
buffer_id_allocator_.reset();
@@ -1026,8 +1023,6 @@ void ResourceProvider::PrepareSendToParent(const ResourceIdArray& resources,
TransferableResourceArray* list) {
DCHECK(thread_checker_.CalledOnValidThread());
WebGraphicsContext3D* context3d = Context3d();
- if (context3d)
- context3d->makeContextCurrent();
bool need_sync_point = false;
for (ResourceIdArray::const_iterator it = resources.begin();
it != resources.end();
@@ -1054,8 +1049,6 @@ void ResourceProvider::ReceiveFromChild(
int child, const TransferableResourceArray& resources) {
DCHECK(thread_checker_.CalledOnValidThread());
WebGraphicsContext3D* context3d = Context3d();
- if (context3d)
- context3d->makeContextCurrent();
Child& child_info = children_.find(child)->second;
DCHECK(!child_info.marked_for_deletion);
for (TransferableResourceArray::const_iterator it = resources.begin();
@@ -1170,9 +1163,6 @@ bool ResourceProvider::CompareResourceMapIteratorsByChildId(
void ResourceProvider::ReceiveReturnsFromParent(
const ReturnedResourceArray& resources) {
DCHECK(thread_checker_.CalledOnValidThread());
- WebGraphicsContext3D* context3d = Context3d();
- if (context3d)
- context3d->makeContextCurrent();
int child_id = 0;
ResourceIdArray resources_for_child;
@@ -1199,6 +1189,7 @@ void ResourceProvider::ReceiveReturnsFromParent(
sorted_resources.end(),
CompareResourceMapIteratorsByChildId);
+ WebGraphicsContext3D* context3d = Context3d();
ChildMap::iterator child_it = children_.end();
for (size_t i = 0; i < sorted_resources.size(); ++i) {
ReturnedResource& returned = sorted_resources[i].first;
@@ -1303,12 +1294,10 @@ void ResourceProvider::DeleteAndReturnUnusedResourcesToChild(
if (unused.empty() && !child_info->marked_for_deletion)
return;
- WebGraphicsContext3D* context3d = Context3d();
- if (context3d)
- context3d->makeContextCurrent();
ReturnedResourceArray to_return;
+ WebGraphicsContext3D* context3d = Context3d();
bool need_sync_point = false;
for (size_t i = 0; i < unused.size(); ++i) {
ResourceId local_id = unused[i];
diff --git a/cc/test/test_context_provider.cc b/cc/test/test_context_provider.cc
index 501570b..3705a60 100644
--- a/cc/test/test_context_provider.cc
+++ b/cc/test/test_context_provider.cc
@@ -94,12 +94,12 @@ bool TestContextProvider::BindToCurrentThread() {
if (bound_)
return true;
- bound_ = true;
- if (!context3d_->makeContextCurrent()) {
+ if (context3d_->isContextLost()) {
base::AutoLock lock(destroyed_lock_);
destroyed_ = true;
return false;
}
+ bound_ = true;
lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this));
swap_buffers_complete_callback_proxy_.reset(
@@ -145,6 +145,8 @@ class GrContext* TestContextProvider::GrContext() {
return NULL;
}
+void TestContextProvider::MakeGrContextCurrent() {}
+
bool TestContextProvider::IsContextLost() {
DCHECK(bound_);
DCHECK(context_thread_checker_.CalledOnValidThread());
diff --git a/cc/test/test_context_provider.h b/cc/test/test_context_provider.h
index 1f086001..9eed424 100644
--- a/cc/test/test_context_provider.h
+++ b/cc/test/test_context_provider.h
@@ -34,6 +34,7 @@ class TestContextProvider : public cc::ContextProvider {
virtual gpu::gles2::GLES2Interface* ContextGL() OVERRIDE;
virtual gpu::ContextSupport* ContextSupport() OVERRIDE;
virtual class GrContext* GrContext() OVERRIDE;
+ virtual void MakeGrContextCurrent() OVERRIDE;
virtual bool IsContextLost() OVERRIDE;
virtual void VerifyContexts() OVERRIDE;
virtual bool DestroyedOnMainThread() OVERRIDE;
diff --git a/cc/test/test_web_graphics_context_3d.cc b/cc/test/test_web_graphics_context_3d.cc
index 3157e27..7e972f7 100644
--- a/cc/test/test_web_graphics_context_3d.cc
+++ b/cc/test/test_web_graphics_context_3d.cc
@@ -61,7 +61,6 @@ scoped_ptr<TestWebGraphicsContext3D> TestWebGraphicsContext3D::Create() {
TestWebGraphicsContext3D::TestWebGraphicsContext3D()
: FakeWebGraphicsContext3D(),
context_id_(s_context_id++),
- times_make_current_succeeds_(-1),
times_bind_texture_succeeds_(-1),
times_end_query_succeeds_(-1),
times_gen_mailbox_succeeds_(-1),
@@ -107,17 +106,6 @@ void TestWebGraphicsContext3D::CreateNamespace() {
}
}
-bool TestWebGraphicsContext3D::makeContextCurrent() {
- if (times_make_current_succeeds_ >= 0) {
- if (!times_make_current_succeeds_) {
- loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
- GL_INNOCENT_CONTEXT_RESET_ARB);
- }
- --times_make_current_succeeds_;
- }
- return !context_lost_;
-}
-
void TestWebGraphicsContext3D::reshapeWithScaleFactor(
int width, int height, float scale_factor) {
reshape_called_ = true;
diff --git a/cc/test/test_web_graphics_context_3d.h b/cc/test/test_web_graphics_context_3d.h
index 54cf543..b74a6be 100644
--- a/cc/test/test_web_graphics_context_3d.h
+++ b/cc/test/test_web_graphics_context_3d.h
@@ -31,8 +31,6 @@ class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D {
virtual ~TestWebGraphicsContext3D();
- virtual bool makeContextCurrent();
-
virtual void reshapeWithScaleFactor(
int width, int height, float scale_factor);
@@ -167,9 +165,8 @@ class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D {
return test_capabilities_;
}
- // When set, MakeCurrent() will fail after this many times.
- void set_times_make_current_succeeds(int times) {
- times_make_current_succeeds_ = times;
+ void set_context_lost(bool context_lost) {
+ context_lost_ = context_lost;
}
void set_times_bind_texture_succeeds(int times) {
times_bind_texture_succeeds_ = times;
@@ -334,7 +331,6 @@ class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D {
unsigned context_id_;
Attributes attributes_;
ContextProvider::Capabilities test_capabilities_;
- int times_make_current_succeeds_;
int times_bind_texture_succeeds_;
int times_end_query_succeeds_;
int times_gen_mailbox_succeeds_;
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 276b114..3a1cf8d 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -83,7 +83,6 @@ class LayerTreeHostImplTest : public testing::Test,
did_request_redraw_(false),
did_request_manage_tiles_(false),
did_upload_visible_tile_(false),
- did_lose_output_surface_(false),
reduce_memory_result_(true),
current_limit_bytes_(0),
current_priority_cutoff_value_(0) {
@@ -104,9 +103,7 @@ class LayerTreeHostImplTest : public testing::Test,
virtual void TearDown() OVERRIDE {}
- virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE {
- did_lose_output_surface_ = true;
- }
+ virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE {}
virtual void DidSwapBuffersOnImplThread() OVERRIDE {}
virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE {}
virtual void BeginImplFrame(const BeginFrameArgs& args) OVERRIDE {}
@@ -364,7 +361,6 @@ class LayerTreeHostImplTest : public testing::Test,
bool did_request_redraw_;
bool did_request_manage_tiles_;
bool did_upload_visible_tile_;
- bool did_lose_output_surface_;
bool reduce_memory_result_;
base::TimeDelta requested_scrollbar_animation_delay_;
size_t current_limit_bytes_;
@@ -476,7 +472,7 @@ TEST_F(LayerTreeHostImplTest, ScrollWithoutRootLayer) {
TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) {
scoped_ptr<TestWebGraphicsContext3D> context_owned =
TestWebGraphicsContext3D::Create();
- context_owned->set_times_make_current_succeeds(0);
+ context_owned->set_context_lost(true);
scoped_ptr<FakeOutputSurface> output_surface(FakeOutputSurface::Create3d(
context_owned.Pass()));
@@ -4963,12 +4959,10 @@ TEST_F(LayerTreeHostImplTestDeferredInitialize, Fails_OnscreenContext_0) {
// Fail initialization of the onscreen context before the OutputSurface binds
// it to the thread.
- onscreen_context_provider_->UnboundTestContext3d()
- ->set_times_make_current_succeeds(0);
+ onscreen_context_provider_->UnboundTestContext3d()->set_context_lost(true);
EXPECT_FALSE(host_impl_->output_surface()->context_provider());
EXPECT_FALSE(host_impl_->offscreen_context_provider());
- EXPECT_FALSE(did_lose_output_surface_);
// DeferredInitialize fails.
EXPECT_FALSE(output_surface_->InitializeAndSetContext3d(
@@ -4984,68 +4978,50 @@ TEST_F(LayerTreeHostImplTestDeferredInitialize, Fails_OnscreenContext_1) {
// Software draw.
DrawFrame();
- // Fail initialization of the onscreen context after the OutputSurface binds
- // it to the thread.
- onscreen_context_provider_->UnboundTestContext3d()
- ->set_times_make_current_succeeds(2);
-
EXPECT_FALSE(host_impl_->output_surface()->context_provider());
EXPECT_FALSE(host_impl_->offscreen_context_provider());
- EXPECT_FALSE(did_lose_output_surface_);
+ onscreen_context_provider_->UnboundTestContext3d()->set_context_lost(true);
+
+ EXPECT_FALSE(host_impl_->output_surface()->context_provider());
// DeferredInitialize fails.
EXPECT_FALSE(output_surface_->InitializeAndSetContext3d(
onscreen_context_provider_, offscreen_context_provider_));
EXPECT_FALSE(host_impl_->output_surface()->context_provider());
EXPECT_FALSE(host_impl_->offscreen_context_provider());
-
- // We lose the output surface.
- EXPECT_TRUE(did_lose_output_surface_);
}
TEST_F(LayerTreeHostImplTestDeferredInitialize, Fails_OnscreenContext_2) {
// Software draw.
DrawFrame();
- // Fail initialization of the onscreen context after the OutputSurface binds
- // it to the thread and during renderer initialization.
- onscreen_context_provider_->UnboundTestContext3d()
- ->set_times_make_current_succeeds(1);
-
EXPECT_FALSE(host_impl_->output_surface()->context_provider());
EXPECT_FALSE(host_impl_->offscreen_context_provider());
- EXPECT_FALSE(did_lose_output_surface_);
+
+ onscreen_context_provider_->UnboundTestContext3d()->set_context_lost(true);
// DeferredInitialize fails.
EXPECT_FALSE(output_surface_->InitializeAndSetContext3d(
onscreen_context_provider_, offscreen_context_provider_));
EXPECT_FALSE(host_impl_->output_surface()->context_provider());
EXPECT_FALSE(host_impl_->offscreen_context_provider());
-
- // We lose the output surface.
- EXPECT_TRUE(did_lose_output_surface_);
}
TEST_F(LayerTreeHostImplTestDeferredInitialize, Fails_OffscreenContext) {
// Software draw.
DrawFrame();
- // Fail initialization of the offscreen context.
- offscreen_context_provider_->UnboundTestContext3d()
- ->set_times_make_current_succeeds(0);
-
EXPECT_FALSE(host_impl_->output_surface()->context_provider());
EXPECT_FALSE(host_impl_->offscreen_context_provider());
- EXPECT_FALSE(did_lose_output_surface_);
+
+ // Fail initialization of the offscreen context.
+ onscreen_context_provider_->UnboundTestContext3d()->set_context_lost(true);
// DeferredInitialize fails.
EXPECT_FALSE(output_surface_->InitializeAndSetContext3d(
onscreen_context_provider_, offscreen_context_provider_));
EXPECT_FALSE(host_impl_->output_surface()->context_provider());
EXPECT_FALSE(host_impl_->offscreen_context_provider());
-
- // We lose the output surface.
- EXPECT_TRUE(did_lose_output_surface_);
}
// Checks that we have a non-0 default allocation if we pass a context that
diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc
index 587d722..5500a8c 100644
--- a/cc/trees/layer_tree_host_unittest_context.cc
+++ b/cc/trees/layer_tree_host_unittest_context.cc
@@ -53,13 +53,9 @@ class LayerTreeHostContextTest : public LayerTreeTest {
: LayerTreeTest(),
context3d_(NULL),
times_to_fail_create_(0),
- times_to_fail_initialize_(0),
- times_to_lose_on_create_(0),
times_to_lose_during_commit_(0),
times_to_lose_during_draw_(0),
times_to_fail_recreate_(0),
- times_to_fail_reinitialize_(0),
- times_to_lose_on_recreate_(0),
times_to_fail_create_offscreen_(0),
times_to_fail_recreate_offscreen_(0),
times_to_expect_create_failed_(0),
@@ -97,19 +93,6 @@ class LayerTreeHostContextTest : public LayerTreeTest {
context3d_->set_have_extension_egl_image(true);
}
- if (times_to_fail_initialize_ && !(fallback && fallback_context_works_)) {
- --times_to_fail_initialize_;
- // Make the context get lost during reinitialization.
- // The number of times MakeCurrent succeeds is not important, and
- // can be changed if needed to make this pass with future changes.
- context3d_->set_times_make_current_succeeds(2);
- ExpectCreateToFail();
- } else if (times_to_lose_on_create_) {
- --times_to_lose_on_create_;
- LoseContext();
- ExpectCreateToFail();
- }
-
if (delegating_renderer()) {
return FakeOutputSurface::CreateDelegating3d(context3d.Pass())
.PassAs<OutputSurface>();
@@ -155,14 +138,10 @@ class LayerTreeHostContextTest : public LayerTreeTest {
return result;
--times_to_lose_during_draw_;
- context3d_->set_times_make_current_succeeds(0);
+ LoseContext();
times_to_fail_create_ = times_to_fail_recreate_;
times_to_fail_recreate_ = 0;
- times_to_fail_initialize_ = times_to_fail_reinitialize_;
- times_to_fail_reinitialize_ = 0;
- times_to_lose_on_create_ = times_to_lose_on_recreate_;
- times_to_lose_on_recreate_ = 0;
times_to_fail_create_offscreen_ = times_to_fail_recreate_offscreen_;
times_to_fail_recreate_offscreen_ = 0;
@@ -179,10 +158,6 @@ class LayerTreeHostContextTest : public LayerTreeTest {
times_to_fail_create_ = times_to_fail_recreate_;
times_to_fail_recreate_ = 0;
- times_to_fail_initialize_ = times_to_fail_reinitialize_;
- times_to_fail_reinitialize_ = 0;
- times_to_lose_on_create_ = times_to_lose_on_recreate_;
- times_to_lose_on_recreate_ = 0;
times_to_fail_create_offscreen_ = times_to_fail_recreate_offscreen_;
times_to_fail_recreate_offscreen_ = 0;
}
@@ -203,13 +178,9 @@ class LayerTreeHostContextTest : public LayerTreeTest {
protected:
TestWebGraphicsContext3D* context3d_;
int times_to_fail_create_;
- int times_to_fail_initialize_;
- int times_to_lose_on_create_;
int times_to_lose_during_commit_;
int times_to_lose_during_draw_;
int times_to_fail_recreate_;
- int times_to_fail_reinitialize_;
- int times_to_lose_on_recreate_;
int times_to_fail_create_offscreen_;
int times_to_fail_recreate_offscreen_;
int times_to_expect_create_failed_;
@@ -229,6 +200,7 @@ class LayerTreeHostContextTestLostContextSucceeds
: LayerTreeHostContextTest(),
test_case_(0),
num_losses_(0),
+ num_losses_last_test_case_(-1),
recovered_context_(true),
first_initialized_(false) {}
@@ -248,8 +220,7 @@ class LayerTreeHostContextTestLostContextSucceeds
}
virtual void AfterTest() OVERRIDE {
- EXPECT_EQ(11u, test_case_);
- EXPECT_EQ(8 + 10 + 10 + 1, num_losses_);
+ EXPECT_EQ(9u, test_case_);
}
virtual void DidCommitAndDrawFrame() OVERRIDE {
@@ -281,65 +252,37 @@ class LayerTreeHostContextTestLostContextSucceeds
// immediately) a small number of times should succeed.
{ 1, // times_to_lose_during_commit
0, // times_to_lose_during_draw
- 3, // times_to_fail_reinitialize
0, // times_to_fail_recreate
- 0, // times_to_lose_on_recreate
0, // times_to_fail_recreate_offscreen
false, // fallback_context_works
},
{ 0, // times_to_lose_during_commit
1, // times_to_lose_during_draw
- 3, // times_to_fail_reinitialize
0, // times_to_fail_recreate
- 0, // times_to_lose_on_recreate
0, // times_to_fail_recreate_offscreen
false, // fallback_context_works
},
{ 1, // times_to_lose_during_commit
0, // times_to_lose_during_draw
- 0, // times_to_fail_reinitialize
3, // times_to_fail_recreate
- 0, // times_to_lose_on_recreate
0, // times_to_fail_recreate_offscreen
false, // fallback_context_works
},
{ 0, // times_to_lose_during_commit
1, // times_to_lose_during_draw
- 0, // times_to_fail_reinitialize
3, // times_to_fail_recreate
- 0, // times_to_lose_on_recreate
0, // times_to_fail_recreate_offscreen
false, // fallback_context_works
},
{ 1, // times_to_lose_during_commit
0, // times_to_lose_during_draw
- 0, // times_to_fail_reinitialize
0, // times_to_fail_recreate
- 3, // times_to_lose_on_recreate
- 0, // times_to_fail_recreate_offscreen
- false, // fallback_context_works
- },
- { 0, // times_to_lose_during_commit
- 1, // times_to_lose_during_draw
- 0, // times_to_fail_reinitialize
- 0, // times_to_fail_recreate
- 3, // times_to_lose_on_recreate
- 0, // times_to_fail_recreate_offscreen
- false, // fallback_context_works
- },
- { 1, // times_to_lose_during_commit
- 0, // times_to_lose_during_draw
- 0, // times_to_fail_reinitialize
- 0, // times_to_fail_recreate
- 0, // times_to_lose_on_recreate
3, // times_to_fail_recreate_offscreen
false, // fallback_context_works
},
{ 0, // times_to_lose_during_commit
1, // times_to_lose_during_draw
- 0, // times_to_fail_reinitialize
0, // times_to_fail_recreate
- 0, // times_to_lose_on_recreate
3, // times_to_fail_recreate_offscreen
false, // fallback_context_works
},
@@ -347,17 +290,13 @@ class LayerTreeHostContextTestLostContextSucceeds
// succeed.
{ 10, // times_to_lose_during_commit
0, // times_to_lose_during_draw
- 0, // times_to_fail_reinitialize
0, // times_to_fail_recreate
- 0, // times_to_lose_on_recreate
0, // times_to_fail_recreate_offscreen
false, // fallback_context_works
},
{ 0, // times_to_lose_during_commit
10, // times_to_lose_during_draw
- 0, // times_to_fail_reinitialize
0, // times_to_fail_recreate
- 0, // times_to_lose_on_recreate
0, // times_to_fail_recreate_offscreen
false, // fallback_context_works
},
@@ -365,9 +304,7 @@ class LayerTreeHostContextTestLostContextSucceeds
// context should work.
{ 0, // times_to_lose_during_commit
1, // times_to_lose_during_draw
- 10, // times_to_fail_reinitialize
0, // times_to_fail_recreate
- 0, // times_to_lose_on_recreate
0, // times_to_fail_recreate_offscreen
true, // fallback_context_works
},
@@ -375,14 +312,16 @@ class LayerTreeHostContextTestLostContextSucceeds
if (test_case_ >= arraysize(kTests))
return false;
+ // Make sure that we lost our context at least once in the last test run so
+ // the test did something.
+ EXPECT_GT(num_losses_, num_losses_last_test_case_);
+ num_losses_last_test_case_ = num_losses_;
times_to_lose_during_commit_ =
kTests[test_case_].times_to_lose_during_commit;
times_to_lose_during_draw_ =
kTests[test_case_].times_to_lose_during_draw;
- times_to_fail_reinitialize_ = kTests[test_case_].times_to_fail_reinitialize;
times_to_fail_recreate_ = kTests[test_case_].times_to_fail_recreate;
- times_to_lose_on_recreate_ = kTests[test_case_].times_to_lose_on_recreate;
times_to_fail_recreate_offscreen_ =
kTests[test_case_].times_to_fail_recreate_offscreen;
fallback_context_works_ = kTests[test_case_].fallback_context_works;
@@ -393,9 +332,7 @@ class LayerTreeHostContextTestLostContextSucceeds
struct TestCase {
int times_to_lose_during_commit;
int times_to_lose_during_draw;
- int times_to_fail_reinitialize;
int times_to_fail_recreate;
- int times_to_lose_on_recreate;
int times_to_fail_recreate_offscreen;
bool fallback_context_works;
};
@@ -403,6 +340,7 @@ class LayerTreeHostContextTestLostContextSucceeds
protected:
size_t test_case_;
int num_losses_;
+ int num_losses_last_test_case_;
bool recovered_context_;
bool first_initialized_;
};
@@ -471,13 +409,11 @@ class LayerTreeHostContextTestLostContextSucceedsWithContent
LayerTreeHostContextTestLostContextSucceeds::AfterTest();
if (use_surface_) {
// 1 create to start with +
- // 6 from test cases that fail on initializing the renderer (after the
- // offscreen context is created) +
- // 6 from test cases that lose the offscreen context directly +
- // 4 from test cases that create a fallback +
+ // 4 from test cases that lose the offscreen context directly +
+ // 2 from test cases that create a fallback +
// All the test cases that recreate both contexts only once
// per time it is lost.
- EXPECT_EQ(6 + 6 + 1 + 4 + num_losses_, times_offscreen_created_);
+ EXPECT_EQ(4 + 1 + 2 + num_losses_, times_offscreen_created_);
} else {
EXPECT_EQ(0, times_offscreen_created_);
}
@@ -625,180 +561,6 @@ class LayerTreeHostContextTestLostContextFails
bool first_initialized_;
};
-TEST_F(LayerTreeHostContextTestLostContextFails,
- FailReinitialize100_SingleThread_DirectRenderer) {
- times_to_fail_reinitialize_ = 100;
- times_to_fail_recreate_ = 0;
- times_to_lose_on_recreate_ = 0;
- RunTest(false, false, false);
-}
-
-TEST_F(LayerTreeHostContextTestLostContextFails,
- FailReinitialize100_SingleThread_DelegatingRenderer) {
- times_to_fail_reinitialize_ = 100;
- times_to_fail_recreate_ = 0;
- times_to_lose_on_recreate_ = 0;
- RunTest(false, true, false);
-}
-
-TEST_F(LayerTreeHostContextTestLostContextFails,
- FailReinitialize100_MultiThread_DirectRenderer_MainThreadPaint) {
- times_to_fail_reinitialize_ = 100;
- times_to_fail_recreate_ = 0;
- times_to_lose_on_recreate_ = 0;
- RunTest(true, false, false);
-}
-
-TEST_F(LayerTreeHostContextTestLostContextFails,
- FailReinitialize100_MultiThread_DirectRenderer_ImplSidePaint) {
- times_to_fail_reinitialize_ = 100;
- times_to_fail_recreate_ = 0;
- times_to_lose_on_recreate_ = 0;
- RunTest(true, false, true);
-}
-
-TEST_F(LayerTreeHostContextTestLostContextFails,
- FailReinitialize100_MultiThread_DelegatingRenderer_MainThreadPaint) {
- times_to_fail_reinitialize_ = 100;
- times_to_fail_recreate_ = 0;
- times_to_lose_on_recreate_ = 0;
- RunTest(true, true, false);
-}
-
-TEST_F(LayerTreeHostContextTestLostContextFails,
- FailReinitialize100_MultiThread_DelegatingRenderer_ImplSidePaint) {
- times_to_fail_reinitialize_ = 100;
- times_to_fail_recreate_ = 0;
- times_to_lose_on_recreate_ = 0;
- RunTest(true, true, true);
-}
-
-TEST_F(LayerTreeHostContextTestLostContextFails,
- FailRecreate100_SingleThread_DirectRenderer) {
- times_to_fail_reinitialize_ = 0;
- times_to_fail_recreate_ = 100;
- times_to_lose_on_recreate_ = 0;
- RunTest(false, false, false);
-}
-
-TEST_F(LayerTreeHostContextTestLostContextFails,
- FailRecreate100_SingleThread_DelegatingRenderer) {
- times_to_fail_reinitialize_ = 0;
- times_to_fail_recreate_ = 100;
- times_to_lose_on_recreate_ = 0;
- RunTest(false, true, false);
-}
-
-TEST_F(LayerTreeHostContextTestLostContextFails,
- FailRecreate100_MultiThread_DirectRenderer_MainThreadPaint) {
- times_to_fail_reinitialize_ = 0;
- times_to_fail_recreate_ = 100;
- times_to_lose_on_recreate_ = 0;
- RunTest(true, false, false);
-}
-
-TEST_F(LayerTreeHostContextTestLostContextFails,
- FailRecreate100_MultiThread_DirectRenderer_ImplSidePaint) {
- times_to_fail_reinitialize_ = 0;
- times_to_fail_recreate_ = 100;
- times_to_lose_on_recreate_ = 0;
- RunTest(true, false, true);
-}
-
-TEST_F(LayerTreeHostContextTestLostContextFails,
- FailRecreate100_MultiThread_DelegatingRenderer_MainThreadPaint) {
- times_to_fail_reinitialize_ = 0;
- times_to_fail_recreate_ = 100;
- times_to_lose_on_recreate_ = 0;
- RunTest(true, true, false);
-}
-
-TEST_F(LayerTreeHostContextTestLostContextFails,
- FailRecreate100_MultiThread_DelegatingRenderer_ImplSidePaint) {
- times_to_fail_reinitialize_ = 0;
- times_to_fail_recreate_ = 100;
- times_to_lose_on_recreate_ = 0;
- RunTest(true, true, true);
-}
-
-TEST_F(LayerTreeHostContextTestLostContextFails,
- LoseOnRecreate100_SingleThread_DirectRenderer) {
- times_to_fail_reinitialize_ = 0;
- times_to_fail_recreate_ = 0;
- times_to_lose_on_recreate_ = 100;
- RunTest(false, false, false);
-}
-
-TEST_F(LayerTreeHostContextTestLostContextFails,
- LoseOnRecreate100_SingleThread_DelegatingRenderer) {
- times_to_fail_reinitialize_ = 0;
- times_to_fail_recreate_ = 0;
- times_to_lose_on_recreate_ = 100;
- RunTest(false, true, false);
-}
-
-TEST_F(LayerTreeHostContextTestLostContextFails,
- LoseOnRecreate100_MultiThread_DirectRenderer_MainThreadPaint) {
- times_to_fail_reinitialize_ = 0;
- times_to_fail_recreate_ = 0;
- times_to_lose_on_recreate_ = 100;
- RunTest(true, false, false);
-}
-
-TEST_F(LayerTreeHostContextTestLostContextFails,
- LoseOnRecreate100_MultiThread_DirectRenderer_ImplSidePaint) {
- times_to_fail_reinitialize_ = 0;
- times_to_fail_recreate_ = 0;
- times_to_lose_on_recreate_ = 100;
- RunTest(true, false, true);
-}
-
-TEST_F(LayerTreeHostContextTestLostContextFails,
- LoseOnRecreate100_MultiThread_DelegatingRenderer_MainThreadPaint) {
- times_to_fail_reinitialize_ = 0;
- times_to_fail_recreate_ = 0;
- times_to_lose_on_recreate_ = 100;
- RunTest(true, true, false);
-}
-
-TEST_F(LayerTreeHostContextTestLostContextFails,
- LoseOnRecreate100_MultiThread_DelegatingRenderer_ImplSidePaint) {
- times_to_fail_reinitialize_ = 0;
- times_to_fail_recreate_ = 0;
- times_to_lose_on_recreate_ = 100;
- RunTest(true, true, true);
-}
-
-class LayerTreeHostContextTestFinishAllRenderingAfterLoss
- : public LayerTreeHostContextTest {
- public:
- virtual void BeginTest() OVERRIDE {
- // Lose the context until the compositor gives up on it.
- first_initialized_ = false;
- times_to_lose_during_commit_ = 1;
- times_to_fail_reinitialize_ = 10;
- PostSetNeedsCommitToMainThread();
- }
-
- virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE {
- if (first_initialized_) {
- EXPECT_FALSE(succeeded);
- layer_tree_host()->FinishAllRendering();
- EndTest();
- } else {
- first_initialized_ = true;
- }
- }
-
- virtual void AfterTest() OVERRIDE {}
-
- private:
- bool first_initialized_;
-};
-
-SINGLE_AND_MULTI_THREAD_TEST_F(
- LayerTreeHostContextTestFinishAllRenderingAfterLoss);
-
class LayerTreeHostContextTestLostContextAndEvictTextures
: public LayerTreeHostContextTest {
public:
@@ -1041,25 +803,9 @@ class LayerTreeHostContextTestLayersNotified
times_to_fail_create_ = 1;
break;
case 2:
- EXPECT_EQ(1u, root->lost_output_surface_count());
- EXPECT_EQ(1u, child->lost_output_surface_count());
- EXPECT_EQ(1u, grandchild->lost_output_surface_count());
- // Lose the context and again during recreate.
- LoseContext();
- times_to_lose_on_create_ = 1;
- break;
- case 3:
- EXPECT_EQ(3u, root->lost_output_surface_count());
- EXPECT_EQ(3u, child->lost_output_surface_count());
- EXPECT_EQ(3u, grandchild->lost_output_surface_count());
- // Lose the context and again during reinitialization.
- LoseContext();
- times_to_fail_initialize_ = 1;
- break;
- case 4:
- EXPECT_EQ(5u, root->lost_output_surface_count());
- EXPECT_EQ(5u, child->lost_output_surface_count());
- EXPECT_EQ(5u, grandchild->lost_output_surface_count());
+ EXPECT_GE(1u, root->lost_output_surface_count());
+ EXPECT_GE(1u, child->lost_output_surface_count());
+ EXPECT_GE(1u, grandchild->lost_output_surface_count());
EndTest();
break;
default:
@@ -1333,73 +1079,6 @@ class LayerTreeHostContextTestDontUseLostResources
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestDontUseLostResources);
-class LayerTreeHostContextTestLosesFirstOutputSurface
- : public LayerTreeHostContextTest {
- public:
- LayerTreeHostContextTestLosesFirstOutputSurface() {
- // Always fail. This needs to be set before LayerTreeHost is created.
- times_to_lose_on_create_ = 1000;
- }
-
- virtual void BeginTest() OVERRIDE {
- PostSetNeedsCommitToMainThread();
- }
-
- virtual void AfterTest() OVERRIDE {}
-
- virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE {
- EXPECT_FALSE(succeeded);
-
- // If we make it this far without crashing, we pass!
- EndTest();
- }
-
- virtual void DidCommitAndDrawFrame() OVERRIDE {
- EXPECT_TRUE(false);
- }
-};
-
-SINGLE_AND_MULTI_THREAD_TEST_F(
- LayerTreeHostContextTestLosesFirstOutputSurface);
-
-class LayerTreeHostContextTestRetriesFirstInitializationAndSucceeds
- : public LayerTreeHostContextTest {
- public:
- virtual void AfterTest() OVERRIDE {}
-
- virtual void BeginTest() OVERRIDE {
- times_to_fail_initialize_ = 2;
- PostSetNeedsCommitToMainThread();
- }
-
- virtual void DidCommitAndDrawFrame() OVERRIDE {
- EndTest();
- }
-};
-
-SINGLE_AND_MULTI_THREAD_TEST_F(
- LayerTreeHostContextTestRetriesFirstInitializationAndSucceeds);
-
-class LayerTreeHostContextTestRetryWorksWithForcedInit
- : public LayerTreeHostContextTestRetriesFirstInitializationAndSucceeds {
- public:
- virtual void DidFailToInitializeOutputSurface() OVERRIDE {
- LayerTreeHostContextTestRetriesFirstInitializationAndSucceeds
- ::DidFailToInitializeOutputSurface();
-
- if (times_create_failed_ == 1) {
- // CompositeAndReadback force recreates the output surface, which should
- // fail.
- char pixels[4];
- EXPECT_FALSE(layer_tree_host()->CompositeAndReadback(
- &pixels, gfx::Rect(1, 1)));
- }
- }
-};
-
-SINGLE_AND_MULTI_THREAD_TEST_F(
- LayerTreeHostContextTestRetryWorksWithForcedInit);
-
class LayerTreeHostContextTestCompositeAndReadbackBeforeOutputSurfaceInit
: public LayerTreeHostContextTest {
public:
@@ -1728,42 +1407,6 @@ class ScrollbarLayerLostContext : public LayerTreeHostContextTest {
SINGLE_AND_MULTI_THREAD_TEST_F(ScrollbarLayerLostContext);
-class LayerTreeHostContextTestFailsToCreateSurface
- : public LayerTreeHostContextTest {
- public:
- LayerTreeHostContextTestFailsToCreateSurface()
- : LayerTreeHostContextTest(),
- failure_count_(0) {
- times_to_lose_on_create_ = 10;
- }
-
- virtual void BeginTest() OVERRIDE {
- PostSetNeedsCommitToMainThread();
- }
-
- virtual void AfterTest() OVERRIDE {}
-
- virtual void DidInitializeOutputSurface(bool success) OVERRIDE {
- EXPECT_FALSE(success);
- EXPECT_EQ(0, failure_count_);
- times_to_lose_on_create_ = 0;
- failure_count_++;
- // Normally, the embedder should stop trying to use the compositor at
- // this point, but let's force it back into action when we shouldn't.
- char pixels[4];
- EXPECT_FALSE(
- layer_tree_host()->CompositeAndReadback(pixels, gfx::Rect(1, 1)));
- // If we've made it this far without crashing, we've succeeded.
- EndTest();
- }
-
- private:
- int failure_count_;
-};
-
-SINGLE_AND_MULTI_THREAD_TEST_F(
- LayerTreeHostContextTestFailsToCreateSurface);
-
// Not reusing LayerTreeTest because it expects creating LTH to always succeed.
class LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface
: public testing::Test,