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

Side by Side Diff: ui/gl/gl_implementation_ozone.cc

Issue 17932004: Support ozone=1 compositor_unittests with OSMesa (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix on linux Created 7 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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"
6 #include "base/command_line.h"
7 #include "base/files/file_path.h"
8 #include "base/logging.h"
9 #include "base/native_library.h"
10 #include "base/path_service.h"
11 #include "ui/base/ozone/surface_factory_ozone.h" 5 #include "ui/base/ozone/surface_factory_ozone.h"
12 #include "ui/gl/gl_bindings.h" 6 #include "ui/gl/gl_bindings.h"
13 #include "ui/gl/gl_egl_api_implementation.h" 7 #include "ui/gl/gl_egl_api_implementation.h"
14 #include "ui/gl/gl_gl_api_implementation.h" 8 #include "ui/gl/gl_gl_api_implementation.h"
15 #include "ui/gl/gl_implementation.h" 9 #include "ui/gl/gl_implementation.h"
10 #include "ui/gl/gl_implementation_linux.h"
16 #include "ui/gl/gl_osmesa_api_implementation.h" 11 #include "ui/gl/gl_osmesa_api_implementation.h"
17 12
18 namespace gfx { 13 namespace gfx {
19 14
20 namespace { 15 namespace {
21 16
22 void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) { 17 void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) {
23 glClearDepthf(static_cast<GLclampf>(depth)); 18 glClearDepthf(static_cast<GLclampf>(depth));
24 } 19 }
25 20
26 void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near, 21 void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near,
27 GLclampd z_far) { 22 GLclampd z_far) {
28 glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far)); 23 glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far));
29 } 24 }
30 25
31 } // namespace 26 } // namespace
32 27
33 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { 28 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) {
34 impls->push_back(kGLImplementationEGLGLES2); 29 impls->push_back(kGLImplementationEGLGLES2);
30 impls->push_back(kGLImplementationOSMesaGL);
35 } 31 }
36 32
37 bool InitializeGLBindings(GLImplementation implementation) { 33 bool InitializeGLBindings(GLImplementation implementation) {
38 // Prevent reinitialization with a different implementation. Once the gpu 34 // Prevent reinitialization with a different implementation. Once the gpu
39 // unit tests have initialized with kGLImplementationMock, we don't want to 35 // unit tests have initialized with kGLImplementationMock, we don't want to
40 // later switch to another GL implementation. 36 // later switch to another GL implementation.
41 if (GetGLImplementation() != kGLImplementationNone) 37 if (GetGLImplementation() != kGLImplementationNone)
42 return true; 38 return true;
43 39
44 switch (implementation) { 40 switch (implementation) {
41 case kGLImplementationOSMesaGL:
42 return InitializeGLBindingsOSMesaGL();
45 case kGLImplementationEGLGLES2: 43 case kGLImplementationEGLGLES2:
46 if (!ui::SurfaceFactoryOzone::GetInstance()->LoadEGLGLES2Bindings()) 44 if (!ui::SurfaceFactoryOzone::GetInstance()->LoadEGLGLES2Bindings())
47 return false; 45 return false;
48 SetGLImplementation(kGLImplementationEGLGLES2); 46 SetGLImplementation(kGLImplementationEGLGLES2);
49 InitializeGLBindingsGL(); 47 InitializeGLBindingsGL();
50 InitializeGLBindingsEGL(); 48 InitializeGLBindingsEGL();
51 49
52 // These two functions take single precision float rather than double 50 // These two functions take single precision float rather than double
53 // precision float parameters in GLES. 51 // precision float parameters in GLES.
54 ::gfx::g_driver_gl.fn.glClearDepthFn = MarshalClearDepthToClearDepthf; 52 ::gfx::g_driver_gl.fn.glClearDepthFn = MarshalClearDepthToClearDepthf;
55 ::gfx::g_driver_gl.fn.glDepthRangeFn = MarshalDepthRangeToDepthRangef; 53 ::gfx::g_driver_gl.fn.glDepthRangeFn = MarshalDepthRangeToDepthRangef;
56 break; 54 break;
57 case kGLImplementationMockGL: { 55 case kGLImplementationMockGL: {
58 SetGLGetProcAddressProc(GetMockGLProcAddress); 56 SetGLGetProcAddressProc(GetMockGLProcAddress);
59 SetGLImplementation(kGLImplementationMockGL); 57 SetGLImplementation(kGLImplementationMockGL);
60 InitializeGLBindingsGL(); 58 InitializeGLBindingsGL();
61 break; 59 break;
62 } 60 }
63 default: 61 default:
64 NOTIMPLEMENTED() 62 NOTIMPLEMENTED()
65 << "Unsupported GL type for NativeSurfaceLinux GL implementation"; 63 << "Unsupported GL type for Ozone surface implementation";
66 return false; 64 return false;
67 } 65 }
68 66
69 return true; 67 return true;
70 } 68 }
71 69
72 bool InitializeGLExtensionBindings(GLImplementation implementation, 70 bool InitializeGLExtensionBindings(GLImplementation implementation,
73 GLContext* context) { 71 GLContext* context) {
74 switch (implementation) { 72 switch (implementation) {
73 case kGLImplementationOSMesaGL:
74 InitializeGLExtensionBindingsGL(context);
75 InitializeGLExtensionBindingsOSMESA(context);
76 break;
75 case kGLImplementationEGLGLES2: 77 case kGLImplementationEGLGLES2:
76 InitializeGLExtensionBindingsGL(context); 78 InitializeGLExtensionBindingsGL(context);
77 InitializeGLExtensionBindingsEGL(context); 79 InitializeGLExtensionBindingsEGL(context);
78 break; 80 break;
79 case kGLImplementationMockGL: 81 case kGLImplementationMockGL:
80 InitializeGLExtensionBindingsGL(context); 82 InitializeGLExtensionBindingsGL(context);
81 break; 83 break;
82 default: 84 default:
83 return false; 85 return false;
84 } 86 }
(...skipping 15 matching lines...) Expand all
100 switch (GetGLImplementation()) { 102 switch (GetGLImplementation()) {
101 case kGLImplementationEGLGLES2: 103 case kGLImplementationEGLGLES2:
102 return GetGLWindowSystemBindingInfoEGL(info); 104 return GetGLWindowSystemBindingInfoEGL(info);
103 default: 105 default:
104 return false; 106 return false;
105 } 107 }
106 return false; 108 return false;
107 } 109 }
108 110
109 } // namespace gfx 111 } // namespace gfx
OLDNEW
« ui/gl/gl.gyp ('K') | « ui/gl/gl_image_ozone.cc ('k') | ui/gl/gl_implementation_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698