diff options
author | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-02 23:21:12 +0000 |
---|---|---|
committer | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-02 23:21:12 +0000 |
commit | 33fc24a0c145c1677a8b505639f7a1130c00aad3 (patch) | |
tree | 02638156e7252399961667134ec47ac19fdedc28 /content/browser/aura | |
parent | 8a698cedf44eaba88fbbb727ea1eaa32cbced8b7 (diff) | |
download | chromium_src-33fc24a0c145c1677a8b505639f7a1130c00aad3.zip chromium_src-33fc24a0c145c1677a8b505639f7a1130c00aad3.tar.gz chromium_src-33fc24a0c145c1677a8b505639f7a1130c00aad3.tar.bz2 |
aura: Attach lost context callback to the shared main thread context
r225643 broke lost context recovery on Aura with the thread (i.e. Chrome OS).
The lost context callback needs to be attached to the shared main thread
context, since that's what creates the resources - the offscreen one may not
even exist / be used.
BUG=none
Review URL: https://codereview.chromium.org/25367003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@226610 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/aura')
-rw-r--r-- | content/browser/aura/gpu_process_transport_factory.cc | 21 | ||||
-rw-r--r-- | content/browser/aura/image_transport_factory_browsertest.cc | 56 |
2 files changed, 64 insertions, 13 deletions
diff --git a/content/browser/aura/gpu_process_transport_factory.cc b/content/browser/aura/gpu_process_transport_factory.cc index e9080f0..2d09b24 100644 --- a/content/browser/aura/gpu_process_transport_factory.cc +++ b/content/browser/aura/gpu_process_transport_factory.cc @@ -407,16 +407,6 @@ GpuProcessTransportFactory::OffscreenCompositorContextProvider() { GpuProcessTransportFactory::CreateOffscreenCommandBufferContext(), "Compositor-Offscreen"); - if (!offscreen_compositor_contexts_.get()) - return NULL; - - if (!ui::Compositor::WasInitializedWithThread()) { - offscreen_compositor_contexts_->SetLostContextCallback(base::Bind( - &GpuProcessTransportFactory:: - OnLostMainThreadSharedContextInsideCallback, - callback_factory_.GetWeakPtr())); - } - return offscreen_compositor_contexts_; } @@ -440,9 +430,14 @@ GpuProcessTransportFactory::SharedMainThreadContextProvider() { OffscreenCompositorContextProvider().get()); } - if (shared_main_thread_contexts_ && - !shared_main_thread_contexts_->BindToCurrentThread()) - shared_main_thread_contexts_ = NULL; + if (shared_main_thread_contexts_) { + shared_main_thread_contexts_->SetLostContextCallback( + base::Bind(&GpuProcessTransportFactory:: + OnLostMainThreadSharedContextInsideCallback, + callback_factory_.GetWeakPtr())); + if (!shared_main_thread_contexts_->BindToCurrentThread()) + shared_main_thread_contexts_ = NULL; + } return shared_main_thread_contexts_; } diff --git a/content/browser/aura/image_transport_factory_browsertest.cc b/content/browser/aura/image_transport_factory_browsertest.cc new file mode 100644 index 0000000..233c06c --- /dev/null +++ b/content/browser/aura/image_transport_factory_browsertest.cc @@ -0,0 +1,56 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/run_loop.h" +#include "content/browser/aura/image_transport_factory.h" +#include "content/test/content_browser_test.h" +#include "gpu/GLES2/gl2extchromium.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" +#include "ui/compositor/compositor.h" + +namespace content { +namespace { + +class ImageTransportFactoryBrowserTest : public ContentBrowserTest { + public: + ImageTransportFactoryBrowserTest() {} + + virtual void SetUp() OVERRIDE { + UseRealGLContexts(); + ContentBrowserTest::SetUp(); + } +}; + +class MockImageTransportFactoryObserver : public ImageTransportFactoryObserver { + public: + MOCK_METHOD0(OnLostResources, void()); +}; + +// Checks that upon context loss, the observer is called and the created +// resources are reset. +IN_PROC_BROWSER_TEST_F(ImageTransportFactoryBrowserTest, TestLostContext) { + ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); + scoped_refptr<ui::Texture> texture = factory->CreateTransportClient(1.f); + + MockImageTransportFactoryObserver observer; + factory->AddObserver(&observer); + + base::RunLoop run_loop; + EXPECT_CALL(observer, OnLostResources()) + .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); + + WebKit::WebGraphicsContext3D* context = texture->HostContext3D(); + context->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, + GL_INNOCENT_CONTEXT_RESET_ARB); + + run_loop.Run(); + EXPECT_FALSE(texture->HostContext3D()); + EXPECT_EQ(0u, texture->PrepareTexture()); + + factory->RemoveObserver(&observer); +} + +} // anonymous namespace +} // namespace content |