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 "ui/gl/gl_context_egl.h" | 5 #include "ui/gl/gl_context_egl.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 config_(nullptr), | 33 config_(nullptr), |
34 unbind_fbo_on_makecurrent_(false), | 34 unbind_fbo_on_makecurrent_(false), |
35 swap_interval_(1) { | 35 swap_interval_(1) { |
36 } | 36 } |
37 | 37 |
38 bool GLContextEGL::Initialize( | 38 bool GLContextEGL::Initialize( |
39 GLSurface* compatible_surface, GpuPreference gpu_preference) { | 39 GLSurface* compatible_surface, GpuPreference gpu_preference) { |
40 DCHECK(compatible_surface); | 40 DCHECK(compatible_surface); |
41 DCHECK(!context_); | 41 DCHECK(!context_); |
42 | 42 |
| 43 display_ = compatible_surface->GetDisplay(); |
| 44 config_ = compatible_surface->GetConfig(); |
| 45 |
| 46 EGLint config_renderable_type = 0; |
| 47 if (!eglGetConfigAttrib(display_, config_, EGL_RENDERABLE_TYPE, |
| 48 &config_renderable_type)) { |
| 49 LOG(ERROR) << "eglGetConfigAttrib failed with error " |
| 50 << GetLastEGLErrorString(); |
| 51 return false; |
| 52 } |
| 53 |
43 EGLint context_client_version = 2; | 54 EGLint context_client_version = 2; |
44 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 55 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
45 switches::kEnableUnsafeES3APIs)) { | 56 switches::kEnableUnsafeES3APIs) && |
| 57 (config_renderable_type & EGL_OPENGL_ES3_BIT) != 0) { |
46 context_client_version = 3; | 58 context_client_version = 3; |
47 } | 59 } |
48 | 60 |
49 const EGLint kContextAttributes[] = { | 61 const EGLint kContextAttributes[] = { |
50 EGL_CONTEXT_CLIENT_VERSION, context_client_version, | 62 EGL_CONTEXT_CLIENT_VERSION, context_client_version, |
51 EGL_NONE | 63 EGL_NONE |
52 }; | 64 }; |
53 const EGLint kContextRobustnessAttributes[] = { | 65 const EGLint kContextRobustnessAttributes[] = { |
54 EGL_CONTEXT_CLIENT_VERSION, context_client_version, | 66 EGL_CONTEXT_CLIENT_VERSION, context_client_version, |
55 EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, | 67 EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, |
56 EGL_LOSE_CONTEXT_ON_RESET_EXT, | 68 EGL_LOSE_CONTEXT_ON_RESET_EXT, |
57 EGL_NONE | 69 EGL_NONE |
58 }; | 70 }; |
59 | 71 |
60 display_ = compatible_surface->GetDisplay(); | |
61 config_ = compatible_surface->GetConfig(); | |
62 | |
63 const EGLint* context_attributes = nullptr; | 72 const EGLint* context_attributes = nullptr; |
64 if (GLSurfaceEGL::IsCreateContextRobustnessSupported()) { | 73 if (GLSurfaceEGL::IsCreateContextRobustnessSupported()) { |
65 DVLOG(1) << "EGL_EXT_create_context_robustness supported."; | 74 DVLOG(1) << "EGL_EXT_create_context_robustness supported."; |
66 context_attributes = kContextRobustnessAttributes; | 75 context_attributes = kContextRobustnessAttributes; |
67 } else { | 76 } else { |
68 // At some point we should require the presence of the robustness | 77 // At some point we should require the presence of the robustness |
69 // extension and remove this code path. | 78 // extension and remove this code path. |
70 DVLOG(1) << "EGL_EXT_create_context_robustness NOT supported."; | 79 DVLOG(1) << "EGL_EXT_create_context_robustness NOT supported."; |
71 context_attributes = kContextAttributes; | 80 context_attributes = kContextAttributes; |
72 } | 81 } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 224 |
216 bool GLContextEGL::WasAllocatedUsingRobustnessExtension() { | 225 bool GLContextEGL::WasAllocatedUsingRobustnessExtension() { |
217 return GLSurfaceEGL::IsCreateContextRobustnessSupported(); | 226 return GLSurfaceEGL::IsCreateContextRobustnessSupported(); |
218 } | 227 } |
219 | 228 |
220 GLContextEGL::~GLContextEGL() { | 229 GLContextEGL::~GLContextEGL() { |
221 Destroy(); | 230 Destroy(); |
222 } | 231 } |
223 | 232 |
224 } // namespace gl | 233 } // namespace gl |
OLD | NEW |