Skip to content

Commit

Permalink
gpu: Add extension check when initializing MailboxSync
Browse files Browse the repository at this point in the history
And do not enable accelerated canvas in webview if extensions are
missing.

BUG=332146

Review URL: https://codereview.chromium.org/196653019

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257295 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
boliu@chromium.org committed Mar 15, 2014
1 parent b7e33ee commit 2df8d41
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
8 changes: 8 additions & 0 deletions android_webview/browser/aw_browser_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
#include "android_webview/browser/aw_result_codes.h"
#include "base/android/build_info.h"
#include "base/android/memory_pressure_listener_android.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/result_codes.h"
#include "content/public/common/url_utils.h"
#include "gpu/command_buffer/service/mailbox_synchronizer.h"
#include "net/android/network_change_notifier_factory_android.h"
#include "net/base/network_change_notifier.h"
#include "ui/base/l10n/l10n_util_android.h"
Expand Down Expand Up @@ -59,6 +62,11 @@ int AwBrowserMainParts::PreCreateThreads() {
}

void AwBrowserMainParts::PreMainMessageLoopRun() {
if (!gpu::gles2::MailboxSynchronizer::Initialize()) {
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kDisableAccelerated2dCanvas);
}

browser_context_->PreMainMessageLoopRun();
// This is needed for WebView Classic backwards compatibility
// See crbug.com/298495
Expand Down
3 changes: 0 additions & 3 deletions android_webview/lib/main/aw_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#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 "gpu/command_buffer/service/mailbox_synchronizer.h"
#include "media/base/media_switches.h"
#include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"

Expand Down Expand Up @@ -67,8 +66,6 @@ bool AwMainDelegate::BasicStartupComplete(int* exit_code) {
cl->AppendSwitch(switches::kDisableExperimentalWebGL);
cl->AppendSwitch(switches::kDisableSharedWorkers);

if (!gpu::gles2::MailboxSynchronizer::Initialize())
cl->AppendSwitch(switches::kDisableAccelerated2dCanvas);

// File system API not supported (requires some new API; internal bug 6930981)
cl->AppendSwitch(switches::kDisableFileSystem);
Expand Down
24 changes: 24 additions & 0 deletions gpu/command_buffer/service/mailbox_synchronizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "base/bind.h"
#include "gpu/command_buffer/service/mailbox_manager.h"
#include "gpu/command_buffer/service/texture_manager.h"
#include "ui/gl/gl_implementation.h"

namespace gpu {
namespace gles2 {
Expand All @@ -20,6 +21,29 @@ MailboxSynchronizer* g_instance = NULL;
// static
bool MailboxSynchronizer::Initialize() {
DCHECK(!g_instance);
DCHECK(gfx::GetGLImplementation() != gfx::kGLImplementationNone)
<< "GL bindings not initialized";
switch (gfx::GetGLImplementation()) {
case gfx::kGLImplementationMockGL:
break;
case gfx::kGLImplementationEGLGLES2:
#if !defined(OS_MACOSX)
{
if (!gfx::g_driver_egl.ext.b_EGL_KHR_image_base ||
!gfx::g_driver_egl.ext.b_EGL_KHR_gl_texture_2D_image ||
!gfx::g_driver_gl.ext.b_GL_OES_EGL_image ||
!gfx::g_driver_egl.ext.b_EGL_KHR_fence_sync) {
LOG(WARNING) << "MailboxSync not supported due to missing EGL "
"image/fence support";
return false;
}
}
break;
#endif
default:
NOTREACHED();
return false;
}
g_instance = new MailboxSynchronizer;
return true;
}
Expand Down
9 changes: 4 additions & 5 deletions gpu/command_buffer/service/texture_definition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,10 @@ scoped_refptr<NativeImageBufferEGL> NativeImageBufferEGL::Create(
DCHECK_NE(EGL_NO_DISPLAY, egl_display);
DCHECK(glIsTexture(texture_id));

// TODO: Need to generate and check EGL_KHR_gl_texture_2D_image
if (!gfx::g_driver_egl.ext.b_EGL_KHR_image_base ||
!gfx::g_driver_gl.ext.b_GL_OES_EGL_image) {
return NULL;
}
DCHECK(gfx::g_driver_egl.ext.b_EGL_KHR_image_base &&
gfx::g_driver_egl.ext.b_EGL_KHR_gl_texture_2D_image &&
gfx::g_driver_gl.ext.b_GL_OES_EGL_image &&
gfx::g_driver_egl.ext.b_EGL_KHR_fence_sync);

const EGLint egl_attrib_list[] = {
EGL_GL_TEXTURE_LEVEL_KHR, 0, EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE};
Expand Down
3 changes: 2 additions & 1 deletion ui/gl/generate_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,8 @@
'EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value', },
{ 'return_type': 'EGLImageKHR',
'versions': [{ 'name': 'eglCreateImageKHR',
'extensions': ['EGL_KHR_image_base'] }],
'extensions':
['EGL_KHR_image_base', 'EGL_KHR_gl_texture_2D_image'] }],
'arguments':
'EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, '
'const EGLint* attrib_list' },
Expand Down

0 comments on commit 2df8d41

Please sign in to comment.