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

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

Issue 7019041: Fix up PathProvider on the Mac for FILE_MODULE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Search for osmesa in build dir, and get rid of copies. Created 9 years, 7 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
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 "base/base_paths.h" 5 #include "base/base_paths.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/foundation_util.h"
8 #include "base/native_library.h" 9 #include "base/native_library.h"
9 #include "base/path_service.h" 10 #include "base/path_service.h"
10 #include "ui/gfx/gl/gl_bindings.h" 11 #include "ui/gfx/gl/gl_bindings.h"
11 #include "ui/gfx/gl/gl_implementation.h" 12 #include "ui/gfx/gl/gl_implementation.h"
12 13
13 namespace gfx { 14 namespace gfx {
14 namespace { 15 namespace {
15 const char kOpenGLFrameworkPath[] = 16 const char kOpenGLFrameworkPath[] =
16 "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL"; 17 "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL";
17 } // namespace anonymous 18 } // namespace anonymous
18 19
19 bool InitializeGLBindings(GLImplementation implementation) { 20 bool InitializeGLBindings(GLImplementation implementation) {
20 // Prevent reinitialization with a different implementation. Once the gpu 21 // Prevent reinitialization with a different implementation. Once the gpu
21 // unit tests have initialized with kGLImplementationMock, we don't want to 22 // unit tests have initialized with kGLImplementationMock, we don't want to
22 // later switch to another GL implementation. 23 // later switch to another GL implementation.
23 if (GetGLImplementation() != kGLImplementationNone) 24 if (GetGLImplementation() != kGLImplementationNone)
24 return true; 25 return true;
25 26
26 switch (implementation) { 27 switch (implementation) {
27 case kGLImplementationOSMesaGL: { 28 case kGLImplementationOSMesaGL: {
28 FilePath module_path; 29 // osmesa.so is located in the build directory. This code path is only
29 if (!PathService::Get(base::DIR_MODULE, &module_path)) { 30 // valid in a developer build environment.
31 FilePath exe_path;
32 if (!PathService::Get(base::FILE_EXE, &exe_path)) {
30 LOG(ERROR) << "PathService::Get failed."; 33 LOG(ERROR) << "PathService::Get failed.";
31 return false; 34 return false;
32 } 35 }
36 FilePath bundle_path = base::mac::GetAppBundlePath(exe_path);
37 FilePath build_dir_path = bundle_path.DirName();
38 FilePath osmesa_path = build_dir_path.Append("osmesa.so");
33 39
34 // When using OSMesa, just use OSMesaGetProcAddress to find entry points. 40 // When using OSMesa, just use OSMesaGetProcAddress to find entry points.
35 base::NativeLibrary library = base::LoadNativeLibrary( 41 base::NativeLibrary library = base::LoadNativeLibrary(osmesa_path, NULL);
36 module_path.Append("osmesa.so"), NULL);
37 if (!library) { 42 if (!library) {
38 VLOG(1) << "osmesa.so not found"; 43 LOG(ERROR) << "osmesa.so not found at " << osmesa_path.value();
39 return false; 44 return false;
40 } 45 }
41 46
42 GLGetProcAddressProc get_proc_address = 47 GLGetProcAddressProc get_proc_address =
43 reinterpret_cast<GLGetProcAddressProc>( 48 reinterpret_cast<GLGetProcAddressProc>(
44 base::GetFunctionPointerFromNativeLibrary( 49 base::GetFunctionPointerFromNativeLibrary(
45 library, "OSMesaGetProcAddress")); 50 library, "OSMesaGetProcAddress"));
46 if (!get_proc_address) { 51 if (!get_proc_address) {
47 LOG(ERROR) << "OSMesaGetProcAddress not found."; 52 LOG(ERROR) << "OSMesaGetProcAddress not found.";
48 base::UnloadNativeLibrary(library); 53 base::UnloadNativeLibrary(library);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 88
84 return true; 89 return true;
85 } 90 }
86 91
87 void InitializeDebugGLBindings() { 92 void InitializeDebugGLBindings() {
88 InitializeDebugGLBindingsGL(); 93 InitializeDebugGLBindingsGL();
89 InitializeDebugGLBindingsOSMESA(); 94 InitializeDebugGLBindingsOSMESA();
90 } 95 }
91 96
92 } // namespace gfx 97 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698