| 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 1becdf1d5a885a2b4830b64ae44b5b70bd96d163..70c2532ca0df2beeebab53cb0542020f4ffa42c3 100644
|
| --- a/android_webview/browser/in_process_view_renderer.cc
|
| +++ b/android_webview/browser/in_process_view_renderer.cc
|
| @@ -22,7 +22,6 @@
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/web_contents.h"
|
| #include "content/public/common/content_switches.h"
|
| -#include "gpu/command_buffer/service/in_process_command_buffer.h"
|
| #include "third_party/skia/include/core/SkBitmap.h"
|
| #include "third_party/skia/include/core/SkBitmapDevice.h"
|
| #include "third_party/skia/include/core/SkCanvas.h"
|
| @@ -192,21 +191,58 @@ void RequestProcessGLOnUIThread() {
|
|
|
| } // namespace
|
|
|
| +DeferredGpuCommandService::DeferredGpuCommandService() {}
|
| +
|
| +DeferredGpuCommandService::~DeferredGpuCommandService() {
|
| + base::AutoLock lock(tasks_lock_);
|
| + DCHECK(tasks_.empty());
|
| +}
|
| +
|
| // Called from different threads!
|
| -static void ScheduleGpuWork() {
|
| +void DeferredGpuCommandService::ScheduleTask(const base::Closure& task) {
|
| + {
|
| + base::AutoLock lock(tasks_lock_);
|
| + tasks_.push(task);
|
| + }
|
| if (ScopedAllowGL::IsAllowed()) {
|
| - gpu::InProcessCommandBuffer::ProcessGpuWorkOnCurrentThread();
|
| + RunTasks();
|
| } else {
|
| RequestProcessGLOnUIThread();
|
| }
|
| }
|
|
|
| +void DeferredGpuCommandService::ScheduleIdleWork(
|
| + const base::Closure& callback) {
|
| + // TODO(sievers): Should this do anything?
|
| +}
|
| +
|
| +void DeferredGpuCommandService::RunTasks() {
|
| + bool has_more_tasks;
|
| + {
|
| + base::AutoLock lock(tasks_lock_);
|
| + has_more_tasks = tasks_.size() > 0;
|
| + }
|
| +
|
| + while (has_more_tasks) {
|
| + base::Closure task;
|
| + {
|
| + base::AutoLock lock(tasks_lock_);
|
| + task = tasks_.front();
|
| + tasks_.pop();
|
| + }
|
| + task.Run();
|
| + {
|
| + base::AutoLock lock(tasks_lock_);
|
| + has_more_tasks = tasks_.size() > 0;
|
| + }
|
| +
|
| + }
|
| +}
|
| +
|
| // static
|
| void BrowserViewRenderer::SetAwDrawSWFunctionTable(
|
| AwDrawSWFunctionTable* table) {
|
| g_sw_draw_functions = table;
|
| - gpu::InProcessCommandBuffer::SetScheduleCallback(
|
| - base::Bind(&ScheduleGpuWork));
|
| }
|
|
|
| // static
|
| @@ -351,7 +387,7 @@ void InProcessViewRenderer::TrimMemory(int level) {
|
| TRACE_EVENT0("android_webview", "InProcessViewRenderer::TrimMemory");
|
| ScopedAppGLStateRestore state_restore(
|
| ScopedAppGLStateRestore::MODE_RESOURCE_MANAGEMENT);
|
| - gpu::InProcessCommandBuffer::ProcessGpuWorkOnCurrentThread();
|
| + gl_queue_->RunTasks();
|
| ScopedAllowGL allow_gl;
|
|
|
| SetMemoryPolicy(policy);
|
| @@ -392,11 +428,14 @@ bool InProcessViewRenderer::InitializeHwDraw() {
|
| TRACE_EVENT0("android_webview", "InitializeHwDraw");
|
| DCHECK(!gl_surface_);
|
| gl_surface_ = new AwGLSurface;
|
| - hardware_failed_ = !compositor_->InitializeHwDraw(gl_surface_);
|
| + gl_queue_ = new DeferredGpuCommandService;
|
| + hardware_failed_ = !compositor_->InitializeHwDraw(gl_surface_, gl_queue_);
|
| hardware_initialized_ = true;
|
|
|
| - if (hardware_failed_)
|
| + if (hardware_failed_) {
|
| gl_surface_ = NULL;
|
| + gl_queue_ = NULL;
|
| + }
|
|
|
| return !hardware_failed_;
|
| }
|
| @@ -416,7 +455,8 @@ void InProcessViewRenderer::DrawGL(AwDrawGLInfo* draw_info) {
|
| }
|
|
|
| ScopedAppGLStateRestore state_restore(ScopedAppGLStateRestore::MODE_DRAW);
|
| - gpu::InProcessCommandBuffer::ProcessGpuWorkOnCurrentThread();
|
| + if (gl_queue_)
|
| + gl_queue_->RunTasks();
|
| ScopedAllowGL allow_gl;
|
|
|
| if (!attached_to_window_) {
|
| @@ -705,13 +745,14 @@ void InProcessViewRenderer::OnDetachedFromWindow() {
|
|
|
| ScopedAppGLStateRestore state_restore(
|
| ScopedAppGLStateRestore::MODE_RESOURCE_MANAGEMENT);
|
| - gpu::InProcessCommandBuffer::ProcessGpuWorkOnCurrentThread();
|
| + gl_queue_->RunTasks();
|
| ScopedAllowGL allow_gl;
|
| compositor_->ReleaseHwDraw();
|
| hardware_initialized_ = false;
|
| }
|
|
|
| gl_surface_ = NULL;
|
| + gl_queue_ = NULL;
|
| attached_to_window_ = false;
|
| }
|
|
|
|
|