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

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 fcd470dfc7f9335d22b5985fc93f72aeac128997..2b21284ffc713175fdfa2b099131adc8a01db000 100644
--- a/android_webview/browser/in_process_view_renderer.cc
+++ b/android_webview/browser/in_process_view_renderer.cc
@@ -16,7 +16,9 @@
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "content/public/browser/android/synchronous_compositor.h"
+#include "content/public/browser/browser_thread.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"
@@ -31,6 +33,7 @@
using base::android::AttachCurrentThread;
using base::android::JavaRef;
using base::android::ScopedJavaLocalRef;
+using content::BrowserThread;
namespace android_webview {
@@ -125,8 +128,44 @@ bool g_is_skia_version_compatible = false;
const int64 kFallbackTickTimeoutInMilliseconds = 500;
+class ScopedAllowGL {
+ public:
+ ScopedAllowGL();
+ ~ScopedAllowGL();
+
+ static bool IsAllowed() {
+ return BrowserThread::CurrentlyOn(BrowserThread::UI) && allow_gl;
+ }
+
+ private:
+ static bool allow_gl;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedAllowGL);
+};
+
+ScopedAllowGL::ScopedAllowGL() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!allow_gl);
+ allow_gl = true;
+}
+
+ScopedAllowGL::~ScopedAllowGL() {
+ allow_gl = false;
+}
+
+bool ScopedAllowGL::allow_gl = false;
+
} // namespace
+// Called from different threads!
+static void ScheduleGpuWork() {
+ if (ScopedAllowGL::IsAllowed()) {
+ gpu::InProcessCommandBuffer::ProcessGpuWorkOnCurrentThread();
+ } else {
+ // TODO: We need to request a callback with a GL context current here.
+ }
+}
+
// static
void BrowserViewRenderer::SetAwDrawSWFunctionTable(
AwDrawSWFunctionTable* table) {
@@ -135,6 +174,9 @@ 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.";
+
+ gpu::InProcessCommandBuffer::SetScheduleCallback(
+ base::Bind(&ScheduleGpuWork));
}
// static
@@ -229,6 +271,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");
@@ -461,6 +505,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