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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "ui/gl/gl_bindings.h" | 9 #include "ui/gl/gl_bindings.h" |
10 #include "ui/gl/gl_egl_api_implementation.h" | 10 #include "ui/gl/gl_egl_api_implementation.h" |
11 #include "ui/gl/gl_gl_api_implementation.h" | 11 #include "ui/gl/gl_gl_api_implementation.h" |
12 #include "ui/gl/gl_implementation_osmesa.h" | 12 #include "ui/gl/gl_implementation_osmesa.h" |
13 #include "ui/gl/gl_osmesa_api_implementation.h" | 13 #include "ui/gl/gl_osmesa_api_implementation.h" |
14 #include "ui/gl/gl_surface_egl.h" | 14 #include "ui/gl/gl_surface_egl.h" |
15 #include "ui/ozone/public/ozone_platform.h" | 15 #include "ui/ozone/public/ozone_platform.h" |
16 #include "ui/ozone/public/surface_factory_ozone.h" | 16 #include "ui/ozone/public/surface_factory_ozone.h" |
17 | 17 |
18 namespace gl { | 18 namespace gl { |
19 namespace init { | 19 namespace init { |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
| 23 ui::SurfaceFactoryOzone* GetSurfaceFactory() { |
| 24 return ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone(); |
| 25 } |
| 26 |
23 bool InitializeStaticEGLInternal() { | 27 bool InitializeStaticEGLInternal() { |
24 auto surface_factory = | 28 if (!GetSurfaceFactory()->LoadEGLGLES2Bindings( |
25 ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone(); | |
26 if (!surface_factory->LoadEGLGLES2Bindings( | |
27 base::Bind(&AddGLNativeLibrary), | 29 base::Bind(&AddGLNativeLibrary), |
28 base::Bind(&SetGLGetProcAddressProc))) { | 30 base::Bind(&SetGLGetProcAddressProc))) { |
29 return false; | 31 return false; |
30 } | 32 } |
31 | 33 |
32 SetGLImplementation(kGLImplementationEGLGLES2); | 34 SetGLImplementation(kGLImplementationEGLGLES2); |
33 InitializeStaticGLBindingsGL(); | 35 InitializeStaticGLBindingsGL(); |
34 InitializeStaticGLBindingsEGL(); | 36 InitializeStaticGLBindingsEGL(); |
35 | 37 |
36 return true; | 38 return true; |
37 } | 39 } |
38 | 40 |
39 } // namespace | 41 } // namespace |
40 | 42 |
41 bool InitializeGLOneOffPlatform() { | 43 bool InitializeGLOneOffPlatform() { |
42 switch (GetGLImplementation()) { | 44 switch (GetGLImplementation()) { |
43 case kGLImplementationEGLGLES2: | 45 case kGLImplementationEGLGLES2: |
44 if (!GLSurfaceEGL::InitializeOneOff()) { | 46 if (!GLSurfaceEGL::InitializeOneOff( |
| 47 GetSurfaceFactory()->GetNativeDisplay())) { |
45 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; | 48 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; |
46 return false; | 49 return false; |
47 } | 50 } |
48 return true; | 51 return true; |
49 case kGLImplementationOSMesaGL: | 52 case kGLImplementationOSMesaGL: |
50 case kGLImplementationMockGL: | 53 case kGLImplementationMockGL: |
51 return true; | 54 return true; |
52 default: | 55 default: |
53 return false; | 56 return false; |
54 } | 57 } |
(...skipping 29 matching lines...) Expand all Loading... |
84 } | 87 } |
85 | 88 |
86 void ClearGLBindingsPlatform() { | 89 void ClearGLBindingsPlatform() { |
87 ClearGLBindingsEGL(); | 90 ClearGLBindingsEGL(); |
88 ClearGLBindingsGL(); | 91 ClearGLBindingsGL(); |
89 ClearGLBindingsOSMESA(); | 92 ClearGLBindingsOSMESA(); |
90 } | 93 } |
91 | 94 |
92 } // namespace init | 95 } // namespace init |
93 } // namespace gl | 96 } // namespace gl |
OLD | NEW |