Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2477)

Unified Diff: android_webview/browser/deferred_gpu_command_service.cc

Issue 431383003: aw: Track UI request GL separately from other threads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | android_webview/browser/shared_renderer_state.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/browser/deferred_gpu_command_service.cc
diff --git a/android_webview/browser/deferred_gpu_command_service.cc b/android_webview/browser/deferred_gpu_command_service.cc
index 8a137a8e7883f0ee76c8b59fa1e01e51fdf0a211..cb13cd77b1c7809ff75b3b94be740ea55ad477ac 100644
--- a/android_webview/browser/deferred_gpu_command_service.cc
+++ b/android_webview/browser/deferred_gpu_command_service.cc
@@ -20,6 +20,7 @@ class ThreadSafeBool {
ThreadSafeBool();
void Set(bool boolean);
bool Get();
+ bool GetAndSet();
private:
base::Lock lock_;
@@ -35,6 +36,13 @@ void ThreadSafeBool::Set(bool boolean) {
boolean_ = boolean;
}
+bool ThreadSafeBool::GetAndSet() {
+ base::AutoLock lock(lock_);
+ bool rv = boolean_;
+ boolean_ = true;
+ return rv;
+}
+
bool ThreadSafeBool::Get() {
base::AutoLock lock(lock_);
return boolean_;
@@ -43,6 +51,11 @@ bool ThreadSafeBool::Get() {
base::LazyInstance<ThreadSafeBool> g_request_pending =
LAZY_INSTANCE_INITIALIZER;
+// Because request is posted to UI thread, have to treat requests on UI thread
+// specifically because UI can immediately block waiting for the request.
+base::LazyInstance<ThreadSafeBool> g_request_pending_on_ui =
+ LAZY_INSTANCE_INITIALIZER;
+
base::LazyInstance<scoped_refptr<DeferredGpuCommandService> >
g_service = LAZY_INSTANCE_INITIALIZER;
} // namespace
@@ -65,6 +78,7 @@ ScopedAllowGL::ScopedAllowGL() {
ScopedAllowGL::~ScopedAllowGL() {
allow_gl.Get().Set(false);
g_request_pending.Get().Set(false);
+ g_request_pending_on_ui.Get().Set(false);
DeferredGpuCommandService* service = g_service.Get();
if (service) {
@@ -83,6 +97,7 @@ void DeferredGpuCommandService::SetInstance() {
// Initialize global booleans.
g_request_pending.Get().Set(false);
+ g_request_pending_on_ui.Get().Set(false);
}
}
@@ -109,8 +124,13 @@ void DeferredGpuCommandService::RequestProcessGL() {
return;
}
- if (!g_request_pending.Get().Get()) {
- g_request_pending.Get().Set(true);
+ bool on_ui_thread = renderer_state->CurrentlyOnUIThread();
hush (inactive) 2014/08/05 23:04:39 on_ui_thread only means render state was running o
boliu 2014/08/05 23:07:55 That's how things work today, before or after this
+ bool need_request = on_ui_thread ? !g_request_pending_on_ui.Get().GetAndSet()
+ : !g_request_pending.Get().GetAndSet();
+ if (need_request) {
+ if (on_ui_thread) {
+ g_request_pending.Get().Set(true);
+ }
hush (inactive) 2014/08/05 23:04:39 if g_request_pending_on_ui is true, g_request_pend
boliu 2014/08/05 23:07:55 Yep, that's what I wanted to do here.
hush (inactive) 2014/08/05 23:55:15 yes. if on_ui_thread is false, you will set g_requ
boliu 2014/08/06 00:05:46 Done.
renderer_state->ClientRequestDrawGL();
}
}
« no previous file with comments | « no previous file | android_webview/browser/shared_renderer_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698