diff options
author | sheu@chromium.org <sheu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-03 23:39:50 +0000 |
---|---|---|
committer | sheu@chromium.org <sheu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-03 23:39:50 +0000 |
commit | df41e253e6918cd035c36936761734f2ac694466 (patch) | |
tree | 9f92ab76398898bbd0f880d821e39a433018526c /cc | |
parent | 3a48972e78af233d570818d21f426afa8c51c2ff (diff) | |
download | chromium_src-df41e253e6918cd035c36936761734f2ac694466.zip chromium_src-df41e253e6918cd035c36936761734f2ac694466.tar.gz chromium_src-df41e253e6918cd035c36936761734f2ac694466.tar.bz2 |
Add gpu::MailboxHolder to hold state for a gpu::Mailbox
gpu::Mailbox by itself can hold only a texture id, but in common usage it comes
with texture target and syncpoint information for cross-context sharing. To
reduce repetition of this pattern, gpu::MailboxHolder holds:
* a gpu::Mailbox
* a GL texture target
* a syncpoint index
Refactor other classes to use a gpu::MailboxHolder instead of separate
gpu::Mailbox and associated state.
Syncpoints are created with uint32 indices; make sure all uses of syncpoints
use the appropriate type.
BUG=None
TEST=local build, unittests on CrOS snow, desktop Linux
TBR=piman@chromium.org, enn@chromium.orge, cevans@chromium.org, scherkus@chromium.org
Review URL: https://codereview.chromium.org/132233041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248612 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
25 files changed, 320 insertions, 337 deletions
@@ -7,6 +7,7 @@ include_rules = [ "+gpu/command_buffer/common/gpu_memory_allocation.h", "+gpu/command_buffer/common/capabilities.h", "+gpu/command_buffer/common/mailbox.h", + "+gpu/command_buffer/common/mailbox_holder.h", "+media", "+skia/ext", "+third_party/skia/include", diff --git a/cc/layers/delegated_frame_provider_unittest.cc b/cc/layers/delegated_frame_provider_unittest.cc index 2a4f564..f29488d 100644 --- a/cc/layers/delegated_frame_provider_unittest.cc +++ b/cc/layers/delegated_frame_provider_unittest.cc @@ -38,7 +38,7 @@ class DelegatedFrameProviderTest ResourceProvider::ResourceId resource_id) { TransferableResource resource; resource.id = resource_id; - resource.target = GL_TEXTURE_2D; + resource.mailbox_holder.texture_target = GL_TEXTURE_2D; frame->resource_list.push_back(resource); } diff --git a/cc/layers/texture_layer.cc b/cc/layers/texture_layer.cc index b37b3e3..bc6b58a 100644 --- a/cc/layers/texture_layer.cc +++ b/cc/layers/texture_layer.cc @@ -142,10 +142,12 @@ void TextureLayer::SetTextureMailboxInternal( DCHECK_EQ(mailbox.IsValid(), !!release_callback); // If we never commited the mailbox, we need to release it here. - if (mailbox.IsValid()) - holder_ref_ = MailboxHolder::Create(mailbox, release_callback.Pass()); - else + if (mailbox.IsValid()) { + holder_ref_ = + TextureMailboxHolder::Create(mailbox, release_callback.Pass()); + } else { holder_ref_.reset(); + } needs_set_mailbox_ = true; // If we are within a commit, no need to do it again immediately after. if (requires_commit) @@ -262,7 +264,7 @@ void TextureLayer::PushPropertiesTo(LayerImpl* layer) { TextureMailbox texture_mailbox; scoped_ptr<SingleReleaseCallback> release_callback; if (holder_ref_) { - MailboxHolder* holder = holder_ref_->holder(); + TextureMailboxHolder* holder = holder_ref_->holder(); texture_mailbox = holder->mailbox(); release_callback = holder->GetCallbackForImplThread(); } @@ -284,17 +286,18 @@ Region TextureLayer::VisibleContentOpaqueRegion() const { return Region(); } -TextureLayer::MailboxHolder::MainThreadReference::MainThreadReference( - MailboxHolder* holder) +TextureLayer::TextureMailboxHolder::MainThreadReference::MainThreadReference( + TextureMailboxHolder* holder) : holder_(holder) { holder_->InternalAddRef(); } -TextureLayer::MailboxHolder::MainThreadReference::~MainThreadReference() { +TextureLayer::TextureMailboxHolder::MainThreadReference:: + ~MainThreadReference() { holder_->InternalRelease(); } -TextureLayer::MailboxHolder::MailboxHolder( +TextureLayer::TextureMailboxHolder::TextureMailboxHolder( const TextureMailbox& mailbox, scoped_ptr<SingleReleaseCallback> release_callback) : message_loop_(BlockingTaskRunner::current()), @@ -302,42 +305,42 @@ TextureLayer::MailboxHolder::MailboxHolder( mailbox_(mailbox), release_callback_(release_callback.Pass()), sync_point_(mailbox.sync_point()), - is_lost_(false) { -} + is_lost_(false) {} -TextureLayer::MailboxHolder::~MailboxHolder() { +TextureLayer::TextureMailboxHolder::~TextureMailboxHolder() { DCHECK_EQ(0u, internal_references_); } -scoped_ptr<TextureLayer::MailboxHolder::MainThreadReference> -TextureLayer::MailboxHolder::Create( +scoped_ptr<TextureLayer::TextureMailboxHolder::MainThreadReference> +TextureLayer::TextureMailboxHolder::Create( const TextureMailbox& mailbox, scoped_ptr<SingleReleaseCallback> release_callback) { return scoped_ptr<MainThreadReference>(new MainThreadReference( - new MailboxHolder(mailbox, release_callback.Pass()))); + new TextureMailboxHolder(mailbox, release_callback.Pass()))); } -void TextureLayer::MailboxHolder::Return(unsigned sync_point, bool is_lost) { +void TextureLayer::TextureMailboxHolder::Return(uint32 sync_point, + bool is_lost) { base::AutoLock lock(arguments_lock_); sync_point_ = sync_point; is_lost_ = is_lost; } scoped_ptr<SingleReleaseCallback> -TextureLayer::MailboxHolder::GetCallbackForImplThread() { +TextureLayer::TextureMailboxHolder::GetCallbackForImplThread() { // We can't call GetCallbackForImplThread if we released the main thread // reference. DCHECK_GT(internal_references_, 0u); InternalAddRef(); return SingleReleaseCallback::Create( - base::Bind(&MailboxHolder::ReturnAndReleaseOnImplThread, this)); + base::Bind(&TextureMailboxHolder::ReturnAndReleaseOnImplThread, this)); } -void TextureLayer::MailboxHolder::InternalAddRef() { +void TextureLayer::TextureMailboxHolder::InternalAddRef() { ++internal_references_; } -void TextureLayer::MailboxHolder::InternalRelease() { +void TextureLayer::TextureMailboxHolder::InternalRelease() { DCHECK(message_loop_->BelongsToCurrentThread()); if (!--internal_references_) { release_callback_->Run(sync_point_, is_lost_); @@ -346,11 +349,12 @@ void TextureLayer::MailboxHolder::InternalRelease() { } } -void TextureLayer::MailboxHolder::ReturnAndReleaseOnImplThread( - unsigned sync_point, bool is_lost) { +void TextureLayer::TextureMailboxHolder::ReturnAndReleaseOnImplThread( + uint32 sync_point, + bool is_lost) { Return(sync_point, is_lost); - message_loop_->PostTask(FROM_HERE, - base::Bind(&MailboxHolder::InternalRelease, this)); + message_loop_->PostTask( + FROM_HERE, base::Bind(&TextureMailboxHolder::InternalRelease, this)); } } // namespace cc diff --git a/cc/layers/texture_layer.h b/cc/layers/texture_layer.h index 8565247..bb179a6 100644 --- a/cc/layers/texture_layer.h +++ b/cc/layers/texture_layer.h @@ -21,22 +21,22 @@ class TextureLayerClient; // A Layer containing a the rendered output of a plugin instance. class CC_EXPORT TextureLayer : public Layer { public: - class CC_EXPORT MailboxHolder - : public base::RefCountedThreadSafe<MailboxHolder> { + class CC_EXPORT TextureMailboxHolder + : public base::RefCountedThreadSafe<TextureMailboxHolder> { public: class CC_EXPORT MainThreadReference { public: - explicit MainThreadReference(MailboxHolder* holder); + explicit MainThreadReference(TextureMailboxHolder* holder); ~MainThreadReference(); - MailboxHolder* holder() { return holder_.get(); } + TextureMailboxHolder* holder() { return holder_.get(); } private: - scoped_refptr<MailboxHolder> holder_; + scoped_refptr<TextureMailboxHolder> holder_; DISALLOW_COPY_AND_ASSIGN(MainThreadReference); }; const TextureMailbox& mailbox() const { return mailbox_; } - void Return(unsigned sync_point, bool is_lost); + void Return(uint32 sync_point, bool is_lost); // Gets a ReleaseCallback that can be called from another thread. Note: the // caller must ensure the callback is called. @@ -49,17 +49,18 @@ class CC_EXPORT TextureLayer : public Layer { static scoped_ptr<MainThreadReference> Create( const TextureMailbox& mailbox, scoped_ptr<SingleReleaseCallback> release_callback); - virtual ~MailboxHolder(); + virtual ~TextureMailboxHolder(); private: - friend class base::RefCountedThreadSafe<MailboxHolder>; + friend class base::RefCountedThreadSafe<TextureMailboxHolder>; friend class MainThreadReference; - explicit MailboxHolder(const TextureMailbox& mailbox, - scoped_ptr<SingleReleaseCallback> release_callback); + explicit TextureMailboxHolder( + const TextureMailbox& mailbox, + scoped_ptr<SingleReleaseCallback> release_callback); void InternalAddRef(); void InternalRelease(); - void ReturnAndReleaseOnImplThread(unsigned sync_point, bool is_lost); + void ReturnAndReleaseOnImplThread(uint32 sync_point, bool is_lost); // This member is thread safe, and is accessed on main and impl threads. const scoped_refptr<BlockingTaskRunner> message_loop_; @@ -75,9 +76,9 @@ class CC_EXPORT TextureLayer : public Layer { // values of these fields are well-ordered such that the last call to // ReturnAndReleaseOnImplThread() defines their values. base::Lock arguments_lock_; - unsigned sync_point_; + uint32 sync_point_; bool is_lost_; - DISALLOW_COPY_AND_ASSIGN(MailboxHolder); + DISALLOW_COPY_AND_ASSIGN(TextureMailboxHolder); }; // If this texture layer requires special preparation logic for each frame @@ -165,7 +166,7 @@ class CC_EXPORT TextureLayer : public Layer { bool content_committed_; unsigned texture_id_; - scoped_ptr<MailboxHolder::MainThreadReference> holder_ref_; + scoped_ptr<TextureMailboxHolder::MainThreadReference> holder_ref_; bool needs_set_mailbox_; DISALLOW_COPY_AND_ASSIGN(TextureLayer); diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc index 24d0500..2287810 100644 --- a/cc/layers/texture_layer_unittest.cc +++ b/cc/layers/texture_layer_unittest.cc @@ -41,6 +41,12 @@ using ::testing::AnyNumber; namespace cc { namespace { +gpu::Mailbox MailboxFromString(const std::string& string) { + gpu::Mailbox mailbox; + mailbox.SetName(reinterpret_cast<const int8*>(string.data())); + return mailbox; +} + class MockLayerTreeHost : public LayerTreeHost { public: explicit MockLayerTreeHost(FakeLayerTreeHostClient* client) @@ -315,12 +321,14 @@ TEST_F(TextureLayerTest, RateLimiter) { class MockMailboxCallback { public: - MOCK_METHOD3(Release, void(const std::string& mailbox, - unsigned sync_point, - bool lost_resource)); - MOCK_METHOD3(Release2, void(base::SharedMemory* shared_memory, - unsigned sync_point, - bool lost_resource)); + MOCK_METHOD3(Release, + void(const std::string& mailbox, + uint32 sync_point, + bool lost_resource)); + MOCK_METHOD3(Release2, + void(base::SharedMemory* shared_memory, + uint32 sync_point, + bool lost_resource)); }; struct CommonMailboxObjects { @@ -336,13 +344,12 @@ struct CommonMailboxObjects { release_mailbox2_ = base::Bind(&MockMailboxCallback::Release, base::Unretained(&mock_callback_), mailbox_name2_); - gpu::Mailbox m1; - m1.SetName(reinterpret_cast<const int8*>(mailbox_name1_.data())); - mailbox1_ = TextureMailbox(m1, sync_point1_); - gpu::Mailbox m2; - m2.SetName(reinterpret_cast<const int8*>(mailbox_name2_.data())); - mailbox2_ = TextureMailbox(m2, sync_point2_); - + const uint32 arbitrary_target1 = 1; + const uint32 arbitrary_target2 = 2; + mailbox1_ = TextureMailbox( + MailboxFromString(mailbox_name1_), arbitrary_target1, sync_point1_); + mailbox2_ = TextureMailbox( + MailboxFromString(mailbox_name2_), arbitrary_target2, sync_point2_); gfx::Size size(128, 128); EXPECT_TRUE(shared_memory_->CreateAndMapAnonymous(4 * size.GetArea())); release_mailbox3_ = base::Bind(&MockMailboxCallback::Release2, @@ -360,14 +367,14 @@ struct CommonMailboxObjects { TextureMailbox mailbox1_; TextureMailbox mailbox2_; TextureMailbox mailbox3_; - unsigned sync_point1_; - unsigned sync_point2_; + uint32 sync_point1_; + uint32 sync_point2_; scoped_ptr<base::SharedMemory> shared_memory_; }; -class TestMailboxHolder : public TextureLayer::MailboxHolder { +class TestMailboxHolder : public TextureLayer::TextureMailboxHolder { public: - using TextureLayer::MailboxHolder::Create; + using TextureLayer::TextureMailboxHolder::Create; protected: virtual ~TestMailboxHolder() {} @@ -754,7 +761,7 @@ class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest { commit_count_(0) {} // Make sure callback is received on main and doesn't block the impl thread. - void ReleaseCallback(unsigned sync_point, bool lost_resource) { + void ReleaseCallback(uint32 sync_point, bool lost_resource) { EXPECT_EQ(true, main_thread_.CalledOnValidThread()); EXPECT_FALSE(lost_resource); ++callback_count_; @@ -762,12 +769,14 @@ class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest { void SetMailbox(char mailbox_char) { EXPECT_EQ(true, main_thread_.CalledOnValidThread()); - TextureMailbox mailbox(std::string(64, mailbox_char)); scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( base::Bind( &TextureLayerImplWithMailboxThreadedCallback::ReleaseCallback, base::Unretained(this))); - layer_->SetTextureMailbox(mailbox, callback.Pass()); + layer_->SetTextureMailbox( + TextureMailbox( + MailboxFromString(std::string(64, mailbox_char)), GL_TEXTURE_2D, 0), + callback.Pass()); } virtual void BeginTest() OVERRIDE { @@ -977,14 +986,16 @@ class TextureLayerMailboxIsActivatedDuringCommit : public LayerTreeTest { protected: TextureLayerMailboxIsActivatedDuringCommit() : activate_count_(0) {} - static void ReleaseCallback(unsigned sync_point, bool lost_resource) {} + static void ReleaseCallback(uint32 sync_point, bool lost_resource) {} void SetMailbox(char mailbox_char) { - TextureMailbox mailbox(std::string(64, mailbox_char)); scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( base::Bind( &TextureLayerMailboxIsActivatedDuringCommit::ReleaseCallback)); - layer_->SetTextureMailbox(mailbox, callback.Pass()); + layer_->SetTextureMailbox( + TextureMailbox( + MailboxFromString(std::string(64, mailbox_char)), GL_TEXTURE_2D, 0), + callback.Pass()); } virtual void BeginTest() OVERRIDE { @@ -1620,22 +1631,23 @@ class TextureLayerNoExtraCommitForMailboxTest return 0; } virtual bool PrepareTextureMailbox( - TextureMailbox* mailbox, + TextureMailbox* texture_mailbox, scoped_ptr<SingleReleaseCallback>* release_callback, bool use_shared_memory) OVERRIDE { if (layer_tree_host()->source_frame_number() == 1) { - *mailbox = TextureMailbox(); + *texture_mailbox = TextureMailbox(); return true; } - *mailbox = TextureMailbox(std::string(64, '1')); + *texture_mailbox = TextureMailbox( + MailboxFromString(std::string(64, '1')), GL_TEXTURE_2D, 0); *release_callback = SingleReleaseCallback::Create( base::Bind(&TextureLayerNoExtraCommitForMailboxTest::MailboxReleased, base::Unretained(this))); return true; } - void MailboxReleased(unsigned sync_point, bool lost_resource) { + void MailboxReleased(uint32 sync_point, bool lost_resource) { EXPECT_EQ(2, layer_tree_host()->source_frame_number()); EndTest(); } @@ -1739,10 +1751,11 @@ class TextureLayerChangeInvisibleMailboxTest } TextureMailbox MakeMailbox(char name) { - return TextureMailbox(std::string(64, name)); + return TextureMailbox( + MailboxFromString(std::string(64, name)), GL_TEXTURE_2D, 0); } - void MailboxReleased(unsigned sync_point, bool lost_resource) { + void MailboxReleased(uint32 sync_point, bool lost_resource) { ++mailbox_returned_; } @@ -1872,7 +1885,8 @@ class TextureLayerReleaseResourcesBase TextureMailbox* mailbox, scoped_ptr<SingleReleaseCallback>* release_callback, bool use_shared_memory) OVERRIDE { - *mailbox = TextureMailbox(std::string(64, '1')); + *mailbox = TextureMailbox( + MailboxFromString(std::string(64, '1')), GL_TEXTURE_2D, 0); *release_callback = SingleReleaseCallback::Create( base::Bind(&TextureLayerReleaseResourcesBase::MailboxReleased, base::Unretained(this))); @@ -2014,7 +2028,7 @@ SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TextureLayerLostContextTest); class TextureLayerWithMailboxMainThreadDeleted : public LayerTreeTest { public: - void ReleaseCallback(unsigned sync_point, bool lost_resource) { + void ReleaseCallback(uint32 sync_point, bool lost_resource) { EXPECT_EQ(true, main_thread_.CalledOnValidThread()); EXPECT_FALSE(lost_resource); ++callback_count_; @@ -2023,12 +2037,14 @@ class TextureLayerWithMailboxMainThreadDeleted : public LayerTreeTest { void SetMailbox(char mailbox_char) { EXPECT_EQ(true, main_thread_.CalledOnValidThread()); - TextureMailbox mailbox(std::string(64, mailbox_char)); scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( base::Bind( &TextureLayerWithMailboxMainThreadDeleted::ReleaseCallback, base::Unretained(this))); - layer_->SetTextureMailbox(mailbox, callback.Pass()); + layer_->SetTextureMailbox( + TextureMailbox( + MailboxFromString(std::string(64, mailbox_char)), GL_TEXTURE_2D, 0), + callback.Pass()); } virtual void SetupTree() OVERRIDE { @@ -2086,7 +2102,7 @@ SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( class TextureLayerWithMailboxImplThreadDeleted : public LayerTreeTest { public: - void ReleaseCallback(unsigned sync_point, bool lost_resource) { + void ReleaseCallback(uint32 sync_point, bool lost_resource) { EXPECT_EQ(true, main_thread_.CalledOnValidThread()); EXPECT_FALSE(lost_resource); ++callback_count_; @@ -2095,12 +2111,14 @@ class TextureLayerWithMailboxImplThreadDeleted : public LayerTreeTest { void SetMailbox(char mailbox_char) { EXPECT_EQ(true, main_thread_.CalledOnValidThread()); - TextureMailbox mailbox(std::string(64, mailbox_char)); scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( base::Bind( &TextureLayerWithMailboxImplThreadDeleted::ReleaseCallback, base::Unretained(this))); - layer_->SetTextureMailbox(mailbox, callback.Pass()); + layer_->SetTextureMailbox( + TextureMailbox( + MailboxFromString(std::string(64, mailbox_char)), GL_TEXTURE_2D, 0), + callback.Pass()); } virtual void SetupTree() OVERRIDE { diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc index f2a3b15..353ea6a 100644 --- a/cc/output/gl_renderer.cc +++ b/cc/output/gl_renderer.cc @@ -2213,7 +2213,7 @@ void GLRenderer::GetFramebufferPixelsAsync( return; } } else { - mailbox = request->texture_mailbox().name(); + mailbox = request->texture_mailbox().mailbox(); DCHECK_EQ(static_cast<unsigned>(GL_TEXTURE_2D), request->texture_mailbox().target()); DCHECK(!mailbox.IsZero()); diff --git a/cc/resources/release_callback.h b/cc/resources/release_callback.h index 9433f7f..b471381 100644 --- a/cc/resources/release_callback.h +++ b/cc/resources/release_callback.h @@ -9,8 +9,7 @@ namespace cc { -typedef base::Callback<void(unsigned sync_point, bool is_lost)> - ReleaseCallback; +typedef base::Callback<void(uint32 sync_point, bool is_lost)> ReleaseCallback; } // namespace cc diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc index 8b9453f..06db279 100644 --- a/cc/resources/resource_provider.cc +++ b/cc/resources/resource_provider.cc @@ -542,7 +542,7 @@ void ResourceProvider::DeleteResourceInternal(ResourceMap::iterator it, GLC(gl, gl->DeleteBuffers(1, &resource->gl_pixel_buffer_id)); } if (resource->mailbox.IsValid() && resource->origin == Resource::External) { - GLuint sync_point = resource->mailbox.sync_point(); + uint32 sync_point = resource->mailbox.sync_point(); if (resource->mailbox.IsTexture()) { lost_resource |= lost_output_surface_; GLES2Interface* gl = ContextGL(); @@ -753,13 +753,13 @@ const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) { DCHECK(gl); if (resource->mailbox.sync_point()) { GLC(gl, gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point())); - resource->mailbox.ResetSyncPoint(); + resource->mailbox.set_sync_point(0); } resource->gl_id = texture_id_allocator_->NextId(); GLC(gl, gl->BindTexture(resource->target, resource->gl_id)); GLC(gl, - gl->ConsumeTextureCHROMIUM(resource->target, - resource->mailbox.data())); + gl->ConsumeTextureCHROMIUM(resource->mailbox.target(), + resource->mailbox.name())); } resource->lock_for_read_count++; @@ -1034,7 +1034,7 @@ void ResourceProvider::PrepareSendToParent(const ResourceIdArray& resources, ++it) { TransferableResource resource; TransferResource(gl, *it, &resource); - if (!resource.sync_point && !resource.is_software) + if (!resource.mailbox_holder.sync_point && !resource.is_software) need_sync_point = true; ++resources_.find(*it)->second.exported_count; list->push_back(resource); @@ -1044,8 +1044,8 @@ void ResourceProvider::PrepareSendToParent(const ResourceIdArray& resources, for (TransferableResourceArray::iterator it = list->begin(); it != list->end(); ++it) { - if (!it->sync_point) - it->sync_point = sync_point; + if (!it->mailbox_holder.sync_point) + it->mailbox_holder.sync_point = sync_point; } } } @@ -1069,9 +1069,10 @@ void ResourceProvider::ReceiveFromChild( scoped_ptr<SharedBitmap> bitmap; uint8_t* pixels = NULL; if (it->is_software) { - if (shared_bitmap_manager_) - bitmap = shared_bitmap_manager_->GetSharedBitmapFromId(it->size, - it->mailbox); + if (shared_bitmap_manager_) { + bitmap = shared_bitmap_manager_->GetSharedBitmapFromId( + it->size, it->mailbox_holder.mailbox); + } if (bitmap) pixels = bitmap->pixels(); } @@ -1092,14 +1093,15 @@ void ResourceProvider::ReceiveFromChild( } else { resource = Resource(0, it->size, - it->target, + it->mailbox_holder.texture_target, it->filter, 0, GL_CLAMP_TO_EDGE, TextureUsageAny, it->format); - resource.mailbox = - TextureMailbox(it->mailbox, it->target, it->sync_point); + resource.mailbox = TextureMailbox(it->mailbox_holder.mailbox, + it->mailbox_holder.texture_target, + it->mailbox_holder.sync_point); } resource.child_id = child; resource.origin = Resource::Delegated; @@ -1211,10 +1213,7 @@ void ResourceProvider::ReceiveReturnsFromParent( // Because CreateResourceFromExternalTexture() never be called, // when enabling delegated compositor. DCHECK(!resource->gl_id); - resource->mailbox = - TextureMailbox(resource->mailbox.name(), - resource->mailbox.target(), - returned.sync_point); + resource->mailbox.set_sync_point(returned.sync_point); } } @@ -1268,41 +1267,47 @@ void ResourceProvider::TransferResource(GLES2Interface* gl, DCHECK_EQ(source->wrap_mode, GL_CLAMP_TO_EDGE); resource->id = id; resource->format = source->format; - resource->target = source->target; + resource->mailbox_holder.texture_target = source->target; resource->filter = source->filter; resource->size = source->size; if (source->shared_bitmap) { - resource->mailbox = source->shared_bitmap->id(); + resource->mailbox_holder.mailbox = source->shared_bitmap->id(); resource->is_software = true; } else if (!source->mailbox.IsValid()) { LazyCreate(source); DCHECK(source->gl_id); DCHECK(source->origin == Resource::Internal); - GLC(gl, gl->BindTexture(resource->target, source->gl_id)); + GLC(gl, + gl->BindTexture(resource->mailbox_holder.texture_target, + source->gl_id)); if (source->image_id) { DCHECK(source->dirty_image); BindImageForSampling(source); } // This is a resource allocated by the compositor, we need to produce it. // Don't set a sync point, the caller will do it. - GLC(gl, gl->GenMailboxCHROMIUM(resource->mailbox.name)); + GLC(gl, gl->GenMailboxCHROMIUM(resource->mailbox_holder.mailbox.name)); GLC(gl, - gl->ProduceTextureCHROMIUM(resource->target, resource->mailbox.name)); - source->mailbox.SetName(resource->mailbox); + gl->ProduceTextureCHROMIUM(resource->mailbox_holder.texture_target, + resource->mailbox_holder.mailbox.name)); + source->mailbox = TextureMailbox(resource->mailbox_holder); } else { DCHECK(source->mailbox.IsTexture()); if (source->image_id && source->dirty_image) { DCHECK(source->gl_id); DCHECK(source->origin == Resource::Internal); - GLC(gl, gl->BindTexture(resource->target, source->gl_id)); + GLC(gl, + gl->BindTexture(resource->mailbox_holder.texture_target, + source->gl_id)); BindImageForSampling(source); } // This is either an external resource, or a compositor resource that we // already exported. Make sure to forward the sync point that we were given. - resource->mailbox = source->mailbox.name(); - resource->sync_point = source->mailbox.sync_point(); - source->mailbox.ResetSyncPoint(); + resource->mailbox_holder.mailbox = source->mailbox.mailbox(); + resource->mailbox_holder.texture_target = source->mailbox.target(); + resource->mailbox_holder.sync_point = source->mailbox.sync_point(); + source->mailbox.set_sync_point(0); } } diff --git a/cc/resources/resource_provider_unittest.cc b/cc/resources/resource_provider_unittest.cc index bce6d5a..b653b08 100644 --- a/cc/resources/resource_provider_unittest.cc +++ b/cc/resources/resource_provider_unittest.cc @@ -37,15 +37,15 @@ using testing::_; namespace cc { namespace { -static void EmptyReleaseCallback(unsigned sync_point, bool lost_resource) {} +static void EmptyReleaseCallback(uint32 sync_point, bool lost_resource) {} static void SharedMemoryReleaseCallback(scoped_ptr<base::SharedMemory> memory, - unsigned sync_point, + uint32 sync_point, bool lost_resource) {} -static void ReleaseTextureMailbox(unsigned* release_sync_point, +static void ReleaseTextureMailbox(uint32* release_sync_point, bool* release_lost_resource, - unsigned sync_point, + uint32 sync_point, bool lost_resource) { *release_sync_point = sync_point; *release_lost_resource = lost_resource; @@ -54,9 +54,9 @@ static void ReleaseTextureMailbox(unsigned* release_sync_point, static void ReleaseSharedMemoryCallback( scoped_ptr<base::SharedMemory> shared_memory, bool* release_called, - unsigned* release_sync_point, + uint32* release_sync_point, bool* lost_resource_result, - unsigned sync_point, + uint32 sync_point, bool lost_resource) { *release_called = true; *release_sync_point = sync_point; @@ -78,8 +78,8 @@ class TextureStateTrackingContext : public TestWebGraphicsContext3D { public: MOCK_METHOD2(bindTexture, void(GLenum target, GLuint texture)); MOCK_METHOD3(texParameteri, void(GLenum target, GLenum pname, GLint param)); - MOCK_METHOD1(waitSyncPoint, void(unsigned sync_point)); - MOCK_METHOD0(insertSyncPoint, unsigned(void)); + MOCK_METHOD1(waitSyncPoint, void(GLuint sync_point)); + MOCK_METHOD0(insertSyncPoint, GLuint(void)); MOCK_METHOD2(produceTextureCHROMIUM, void(GLenum target, const GLbyte* mailbox)); MOCK_METHOD2(consumeTextureCHROMIUM, @@ -102,7 +102,7 @@ class ContextSharedData { return make_scoped_ptr(new ContextSharedData()); } - unsigned InsertSyncPoint() { return next_sync_point_++; } + uint32 InsertSyncPoint() { return next_sync_point_++; } void GenMailbox(GLbyte* mailbox) { memset(mailbox, 0, sizeof(GLbyte[64])); @@ -111,7 +111,7 @@ class ContextSharedData { } void ProduceTexture(const GLbyte* mailbox_name, - unsigned sync_point, + uint32 sync_point, scoped_refptr<TestTexture> texture) { unsigned mailbox = 0; memcpy(&mailbox, mailbox_name, sizeof(mailbox)); @@ -122,7 +122,7 @@ class ContextSharedData { } scoped_refptr<TestTexture> ConsumeTexture(const GLbyte* mailbox_name, - unsigned sync_point) { + uint32 sync_point) { unsigned mailbox = 0; memcpy(&mailbox, mailbox_name, sizeof(mailbox)); DCHECK(mailbox && mailbox < next_mailbox_); @@ -140,11 +140,11 @@ class ContextSharedData { private: ContextSharedData() : next_sync_point_(1), next_mailbox_(1) {} - unsigned next_sync_point_; + uint32 next_sync_point_; unsigned next_mailbox_; typedef base::hash_map<unsigned, scoped_refptr<TestTexture> > TextureMap; TextureMap textures_; - base::hash_map<unsigned, unsigned> sync_point_for_mailbox_; + base::hash_map<unsigned, uint32> sync_point_for_mailbox_; }; class ResourceProviderContext : public TestWebGraphicsContext3D { @@ -154,8 +154,8 @@ class ResourceProviderContext : public TestWebGraphicsContext3D { return make_scoped_ptr(new ResourceProviderContext(shared_data)); } - virtual unsigned insertSyncPoint() OVERRIDE { - unsigned sync_point = shared_data_->InsertSyncPoint(); + virtual GLuint insertSyncPoint() OVERRIDE { + uint32 sync_point = shared_data_->InsertSyncPoint(); // Commit the produceTextureCHROMIUM calls at this point, so that // they're associated with the sync point. for (PendingProduceTextureList::iterator it = @@ -169,7 +169,7 @@ class ResourceProviderContext : public TestWebGraphicsContext3D { return sync_point; } - virtual void waitSyncPoint(unsigned sync_point) OVERRIDE { + virtual void waitSyncPoint(GLuint sync_point) OVERRIDE { last_waited_sync_point_ = std::max(sync_point, last_waited_sync_point_); } @@ -327,7 +327,7 @@ class ResourceProviderContext : public TestWebGraphicsContext3D { }; typedef ScopedPtrDeque<PendingProduceTexture> PendingProduceTextureList; ContextSharedData* shared_data_; - unsigned last_waited_sync_point_; + GLuint last_waited_sync_point_; PendingProduceTextureList pending_produce_textures_; }; @@ -477,10 +477,10 @@ class ResourceProviderTest ResourceProviderContext* context() { return context3d_; } - ResourceProvider::ResourceId CreateChildMailbox(unsigned* release_sync_point, + ResourceProvider::ResourceId CreateChildMailbox(uint32* release_sync_point, bool* lost_resource, bool* release_called, - unsigned* sync_point) { + uint32* sync_point) { if (GetParam() == ResourceProvider::GLTexture) { unsigned texture = child_context_->createTexture(); gpu::Mailbox gpu_mailbox; @@ -498,7 +498,8 @@ class ResourceProviderTest release_sync_point, lost_resource)); return child_resource_provider_->CreateResourceFromTextureMailbox( - TextureMailbox(gpu_mailbox, *sync_point), callback.Pass()); + TextureMailbox(gpu_mailbox, GL_TEXTURE_2D, *sync_point), + callback.Pass()); } else { gfx::Size size(64, 64); scoped_ptr<base::SharedMemory> shared_memory( @@ -664,7 +665,7 @@ TEST_P(ResourceProviderTest, TransferGLResources) { child_context_->genMailboxCHROMIUM(external_mailbox.name); child_context_->produceTextureCHROMIUM(GL_TEXTURE_EXTERNAL_OES, external_mailbox.name); - const unsigned external_sync_point = child_context_->insertSyncPoint(); + const GLuint external_sync_point = child_context_->insertSyncPoint(); ResourceProvider::ResourceId id4 = child_resource_provider_->CreateResourceFromTextureMailbox( TextureMailbox( @@ -685,27 +686,35 @@ TEST_P(ResourceProviderTest, TransferGLResources) { child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); ASSERT_EQ(4u, list.size()); - EXPECT_NE(0u, list[0].sync_point); - EXPECT_NE(0u, list[1].sync_point); - EXPECT_EQ(list[0].sync_point, list[1].sync_point); - EXPECT_NE(0u, list[2].sync_point); - EXPECT_EQ(list[0].sync_point, list[2].sync_point); - EXPECT_EQ(external_sync_point, list[3].sync_point); - EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[0].target); - EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[1].target); - EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[2].target); - EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), list[3].target); + EXPECT_NE(0u, list[0].mailbox_holder.sync_point); + EXPECT_NE(0u, list[1].mailbox_holder.sync_point); + EXPECT_EQ(list[0].mailbox_holder.sync_point, + list[1].mailbox_holder.sync_point); + EXPECT_NE(0u, list[2].mailbox_holder.sync_point); + EXPECT_EQ(list[0].mailbox_holder.sync_point, + list[2].mailbox_holder.sync_point); + EXPECT_EQ(external_sync_point, list[3].mailbox_holder.sync_point); + EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), + list[0].mailbox_holder.texture_target); + EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), + list[1].mailbox_holder.texture_target); + EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), + list[2].mailbox_holder.texture_target); + EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), + list[3].mailbox_holder.texture_target); EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4)); resource_provider_->ReceiveFromChild(child_id, list); - EXPECT_NE(list[0].sync_point, context3d_->last_waited_sync_point()); + EXPECT_NE(list[0].mailbox_holder.sync_point, + context3d_->last_waited_sync_point()); { ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(), list[0].id); } - EXPECT_EQ(list[0].sync_point, context3d_->last_waited_sync_point()); + EXPECT_EQ(list[0].mailbox_holder.sync_point, + context3d_->last_waited_sync_point()); resource_provider_->DeclareUsedResourcesFromChild(child_id, resource_ids_to_transfer); } @@ -749,9 +758,12 @@ TEST_P(ResourceProviderTest, TransferGLResources) { EXPECT_EQ(id1, list[0].id); EXPECT_EQ(id2, list[1].id); EXPECT_EQ(id3, list[2].id); - EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[0].target); - EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[1].target); - EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[2].target); + EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), + list[0].mailbox_holder.texture_target); + EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), + list[1].mailbox_holder.texture_target); + EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), + list[2].mailbox_holder.texture_target); ReturnedResourceArray returned; TransferableResource::ReturnResources(list, &returned); child_resource_provider_->ReceiveReturnsFromParent(returned); @@ -823,14 +835,18 @@ TEST_P(ResourceProviderTest, TransferGLResources) { EXPECT_EQ(id2, list[1].id); EXPECT_EQ(id3, list[2].id); EXPECT_EQ(id4, list[3].id); - EXPECT_NE(0u, list[0].sync_point); - EXPECT_NE(0u, list[1].sync_point); - EXPECT_NE(0u, list[2].sync_point); - EXPECT_NE(0u, list[3].sync_point); - EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[0].target); - EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[1].target); - EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[2].target); - EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), list[3].target); + EXPECT_NE(0u, list[0].mailbox_holder.sync_point); + EXPECT_NE(0u, list[1].mailbox_holder.sync_point); + EXPECT_NE(0u, list[2].mailbox_holder.sync_point); + EXPECT_NE(0u, list[3].mailbox_holder.sync_point); + EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), + list[0].mailbox_holder.texture_target); + EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), + list[1].mailbox_holder.texture_target); + EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), + list[2].mailbox_holder.texture_target); + EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), + list[3].mailbox_holder.texture_target); EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); @@ -908,10 +924,10 @@ TEST_P(ResourceProviderTest, TransferSoftwareResources) { child_resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); ASSERT_EQ(4u, list.size()); - EXPECT_EQ(0u, list[0].sync_point); - EXPECT_EQ(0u, list[1].sync_point); - EXPECT_EQ(0u, list[2].sync_point); - EXPECT_EQ(0u, list[3].sync_point); + EXPECT_EQ(0u, list[0].mailbox_holder.sync_point); + EXPECT_EQ(0u, list[1].mailbox_holder.sync_point); + EXPECT_EQ(0u, list[2].mailbox_holder.sync_point); + EXPECT_EQ(0u, list[3].mailbox_holder.sync_point); EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3)); @@ -1169,8 +1185,9 @@ TEST_P(ResourceProviderTest, TransferGLToSoftware) { child_resource_provider->PrepareSendToParent(resource_ids_to_transfer, &list); ASSERT_EQ(1u, list.size()); - EXPECT_NE(0u, list[0].sync_point); - EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[0].target); + EXPECT_NE(0u, list[0].mailbox_holder.sync_point); + EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), + list[0].mailbox_holder.texture_target); EXPECT_TRUE(child_resource_provider->InUseByConsumer(id1)); resource_provider_->ReceiveFromChild(child_id, list); } @@ -1216,7 +1233,7 @@ TEST_P(ResourceProviderTest, TransferInvalidSoftware) { &list); ASSERT_EQ(1u, list.size()); // Make invalid. - list[0].mailbox.name[1] = 5; + list[0].mailbox_holder.mailbox.name[1] = 5; EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); resource_provider_->ReceiveFromChild(child_id, list); } @@ -1266,8 +1283,8 @@ TEST_P(ResourceProviderTest, DeleteExportedResources) { &list); ASSERT_EQ(2u, list.size()); if (GetParam() == ResourceProvider::GLTexture) { - EXPECT_NE(0u, list[0].sync_point); - EXPECT_NE(0u, list[1].sync_point); + EXPECT_NE(0u, list[0].mailbox_holder.sync_point); + EXPECT_NE(0u, list[1].mailbox_holder.sync_point); } EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); @@ -1296,8 +1313,8 @@ TEST_P(ResourceProviderTest, DeleteExportedResources) { ASSERT_EQ(2u, list.size()); if (GetParam() == ResourceProvider::GLTexture) { - EXPECT_NE(0u, list[0].sync_point); - EXPECT_NE(0u, list[1].sync_point); + EXPECT_NE(0u, list[0].mailbox_holder.sync_point); + EXPECT_NE(0u, list[1].mailbox_holder.sync_point); } EXPECT_TRUE(resource_provider_->InUseByConsumer(id1)); EXPECT_TRUE(resource_provider_->InUseByConsumer(id2)); @@ -1360,8 +1377,8 @@ TEST_P(ResourceProviderTest, DestroyChildWithExportedResources) { &list); ASSERT_EQ(2u, list.size()); if (GetParam() == ResourceProvider::GLTexture) { - EXPECT_NE(0u, list[0].sync_point); - EXPECT_NE(0u, list[1].sync_point); + EXPECT_NE(0u, list[0].mailbox_holder.sync_point); + EXPECT_NE(0u, list[1].mailbox_holder.sync_point); } EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id1)); EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id2)); @@ -1390,8 +1407,8 @@ TEST_P(ResourceProviderTest, DestroyChildWithExportedResources) { ASSERT_EQ(2u, list.size()); if (GetParam() == ResourceProvider::GLTexture) { - EXPECT_NE(0u, list[0].sync_point); - EXPECT_NE(0u, list[1].sync_point); + EXPECT_NE(0u, list[0].mailbox_holder.sync_point); + EXPECT_NE(0u, list[1].mailbox_holder.sync_point); } EXPECT_TRUE(resource_provider_->InUseByConsumer(id1)); EXPECT_TRUE(resource_provider_->InUseByConsumer(id2)); @@ -1465,7 +1482,7 @@ TEST_P(ResourceProviderTest, DeleteTransferredResources) { &list); ASSERT_EQ(1u, list.size()); if (GetParam() == ResourceProvider::GLTexture) - EXPECT_NE(0u, list[0].sync_point); + EXPECT_NE(0u, list[0].mailbox_holder.sync_point); EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id)); resource_provider_->ReceiveFromChild(child_id, list); resource_provider_->DeclareUsedResourcesFromChild(child_id, @@ -1683,18 +1700,18 @@ TEST_P(ResourceProviderTest, TransferMailboxResources) { gpu::Mailbox mailbox; context()->genMailboxCHROMIUM(mailbox.name); context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); - unsigned sync_point = context()->insertSyncPoint(); + uint32 sync_point = context()->insertSyncPoint(); // All the logic below assumes that the sync points are all positive. EXPECT_LT(0u, sync_point); - unsigned release_sync_point = 0; + uint32 release_sync_point = 0; bool lost_resource = false; ReleaseCallback callback = base::Bind(ReleaseTextureMailbox, &release_sync_point, &lost_resource); ResourceProvider::ResourceId resource = resource_provider_->CreateResourceFromTextureMailbox( - TextureMailbox(mailbox, sync_point), + TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), SingleReleaseCallback::Create(callback)); EXPECT_EQ(1u, context()->NumTextures()); EXPECT_EQ(0u, release_sync_point); @@ -1705,12 +1722,14 @@ TEST_P(ResourceProviderTest, TransferMailboxResources) { TransferableResourceArray list; resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); ASSERT_EQ(1u, list.size()); - EXPECT_LE(sync_point, list[0].sync_point); + EXPECT_LE(sync_point, list[0].mailbox_holder.sync_point); EXPECT_EQ(0, - memcmp(mailbox.name, list[0].mailbox.name, sizeof(mailbox.name))); + memcmp(mailbox.name, + list[0].mailbox_holder.mailbox.name, + sizeof(mailbox.name))); EXPECT_EQ(0u, release_sync_point); - context()->waitSyncPoint(list[0].sync_point); + context()->waitSyncPoint(list[0].mailbox_holder.sync_point); unsigned other_texture = context()->createTexture(); context()->bindTexture(GL_TEXTURE_2D, other_texture); context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); @@ -1720,8 +1739,8 @@ TEST_P(ResourceProviderTest, TransferMailboxResources) { EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); context()->deleteTexture(other_texture); - list[0].sync_point = context()->insertSyncPoint(); - EXPECT_LT(0u, list[0].sync_point); + list[0].mailbox_holder.sync_point = context()->insertSyncPoint(); + EXPECT_LT(0u, list[0].mailbox_holder.sync_point); // Receive the resource, then delete it, expect the sync points to be // consistent. @@ -1732,7 +1751,7 @@ TEST_P(ResourceProviderTest, TransferMailboxResources) { EXPECT_EQ(0u, release_sync_point); resource_provider_->DeleteResource(resource); - EXPECT_LE(list[0].sync_point, release_sync_point); + EXPECT_LE(list[0].mailbox_holder.sync_point, release_sync_point); EXPECT_FALSE(lost_resource); } @@ -1742,7 +1761,7 @@ TEST_P(ResourceProviderTest, TransferMailboxResources) { EXPECT_LT(0u, sync_point); release_sync_point = 0; resource = resource_provider_->CreateResourceFromTextureMailbox( - TextureMailbox(mailbox, sync_point), + TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), SingleReleaseCallback::Create(callback)); EXPECT_EQ(1u, context()->NumTextures()); EXPECT_EQ(0u, release_sync_point); @@ -1753,12 +1772,14 @@ TEST_P(ResourceProviderTest, TransferMailboxResources) { TransferableResourceArray list; resource_provider_->PrepareSendToParent(resource_ids_to_transfer, &list); ASSERT_EQ(1u, list.size()); - EXPECT_LE(sync_point, list[0].sync_point); + EXPECT_LE(sync_point, list[0].mailbox_holder.sync_point); EXPECT_EQ(0, - memcmp(mailbox.name, list[0].mailbox.name, sizeof(mailbox.name))); + memcmp(mailbox.name, + list[0].mailbox_holder.mailbox.name, + sizeof(mailbox.name))); EXPECT_EQ(0u, release_sync_point); - context()->waitSyncPoint(list[0].sync_point); + context()->waitSyncPoint(list[0].mailbox_holder.sync_point); unsigned other_texture = context()->createTexture(); context()->bindTexture(GL_TEXTURE_2D, other_texture); context()->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); @@ -1768,8 +1789,8 @@ TEST_P(ResourceProviderTest, TransferMailboxResources) { EXPECT_EQ(0, memcmp(data, test_data, sizeof(data))); context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); context()->deleteTexture(other_texture); - list[0].sync_point = context()->insertSyncPoint(); - EXPECT_LT(0u, list[0].sync_point); + list[0].mailbox_holder.sync_point = context()->insertSyncPoint(); + EXPECT_LT(0u, list[0].mailbox_holder.sync_point); // Delete the resource, which shouldn't do anything. resource_provider_->DeleteResource(resource); @@ -1781,7 +1802,7 @@ TEST_P(ResourceProviderTest, TransferMailboxResources) { ReturnedResourceArray returned; TransferableResource::ReturnResources(list, &returned); resource_provider_->ReceiveReturnsFromParent(returned); - EXPECT_LE(list[0].sync_point, release_sync_point); + EXPECT_LE(list[0].mailbox_holder.sync_point, release_sync_point); EXPECT_FALSE(lost_resource); } @@ -1921,10 +1942,10 @@ TEST_P(ResourceProviderTest, LostResourceInGrandParent) { } TEST_P(ResourceProviderTest, LostMailboxInParent) { - unsigned release_sync_point = 0; + uint32 release_sync_point = 0; bool lost_resource = false; bool release_called = false; - unsigned sync_point = 0; + uint32 sync_point = 0; ResourceProvider::ResourceId resource = CreateChildMailbox( &release_sync_point, &lost_resource, &release_called, &sync_point); @@ -1971,10 +1992,10 @@ TEST_P(ResourceProviderTest, LostMailboxInParent) { } TEST_P(ResourceProviderTest, LostMailboxInGrandParent) { - unsigned release_sync_point = 0; + uint32 release_sync_point = 0; bool lost_resource = false; bool release_called = false; - unsigned sync_point = 0; + uint32 sync_point = 0; ResourceProvider::ResourceId resource = CreateChildMailbox( &release_sync_point, &lost_resource, &release_called, &sync_point); @@ -2039,10 +2060,10 @@ TEST_P(ResourceProviderTest, LostMailboxInGrandParent) { } TEST_P(ResourceProviderTest, Shutdown) { - unsigned release_sync_point = 0; + uint32 release_sync_point = 0; bool lost_resource = false; bool release_called = false; - unsigned sync_point = 0; + uint32 sync_point = 0; CreateChildMailbox( &release_sync_point, &lost_resource, &release_called, &sync_point); @@ -2059,10 +2080,10 @@ TEST_P(ResourceProviderTest, Shutdown) { } TEST_P(ResourceProviderTest, ShutdownWithExportedResource) { - unsigned release_sync_point = 0; + uint32 release_sync_point = 0; bool lost_resource = false; bool release_called = false; - unsigned sync_point = 0; + uint32 sync_point = 0; ResourceProvider::ResourceId resource = CreateChildMailbox( &release_sync_point, &lost_resource, &release_called, &sync_point); @@ -2092,17 +2113,16 @@ TEST_P(ResourceProviderTest, LostContext) { gpu::Mailbox mailbox; context()->genMailboxCHROMIUM(mailbox.name); context()->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); - unsigned sync_point = context()->insertSyncPoint(); + uint32 sync_point = context()->insertSyncPoint(); EXPECT_LT(0u, sync_point); - unsigned release_sync_point = 0; + uint32 release_sync_point = 0; bool lost_resource = false; scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( base::Bind(ReleaseTextureMailbox, &release_sync_point, &lost_resource)); resource_provider_->CreateResourceFromTextureMailbox( - TextureMailbox(mailbox, sync_point), - callback.Pass()); + TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), callback.Pass()); EXPECT_EQ(0u, release_sync_point); EXPECT_FALSE(lost_resource); @@ -2351,7 +2371,7 @@ TEST_P(ResourceProviderTest, TextureMailbox_GLTexture2D) { ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); unsigned texture_id = 1; - unsigned sync_point = 30; + uint32 sync_point = 30; unsigned target = GL_TEXTURE_2D; EXPECT_CALL(*context, bindTexture(_, _)).Times(0); @@ -2365,7 +2385,7 @@ TEST_P(ResourceProviderTest, TextureMailbox_GLTexture2D) { scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( base::Bind(&EmptyReleaseCallback)); - TextureMailbox mailbox(gpu_mailbox, sync_point); + TextureMailbox mailbox(gpu_mailbox, target, sync_point); ResourceProvider::ResourceId id = resource_provider->CreateResourceFromTextureMailbox( @@ -2415,7 +2435,7 @@ TEST_P(ResourceProviderTest, TextureMailbox_GLTextureExternalOES) { ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); unsigned texture_id = 1; - unsigned sync_point = 30; + uint32 sync_point = 30; unsigned target = GL_TEXTURE_EXTERNAL_OES; EXPECT_CALL(*context, bindTexture(_, _)).Times(0); diff --git a/cc/resources/single_release_callback.cc b/cc/resources/single_release_callback.cc index 9c6b9de..4565963 100644 --- a/cc/resources/single_release_callback.cc +++ b/cc/resources/single_release_callback.cc @@ -20,7 +20,7 @@ SingleReleaseCallback::~SingleReleaseCallback() { << "SingleReleaseCallback was never run."; } -void SingleReleaseCallback::Run(unsigned sync_point, bool is_lost) { +void SingleReleaseCallback::Run(uint32 sync_point, bool is_lost) { DCHECK(!has_been_run_) << "SingleReleaseCallback was run more than once."; has_been_run_ = true; callback_.Run(sync_point, is_lost); diff --git a/cc/resources/single_release_callback.h b/cc/resources/single_release_callback.h index fe1a3ba..6f64df6 100644 --- a/cc/resources/single_release_callback.h +++ b/cc/resources/single_release_callback.h @@ -19,7 +19,7 @@ class CC_EXPORT SingleReleaseCallback { ~SingleReleaseCallback(); - void Run(unsigned sync_point, bool is_lost); + void Run(uint32 sync_point, bool is_lost); private: explicit SingleReleaseCallback(const ReleaseCallback& callback); diff --git a/cc/resources/texture_mailbox.cc b/cc/resources/texture_mailbox.cc index 074967f..a6c2fde 100644 --- a/cc/resources/texture_mailbox.cc +++ b/cc/resources/texture_mailbox.cc @@ -9,78 +9,36 @@ namespace cc { -TextureMailbox::TextureMailbox() - : target_(GL_TEXTURE_2D), - sync_point_(0), - shared_memory_(NULL) { -} - -TextureMailbox::TextureMailbox(const std::string& mailbox_name) - : target_(GL_TEXTURE_2D), - sync_point_(0), - shared_memory_(NULL) { - if (!mailbox_name.empty()) { - CHECK(mailbox_name.size() == sizeof(name_.name)); - name_.SetName(reinterpret_cast<const int8*>(mailbox_name.data())); - } -} +TextureMailbox::TextureMailbox() : shared_memory_(NULL) {} -TextureMailbox::TextureMailbox(const gpu::Mailbox& mailbox_name) - : target_(GL_TEXTURE_2D), - sync_point_(0), - shared_memory_(NULL) { - name_.SetName(mailbox_name.name); -} - -TextureMailbox::TextureMailbox(const gpu::Mailbox& mailbox_name, - unsigned sync_point) - : target_(GL_TEXTURE_2D), - sync_point_(sync_point), - shared_memory_(NULL) { - name_.SetName(mailbox_name.name); -} +TextureMailbox::TextureMailbox(const gpu::MailboxHolder& mailbox_holder) + : mailbox_holder_(mailbox_holder), shared_memory_(NULL) {} -TextureMailbox::TextureMailbox(const gpu::Mailbox& mailbox_name, - unsigned texture_target, - unsigned sync_point) - : target_(texture_target), - sync_point_(sync_point), - shared_memory_(NULL) { - name_.SetName(mailbox_name.name); -} +TextureMailbox::TextureMailbox(const gpu::Mailbox& mailbox, + uint32 target, + uint32 sync_point) + : mailbox_holder_(mailbox, target, sync_point), shared_memory_(NULL) {} TextureMailbox::TextureMailbox(base::SharedMemory* shared_memory, const gfx::Size& size) - : target_(GL_TEXTURE_2D), - sync_point_(0), - shared_memory_(shared_memory), - shared_memory_size_(size) {} + : shared_memory_(shared_memory), shared_memory_size_(size) {} TextureMailbox::~TextureMailbox() {} bool TextureMailbox::Equals(const TextureMailbox& other) const { - if (other.IsTexture()) - return ContainsMailbox(other.name()); - else if (other.IsSharedMemory()) - return ContainsHandle(other.shared_memory_->handle()); + if (other.IsTexture()) { + return IsTexture() && !memcmp(mailbox_holder_.mailbox.name, + other.mailbox_holder_.mailbox.name, + sizeof(mailbox_holder_.mailbox.name)); + } else if (other.IsSharedMemory()) { + return IsSharedMemory() && + shared_memory_->handle() == other.shared_memory_->handle(); + } DCHECK(!other.IsValid()); return !IsValid(); } -bool TextureMailbox::ContainsMailbox(const gpu::Mailbox& other) const { - return IsTexture() && !memcmp(data(), other.name, sizeof(name_.name)); -} - -bool TextureMailbox::ContainsHandle(base::SharedMemoryHandle handle) const { - return shared_memory_ && shared_memory_->handle() == handle; -} - -void TextureMailbox::SetName(const gpu::Mailbox& name) { - DCHECK(shared_memory_ == NULL); - name_ = name; -} - size_t TextureMailbox::shared_memory_size_in_bytes() const { return 4 * shared_memory_size_.GetArea(); } diff --git a/cc/resources/texture_mailbox.h b/cc/resources/texture_mailbox.h index 8ff87cc..229f7a7 100644 --- a/cc/resources/texture_mailbox.h +++ b/cc/resources/texture_mailbox.h @@ -10,7 +10,7 @@ #include "base/callback.h" #include "base/memory/shared_memory.h" #include "cc/base/cc_export.h" -#include "gpu/command_buffer/common/mailbox.h" +#include "gpu/command_buffer/common/mailbox_holder.h" #include "ui/gfx/size.h" namespace cc { @@ -20,44 +20,32 @@ namespace cc { class CC_EXPORT TextureMailbox { public: TextureMailbox(); - explicit TextureMailbox(const std::string& mailbox_name); - explicit TextureMailbox(const gpu::Mailbox& mailbox_name); - TextureMailbox(const gpu::Mailbox& mailbox_name, - unsigned sync_point); - TextureMailbox(const gpu::Mailbox& mailbox_name, - unsigned texture_target, - unsigned sync_point); - TextureMailbox(base::SharedMemory* shared_memory, - const gfx::Size& size); + explicit TextureMailbox(const gpu::MailboxHolder& mailbox_holder); + TextureMailbox(const gpu::Mailbox& mailbox, uint32 target, uint32 sync_point); + TextureMailbox(base::SharedMemory* shared_memory, const gfx::Size& size); ~TextureMailbox(); bool IsValid() const { return IsTexture() || IsSharedMemory(); } - bool IsTexture() const { return !name_.IsZero(); } + bool IsTexture() const { return !mailbox_holder_.mailbox.IsZero(); } bool IsSharedMemory() const { return shared_memory_ != NULL; } bool Equals(const TextureMailbox&) const; - bool ContainsMailbox(const gpu::Mailbox&) const; - bool ContainsHandle(base::SharedMemoryHandle handle) const; - const int8* data() const { return name_.name; } - const gpu::Mailbox& name() const { return name_; } - void ResetSyncPoint() { sync_point_ = 0; } - unsigned target() const { return target_; } - unsigned sync_point() const { return sync_point_; } + const gpu::Mailbox& mailbox() const { return mailbox_holder_.mailbox; } + const int8* name() const { return mailbox().name; } + uint32 target() const { return mailbox_holder_.texture_target; } + uint32 sync_point() const { return mailbox_holder_.sync_point; } + void set_sync_point(int32 sync_point) { + mailbox_holder_.sync_point = sync_point; + } base::SharedMemory* shared_memory() const { return shared_memory_; } gfx::Size shared_memory_size() const { return shared_memory_size_; } size_t shared_memory_size_in_bytes() const; - // TODO(danakj): ReleaseCallback should be separate from this class, and stop - // storing a TextureMailbox in ResourceProvider. Then we can remove this. - void SetName(const gpu::Mailbox& name); - private: - gpu::Mailbox name_; - unsigned target_; - unsigned sync_point_; + gpu::MailboxHolder mailbox_holder_; base::SharedMemory* shared_memory_; gfx::Size shared_memory_size_; }; diff --git a/cc/resources/texture_mailbox_deleter.cc b/cc/resources/texture_mailbox_deleter.cc index cf7b3b61..542b95e 100644 --- a/cc/resources/texture_mailbox_deleter.cc +++ b/cc/resources/texture_mailbox_deleter.cc @@ -17,7 +17,7 @@ namespace cc { static void DeleteTextureOnImplThread( const scoped_refptr<ContextProvider>& context_provider, unsigned texture_id, - unsigned sync_point, + uint32 sync_point, bool is_lost) { if (sync_point) context_provider->ContextGL()->WaitSyncPointCHROMIUM(sync_point); diff --git a/cc/resources/texture_mailbox_deleter.h b/cc/resources/texture_mailbox_deleter.h index 9b6d771..add1549 100644 --- a/cc/resources/texture_mailbox_deleter.h +++ b/cc/resources/texture_mailbox_deleter.h @@ -32,10 +32,9 @@ class CC_EXPORT TextureMailboxDeleter { private: // Runs the |impl_callback| to delete the texture and removes the callback // from the |impl_callbacks_| list. - void RunDeleteTextureOnImplThread( - SingleReleaseCallback* impl_callback, - unsigned sync_point, - bool is_lost); + void RunDeleteTextureOnImplThread(SingleReleaseCallback* impl_callback, + uint32 sync_point, + bool is_lost); ScopedPtrVector<SingleReleaseCallback> impl_callbacks_; base::WeakPtrFactory<TextureMailboxDeleter> weak_ptr_factory_; diff --git a/cc/resources/transferable_resource.cc b/cc/resources/transferable_resource.cc index 62f1bdb..e7e9e24 100644 --- a/cc/resources/transferable_resource.cc +++ b/cc/resources/transferable_resource.cc @@ -10,9 +10,7 @@ namespace cc { TransferableResource::TransferableResource() : id(0), - sync_point(0), format(RGBA_8888), - target(0), filter(0), is_software(false) {} @@ -22,7 +20,7 @@ TransferableResource::~TransferableResource() { ReturnedResource TransferableResource::ToReturnedResource() const { ReturnedResource returned; returned.id = id; - returned.sync_point = sync_point; + returned.sync_point = mailbox_holder.sync_point; returned.count = 1; return returned; } diff --git a/cc/resources/transferable_resource.h b/cc/resources/transferable_resource.h index 5c93d1c..8ca9ffa 100644 --- a/cc/resources/transferable_resource.h +++ b/cc/resources/transferable_resource.h @@ -10,7 +10,7 @@ #include "base/basictypes.h" #include "cc/base/cc_export.h" #include "cc/resources/resource_format.h" -#include "gpu/command_buffer/common/mailbox.h" +#include "gpu/command_buffer/common/mailbox_holder.h" #include "ui/gfx/size.h" namespace cc { @@ -29,12 +29,10 @@ struct CC_EXPORT TransferableResource { ReturnedResourceArray* output); unsigned id; - unsigned sync_point; ResourceFormat format; - uint32 target; uint32 filter; gfx::Size size; - gpu::Mailbox mailbox; + gpu::MailboxHolder mailbox_holder; bool is_software; }; diff --git a/cc/resources/video_resource_updater.cc b/cc/resources/video_resource_updater.cc index 54e4a5c..bd91417 100644 --- a/cc/resources/video_resource_updater.cc +++ b/cc/resources/video_resource_updater.cc @@ -306,7 +306,7 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes( }; external_resources.mailboxes.push_back( - TextureMailbox(plane_resources[i].mailbox)); + TextureMailbox(plane_resources[i].mailbox, GL_TEXTURE_2D, 0)); external_resources.release_callbacks.push_back( base::Bind(&RecycleResource, AsWeakPtr(), recycle_data)); } @@ -316,9 +316,9 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes( } static void ReturnTexture(const scoped_refptr<media::VideoFrame>& frame, - unsigned sync_point, + uint32 sync_point, bool lost_resource) { - frame->texture_mailbox()->Resync(sync_point); + frame->mailbox_holder()->sync_point = sync_point; } VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( @@ -332,8 +332,9 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( if (!context_provider_) return VideoFrameExternalResources(); + gpu::MailboxHolder* mailbox_holder = video_frame->mailbox_holder(); VideoFrameExternalResources external_resources; - switch (video_frame->texture_target()) { + switch (mailbox_holder->texture_target) { case GL_TEXTURE_2D: external_resources.type = VideoFrameExternalResources::RGB_RESOURCE; break; @@ -349,13 +350,10 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( return VideoFrameExternalResources(); } - media::VideoFrame::MailboxHolder* mailbox_holder = - video_frame->texture_mailbox(); - external_resources.mailboxes.push_back( - TextureMailbox(mailbox_holder->mailbox(), - video_frame->texture_target(), - mailbox_holder->sync_point())); + TextureMailbox(mailbox_holder->mailbox, + mailbox_holder->texture_target, + mailbox_holder->sync_point)); external_resources.release_callbacks.push_back( base::Bind(&ReturnTexture, video_frame)); return external_resources; @@ -365,7 +363,7 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( void VideoResourceUpdater::RecycleResource( base::WeakPtr<VideoResourceUpdater> updater, RecycleResourceData data, - unsigned sync_point, + uint32 sync_point, bool lost_resource) { if (!updater.get()) { // Resource was already deleted. diff --git a/cc/resources/video_resource_updater.h b/cc/resources/video_resource_updater.h index afc3b88..eaaa8c1 100644 --- a/cc/resources/video_resource_updater.h +++ b/cc/resources/video_resource_updater.h @@ -104,7 +104,7 @@ class CC_EXPORT VideoResourceUpdater }; static void RecycleResource(base::WeakPtr<VideoResourceUpdater> updater, RecycleResourceData data, - unsigned sync_point, + uint32 sync_point, bool lost_resource); ContextProvider* context_provider_; diff --git a/cc/test/fake_delegated_renderer_layer_impl.cc b/cc/test/fake_delegated_renderer_layer_impl.cc index 4057736..8f4c104 100644 --- a/cc/test/fake_delegated_renderer_layer_impl.cc +++ b/cc/test/fake_delegated_renderer_layer_impl.cc @@ -30,7 +30,8 @@ static ResourceProvider::ResourceId AddResourceToFrame( ResourceProvider::ResourceId resource_id) { TransferableResource resource; resource.id = resource_id; - resource.target = resource_provider->TargetForTesting(resource_id); + resource.mailbox_holder.texture_target = + resource_provider->TargetForTesting(resource_id); frame->resource_list.push_back(resource); return resource_id; } diff --git a/cc/test/layer_tree_pixel_test.cc b/cc/test/layer_tree_pixel_test.cc index 2792f66..7ae11c3 100644 --- a/cc/test/layer_tree_pixel_test.cc +++ b/cc/test/layer_tree_pixel_test.cc @@ -244,7 +244,7 @@ scoped_ptr<SkBitmap> LayerTreePixelTest::CopyTextureMailboxToBitmap( gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - gl->ConsumeTextureCHROMIUM(texture_mailbox.target(), texture_mailbox.data()); + gl->ConsumeTextureCHROMIUM(texture_mailbox.target(), texture_mailbox.name()); gl->BindTexture(GL_TEXTURE_2D, 0); GLuint fbo = 0; @@ -364,7 +364,7 @@ void LayerTreePixelTest::CopyBitmapToTextureMailboxAsTexture( gl->BindTexture(GL_TEXTURE_2D, 0); uint32 sync_point = gl->InsertSyncPointCHROMIUM(); - *texture_mailbox = TextureMailbox(mailbox, sync_point); + *texture_mailbox = TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point); *release_callback = SingleReleaseCallback::Create( base::Bind(&LayerTreePixelTest::ReleaseTextureMailbox, base::Unretained(this), diff --git a/cc/trees/layer_tree_host_perftest.cc b/cc/trees/layer_tree_host_perftest.cc index 16b801d..7ca0f51 100644 --- a/cc/trees/layer_tree_host_perftest.cc +++ b/cc/trees/layer_tree_host_perftest.cc @@ -246,7 +246,7 @@ TEST_F(ScrollingLayerTreePerfTest, LongScrollablePageThreadedImplSide) { RunTestWithImplSidePainting(); } -static void EmptyReleaseCallback(unsigned sync_point, bool lost_resource) {} +static void EmptyReleaseCallback(uint32 sync_point, bool lost_resource) {} // Simulates main-thread scrolling on each frame. class BrowserCompositorInvalidateLayerTreePerfTest @@ -274,7 +274,7 @@ class BrowserCompositorInvalidateLayerTreePerfTest reinterpret_cast<const int8*>(name_stream.str().c_str())); scoped_ptr<SingleReleaseCallback> callback = SingleReleaseCallback::Create( base::Bind(&EmptyReleaseCallback)); - TextureMailbox mailbox(gpu_mailbox, next_sync_point_); + TextureMailbox mailbox(gpu_mailbox, GL_TEXTURE_2D, next_sync_point_); next_sync_point_++; tab_contents_->SetTextureMailbox(mailbox, callback.Pass()); diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc index 8db1faa2..34bc246 100644 --- a/cc/trees/layer_tree_host_unittest_context.cc +++ b/cc/trees/layer_tree_host_unittest_context.cc @@ -1004,7 +1004,7 @@ class LayerTreeHostContextTestDontUseLostResources texture->SetAnchorPoint(gfx::PointF()); texture->SetIsDrawable(true); texture->SetTextureMailbox( - TextureMailbox(mailbox, sync_point), + TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point), SingleReleaseCallback::Create( base::Bind(&LayerTreeHostContextTestDontUseLostResources:: EmptyReleaseCallback))); @@ -1045,30 +1045,24 @@ class LayerTreeHostContextTestDontUseLostResources color_video_frame_ = VideoFrame::CreateColorFrame( gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); - hw_video_frame_ = VideoFrame::WrapNativeTexture( - make_scoped_ptr(new VideoFrame::MailboxHolder( - mailbox, - sync_point, - VideoFrame::MailboxHolder::TextureNoLongerNeededCallback())), - GL_TEXTURE_2D, - gfx::Size(4, 4), - gfx::Rect(0, 0, 4, 4), - gfx::Size(4, 4), - base::TimeDelta(), - VideoFrame::ReadPixelsCB(), - base::Closure()); - scaled_hw_video_frame_ = VideoFrame::WrapNativeTexture( - make_scoped_ptr(new VideoFrame::MailboxHolder( - mailbox, - sync_point, - VideoFrame::MailboxHolder::TextureNoLongerNeededCallback())), - GL_TEXTURE_2D, - gfx::Size(4, 4), - gfx::Rect(0, 0, 3, 2), - gfx::Size(4, 4), - base::TimeDelta(), - VideoFrame::ReadPixelsCB(), - base::Closure()); + hw_video_frame_ = + VideoFrame::WrapNativeTexture(make_scoped_ptr(new gpu::MailboxHolder( + mailbox, GL_TEXTURE_2D, sync_point)), + media::VideoFrame::ReleaseMailboxCB(), + gfx::Size(4, 4), + gfx::Rect(0, 0, 4, 4), + gfx::Size(4, 4), + base::TimeDelta(), + VideoFrame::ReadPixelsCB()); + scaled_hw_video_frame_ = + VideoFrame::WrapNativeTexture(make_scoped_ptr(new gpu::MailboxHolder( + mailbox, GL_TEXTURE_2D, sync_point)), + media::VideoFrame::ReleaseMailboxCB(), + gfx::Size(4, 4), + gfx::Rect(0, 0, 3, 2), + gfx::Size(4, 4), + base::TimeDelta(), + VideoFrame::ReadPixelsCB()); color_frame_provider_.set_frame(color_video_frame_); hw_frame_provider_.set_frame(hw_video_frame_); diff --git a/cc/trees/layer_tree_host_unittest_copyrequest.cc b/cc/trees/layer_tree_host_unittest_copyrequest.cc index 2156c64..23d3347 100644 --- a/cc/trees/layer_tree_host_unittest_copyrequest.cc +++ b/cc/trees/layer_tree_host_unittest_copyrequest.cc @@ -807,7 +807,8 @@ class LayerTreeHostCopyRequestTestProvideTexture gpu::Mailbox mailbox; gl->GenMailboxCHROMIUM(mailbox.name); sync_point_ = gl->InsertSyncPointCHROMIUM(); - request->SetTextureMailbox(TextureMailbox(mailbox, sync_point_)); + request->SetTextureMailbox( + TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point_)); EXPECT_TRUE(request->has_texture_mailbox()); copy_layer_->RequestCopyOfOutput(request.Pass()); diff --git a/cc/trees/layer_tree_host_unittest_delegated.cc b/cc/trees/layer_tree_host_unittest_delegated.cc index 7c42b80..a820606 100644 --- a/cc/trees/layer_tree_host_unittest_delegated.cc +++ b/cc/trees/layer_tree_host_unittest_delegated.cc @@ -135,14 +135,14 @@ class LayerTreeHostDelegatedTest : public LayerTreeTest { ResourceProvider::ResourceId resource_id) { TransferableResource resource; resource.id = resource_id; - resource.target = GL_TEXTURE_2D; + resource.mailbox_holder.texture_target = GL_TEXTURE_2D; GLbyte arbitrary_mailbox[64] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4 }; - resource.mailbox.SetName(arbitrary_mailbox); + resource.mailbox_holder.mailbox.SetName(arbitrary_mailbox); frame->resource_list.push_back(resource); } |