| 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..86eb536a9eaa8d8bd226f37a4eff23344f32baec 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,8 +127,35 @@ bool g_is_skia_version_compatible = false;
|
|
|
| const int64 kFallbackTickTimeoutInMilliseconds = 500;
|
|
|
| +LazyInstance<ThreadLocalBoolean>::Leaky tls_gl_allowed =
|
| + LAZY_INSTANCE_INITIALIZER;
|
| +
|
| +class ScopedAllowGL {
|
| + public:
|
| + ScopedAllowGL();
|
| + ~ScopedAllowGL();
|
| +};
|
| +
|
| +ScopedAllowGL::ScopedAllowGL() {
|
| + DCHECK(!tls_gl_allowed.Get().Get());
|
| + tls_gl_allowed.Get().Set(true);
|
| +}
|
| +
|
| +ScopedAllowGL::~ScopedAllowGL() {
|
| + tls_gl_allowed.Get().Set(false);
|
| +}
|
| +
|
| } // namespace
|
|
|
| +// Called from different threads!
|
| +static void ScheduleGpuWork() {
|
| + if (tls_gl_allowed.Get().Get()) {
|
| + gpu::InProcessCommandBuffer::ProcessGpuWorkOnCurrentThread();
|
| + } else {
|
| + // TODO: We need to request a callback with a GL context current here.
|
| + }
|
| +}
|
| +
|
| // static
|
| void BrowserViewRenderer::SetAwDrawSWFunctionTable(
|
| AwDrawSWFunctionTable* table) {
|
| @@ -227,6 +257,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 +489,8 @@ void InProcessViewRenderer::OnDetachedFromWindow() {
|
|
|
| ScopedAppGLStateRestore state_restore(
|
| ScopedAppGLStateRestore::MODE_DETACH_FROM_WINDOW);
|
| + gpu::InProcessCommandBuffer::ProcessGpuWorkOnCurrentThread();
|
| + ScopedAllowGL allow_gl;
|
| compositor_->ReleaseHwDraw();
|
| hardware_initialized_ = false;
|
| }
|
|
|