summaryrefslogtreecommitdiffstats
path: root/app/gfx/gl/gl_implementation.cc
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-14 19:46:12 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-14 19:46:12 +0000
commit83c86b6790ca8f58c910d7f68ae257a34b9a3206 (patch)
tree93aa93377154b10264cc3a0b06b56c49b33df0d6 /app/gfx/gl/gl_implementation.cc
parent2ec7913df091ef6894ff32a9d85fb9e693b6dec0 (diff)
downloadchromium_src-83c86b6790ca8f58c910d7f68ae257a34b9a3206.zip
chromium_src-83c86b6790ca8f58c910d7f68ae257a34b9a3206.tar.gz
chromium_src-83c86b6790ca8f58c910d7f68ae257a34b9a3206.tar.bz2
Use GL rather than EGL by default on linux.
Debug Chromium builds display an error if they don't find EGL, even if GLX is available. This prompts people to install the EGL packages, even though that probably isn't their issue. Also, it looks like EGL, even if available, has some issues. If GLX isn't available, it still falls back to EGL. --use-gl=desktop should not be required to force use of GLX on boxes that also have EGL installed. Changed LOG(ERROR) to VLOG(1) if a shared library fails to load since this is not necessarily an error. Report an error only if no GL implementation can be initialized. Log which GL implementation was selected. TEST=launch chrome with various combinations of --use-gl switch and check the log output is correct. BUG=none Review URL: http://codereview.chromium.org/6342001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71472 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/gfx/gl/gl_implementation.cc')
-rw-r--r--app/gfx/gl/gl_implementation.cc53
1 files changed, 34 insertions, 19 deletions
diff --git a/app/gfx/gl/gl_implementation.cc b/app/gfx/gl/gl_implementation.cc
index fccfb09..30ff0e3 100644
--- a/app/gfx/gl/gl_implementation.cc
+++ b/app/gfx/gl/gl_implementation.cc
@@ -21,6 +21,16 @@ const char kGLImplementationMockName[] = "mock";
namespace {
+const struct {
+ const char* name;
+ GLImplementation implementation;
+} kGLImplementationNamePairs[] = {
+ { kGLImplementationDesktopName, kGLImplementationDesktopGL },
+ { kGLImplementationOSMesaName, kGLImplementationOSMesaGL },
+ { kGLImplementationEGLName, kGLImplementationEGLGLES2 },
+ { kGLImplementationMockName, kGLImplementationMockGL }
+};
+
typedef std::vector<base::NativeLibrary> LibraryArray;
GLImplementation g_gl_implementation = kGLImplementationNone;
@@ -40,24 +50,23 @@ void CleanupNativeLibraries(void* unused) {
}
GLImplementation GetNamedGLImplementation(const std::string& name) {
- static const struct {
- const char* name;
- GLImplementation implemention;
- } name_pairs[] = {
- { kGLImplementationDesktopName, kGLImplementationDesktopGL },
- { kGLImplementationOSMesaName, kGLImplementationOSMesaGL },
- { kGLImplementationEGLName, kGLImplementationEGLGLES2 },
- { kGLImplementationMockName, kGLImplementationMockGL }
- };
-
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(name_pairs); ++i) {
- if (name == name_pairs[i].name)
- return name_pairs[i].implemention;
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kGLImplementationNamePairs); ++i) {
+ if (name == kGLImplementationNamePairs[i].name)
+ return kGLImplementationNamePairs[i].implementation;
}
return kGLImplementationNone;
}
+const char* GetGLImplementationName(GLImplementation implementation) {
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kGLImplementationNamePairs); ++i) {
+ if (implementation == kGLImplementationNamePairs[i].implementation)
+ return kGLImplementationNamePairs[i].name;
+ }
+
+ return "unknown";
+}
+
bool InitializeBestGLBindings(
const GLImplementation* allowed_implementations_begin,
const GLImplementation* allowed_implementations_end) {
@@ -69,23 +78,29 @@ bool InitializeBestGLBindings(
if (std::find(allowed_implementations_begin,
allowed_implementations_end,
requested_implementation) == allowed_implementations_end) {
- LOG(ERROR) << "Requested GL implementation is not allowed.";
+ LOG(ERROR) << "Requested GL implementation is not available.";
return false;
}
- if (InitializeGLBindings(requested_implementation))
- return true;
+ InitializeGLBindings(requested_implementation);
} else {
for (const GLImplementation* p = allowed_implementations_begin;
p < allowed_implementations_end;
++p) {
if (InitializeGLBindings(*p))
- return true;
+ break;
}
}
- LOG(ERROR) << "Could not initialize GL.";
- return false;
+ if (GetGLImplementation() == kGLImplementationNone) {
+ LOG(ERROR) << "Could not initialize GL.";
+ return false;
+ } else {
+ LOG(INFO) << "Using "
+ << GetGLImplementationName(GetGLImplementation())
+ << " GL implementation.";
+ return true;
+ }
}
void SetGLImplementation(GLImplementation implementation) {