Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Unified Diff: app/gfx/gl/gl_implementation_mac.cc

Issue 2134006: Added EGL based GLContext.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « app/gfx/gl/gl_implementation_linux.cc ('k') | app/gfx/gl/gl_implementation_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/gfx/gl/gl_implementation_mac.cc
===================================================================
--- app/gfx/gl/gl_implementation_mac.cc (revision 0)
+++ app/gfx/gl/gl_implementation_mac.cc (revision 0)
@@ -0,0 +1,76 @@
+// Copyright (c) 2010 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 <dlfcn.h>
+
+#include "base/logging.h"
+#include "app/gfx/gl/gl_bindings.h"
+#include "app/gfx/gl/gl_implementation.h"
+
+namespace gfx {
+namespace {
+typedef void* (*GetProcAddressProc)(const char* name);
+
+GLImplementation g_gl_implementation = kGLImplementationNone;
+void* g_shared_library;
+GetProcAddressProc g_get_proc_address;
+} // namespace anonymous
+
+bool InitializeGLBindings(GLImplementation implementation) {
+ // Prevent reinitialization with a different implementation. Once the gpu
+ // unit tests have initialized with kGLImplementationMock, we don't want to
+ // later switch to another GL implementation.
+ if (g_gl_implementation != kGLImplementationNone)
+ return true;
+
+ switch (implementation) {
+ case kGLImplementationDesktopGL:
+ g_shared_library = dlopen(
+ "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL",
+ RTLD_LAZY | RTLD_LOCAL);
+ if (!g_shared_library)
+ return false;
+
+ g_gl_implementation = kGLImplementationDesktopGL;
+ g_get_proc_address = NULL;
+
+ InitializeGLBindingsGL();
+ break;
+
+ case kGLImplementationMockGL:
+ g_get_proc_address = GetMockGLProcAddress;
+ g_gl_implementation = kGLImplementationMockGL;
+ InitializeGLBindingsGL();
+ break;
+
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+GLImplementation GetGLImplementation() {
+ return g_gl_implementation;
+}
+
+void* GetGLProcAddress(const char* name) {
+ DCHECK(g_gl_implementation != kGLImplementationNone);
+
+ if (g_get_proc_address) {
+ void* proc = g_get_proc_address(name);
+ if (proc)
+ return proc;
+ }
+
+ if (g_shared_library) {
+ void* proc = dlsym(g_shared_library, name);
+ if (proc)
+ return proc;
+ }
+
+ return NULL;
+}
+
+} // namespace gfx
Property changes on: app\gfx\gl\gl_implementation_mac.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « app/gfx/gl/gl_implementation_linux.cc ('k') | app/gfx/gl/gl_implementation_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698