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

Side by Side Diff: ui/gfx/gl/gl_implementation_linux.cc

Issue 6864020: linux: don't always print dlopen errors from LoadNativeLibrary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: owners Created 9 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_auth_gssapi_posix.cc ('k') | ui/gfx/gl/gl_implementation_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/native_library.h" 11 #include "base/native_library.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "ui/gfx/gl/gl_bindings.h" 13 #include "ui/gfx/gl/gl_bindings.h"
14 #include "ui/gfx/gl/gl_implementation.h" 14 #include "ui/gfx/gl/gl_implementation.h"
15 15
16 namespace gfx { 16 namespace gfx {
17 namespace { 17 namespace {
18 18
19 // TODO(piman): it should be Desktop GL marshalling from double to float. Today 19 // TODO(piman): it should be Desktop GL marshalling from double to float. Today
20 // on native GLES, we do float->double->float. 20 // on native GLES, we do float->double->float.
21 void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) { 21 void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) {
22 glClearDepthf(static_cast<GLclampf>(depth)); 22 glClearDepthf(static_cast<GLclampf>(depth));
23 } 23 }
24 24
25 void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near, 25 void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near,
26 GLclampd z_far) { 26 GLclampd z_far) {
27 glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far)); 27 glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far));
28 } 28 }
29 29
30 // Load a library, printing an error message on failure.
31 base::NativeLibrary LoadLibrary(const char* filename) {
32 std::string error;
33 base::NativeLibrary library = base::LoadNativeLibrary(FilePath(filename),
34 &error);
35 if (!library) {
36 VLOG(1) << "Failed to load " << filename << ": " << error;
37 return NULL;
38 }
39 return library;
40 }
41
30 } // namespace anonymous 42 } // namespace anonymous
31 43
32 bool InitializeGLBindings(GLImplementation implementation) { 44 bool InitializeGLBindings(GLImplementation implementation) {
33 // Prevent reinitialization with a different implementation. Once the gpu 45 // Prevent reinitialization with a different implementation. Once the gpu
34 // unit tests have initialized with kGLImplementationMock, we don't want to 46 // unit tests have initialized with kGLImplementationMock, we don't want to
35 // later switch to another GL implementation. 47 // later switch to another GL implementation.
36 if (GetGLImplementation() != kGLImplementationNone) 48 if (GetGLImplementation() != kGLImplementationNone)
37 return true; 49 return true;
38 50
39 switch (implementation) { 51 switch (implementation) {
40 case kGLImplementationOSMesaGL: { 52 case kGLImplementationOSMesaGL: {
41 FilePath module_path; 53 FilePath module_path;
42 if (!PathService::Get(base::DIR_MODULE, &module_path)) { 54 if (!PathService::Get(base::DIR_MODULE, &module_path)) {
43 LOG(ERROR) << "PathService::Get failed."; 55 LOG(ERROR) << "PathService::Get failed.";
44 return false; 56 return false;
45 } 57 }
46 58
47 base::NativeLibrary library = base::LoadNativeLibrary( 59 base::NativeLibrary library = LoadLibrary("libosmesa.so");
48 module_path.Append("libosmesa.so")); 60 if (!library)
49 if (!library) {
50 VLOG(1) << "libosmesa.so not found";
51 return false; 61 return false;
52 }
53 62
54 GLGetProcAddressProc get_proc_address = 63 GLGetProcAddressProc get_proc_address =
55 reinterpret_cast<GLGetProcAddressProc>( 64 reinterpret_cast<GLGetProcAddressProc>(
56 base::GetFunctionPointerFromNativeLibrary( 65 base::GetFunctionPointerFromNativeLibrary(
57 library, "OSMesaGetProcAddress")); 66 library, "OSMesaGetProcAddress"));
58 if (!get_proc_address) { 67 if (!get_proc_address) {
59 LOG(ERROR) << "OSMesaGetProcAddress not found."; 68 LOG(ERROR) << "OSMesaGetProcAddress not found.";
60 base::UnloadNativeLibrary(library); 69 base::UnloadNativeLibrary(library);
61 return false; 70 return false;
62 } 71 }
63 72
64 SetGLGetProcAddressProc(get_proc_address); 73 SetGLGetProcAddressProc(get_proc_address);
65 AddGLNativeLibrary(library); 74 AddGLNativeLibrary(library);
66 SetGLImplementation(kGLImplementationOSMesaGL); 75 SetGLImplementation(kGLImplementationOSMesaGL);
67 76
68 InitializeGLBindingsGL(); 77 InitializeGLBindingsGL();
69 InitializeGLBindingsOSMESA(); 78 InitializeGLBindingsOSMESA();
70 break; 79 break;
71 } 80 }
72 case kGLImplementationDesktopGL: { 81 case kGLImplementationDesktopGL: {
73 base::NativeLibrary library = base::LoadNativeLibrary( 82 base::NativeLibrary library = LoadLibrary("libGL.so.1");
74 FilePath("libGL.so.1")); 83 if (!library)
75 if (!library) {
76 VLOG(1) << "libGL.so.1 not found.";
77 return false; 84 return false;
78 }
79 85
80 GLGetProcAddressProc get_proc_address = 86 GLGetProcAddressProc get_proc_address =
81 reinterpret_cast<GLGetProcAddressProc>( 87 reinterpret_cast<GLGetProcAddressProc>(
82 base::GetFunctionPointerFromNativeLibrary( 88 base::GetFunctionPointerFromNativeLibrary(
83 library, "glXGetProcAddress")); 89 library, "glXGetProcAddress"));
84 if (!get_proc_address) { 90 if (!get_proc_address) {
85 LOG(ERROR) << "glxGetProcAddress not found."; 91 LOG(ERROR) << "glxGetProcAddress not found.";
86 base::UnloadNativeLibrary(library); 92 base::UnloadNativeLibrary(library);
87 return false; 93 return false;
88 } 94 }
89 95
90 SetGLGetProcAddressProc(get_proc_address); 96 SetGLGetProcAddressProc(get_proc_address);
91 AddGLNativeLibrary(library); 97 AddGLNativeLibrary(library);
92 SetGLImplementation(kGLImplementationDesktopGL); 98 SetGLImplementation(kGLImplementationDesktopGL);
93 99
94 InitializeGLBindingsGL(); 100 InitializeGLBindingsGL();
95 InitializeGLBindingsGLX(); 101 InitializeGLBindingsGLX();
96 break; 102 break;
97 } 103 }
98 case kGLImplementationEGLGLES2: { 104 case kGLImplementationEGLGLES2: {
99 base::NativeLibrary gles_library = base::LoadNativeLibrary( 105 base::NativeLibrary gles_library = LoadLibrary("libGLESv2.so");
100 FilePath("libGLESv2.so")); 106 if (!gles_library)
101 if (!gles_library) {
102 VLOG(1) << "libGLESv2.so not found";
103 return false; 107 return false;
104 } 108 base::NativeLibrary egl_library = LoadLibrary("libEGL.so");
105 109 if (!egl_library)
106 base::NativeLibrary egl_library = base::LoadNativeLibrary(
107 FilePath("libEGL.so"));
108 if (!egl_library) {
109 VLOG(1) << "libEGL.so not found";
110 base::UnloadNativeLibrary(gles_library);
111 return false; 110 return false;
112 }
113 111
114 GLGetProcAddressProc get_proc_address = 112 GLGetProcAddressProc get_proc_address =
115 reinterpret_cast<GLGetProcAddressProc>( 113 reinterpret_cast<GLGetProcAddressProc>(
116 base::GetFunctionPointerFromNativeLibrary( 114 base::GetFunctionPointerFromNativeLibrary(
117 egl_library, "eglGetProcAddress")); 115 egl_library, "eglGetProcAddress"));
118 if (!get_proc_address) { 116 if (!get_proc_address) {
119 LOG(ERROR) << "eglGetProcAddress not found."; 117 LOG(ERROR) << "eglGetProcAddress not found.";
120 base::UnloadNativeLibrary(egl_library); 118 base::UnloadNativeLibrary(egl_library);
121 base::UnloadNativeLibrary(gles_library); 119 base::UnloadNativeLibrary(gles_library);
122 return false; 120 return false;
(...skipping 28 matching lines...) Expand all
151 } 149 }
152 150
153 void InitializeDebugGLBindings() { 151 void InitializeDebugGLBindings() {
154 InitializeDebugGLBindingsEGL(); 152 InitializeDebugGLBindingsEGL();
155 InitializeDebugGLBindingsGL(); 153 InitializeDebugGLBindingsGL();
156 InitializeDebugGLBindingsGLX(); 154 InitializeDebugGLBindingsGLX();
157 InitializeDebugGLBindingsOSMESA(); 155 InitializeDebugGLBindingsOSMESA();
158 } 156 }
159 157
160 } // namespace gfx 158 } // namespace gfx
OLDNEW
« no previous file with comments | « net/http/http_auth_gssapi_posix.cc ('k') | ui/gfx/gl/gl_implementation_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698