summaryrefslogtreecommitdiff
path: root/android_webview
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2013-08-01 12:44:22 +0100
committerBen Murdoch <benm@google.com>2013-08-01 13:12:08 +0100
commit28390f6bb8dc6eb59bac1e0576f95a7740a9bd61 (patch)
tree02dad0e26c6660746a487ef814fffb404e16c12a /android_webview
parent226ac25887216e7df5a5dbd091cae3894b3497d2 (diff)
downloadchromium_org-28390f6bb8dc6eb59bac1e0576f95a7740a9bd61.tar.gz
Cherry pick of https://codereview.chromium.org/19522006
Stability fixes for Chromium WebView. Bug:9915533 Change-Id: If5730b3f0c79b1ddd56bce3a2903531632ea0bc6
Diffstat (limited to 'android_webview')
-rw-r--r--android_webview/DEPS2
-rw-r--r--android_webview/android_webview.gyp1
-rw-r--r--android_webview/browser/in_process_view_renderer.cc46
-rw-r--r--android_webview/lib/main/aw_main_delegate.cc3
4 files changed, 50 insertions, 2 deletions
diff --git a/android_webview/DEPS b/android_webview/DEPS
index 5f848d2fc6..1ce4c334c0 100644
--- a/android_webview/DEPS
+++ b/android_webview/DEPS
@@ -8,7 +8,7 @@ include_rules = [
"-android_webview/lib",
"+content/public/common",
- "+gpu/command_buffer/client",
+ "+gpu",
"+jni",
"+net",
"+skia",
diff --git a/android_webview/android_webview.gyp b/android_webview/android_webview.gyp
index ddbd1b8b90..299dc12783 100644
--- a/android_webview/android_webview.gyp
+++ b/android_webview/android_webview.gyp
@@ -83,6 +83,7 @@
'../components/components.gyp:web_contents_delegate_android',
'../content/content.gyp:content',
'../skia/skia.gyp:skia',
+ '../gpu/gpu.gyp:command_buffer_service',
'../gpu/gpu.gyp:gles2_implementation',
'../ui/gl/gl.gyp:gl',
'../webkit/common/gpu/webkit_gpu.gyp:webkit_gpu',
diff --git a/android_webview/browser/in_process_view_renderer.cc b/android_webview/browser/in_process_view_renderer.cc
index f5e1762cef..d761124856 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");
@@ -462,6 +506,8 @@ void InProcessViewRenderer::OnDetachedFromWindow() {
ScopedAppGLStateRestore state_restore(
ScopedAppGLStateRestore::MODE_DETACH_FROM_WINDOW);
+ gpu::InProcessCommandBuffer::ProcessGpuWorkOnCurrentThread();
+ ScopedAllowGL allow_gl;
compositor_->ReleaseHwDraw();
hardware_initialized_ = false;
}
diff --git a/android_webview/lib/main/aw_main_delegate.cc b/android_webview/lib/main/aw_main_delegate.cc
index 4c94d1feaf..0e43adde6a 100644
--- a/android_webview/lib/main/aw_main_delegate.cc
+++ b/android_webview/lib/main/aw_main_delegate.cc
@@ -22,6 +22,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_switches.h"
#include "gpu/command_buffer/client/gl_in_process_context.h"
+#include "gpu/command_buffer/service/in_process_command_buffer.h"
#include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
namespace android_webview {
@@ -45,9 +46,9 @@ AwMainDelegate::~AwMainDelegate() {
bool AwMainDelegate::BasicStartupComplete(int* exit_code) {
content::SetContentClient(&content_client_);
- gpu::GLInProcessContext::EnableVirtualizedContext();
gpu::GLInProcessContext::SetGpuMemoryBufferFactory(
gpu_memory_buffer_factory_.get());
+ gpu::InProcessCommandBuffer::EnableVirtualizedContext();
CommandLine* cl = CommandLine::ForCurrentProcess();
cl->AppendSwitch(switches::kEnableBeginFrameScheduling);