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

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: 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 unified diff | Download patch | Annotate | Revision Log
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.
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.
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 AddGLNativeLibrary(egl_library);
73 AddGLNativeLibrary(gles_library);
74 SetGLImplementation(kGLImplementationEGLGLES2);
75
76 InitializeGLBindingsGL();
77 InitializeGLBindingsEGL();
78
79 // These two functions take single precision float rather than double
80 // precision float parameters in GLES.
81 ::gfx::g_glClearDepth = MarshalClearDepthToClearDepthf;
82 ::gfx::g_glDepthRange = MarshalDepthRangeToDepthRangef;
83 break;
84 }
85 case kGLImplementationMockGL: {
86 SetGLGetProcAddressProc(GetMockGLProcAddress);
87 SetGLImplementation(kGLImplementationMockGL);
88 InitializeGLBindingsGL();
89 break;
90 }
91 default:
92 NOTIMPLEMENTED() << "InitializeGLBindings on Android";
93 return false;
94 }
95
96 return true;
97 }
98
99 void InitializeDebugGLBindings() {
100 }
101
102 } // namespace gfx
OLDNEW
« 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