summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjbauman <jbauman@chromium.org>2015-05-28 15:49:19 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-28 22:49:47 +0000
commit63c0353edfa8cf894f10415928ad728e9cdb6669 (patch)
tree3024acfa2da9e75fbf6f9a5c938b6ab3bd657daf
parentaf43f9f780b5fcca30faef007745306827d69c23 (diff)
downloadchromium_src-63c0353edfa8cf894f10415928ad728e9cdb6669.zip
chromium_src-63c0353edfa8cf894f10415928ad728e9cdb6669.tar.gz
chromium_src-63c0353edfa8cf894f10415928ad728e9cdb6669.tar.bz2
Allow creation of TextureMailboxDeleter without a task runner.
In this case, the deletion will happen on the current thread. This is necessary for android webview, because the Display lives on a thread without a task runner. CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1158563005 Cr-Commit-Position: refs/heads/master@{#331870}
-rw-r--r--cc/output/texture_mailbox_deleter.cc10
-rw-r--r--cc/output/texture_mailbox_deleter.h2
-rw-r--r--cc/output/texture_mailbox_deleter_unittest.cc26
-rw-r--r--cc/surfaces/display.cc3
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);
}