diff options
author | alexst@chromium.org <alexst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-24 21:27:54 +0000 |
---|---|---|
committer | alexst@chromium.org <alexst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-24 21:27:54 +0000 |
commit | a7acdbd4477a0c1b970731843ef30426fd63ce17 (patch) | |
tree | c23bc8f602d5e2ceea3e8a0c8910ba58bbcc5430 | |
parent | 900efd6f8aa96117ed241fef63587143249f8d85 (diff) | |
download | chromium_src-a7acdbd4477a0c1b970731843ef30426fd63ce17.zip chromium_src-a7acdbd4477a0c1b970731843ef30426fd63ce17.tar.gz chromium_src-a7acdbd4477a0c1b970731843ef30426fd63ce17.tar.bz2 |
Add sync point to wait on before consuming texture_mailbox.
BUG=
Review URL: https://chromiumcodereview.appspot.com/12036086
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178647 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/resource_provider.cc | 6 | ||||
-rw-r--r-- | cc/texture_layer.cc | 6 | ||||
-rw-r--r-- | cc/texture_layer_impl.cc | 4 | ||||
-rw-r--r-- | cc/texture_layer_unittest.cc | 31 | ||||
-rw-r--r-- | cc/texture_mailbox.cc | 19 | ||||
-rw-r--r-- | cc/texture_mailbox.h | 7 |
6 files changed, 55 insertions, 18 deletions
diff --git a/cc/resource_provider.cc b/cc/resource_provider.cc index 1ec1e8f..67d3adf 100644 --- a/cc/resource_provider.cc +++ b/cc/resource_provider.cc @@ -293,7 +293,7 @@ void ResourceProvider::deleteResourceInternal(ResourceMap::iterator it) if (!resource->mailbox.IsEmpty() && resource->external) { WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); DCHECK(context3d); - unsigned syncPoint = 0; + unsigned syncPoint = resource->mailbox.sync_point(); if (resource->glId) { GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId)); GLC(context3d, context3d->produceTextureCHROMIUM(GL_TEXTURE_2D, resource->mailbox.data())); @@ -425,6 +425,10 @@ const ResourceProvider::Resource* ResourceProvider::lockForRead(ResourceId id) if (!resource->glId && resource->external && !resource->mailbox.IsEmpty()) { WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); DCHECK(context3d); + if (resource->mailbox.sync_point()) { + GLC(context3d, context3d->waitSyncPoint(resource->mailbox.sync_point())); + resource->mailbox.ResetSyncPoint(); + } resource->glId = context3d->createTexture(); GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId)); GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, resource->mailbox.data())); diff --git a/cc/texture_layer.cc b/cc/texture_layer.cc index 7f2bb08..32a9fad 100644 --- a/cc/texture_layer.cc +++ b/cc/texture_layer.cc @@ -60,7 +60,7 @@ TextureLayer::~TextureLayer() layerTreeHost()->stopRateLimiter(m_client->context()); } if (!m_contentCommitted) - m_textureMailbox.RunReleaseCallback(0); + m_textureMailbox.RunReleaseCallback(m_textureMailbox.sync_point()); } scoped_ptr<LayerImpl> TextureLayer::createLayerImpl(LayerTreeImpl* treeImpl) @@ -128,7 +128,7 @@ void TextureLayer::setTextureMailbox(const TextureMailbox& mailbox) return; // If we never commited the mailbox, we need to release it here if (!m_contentCommitted) - m_textureMailbox.RunReleaseCallback(0); + m_textureMailbox.RunReleaseCallback(m_textureMailbox.sync_point()); m_textureMailbox = mailbox; setNeedsCommit(); @@ -187,7 +187,7 @@ void TextureLayer::pushPropertiesTo(LayerImpl* layer) TextureMailbox::ReleaseCallback callback; if (!m_textureMailbox.IsEmpty()) callback = base::Bind(&postCallbackToMainThread, mainThread, m_textureMailbox.callback()); - textureLayer->setTextureMailbox(TextureMailbox(m_textureMailbox.name(), callback)); + textureLayer->setTextureMailbox(TextureMailbox(m_textureMailbox.name(), callback, m_textureMailbox.sync_point())); } else { textureLayer->setTextureId(m_textureId); } diff --git a/cc/texture_layer_impl.cc b/cc/texture_layer_impl.cc index 279decc..7a6a5d6 100644 --- a/cc/texture_layer_impl.cc +++ b/cc/texture_layer_impl.cc @@ -37,7 +37,7 @@ TextureLayerImpl::~TextureLayerImpl() provider->deleteResource(m_externalTextureResource); } if (m_hasPendingMailbox) - m_pendingTextureMailbox.RunReleaseCallback(0); + m_pendingTextureMailbox.RunReleaseCallback(m_pendingTextureMailbox.sync_point()); } void TextureLayerImpl::setTextureMailbox(const TextureMailbox& mailbox) @@ -48,7 +48,7 @@ void TextureLayerImpl::setTextureMailbox(const TextureMailbox& mailbox) return; // Two commits without a draw, ack the previous mailbox. if (m_hasPendingMailbox) - m_pendingTextureMailbox.RunReleaseCallback(0); + m_pendingTextureMailbox.RunReleaseCallback(m_pendingTextureMailbox.sync_point()); m_pendingTextureMailbox = mailbox; m_hasPendingMailbox = true; diff --git a/cc/texture_layer_unittest.cc b/cc/texture_layer_unittest.cc index cada101..bc09d93f 100644 --- a/cc/texture_layer_unittest.cc +++ b/cc/texture_layer_unittest.cc @@ -198,6 +198,8 @@ struct CommonMailboxObjects { CommonMailboxObjects() : m_mailboxName1(64, '1') , m_mailboxName2(64, '2') + , m_syncPoint1(1) + , m_syncPoint2(2) { m_releaseMailbox1 = base::Bind(&MockMailboxCallback::Release, base::Unretained(&m_mockCallback), @@ -205,9 +207,12 @@ struct CommonMailboxObjects { m_releaseMailbox2 = base::Bind(&MockMailboxCallback::Release, base::Unretained(&m_mockCallback), m_mailboxName2); - - m_mailbox1 = TextureMailbox(m_mailboxName1, m_releaseMailbox1); - m_mailbox2 = TextureMailbox(m_mailboxName2, m_releaseMailbox2); + Mailbox m1; + m1.setName(reinterpret_cast<const int8*>(m_mailboxName1.data())); + m_mailbox1 = TextureMailbox(m1, m_releaseMailbox1, m_syncPoint1); + Mailbox m2; + m2.setName(reinterpret_cast<const int8*>(m_mailboxName2.data())); + m_mailbox2 = TextureMailbox(m2, m_releaseMailbox2, m_syncPoint2); } std::string m_mailboxName1; @@ -217,6 +222,8 @@ struct CommonMailboxObjects { TextureMailbox::ReleaseCallback m_releaseMailbox2; TextureMailbox m_mailbox1; TextureMailbox m_mailbox2; + unsigned m_syncPoint1; + unsigned m_syncPoint2; }; class TextureLayerWithMailboxTest : public TextureLayerTest { @@ -225,7 +232,8 @@ protected: { Mock::VerifyAndClearExpectations(&m_testData.m_mockCallback); EXPECT_CALL(m_testData.m_mockCallback, - Release(m_testData.m_mailboxName1, _)).Times(1); + Release(m_testData.m_mailboxName1, + m_testData.m_syncPoint1)).Times(1); TextureLayerTest::TearDown(); } @@ -250,7 +258,8 @@ TEST_F(TextureLayerWithMailboxTest, replaceMailboxOnMainThreadBeforeCommit) EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); EXPECT_CALL(m_testData.m_mockCallback, - Release(m_testData.m_mailboxName1, _)).Times(1); + Release(m_testData.m_mailboxName1, + m_testData.m_syncPoint1)).Times(1); testLayer->setTextureMailbox(m_testData.m_mailbox2); Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); Mock::VerifyAndClearExpectations(&m_testData.m_mockCallback); @@ -258,7 +267,8 @@ TEST_F(TextureLayerWithMailboxTest, replaceMailboxOnMainThreadBeforeCommit) EXPECT_CALL(*m_layerTreeHost, acquireLayerTextures()).Times(0); EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); EXPECT_CALL(m_testData.m_mockCallback, - Release(m_testData.m_mailboxName2, _)).Times(1); + Release(m_testData.m_mailboxName2, + m_testData.m_syncPoint2)).Times(1); testLayer->setTextureMailbox(TextureMailbox()); Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); Mock::VerifyAndClearExpectations(&m_testData.m_mockCallback); @@ -341,19 +351,22 @@ TEST_F(TextureLayerImplWithMailboxTest, testImplLayerCallbacks) // Test multiple commits without a draw. EXPECT_CALL(m_testData.m_mockCallback, - Release(m_testData.m_mailboxName1, _)).Times(1); + Release(m_testData.m_mailboxName1, + m_testData.m_syncPoint1)).Times(1); implLayer->setTextureMailbox(m_testData.m_mailbox2); Mock::VerifyAndClearExpectations(&m_testData.m_mockCallback); // Test resetting the mailbox. EXPECT_CALL(m_testData.m_mockCallback, - Release(m_testData.m_mailboxName2, _)).Times(1); + Release(m_testData.m_mailboxName2, + m_testData.m_syncPoint2)).Times(1); implLayer->setTextureMailbox(TextureMailbox()); Mock::VerifyAndClearExpectations(&m_testData.m_mockCallback); // Test destructor. EXPECT_CALL(m_testData.m_mockCallback, - Release(m_testData.m_mailboxName1, _)).Times(1); + Release(m_testData.m_mailboxName1, + m_testData.m_syncPoint1)).Times(1); implLayer->setTextureMailbox(m_testData.m_mailbox1); } diff --git a/cc/texture_mailbox.cc b/cc/texture_mailbox.cc index c25ab81..c0990b1 100644 --- a/cc/texture_mailbox.cc +++ b/cc/texture_mailbox.cc @@ -7,13 +7,15 @@ namespace cc { -TextureMailbox::TextureMailbox() { +TextureMailbox::TextureMailbox() + : sync_point_(0) { } TextureMailbox::TextureMailbox( const std::string& mailbox_name, const ReleaseCallback& mailbox_callback) - : callback_(mailbox_callback) { + : callback_(mailbox_callback), + sync_point_(0) { DCHECK(mailbox_name.empty() == mailbox_callback.is_null()); if (!mailbox_name.empty()) { CHECK(mailbox_name.size() == sizeof(name_.name)); @@ -24,7 +26,18 @@ TextureMailbox::TextureMailbox( TextureMailbox::TextureMailbox( const Mailbox& mailbox_name, const ReleaseCallback& mailbox_callback) - : callback_(mailbox_callback) { + : callback_(mailbox_callback), + sync_point_(0) { + DCHECK(mailbox_name.isZero() == mailbox_callback.is_null()); + name_.setName(mailbox_name.name); +} + +TextureMailbox::TextureMailbox( + const Mailbox& mailbox_name, + const ReleaseCallback& mailbox_callback, + unsigned sync_point) + : callback_(mailbox_callback), + sync_point_(sync_point) { DCHECK(mailbox_name.isZero() == mailbox_callback.is_null()); name_.setName(mailbox_name.name); } diff --git a/cc/texture_mailbox.h b/cc/texture_mailbox.h index 178a618..95bf170 100644 --- a/cc/texture_mailbox.h +++ b/cc/texture_mailbox.h @@ -22,6 +22,10 @@ class CC_EXPORT TextureMailbox { const ReleaseCallback& callback); TextureMailbox(const Mailbox& mailbox_name, const ReleaseCallback& callback); + TextureMailbox(const Mailbox& mailbox_name, + const ReleaseCallback& callback, + unsigned sync_point); + ~TextureMailbox(); const ReleaseCallback& callback() const { return callback_; } @@ -30,12 +34,15 @@ class CC_EXPORT TextureMailbox { bool Equals(const TextureMailbox&) const; bool IsEmpty() const; const Mailbox& name() const { return name_; } + void ResetSyncPoint() { sync_point_ = 0; } void RunReleaseCallback(unsigned sync_point) const; void SetName(const Mailbox&); + unsigned sync_point() const { return sync_point_; } private: Mailbox name_; ReleaseCallback callback_; + unsigned sync_point_; }; } // namespace cc |