OLD | NEW |
---|---|
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/bind.h" | 5 #include "base/bind.h" |
6 #include "ui/gfx/ozone/surface_factory_ozone.h" | 6 #include "ui/gfx/ozone/surface_factory_ozone.h" |
7 #include "ui/gl/gl_bindings.h" | 7 #include "ui/gl/gl_bindings.h" |
8 #include "ui/gl/gl_context_mock_version.h" | |
8 #include "ui/gl/gl_egl_api_implementation.h" | 9 #include "ui/gl/gl_egl_api_implementation.h" |
9 #include "ui/gl/gl_gl_api_implementation.h" | 10 #include "ui/gl/gl_gl_api_implementation.h" |
10 #include "ui/gl/gl_implementation.h" | 11 #include "ui/gl/gl_implementation.h" |
11 #include "ui/gl/gl_implementation_linux.h" | 12 #include "ui/gl/gl_implementation_linux.h" |
12 #include "ui/gl/gl_osmesa_api_implementation.h" | 13 #include "ui/gl/gl_osmesa_api_implementation.h" |
13 #include "ui/ozone/ozone_platform.h" | 14 #include "ui/ozone/ozone_platform.h" |
14 | 15 |
15 namespace gfx { | 16 namespace gfx { |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) { | 20 void GL_BINDING_CALL MarshalClearDepthToClearDepthf(GLclampd depth) { |
20 glClearDepthf(static_cast<GLclampf>(depth)); | 21 glClearDepthf(static_cast<GLclampf>(depth)); |
21 } | 22 } |
22 | 23 |
23 void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near, | 24 void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near, |
24 GLclampd z_far) { | 25 GLclampd z_far) { |
25 glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far)); | 26 glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far)); |
26 } | 27 } |
27 | 28 |
28 } // namespace | 29 } // namespace |
29 | 30 |
30 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { | 31 void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) { |
31 impls->push_back(kGLImplementationEGLGLES2); | 32 impls->push_back(kGLImplementationEGLGLES2); |
32 impls->push_back(kGLImplementationOSMesaGL); | 33 impls->push_back(kGLImplementationOSMesaGL); |
33 } | 34 } |
34 | 35 |
35 bool InitializeGLBindings(GLImplementation implementation) { | 36 bool InitializeStaticGLBindings(GLImplementation implementation) { |
36 // Prevent reinitialization with a different implementation. Once the gpu | 37 // Prevent reinitialization with a different implementation. Once the gpu |
37 // unit tests have initialized with kGLImplementationMock, we don't want to | 38 // unit tests have initialized with kGLImplementationMock, we don't want to |
38 // later switch to another GL implementation. | 39 // later switch to another GL implementation. |
39 if (GetGLImplementation() != kGLImplementationNone) | 40 if (GetGLImplementation() != kGLImplementationNone) |
40 return true; | 41 return true; |
41 | 42 |
42 switch (implementation) { | 43 switch (implementation) { |
43 case kGLImplementationOSMesaGL: | 44 case kGLImplementationOSMesaGL: |
44 return InitializeGLBindingsOSMesaGL(); | 45 return InitializeStaticGLBindingsOSMesaGL(); |
45 case kGLImplementationEGLGLES2: | 46 case kGLImplementationEGLGLES2: |
46 ui::OzonePlatform::Initialize(); | 47 ui::OzonePlatform::Initialize(); |
47 if (!gfx::SurfaceFactoryOzone::GetInstance()->LoadEGLGLES2Bindings( | 48 if (!gfx::SurfaceFactoryOzone::GetInstance()->LoadEGLGLES2Bindings( |
48 base::Bind(&AddGLNativeLibrary), | 49 base::Bind(&AddGLNativeLibrary), |
49 base::Bind(&SetGLGetProcAddressProc))) | 50 base::Bind(&SetGLGetProcAddressProc))) |
50 return false; | 51 return false; |
51 SetGLImplementation(kGLImplementationEGLGLES2); | 52 SetGLImplementation(kGLImplementationEGLGLES2); |
52 InitializeGLBindingsGL(); | 53 InitializeStaticGLBindingsGL(); |
53 InitializeGLBindingsEGL(); | 54 InitializeStaticGLBindingsEGL(); |
54 | 55 |
55 // These two functions take single precision float rather than double | 56 // These two functions take single precision float rather than double |
56 // precision float parameters in GLES. | 57 // precision float parameters in GLES. |
57 ::gfx::g_driver_gl.fn.glClearDepthFn = MarshalClearDepthToClearDepthf; | 58 ::gfx::g_driver_gl.fn.glClearDepthFn = MarshalClearDepthToClearDepthf; |
58 ::gfx::g_driver_gl.fn.glDepthRangeFn = MarshalDepthRangeToDepthRangef; | 59 ::gfx::g_driver_gl.fn.glDepthRangeFn = MarshalDepthRangeToDepthRangef; |
59 break; | 60 break; |
60 case kGLImplementationMockGL: { | 61 case kGLImplementationMockGL: { |
61 SetGLGetProcAddressProc(GetMockGLProcAddress); | 62 SetGLGetProcAddressProc(GetMockGLProcAddress); |
62 SetGLImplementation(kGLImplementationMockGL); | 63 SetGLImplementation(kGLImplementationMockGL); |
63 InitializeGLBindingsGL(); | 64 InitializeStaticGLBindingsGL(); |
64 break; | 65 break; |
65 } | 66 } |
66 default: | 67 default: |
67 NOTIMPLEMENTED() | 68 NOTIMPLEMENTED() |
68 << "Unsupported GL type for Ozone surface implementation"; | 69 << "Unsupported GL type for Ozone surface implementation"; |
69 return false; | 70 return false; |
70 } | 71 } |
71 | 72 |
72 return true; | 73 return true; |
73 } | 74 } |
74 | 75 |
75 bool InitializeGLExtensionBindings(GLImplementation implementation, | 76 bool InitializeDynamicGLBindings(GLImplementation implementation, |
76 GLContext* context) { | 77 GLContext* context) { |
77 switch (implementation) { | 78 switch (implementation) { |
78 case kGLImplementationOSMesaGL: | 79 case kGLImplementationOSMesaGL: |
79 InitializeGLExtensionBindingsGL(context); | 80 InitializeDynamicGLBindingsGL(context); |
80 InitializeGLExtensionBindingsOSMESA(context); | 81 InitializeDynamicGLBindingsOSMESA(context); |
81 break; | 82 break; |
82 case kGLImplementationEGLGLES2: | 83 case kGLImplementationEGLGLES2: |
83 InitializeGLExtensionBindingsGL(context); | 84 InitializeDynamicGLBindingsGL(context); |
84 InitializeGLExtensionBindingsEGL(context); | 85 InitializeDynamicGLBindingsEGL(context); |
85 break; | 86 break; |
86 case kGLImplementationMockGL: | 87 case kGLImplementationMockGL: |
87 InitializeGLExtensionBindingsGL(context); | 88 { |
89 scoped_refptr<GLContextMockVersion> mock_context( | |
90 new GLContextMockVersion("4.0")); | |
Ken Russell (switch to Gerrit)
2013/12/04 02:30:51
Similar comment here and in later files.
| |
91 InitializeDynamicGLBindingsGL(mock_context.get()); | |
92 } | |
88 break; | 93 break; |
89 default: | 94 default: |
90 return false; | 95 return false; |
91 } | 96 } |
92 | 97 |
93 return true; | 98 return true; |
94 } | 99 } |
95 | 100 |
96 void InitializeDebugGLBindings() { | 101 void InitializeDebugGLBindings() { |
97 } | 102 } |
98 | 103 |
99 void ClearGLBindings() { | 104 void ClearGLBindings() { |
100 ClearGLBindingsEGL(); | 105 ClearGLBindingsEGL(); |
101 ClearGLBindingsGL(); | 106 ClearGLBindingsGL(); |
102 SetGLImplementation(kGLImplementationNone); | 107 SetGLImplementation(kGLImplementationNone); |
103 UnloadGLNativeLibraries(); | 108 UnloadGLNativeLibraries(); |
104 } | 109 } |
105 | 110 |
106 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { | 111 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { |
107 switch (GetGLImplementation()) { | 112 switch (GetGLImplementation()) { |
108 case kGLImplementationEGLGLES2: | 113 case kGLImplementationEGLGLES2: |
109 return GetGLWindowSystemBindingInfoEGL(info); | 114 return GetGLWindowSystemBindingInfoEGL(info); |
110 default: | 115 default: |
111 return false; | 116 return false; |
112 } | 117 } |
113 return false; | 118 return false; |
114 } | 119 } |
115 | 120 |
116 } // namespace gfx | 121 } // namespace gfx |
OLD | NEW |