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

Unified Diff: ui/gfx/gl/gl_implementation_android.cc

Issue 8588059: Upstream: GL implementation on Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address the comments Created 9 years, 1 month 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
Index: ui/gfx/gl/gl_implementation_android.cc
diff --git a/ui/gfx/gl/gl_implementation_android.cc b/ui/gfx/gl/gl_implementation_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..690f5f92481eec94a35c43a071e18144b010b16f
--- /dev/null
+++ b/ui/gfx/gl/gl_implementation_android.cc
@@ -0,0 +1,102 @@
+// Copyright (c) 2011 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 "base/base_paths.h"
+#include "base/command_line.h"
+#include "base/file_path.h"
+#include "base/logging.h"
+#include "base/native_library.h"
+#include "base/path_service.h"
+#include "ui/gfx/gl/gl_bindings.h"
+#include "ui/gfx/gl/gl_implementation.h"
+
+namespace gfx {
+
+namespace {
+
+void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) {
+ glClearDepthf(static_cast<GLclampf>(depth));
+}
+
+void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near,
+ GLclampd z_far) {
+ glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far));
+}
+
+base::NativeLibrary LoadLibrary(const FilePath& filename) {
+ std::string error;
+ base::NativeLibrary library = base::LoadNativeLibrary(filename, &error);
+ if (!library) {
+ VLOG(1) << "Failed to load " << filename.MaybeAsASCII() << ": " << error;
+ return NULL;
+ }
+ return library;
+}
+
+base::NativeLibrary LoadLibrary(const char* filename) {
+ return LoadLibrary(FilePath(filename));
+}
+
+} // 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 (GetGLImplementation() != kGLImplementationNone)
+ return true;
+
+ switch (implementation) {
+ case kGLImplementationEGLGLES2: {
+ base::NativeLibrary gles_library = LoadLibrary("libGLESv2.so");
+ if (!gles_library)
+ return false;
+ base::NativeLibrary egl_library = LoadLibrary("libEGL.so");
+ if (!egl_library)
+ return false;
+
+ // Note: Android is a GLES2 platform so no EXT or ARB entry points are
+ // used by Chromium on such platforms. However, gl_bindings_autogen_gl.cc
+ // code looks up the EXT entry points with eglGetProcAddress(), comparing
+ // the resulting function pointers against NULL to decide whether it
+ // should fall back to the non-EXT versions of these functions.
+ // However, this is wrong as eglGetProcAddress() is not guaranteed to
+ // return NULL if an extension is not supported. On Android, the
+ // end-result is that we end up with the wrong function pointers for
+ // many GL functions and the rendering is broken.
jonathan.backer 2011/11/21 18:54:45 I see what you mean. glBlitFramebuffer for example
michaelbai 2011/11/21 19:29:04 Done. Also add issue link here.
+ // TODO(andreip): Fix this properly by modifying the generate_bindings.py
+ // python script that generates the lookup code so that we give it two
+ // lists: one of function names to look up on desktop GL and one for
+ // those to look up on GLES2.
+ AddGLNativeLibrary(egl_library);
+ AddGLNativeLibrary(gles_library);
+ SetGLImplementation(kGLImplementationEGLGLES2);
+
+ InitializeGLBindingsGL();
+ InitializeGLBindingsEGL();
+
+ // These two functions take single precision float rather than double
+ // precision float parameters in GLES.
+ ::gfx::g_glClearDepth = MarshalClearDepthToClearDepthf;
+ ::gfx::g_glDepthRange = MarshalDepthRangeToDepthRangef;
+ break;
+ }
+ case kGLImplementationMockGL: {
+ SetGLGetProcAddressProc(GetMockGLProcAddress);
+ SetGLImplementation(kGLImplementationMockGL);
+ InitializeGLBindingsGL();
+ break;
+ }
+ default:
+ NOTIMPLEMENTED() << "InitializeGLBindings on Android";
+ return false;
+ }
+
+ return true;
+}
+
+void InitializeDebugGLBindings() {
+}
+
+} // namespace gfx
« no previous file with comments | « ui/gfx/gl/gl_context_android.cc ('k') | ui/gfx/gl/gl_surface.h » ('j') | ui/gfx/gl/gl_surface.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698