diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-06 19:44:57 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-06 19:44:57 +0000 |
commit | f5931d4341bc85b6f987c2b664154cc047f2b570 (patch) | |
tree | 345c258cb9134399e1770e8d102b6305e20e5cd7 /cc/layers | |
parent | 91dcae34f2f3c83e2bdddb9908c5ce394069e4bf (diff) | |
download | chromium_src-f5931d4341bc85b6f987c2b664154cc047f2b570.zip chromium_src-f5931d4341bc85b6f987c2b664154cc047f2b570.tar.gz chromium_src-f5931d4341bc85b6f987c2b664154cc047f2b570.tar.bz2 |
Remove WGC3D::isContextLost references from cc
The notion of whether a context is lost is a property of both the gpu::
context itself and the system providing it. For instance, the content
context provider checks if there is an error in the context or if the IPC
channel backing the command buffer is down. Thus, asking if a context is
lost really should go through the ContextProvider. This patch routes all
lost context checks from cc through the ContextProvider.
Unfortunately, this required reworking the program initialization code
considerably due to the way some DCHECKs were written. The new model is that
the program binding itself is inert upon construction and all initialization
is done in the Initialize() call. This call is still made eagerly for some
expected-to-be-common programs and lazily for the rest. This patch moves
when the linkProgram() call is issued slightly for the eagerly compiled programs,
but it shouldn't make any difference in practice.
This patch also revamps TextureLayerClient to hide the backing context since
cc only makes two calls (check for loss and insert rate limiting token) on
the client's context.
R=piman
BUG=181120
Review URL: https://codereview.chromium.org/51653008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233325 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layers')
-rw-r--r-- | cc/layers/texture_layer.cc | 4 | ||||
-rw-r--r-- | cc/layers/texture_layer_client.h | 4 | ||||
-rw-r--r-- | cc/layers/texture_layer_unittest.cc | 118 |
3 files changed, 40 insertions, 86 deletions
diff --git a/cc/layers/texture_layer.cc b/cc/layers/texture_layer.cc index 80bd4d4..1d21dba 100644 --- a/cc/layers/texture_layer.cc +++ b/cc/layers/texture_layer.cc @@ -233,10 +233,6 @@ bool TextureLayer::Update(ResourceUpdateQueue* queue, } } else { texture_id_ = client_->PrepareTexture(); - DCHECK_EQ(!!texture_id_, !!client_->Context3d()); - if (client_->Context3d() && - client_->Context3d()->getGraphicsResetStatusARB() != GL_NO_ERROR) - texture_id_ = 0; updated = true; SetNeedsPushProperties(); // The texture id needs to be removed from the active tree before the diff --git a/cc/layers/texture_layer_client.h b/cc/layers/texture_layer_client.h index 187b12f..d191a5b 100644 --- a/cc/layers/texture_layer_client.h +++ b/cc/layers/texture_layer_client.h @@ -19,10 +19,6 @@ class TextureLayerClient { // Returns the texture ID to be used for compositing. virtual unsigned PrepareTexture() = 0; - // Returns the context that is providing the texture. Used for rate limiting - // and detecting lost context. - virtual WebKit::WebGraphicsContext3D* Context3d() = 0; - // Returns true and provides a mailbox if a new frame is available. // Returns false if no new data is available // and the old mailbox is to be reused. diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc index 9c999fc..d793473 100644 --- a/cc/layers/texture_layer_unittest.cc +++ b/cc/layers/texture_layer_unittest.cc @@ -245,16 +245,12 @@ TEST_F(TextureLayerTest, VisibleContentOpaqueRegion) { class FakeTextureLayerClient : public TextureLayerClient { public: - FakeTextureLayerClient() : context_(TestWebGraphicsContext3D::Create()) {} + FakeTextureLayerClient() {} virtual unsigned PrepareTexture() OVERRIDE { return 0; } - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { - return context_.get(); - } - virtual bool PrepareTextureMailbox( TextureMailbox* mailbox, scoped_ptr<SingleReleaseCallback>* release_callback, @@ -265,7 +261,6 @@ class FakeTextureLayerClient : public TextureLayerClient { } private: - scoped_ptr<TestWebGraphicsContext3D> context_; DISALLOW_COPY_AND_ASSIGN(FakeTextureLayerClient); }; @@ -893,7 +888,7 @@ class TextureLayerNoMailboxIsActivatedDuringCommit : public LayerTreeTest, TextureLayerNoMailboxIsActivatedDuringCommit() : wait_thread_("WAIT"), wait_event_(false, false), - context_(TestWebGraphicsContext3D::Create()) { + texture_(0u) { wait_thread_.Start(); } @@ -917,13 +912,16 @@ class TextureLayerNoMailboxIsActivatedDuringCommit : public LayerTreeTest, PostSetNeedsCommitToMainThread(); } + virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) + OVERRIDE { + scoped_refptr<TestContextProvider> provider = TestContextProvider::Create(); + texture_ = provider->UnboundTestContext3d()->createExternalTexture(); + return FakeOutputSurface::Create3d(provider).PassAs<OutputSurface>(); + } + // TextureLayerClient implementation. virtual unsigned PrepareTexture() OVERRIDE { - context_->makeContextCurrent(); - return context_->createTexture(); - } - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { - return context_.get(); + return texture_; } virtual bool PrepareTextureMailbox( TextureMailbox* mailbox, @@ -1002,11 +1000,10 @@ class TextureLayerNoMailboxIsActivatedDuringCommit : public LayerTreeTest, base::Thread wait_thread_; base::WaitableEvent wait_event_; base::Lock activate_lock_; + unsigned texture_; int activate_count_; - int activate_commit_; scoped_refptr<Layer> root_; scoped_refptr<TextureLayer> layer_; - scoped_ptr<TestWebGraphicsContext3D> context_; }; SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( @@ -1406,28 +1403,19 @@ class TextureLayerClientTest public TextureLayerClient { public: TextureLayerClientTest() - : context_(NULL), - texture_(0), + : texture_(0), commit_count_(0), expected_used_textures_on_draw_(0), expected_used_textures_on_commit_(0) {} virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) OVERRIDE { - scoped_ptr<TestWebGraphicsContext3D> context( - TestWebGraphicsContext3D::Create()); - context_ = context.get(); - texture_ = context->createTexture(); - return FakeOutputSurface::Create3d(context.Pass()).PassAs<OutputSurface>(); - } - - virtual unsigned PrepareTexture() OVERRIDE { - return texture_; + scoped_refptr<TestContextProvider> provider = TestContextProvider::Create(); + texture_ = provider->UnboundTestContext3d()->createExternalTexture(); + return FakeOutputSurface::Create3d(provider).PassAs<OutputSurface>(); } - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { - return context_; - } + virtual unsigned PrepareTexture() OVERRIDE { return texture_; } virtual bool PrepareTextureMailbox( TextureMailbox* mailbox, @@ -1470,7 +1458,6 @@ class TextureLayerClientTest base::AutoLock lock(lock_); expected_used_textures_on_commit_ = 0; } - texture_ = 0; break; case 2: EndTest(); @@ -1489,21 +1476,26 @@ class TextureLayerClientTest virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, LayerTreeHostImpl::FrameData* frame_data, bool result) OVERRIDE { - context_->ResetUsedTextures(); + ContextForImplThread(host_impl)->ResetUsedTextures(); return true; } virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, bool result) OVERRIDE { ASSERT_TRUE(result); - EXPECT_EQ(expected_used_textures_on_draw_, context_->NumUsedTextures()); + EXPECT_EQ(expected_used_textures_on_draw_, + ContextForImplThread(host_impl)->NumUsedTextures()); } virtual void AfterTest() OVERRIDE {} private: + TestWebGraphicsContext3D* ContextForImplThread(LayerTreeHostImpl* host_impl) { + return static_cast<TestWebGraphicsContext3D*>( + host_impl->output_surface()->context_provider()->Context3d()); + } + scoped_refptr<TextureLayer> texture_layer_; - TestWebGraphicsContext3D* context_; unsigned texture_; int commit_count_; @@ -1528,25 +1520,23 @@ class TextureLayerChangeInvisibleTest public TextureLayerClient { public: TextureLayerChangeInvisibleTest() - : client_context_(TestWebGraphicsContext3D::Create()), - texture_(client_context_->createTexture()), - texture_to_delete_on_next_commit_(0), + : texture_(0u), prepare_called_(0), commit_count_(0), expected_texture_on_draw_(0) {} + virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) + OVERRIDE { + scoped_refptr<TestContextProvider> provider = TestContextProvider::Create(); + texture_ = provider->UnboundTestContext3d()->createExternalTexture(); + return FakeOutputSurface::Create3d(provider).PassAs<OutputSurface>(); + } + // TextureLayerClient implementation. virtual unsigned PrepareTexture() OVERRIDE { ++prepare_called_; return texture_; } - - // TextureLayerClient implementation. - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { - return client_context_.get(); - } - - // TextureLayerClient implementation. virtual bool PrepareTextureMailbox( cc::TextureMailbox* mailbox, scoped_ptr<SingleReleaseCallback>* release_callback, @@ -1597,9 +1587,6 @@ class TextureLayerChangeInvisibleTest case 2: { // Layer shouldn't have been updated. EXPECT_EQ(1, prepare_called_); - // Change the texture. - texture_to_delete_on_next_commit_ = texture_; - texture_ = client_context_->createTexture(); texture_layer_->SetNeedsDisplay(); // Force a change to make sure we draw a frame. solid_layer_->SetBackgroundColor(SK_ColorGRAY); @@ -1607,8 +1594,6 @@ class TextureLayerChangeInvisibleTest } case 3: EXPECT_EQ(1, prepare_called_); - client_context_->deleteTexture(texture_to_delete_on_next_commit_); - texture_to_delete_on_next_commit_ = 0; // Make layer visible again. parent_layer_->SetOpacity(1.f); break; @@ -1616,7 +1601,6 @@ class TextureLayerChangeInvisibleTest // Layer should have been updated. EXPECT_EQ(2, prepare_called_); texture_layer_->ClearClient(); - client_context_->deleteTexture(texture_); texture_ = 0; break; } @@ -1676,14 +1660,12 @@ class TextureLayerChangeInvisibleTest scoped_refptr<SolidColorLayer> solid_layer_; scoped_refptr<Layer> parent_layer_; scoped_refptr<TextureLayer> texture_layer_; - scoped_ptr<TestWebGraphicsContext3D> client_context_; // Used on the main thread, and on the impl thread while the main thread is // blocked. unsigned texture_; // Used on the main thread. - unsigned texture_to_delete_on_next_commit_; int prepare_called_; int commit_count_; @@ -1710,12 +1692,6 @@ class TextureLayerNoExtraCommitForMailboxTest return 0; } - // TextureLayerClient implementation. - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { - NOTREACHED(); - return NULL; - } - virtual bool PrepareTextureMailbox( cc::TextureMailbox* mailbox, scoped_ptr<SingleReleaseCallback>* release_callback, @@ -1819,13 +1795,6 @@ class TextureLayerChangeInvisibleMailboxTest return 0; } - // TextureLayerClient implementation. - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { - NOTREACHED(); - return NULL; - } - - // TextureLayerClient implementation. virtual bool PrepareTextureMailbox( cc::TextureMailbox* mailbox, scoped_ptr<SingleReleaseCallback>* release_callback, @@ -1965,26 +1934,20 @@ class TextureLayerLostContextTest public TextureLayerClient { public: TextureLayerLostContextTest() - : texture_(0), + : context_lost_(false), draw_count_(0) {} virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) OVERRIDE { - texture_context_ = TestWebGraphicsContext3D::Create(); - texture_ = texture_context_->createTexture(); return CreateFakeOutputSurface(); } virtual unsigned PrepareTexture() OVERRIDE { - if (draw_count_ == 0) { - texture_context_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, - GL_INNOCENT_CONTEXT_RESET_ARB); - } - return texture_; - } - - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { - return texture_context_.get(); + if (draw_count_ == 0) + context_lost_ = true; + if (context_lost_) + return 0u; + return 1u; } virtual bool PrepareTextureMailbox( @@ -2021,7 +1984,7 @@ class TextureLayerLostContextTest if (++draw_count_ == 1) EXPECT_EQ(0u, texture_layer->texture_id()); else - EXPECT_EQ(texture_, texture_layer->texture_id()); + EXPECT_EQ(1u, texture_layer->texture_id()); return true; } @@ -2033,8 +1996,7 @@ class TextureLayerLostContextTest private: scoped_refptr<TextureLayer> texture_layer_; - scoped_ptr<TestWebGraphicsContext3D> texture_context_; - unsigned texture_; + bool context_lost_; int draw_count_; }; |