OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/gl/init/gl_initializer.h" | 5 #include "ui/gl/init/gl_initializer.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/gl/gl_bindings.h" | 8 #include "ui/gl/gl_bindings.h" |
9 #include "ui/gl/gl_gl_api_implementation.h" | 9 #include "ui/gl/gl_gl_api_implementation.h" |
10 #include "ui/gl/gl_implementation_osmesa.h" | |
11 #include "ui/gl/gl_osmesa_api_implementation.h" | |
12 #include "ui/gl/gl_surface.h" | 10 #include "ui/gl/gl_surface.h" |
13 #include "ui/gl/init/ozone_util.h" | 11 #include "ui/gl/init/ozone_util.h" |
14 | 12 |
15 namespace gl { | 13 namespace gl { |
16 namespace init { | 14 namespace init { |
17 | 15 |
18 bool InitializeGLOneOffPlatform() { | 16 bool InitializeGLOneOffPlatform() { |
19 if (HasGLOzone()) | 17 if (HasGLOzone()) |
20 return GetGLOzone()->InitializeGLOneOffPlatform(); | 18 return GetGLOzone()->InitializeGLOneOffPlatform(); |
21 | 19 |
22 switch (GetGLImplementation()) { | 20 switch (GetGLImplementation()) { |
23 case kGLImplementationOSMesaGL: | |
24 case kGLImplementationMockGL: | 21 case kGLImplementationMockGL: |
25 case kGLImplementationStubGL: | 22 case kGLImplementationStubGL: |
26 return true; | 23 return true; |
27 default: | 24 default: |
28 return false; | 25 NOTREACHED(); |
29 } | 26 } |
| 27 return false; |
30 } | 28 } |
31 | 29 |
32 bool InitializeStaticGLBindings(GLImplementation implementation) { | 30 bool InitializeStaticGLBindings(GLImplementation implementation) { |
33 // Prevent reinitialization with a different implementation. Once the gpu | 31 // Prevent reinitialization with a different implementation. Once the gpu |
34 // unit tests have initialized with kGLImplementationMock, we don't want to | 32 // unit tests have initialized with kGLImplementationMock, we don't want to |
35 // later switch to another GL implementation. | 33 // later switch to another GL implementation. |
36 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); | 34 DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); |
37 | 35 |
38 if (HasGLOzone(implementation)) { | 36 if (HasGLOzone(implementation)) { |
39 return GetGLOzone(implementation) | 37 return GetGLOzone(implementation) |
40 ->InitializeStaticGLBindings(implementation); | 38 ->InitializeStaticGLBindings(implementation); |
41 } | 39 } |
42 | 40 |
43 switch (implementation) { | 41 switch (implementation) { |
44 case kGLImplementationOSMesaGL: | |
45 return InitializeStaticGLBindingsOSMesaGL(); | |
46 case kGLImplementationMockGL: | 42 case kGLImplementationMockGL: |
47 case kGLImplementationStubGL: | 43 case kGLImplementationStubGL: |
48 SetGLImplementation(implementation); | 44 SetGLImplementation(implementation); |
49 InitializeStaticGLBindingsGL(); | 45 InitializeStaticGLBindingsGL(); |
50 return true; | 46 return true; |
51 default: | 47 default: |
52 NOTREACHED(); | 48 NOTREACHED(); |
53 } | 49 } |
54 | 50 |
55 return false; | 51 return false; |
56 } | 52 } |
57 | 53 |
58 void InitializeDebugGLBindings() { | 54 void InitializeDebugGLBindings() { |
59 if (HasGLOzone()) { | 55 if (HasGLOzone()) { |
60 GetGLOzone()->InitializeDebugGLBindings(); | 56 GetGLOzone()->InitializeDebugGLBindings(); |
61 return; | 57 return; |
62 } | 58 } |
63 | 59 |
64 InitializeDebugGLBindingsGL(); | 60 InitializeDebugGLBindingsGL(); |
65 InitializeDebugGLBindingsOSMESA(); | |
66 } | 61 } |
67 | 62 |
68 void ShutdownGLPlatform() { | 63 void ShutdownGLPlatform() { |
69 if (HasGLOzone()) { | 64 if (HasGLOzone()) { |
70 GetGLOzone()->ShutdownGL(); | 65 GetGLOzone()->ShutdownGL(); |
71 return; | 66 return; |
72 } | 67 } |
73 | 68 |
74 ClearBindingsGL(); | 69 ClearBindingsGL(); |
75 ClearBindingsOSMESA(); | |
76 } | 70 } |
77 | 71 |
78 } // namespace init | 72 } // namespace init |
79 } // namespace gl | 73 } // namespace gl |
OLD | NEW |