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

Unified Diff: android_webview/browser/in_process_view_renderer.cc

Issue 19522006: GLInProcessContext: support async flushes and dedicated GPU thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
Index: android_webview/browser/in_process_view_renderer.cc
diff --git a/android_webview/browser/in_process_view_renderer.cc b/android_webview/browser/in_process_view_renderer.cc
index 2b60bea7e39de5275359f49ba18a9bf938b72066..67ff0a73519cadcfa9d570fffdf1ef714fc31746 100644
--- a/android_webview/browser/in_process_view_renderer.cc
+++ b/android_webview/browser/in_process_view_renderer.cc
@@ -12,10 +12,13 @@
#include "base/android/jni_android.h"
#include "base/command_line.h"
#include "base/debug/trace_event.h"
+#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
+#include "base/threading/thread_local.h"
#include "content/public/browser/android/synchronous_compositor.h"
#include "content/public/browser/web_contents.h"
+#include "gpu/command_buffer/service/in_process_command_buffer.h"
#include "skia/ext/refptr.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
@@ -124,6 +127,31 @@ bool g_is_skia_version_compatible = false;
const int64 kFallbackTickTimeoutInMilliseconds = 500;
+LazyInstance<ThreadLocalBoolean>::Leaky tls_gl_allowed =
+ LAZY_INSTANCE_INITIALIZER;
+
+// Called from different threads!
+static void ScheduleGpuWork() {
+ if (tls_gl_allowed.Get().Get())
+ gpu::InProcessCommandBuffer::ProcessGpuWorkOnCurrentThread();
piman 2013/07/23 01:57:14 Should this DCHECK if GL is allowed? I'm worried t
no sievers 2013/07/25 00:41:23 I put a TODO. I'll have to figure this out with Bo
+}
+
+class ScopedAllowGL {
+ public:
+ ScopedAllowGL();
+ ~ScopedAllowGL();
+
piman 2013/07/23 01:57:14 nit: no need for blank line.
no sievers 2013/07/25 00:41:23 Done.
+};
+
+ScopedAllowGL::ScopedAllowGL() {
+ DCHECK(!tls_gl_allowed.Get().Get());
+ tls_gl_allowed.Get().Set(true);
+}
+
+ScopedAllowGL::~ScopedAllowGL() {
+ tls_gl_allowed.Get().Set(false);
+}
+
} // namespace
// static
@@ -134,6 +162,10 @@ void BrowserViewRenderer::SetAwDrawSWFunctionTable(
g_sw_draw_functions->is_skia_version_compatible(&SkGraphics::GetVersion);
LOG_IF(WARNING, !g_is_skia_version_compatible)
<< "Skia versions are not compatible, rendering performance will suffer.";
+
+ // TODO: There is probably a better place to do this.
+ gpu::InProcessCommandBuffer::SetScheduleCallback(
+ base::Bind(&ScheduleGpuWork));
}
// static
@@ -227,6 +259,8 @@ void InProcessViewRenderer::DrawGL(AwDrawGLInfo* draw_info) {
}
ScopedAppGLStateRestore state_restore(ScopedAppGLStateRestore::MODE_DRAW);
+ gpu::InProcessCommandBuffer::ProcessGpuWorkOnCurrentThread();
+ ScopedAllowGL allow_gl;
if (attached_to_window_ && compositor_ && !hardware_initialized_) {
TRACE_EVENT0("android_webview", "InitializeHwDraw");
@@ -457,6 +491,8 @@ void InProcessViewRenderer::OnDetachedFromWindow() {
ScopedAppGLStateRestore state_restore(
ScopedAppGLStateRestore::MODE_DETACH_FROM_WINDOW);
+ gpu::InProcessCommandBuffer::ProcessGpuWorkOnCurrentThread();
+ ScopedAllowGL allow_gl;
compositor_->ReleaseHwDraw();
hardware_initialized_ = false;
}

Powered by Google App Engine
This is Rietveld 408576698