OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ozone/common/egl_util.h" | 5 #include "ui/ozone/common/egl_util.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "ui/gl/egl_util.h" |
| 9 #include "ui/gl/gl_bindings.h" |
8 | 10 |
9 namespace ui { | 11 namespace ui { |
10 namespace { | 12 namespace { |
11 | 13 |
12 const char kDefaultEglSoname[] = "libEGL.so.1"; | 14 const char kDefaultEglSoname[] = "libEGL.so.1"; |
13 const char kDefaultGlesSoname[] = "libGLESv2.so.2"; | 15 const char kDefaultGlesSoname[] = "libGLESv2.so.2"; |
14 | 16 |
15 } // namespace | 17 } // namespace |
16 | 18 |
17 bool LoadDefaultEGLGLES2Bindings( | 19 bool LoadDefaultEGLGLES2Bindings( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 return false; | 57 return false; |
56 } | 58 } |
57 | 59 |
58 set_gl_get_proc_address.Run(get_proc_address); | 60 set_gl_get_proc_address.Run(get_proc_address); |
59 add_gl_library.Run(egl_library); | 61 add_gl_library.Run(egl_library); |
60 add_gl_library.Run(gles_library); | 62 add_gl_library.Run(gles_library); |
61 | 63 |
62 return true; | 64 return true; |
63 } | 65 } |
64 | 66 |
| 67 EGLConfig ChooseEGLConfig(EGLDisplay display, const int32_t* attributes) { |
| 68 int32_t num_configs; |
| 69 if (!eglChooseConfig(display, attributes, nullptr, 0, &num_configs)) { |
| 70 LOG(ERROR) << "eglChooseConfig failed with error " |
| 71 << GetLastEGLErrorString(); |
| 72 return nullptr; |
| 73 } |
| 74 |
| 75 if (num_configs == 0) { |
| 76 LOG(ERROR) << "No suitable EGL configs found."; |
| 77 return nullptr; |
| 78 } |
| 79 |
| 80 EGLConfig config; |
| 81 if (!eglChooseConfig(display, attributes, &config, 1, &num_configs)) { |
| 82 LOG(ERROR) << "eglChooseConfig failed with error " |
| 83 << GetLastEGLErrorString(); |
| 84 return nullptr; |
| 85 } |
| 86 return config; |
| 87 } |
| 88 |
65 void* /* EGLConfig */ ChooseEGLConfig(const EglConfigCallbacks& egl, | 89 void* /* EGLConfig */ ChooseEGLConfig(const EglConfigCallbacks& egl, |
66 const int32_t* attributes) { | 90 const int32_t* attributes) { |
67 void* config; | 91 void* config; |
68 int32_t num_configs; | 92 int32_t num_configs; |
69 if (!egl.choose_config.Run(attributes, nullptr, 0, &num_configs)) { | 93 if (!egl.choose_config.Run(attributes, nullptr, 0, &num_configs)) { |
70 LOG(ERROR) << "eglChooseConfig failed with error " | 94 LOG(ERROR) << "eglChooseConfig failed with error " |
71 << egl.get_last_error_string.Run(); | 95 << egl.get_last_error_string.Run(); |
72 return nullptr; | 96 return nullptr; |
73 } | 97 } |
74 | 98 |
75 if (num_configs == 0) { | 99 if (num_configs == 0) { |
76 LOG(ERROR) << "No suitable EGL configs found."; | 100 LOG(ERROR) << "No suitable EGL configs found."; |
77 return nullptr; | 101 return nullptr; |
78 } | 102 } |
79 | 103 |
80 if (!egl.choose_config.Run(attributes, &config, 1, &num_configs)) { | 104 if (!egl.choose_config.Run(attributes, &config, 1, &num_configs)) { |
81 LOG(ERROR) << "eglChooseConfig failed with error " | 105 LOG(ERROR) << "eglChooseConfig failed with error " |
82 << egl.get_last_error_string.Run(); | 106 << egl.get_last_error_string.Run(); |
83 return nullptr; | 107 return nullptr; |
84 } | 108 } |
85 return config; | 109 return config; |
86 } | 110 } |
87 | 111 |
88 } // namespace ui | 112 } // namespace ui |
OLD | NEW |