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

Side by Side 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: Sync 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/gl/gl_context_android.cc ('k') | ui/gfx/gl/gl_surface_egl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/base_paths.h"
6 #include "base/command_line.h"
7 #include "base/file_path.h"
8 #include "base/logging.h"
9 #include "base/native_library.h"
10 #include "base/path_service.h"
11 #include "ui/gfx/gl/gl_bindings.h"
12 #include "ui/gfx/gl/gl_implementation.h"
13
14 namespace gfx {
15
16 namespace {
17
18 void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) {
19 glClearDepthf(static_cast<GLclampf>(depth));
20 }
21
22 void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near,
23 GLclampd z_far) {
24 glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far));
25 }
26
27 base::NativeLibrary LoadLibrary(const FilePath& filename) {
28 std::string error;
29 base::NativeLibrary library = base::LoadNativeLibrary(filename, &error);
30 if (!library) {
31 VLOG(1) << "Failed to load " << filename.MaybeAsASCII() << ": " << error;
32 return NULL;
33 }
34 return library;
35 }
36
37 base::NativeLibrary LoadLibrary(const char* filename) {
38 return LoadLibrary(FilePath(filename));
39 }
40
41 } // namespace anonymous
42
43 bool InitializeGLBindings(GLImplementation implementation) {
44 // Prevent reinitialization with a different implementation. Once the gpu
45 // unit tests have initialized with kGLImplementationMock, we don't want to
46 // later switch to another GL implementation.
47 if (GetGLImplementation() != kGLImplementationNone)
48 return true;
49
50 switch (implementation) {
51 case kGLImplementationEGLGLES2: {
52 base::NativeLibrary gles_library = LoadLibrary("libGLESv2.so");
53 if (!gles_library)
54 return false;
55 base::NativeLibrary egl_library = LoadLibrary("libEGL.so");
56 if (!egl_library)
57 return false;
58
59 // Note: Android is a GLES2 platform so no EXT or ARB entry points are
60 // used by Chromium on such platforms. However, gl_bindings_autogen_gl.cc
61 // code looks up the EXT entry points with eglGetProcAddress(), comparing
62 // the resulting function pointers against NULL to decide whether it
63 // should fall back to the non-EXT versions of these functions.
64 // However, this is wrong as eglGetProcAddress() is not guaranteed to
65 // return NULL if an extension is not supported. On Android, the
66 // end-result is that we end up with the wrong function pointers for
67 // many GL functions and the rendering is broken.
68 // TODO(andreip): Fix this properly by modifying the generate_bindings.py
69 // python script that generates the lookup code so that we give it two
70 // lists: one of function names to look up on desktop GL and one for
71 // those to look up on GLES2.
72 // see, http://code.google.com/p/chromium/issues/detail?id=105011
73 AddGLNativeLibrary(egl_library);
74 AddGLNativeLibrary(gles_library);
75 SetGLImplementation(kGLImplementationEGLGLES2);
76
77 InitializeGLBindingsGL();
78 InitializeGLBindingsEGL();
79
80 // These two functions take single precision float rather than double
81 // precision float parameters in GLES.
82 ::gfx::g_glClearDepth = MarshalClearDepthToClearDepthf;
83 ::gfx::g_glDepthRange = MarshalDepthRangeToDepthRangef;
84 break;
85 }
86 case kGLImplementationMockGL: {
87 SetGLGetProcAddressProc(GetMockGLProcAddress);
88 SetGLImplementation(kGLImplementationMockGL);
89 InitializeGLBindingsGL();
90 break;
91 }
92 default:
93 NOTIMPLEMENTED() << "InitializeGLBindings on Android";
94 return false;
95 }
96
97 return true;
98 }
99
100 void InitializeDebugGLBindings() {
101 }
102
103 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/gl/gl_context_android.cc ('k') | ui/gfx/gl/gl_surface_egl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698