summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorpeter@chromium.org <peter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-21 17:08:34 +0000
committerpeter@chromium.org <peter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-21 17:08:34 +0000
commitabeda1fe53a5f2763cc17d45d53316b5ee27b510 (patch)
treea5417cec20467a3ead3133c6268cf1c27ae48444 /ui
parentb9eafce1fe478fdb1a7406f99b7daa7ff2d38287 (diff)
downloadchromium_src-abeda1fe53a5f2763cc17d45d53316b5ee27b510.zip
chromium_src-abeda1fe53a5f2763cc17d45d53316b5ee27b510.tar.gz
chromium_src-abeda1fe53a5f2763cc17d45d53316b5ee27b510.tar.bz2
Make it possible to use OSMesa on Android
This patch will start compiling OSMesa as a dependency of the content_shell_apk target, and changes the GL implementation for Android to recognize OSMesa as a valid implementation. libosmesa.so will be separately included in ContentShell.apk, and will be lazily loaded depending on whether OSMesa will be used or not. When running a set of 54 layout tests on a Nexus 4, total time is [69, 68, 68] ~68 seconds with this patch, [62, 60, 61] ~61 seconds without this patch. Compensated for the setup time (13 seconds), this means pixel tests are on average 14 percent slower. I believe the win of (a) consistency with Chrome, (b) more reliable results and (c) less cross-device differences warrants this, however. Switching to OSMesa does also enable us to reliably enable impl-side painting without getting garbage rendering on higher-end devices. At time time it's not yet enabled by default however, as it makes content_shell time out when ran on the Nexus 7. BUG=232044, 248925, 250777 Review URL: https://codereview.chromium.org/23868030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252583 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/gl/gl.gyp9
-rw-r--r--ui/gl/gl_context_android.cc23
-rw-r--r--ui/gl/gl_implementation_android.cc25
-rw-r--r--ui/gl/gl_implementation_osmesa.cc (renamed from ui/gl/gl_implementation_linux.cc)4
-rw-r--r--ui/gl/gl_implementation_osmesa.h (renamed from ui/gl/gl_implementation_linux.h)7
-rw-r--r--ui/gl/gl_implementation_ozone.cc2
-rw-r--r--ui/gl/gl_implementation_x11.cc2
7 files changed, 43 insertions, 29 deletions
diff --git a/ui/gl/gl.gyp b/ui/gl/gl.gyp
index 702f4cc..527c5c4 100644
--- a/ui/gl/gl.gyp
+++ b/ui/gl/gl.gyp
@@ -84,8 +84,6 @@
'gl_implementation.cc',
'gl_implementation.h',
'gl_implementation_android.cc',
- 'gl_implementation_linux.cc',
- 'gl_implementation_linux.h',
'gl_implementation_ozone.cc',
'gl_implementation_mac.cc',
'gl_implementation_win.cc',
@@ -187,6 +185,12 @@
'<(DEPTH)/third_party/khronos',
],
}],
+ ['OS in ("android", "linux")', {
+ 'sources': [
+ 'gl_implementation_osmesa.cc',
+ 'gl_implementation_osmesa.h',
+ ],
+ }],
['use_x11 == 1', {
'sources': [
'gl_context_glx.cc',
@@ -277,7 +281,6 @@
],
},
'sources!': [
- 'gl_context_osmesa.cc',
'system_monitor_posix.cc',
],
'defines': [
diff --git a/ui/gl/gl_context_android.cc b/ui/gl/gl_context_android.cc
index f4555a2..2b91892 100644
--- a/ui/gl/gl_context_android.cc
+++ b/ui/gl/gl_context_android.cc
@@ -10,6 +10,7 @@
#include "base/sys_info.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context_egl.h"
+#include "ui/gl/gl_context_osmesa.h"
#include "ui/gl/gl_context_stub.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h"
@@ -75,16 +76,24 @@ scoped_refptr<GLContext> GLContext::CreateGLContext(
GLShareGroup* share_group,
GLSurface* compatible_surface,
GpuPreference gpu_preference) {
- if (GetGLImplementation() == kGLImplementationMockGL)
- return scoped_refptr<GLContext>(new GLContextStub());
-
scoped_refptr<GLContext> context;
- if (compatible_surface->GetHandle())
- context = new GLContextEGL(share_group);
- else
- context = new GLNonOwnedContext(share_group);
+ switch (GetGLImplementation()) {
+ case kGLImplementationMockGL:
+ return scoped_refptr<GLContext>(new GLContextStub());
+ case kGLImplementationOSMesaGL:
+ context = new GLContextOSMesa(share_group);
+ break;
+ default:
+ if (compatible_surface->GetHandle())
+ context = new GLContextEGL(share_group);
+ else
+ context = new GLNonOwnedContext(share_group);
+ break;
+ }
+
if (!context->Initialize(compatible_surface, gpu_preference))
return NULL;
+
return context;
}
diff --git a/ui/gl/gl_implementation_android.cc b/ui/gl/gl_implementation_android.cc
index 22d5ec6..3fae1ee 100644
--- a/ui/gl/gl_implementation_android.cc
+++ b/ui/gl/gl_implementation_android.cc
@@ -13,6 +13,7 @@
#include "ui/gl/gl_egl_api_implementation.h"
#include "ui/gl/gl_gl_api_implementation.h"
#include "ui/gl/gl_implementation.h"
+#include "ui/gl/gl_implementation_osmesa.h"
#include "ui/gl/gl_osmesa_api_implementation.h"
namespace gfx {
@@ -28,24 +29,11 @@ void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near,
glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far));
}
-base::NativeLibrary LoadLibrary(const base::FilePath& filename) {
- std::string error;
- base::NativeLibrary library = base::LoadNativeLibrary(filename, &error);
- if (!library) {
- DVLOG(1) << "Failed to load " << filename.MaybeAsASCII() << ": " << error;
- return NULL;
- }
- return library;
-}
-
-base::NativeLibrary LoadLibrary(const char* filename) {
- return LoadLibrary(base::FilePath(filename));
-}
-
} // namespace
void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) {
impls->push_back(kGLImplementationEGLGLES2);
+ impls->push_back(kGLImplementationOSMesaGL);
}
bool InitializeStaticGLBindings(GLImplementation implementation) {
@@ -93,6 +81,9 @@ bool InitializeStaticGLBindings(GLImplementation implementation) {
::gfx::g_driver_gl.fn.glDepthRangeFn = MarshalDepthRangeToDepthRangef;
break;
}
+ case kGLImplementationOSMesaGL:
+ InitializeStaticGLBindingsOSMesaGL();
+ break;
case kGLImplementationMockGL: {
SetGLImplementation(kGLImplementationMockGL);
InitializeStaticGLBindingsGL();
@@ -113,6 +104,10 @@ bool InitializeDynamicGLBindings(GLImplementation implementation,
InitializeDynamicGLBindingsGL(context);
InitializeDynamicGLBindingsEGL(context);
break;
+ case kGLImplementationOSMesaGL:
+ InitializeDynamicGLBindingsGL(context);
+ InitializeDynamicGLBindingsOSMESA(context);
+ break;
case kGLImplementationMockGL:
if (!context) {
scoped_refptr<GLContextStubWithExtensions> mock_context(
@@ -133,11 +128,13 @@ bool InitializeDynamicGLBindings(GLImplementation implementation,
void InitializeDebugGLBindings() {
InitializeDebugGLBindingsEGL();
InitializeDebugGLBindingsGL();
+ InitializeDebugGLBindingsOSMESA();
}
void ClearGLBindings() {
ClearGLBindingsEGL();
ClearGLBindingsGL();
+ ClearGLBindingsOSMESA();
SetGLImplementation(kGLImplementationNone);
UnloadGLNativeLibraries();
diff --git a/ui/gl/gl_implementation_linux.cc b/ui/gl/gl_implementation_osmesa.cc
index 0968dfe..79d506f 100644
--- a/ui/gl/gl_implementation_linux.cc
+++ b/ui/gl/gl_implementation_osmesa.cc
@@ -1,8 +1,8 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/gl/gl_implementation_linux.h"
+#include "ui/gl/gl_implementation_osmesa.h"
#include "base/files/file_path.h"
#include "base/logging.h"
diff --git a/ui/gl/gl_implementation_linux.h b/ui/gl/gl_implementation_osmesa.h
index 1c32d4c..16180b7 100644
--- a/ui/gl/gl_implementation_linux.h
+++ b/ui/gl/gl_implementation_osmesa.h
@@ -1,7 +1,10 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef UI_GL_GL_IMPLEMENTATION_OSMESA_
+#define UI_GL_GL_IMPLEMENTATION_OSMESA_
+
#include "base/files/file_path.h"
#include "base/native_library.h"
@@ -12,3 +15,5 @@ base::NativeLibrary LoadLibrary(const char* filename);
base::NativeLibrary LoadLibrary(const base::FilePath& filename);
} // namespace gfx
+
+#endif // UI_GL_GL_IMPLEMENTATION_OSMESA_ \ No newline at end of file
diff --git a/ui/gl/gl_implementation_ozone.cc b/ui/gl/gl_implementation_ozone.cc
index b8dd2c4..cb08036 100644
--- a/ui/gl/gl_implementation_ozone.cc
+++ b/ui/gl/gl_implementation_ozone.cc
@@ -9,7 +9,7 @@
#include "ui/gl/gl_egl_api_implementation.h"
#include "ui/gl/gl_gl_api_implementation.h"
#include "ui/gl/gl_implementation.h"
-#include "ui/gl/gl_implementation_linux.h"
+#include "ui/gl/gl_implementation_osmesa.h"
#include "ui/gl/gl_osmesa_api_implementation.h"
#include "ui/ozone/ozone_platform.h"
diff --git a/ui/gl/gl_implementation_x11.cc b/ui/gl/gl_implementation_x11.cc
index c19b39e..e70dbde 100644
--- a/ui/gl/gl_implementation_x11.cc
+++ b/ui/gl/gl_implementation_x11.cc
@@ -13,7 +13,7 @@
#include "ui/gl/gl_gl_api_implementation.h"
#include "ui/gl/gl_glx_api_implementation.h"
#include "ui/gl/gl_implementation.h"
-#include "ui/gl/gl_implementation_linux.h"
+#include "ui/gl/gl_implementation_osmesa.h"
#include "ui/gl/gl_osmesa_api_implementation.h"
#include "ui/gl/gl_switches.h"