diff options
Diffstat (limited to 'cc')
-rw-r--r-- | cc/output/texture_mailbox_deleter.cc | 10 | ||||
-rw-r--r-- | cc/output/texture_mailbox_deleter.h | 2 | ||||
-rw-r--r-- | cc/output/texture_mailbox_deleter_unittest.cc | 26 | ||||
-rw-r--r-- | cc/surfaces/display.cc | 3 |
4 files changed, 36 insertions, 5 deletions
diff --git a/cc/output/texture_mailbox_deleter.cc b/cc/output/texture_mailbox_deleter.cc index aaf2a0e..7729c4e 100644 --- a/cc/output/texture_mailbox_deleter.cc +++ b/cc/output/texture_mailbox_deleter.cc @@ -65,9 +65,13 @@ scoped_ptr<SingleReleaseCallback> TextureMailboxDeleter::GetReleaseCallback( // Provide a callback for the main thread that posts back to the impl // thread. - scoped_ptr<SingleReleaseCallback> main_callback = - SingleReleaseCallback::Create(base::Bind( - &PostTaskFromMainToImplThread, impl_task_runner_, run_impl_callback)); + scoped_ptr<SingleReleaseCallback> main_callback; + if (impl_task_runner_) { + main_callback = SingleReleaseCallback::Create(base::Bind( + &PostTaskFromMainToImplThread, impl_task_runner_, run_impl_callback)); + } else { + main_callback = SingleReleaseCallback::Create(run_impl_callback); + } return main_callback.Pass(); } diff --git a/cc/output/texture_mailbox_deleter.h b/cc/output/texture_mailbox_deleter.h index 2865126..19760ea 100644 --- a/cc/output/texture_mailbox_deleter.h +++ b/cc/output/texture_mailbox_deleter.h @@ -19,6 +19,8 @@ class SingleReleaseCallback; class CC_EXPORT TextureMailboxDeleter { public: + // task_runner corresponds with the thread the delete task should be posted + // to. If null, the delete will happen on the calling thread. explicit TextureMailboxDeleter( const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); ~TextureMailboxDeleter(); diff --git a/cc/output/texture_mailbox_deleter_unittest.cc b/cc/output/texture_mailbox_deleter_unittest.cc index 34d8595..37b9712 100644 --- a/cc/output/texture_mailbox_deleter_unittest.cc +++ b/cc/output/texture_mailbox_deleter_unittest.cc @@ -44,5 +44,31 @@ TEST(TextureMailboxDeleterTest, Destroy) { cb->Run(0, false); } +TEST(TextureMailboxDeleterTest, NullTaskRunner) { + scoped_ptr<TextureMailboxDeleter> deleter(new TextureMailboxDeleter(nullptr)); + + scoped_refptr<TestContextProvider> context_provider = + TestContextProvider::Create(); + context_provider->BindToCurrentThread(); + + GLuint texture_id = 0u; + context_provider->ContextGL()->GenTextures(1, &texture_id); + + EXPECT_TRUE(context_provider->HasOneRef()); + EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); + + scoped_ptr<SingleReleaseCallback> cb = + deleter->GetReleaseCallback(context_provider, texture_id); + EXPECT_FALSE(context_provider->HasOneRef()); + EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); + + cb->Run(0, false); + + // With no task runner the callback will immediately drops its ref on the + // ContextProvider and delete the texture. + EXPECT_TRUE(context_provider->HasOneRef()); + EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); +} + } // namespace } // namespace cc diff --git a/cc/surfaces/display.cc b/cc/surfaces/display.cc index ca35b67..fadb165 100644 --- a/cc/surfaces/display.cc +++ b/cc/surfaces/display.cc @@ -35,8 +35,7 @@ Display::Display(DisplayClient* client, device_scale_factor_(1.f), swapped_since_resize_(false), scheduler_(nullptr), - texture_mailbox_deleter_( - new TextureMailboxDeleter(base::ThreadTaskRunnerHandle::Get())) { + texture_mailbox_deleter_(new TextureMailboxDeleter(nullptr)) { manager_->AddObserver(this); } |