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_surface_egl.h" | 5 #include "ui/gl/gl_surface_egl.h" |
6 | 6 |
7 #if defined(OS_ANDROID) | 7 #if defined(OS_ANDROID) |
8 #include <android/native_window_jni.h> | 8 #include <android/native_window_jni.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 #if !defined(EGL_OPENGL_ES3_BIT) | 40 #if !defined(EGL_OPENGL_ES3_BIT) |
41 #define EGL_OPENGL_ES3_BIT 0x00000040 | 41 #define EGL_OPENGL_ES3_BIT 0x00000040 |
42 #endif | 42 #endif |
43 | 43 |
44 using ui::GetLastEGLErrorString; | 44 using ui::GetLastEGLErrorString; |
45 | 45 |
46 namespace gfx { | 46 namespace gfx { |
47 | 47 |
48 namespace { | 48 namespace { |
49 | 49 |
50 EGLConfig g_config; | |
51 EGLDisplay g_display; | 50 EGLDisplay g_display; |
52 EGLNativeDisplayType g_native_display_type; | 51 EGLNativeDisplayType g_native_display_type; |
53 | 52 |
54 // In the Cast environment, we need to destroy the EGLNativeDisplayType and | 53 // In the Cast environment, we need to destroy the EGLNativeDisplayType and |
55 // EGLDisplay returned by the GPU platform when we switch to an external app | 54 // EGLDisplay returned by the GPU platform when we switch to an external app |
56 // which will temporarily own all screen and GPU resources. | 55 // which will temporarily own all screen and GPU resources. |
57 // Even though Chromium is still in the background. | 56 // Even though Chromium is still in the background. |
58 // As such, it must be reinitialized each time we come back to the foreground. | 57 // As such, it must be reinitialized each time we come back to the foreground. |
59 bool g_initialized = false; | 58 bool g_initialized = false; |
60 int g_num_surfaces = 0; | 59 int g_num_surfaces = 0; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 103 |
105 void DeinitializeEgl() { | 104 void DeinitializeEgl() { |
106 if (g_initialized) { | 105 if (g_initialized) { |
107 g_initialized = false; | 106 g_initialized = false; |
108 eglTerminate(g_display); | 107 eglTerminate(g_display); |
109 } | 108 } |
110 } | 109 } |
111 | 110 |
112 } // namespace | 111 } // namespace |
113 | 112 |
114 GLSurfaceEGL::GLSurfaceEGL() { | 113 GLSurfaceEGL::GLSurfaceEGL( |
| 114 const gfx::SurfaceConfiguration requested_configuration) |
| 115 : GLSurface(requested_configuration) { |
115 ++g_num_surfaces; | 116 ++g_num_surfaces; |
116 if (!g_initialized) { | 117 if (!g_initialized) { |
117 bool result = GLSurfaceEGL::InitializeOneOff(); | 118 bool result = GLSurfaceEGL::InitializeOneOff(); |
118 DCHECK(result); | 119 DCHECK(result); |
119 DCHECK(g_initialized); | 120 DCHECK(g_initialized); |
120 } | 121 } |
121 } | 122 } |
122 | 123 |
123 bool GLSurfaceEGL::InitializeOneOff() { | 124 void* GetEGLConfig(const EGLNativeWindowType window, |
124 if (g_initialized) | 125 const gfx::SurfaceConfiguration configuration, |
125 return true; | 126 bool allow_window_bit) { |
126 | |
127 g_native_display_type = GetPlatformDefaultEGLNativeDisplay(); | |
128 | |
129 g_display = eglGetDisplay(g_native_display_type); | |
130 | |
131 if (!g_display) { | |
132 LOG(ERROR) << "eglGetDisplay failed with error " << GetLastEGLErrorString(); | |
133 return false; | |
134 } | |
135 | |
136 if (!eglInitialize(g_display, NULL, NULL)) { | |
137 LOG(ERROR) << "eglInitialize failed with error " << GetLastEGLErrorString(); | |
138 return false; | |
139 } | |
140 | |
141 // Choose an EGL configuration. | 127 // Choose an EGL configuration. |
142 // On X this is only used for PBuffer surfaces. | 128 // On X this is only used for PBuffer surfaces. |
| 129 EGLConfig config = {0}; |
| 130 |
| 131 #if defined(USE_X11) |
| 132 XWindowAttributes win_attribs; |
| 133 if (!XGetWindowAttributes(GLSurfaceEGL::GetNativeDisplay(), |
| 134 window, |
| 135 &win_attribs)) { |
| 136 return nullptr; |
| 137 } |
| 138 #endif |
| 139 |
143 EGLint renderable_type = EGL_OPENGL_ES2_BIT; | 140 EGLint renderable_type = EGL_OPENGL_ES2_BIT; |
144 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 141 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
145 switches::kEnableUnsafeES3APIs)) { | 142 switches::kEnableUnsafeES3APIs)) { |
146 renderable_type = EGL_OPENGL_ES3_BIT; | 143 renderable_type = EGL_OPENGL_ES3_BIT; |
147 } | 144 } |
148 const EGLint kConfigAttribs[] = { | 145 EGLint config_attribs[] = { |
149 EGL_BUFFER_SIZE, 32, | 146 EGL_BUFFER_SIZE, configuration.alpha_bits + |
150 EGL_ALPHA_SIZE, 8, | 147 configuration.red_bits + |
151 EGL_BLUE_SIZE, 8, | 148 configuration.green_bits + |
152 EGL_GREEN_SIZE, 8, | 149 configuration.blue_bits, |
153 EGL_RED_SIZE, 8, | 150 EGL_ALPHA_SIZE, configuration.alpha_bits, |
| 151 EGL_BLUE_SIZE, configuration.blue_bits, |
| 152 EGL_GREEN_SIZE, configuration.green_bits, |
| 153 EGL_RED_SIZE, configuration.red_bits, |
| 154 EGL_DEPTH_SIZE, configuration.depth_bits, |
| 155 EGL_STENCIL_SIZE, configuration.stencil_bits, |
154 EGL_RENDERABLE_TYPE, renderable_type, | 156 EGL_RENDERABLE_TYPE, renderable_type, |
155 EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, | 157 EGL_SURFACE_TYPE, (allow_window_bit ? |
| 158 (EGL_WINDOW_BIT | EGL_PBUFFER_BIT) : |
| 159 EGL_PBUFFER_BIT), |
156 EGL_NONE | 160 EGL_NONE |
157 }; | 161 }; |
158 | 162 |
159 #if defined(USE_OZONE) | 163 #if defined(USE_OZONE) |
160 const EGLint* config_attribs = | 164 config_attribs = |
161 ui::SurfaceFactoryOzone::GetInstance()->GetEGLSurfaceProperties( | 165 ui::SurfaceFactoryOzone::GetInstance()->GetEGLSurfaceProperties( |
162 kConfigAttribs); | 166 config_attribs); |
163 #else | 167 #elif defined(USE_X11) |
164 const EGLint* config_attribs = kConfigAttribs; | 168 // Try matching the window depth with an alpha channel, |
| 169 // because we're worried the destination alpha width could |
| 170 // constrain blending precision. |
| 171 const int kBufferSizeOffset = 1; |
| 172 const int kAlphaSizeOffset = 3; |
| 173 config_attribs[kBufferSizeOffset] = win_attribs.depth; |
165 #endif | 174 #endif |
166 | 175 |
167 EGLint num_configs; | 176 EGLint num_configs; |
168 if (!eglChooseConfig(g_display, | 177 if (!eglChooseConfig(g_display, |
169 config_attribs, | 178 config_attribs, |
170 NULL, | 179 NULL, |
171 0, | 180 0, |
172 &num_configs)) { | 181 &num_configs)) { |
173 LOG(ERROR) << "eglChooseConfig failed with error " | 182 LOG(ERROR) << "eglChooseConfig failed with error " |
174 << GetLastEGLErrorString(); | 183 << GetLastEGLErrorString(); |
175 return false; | 184 return nullptr; |
176 } | |
177 | |
178 if (num_configs == 0) { | |
179 LOG(ERROR) << "No suitable EGL configs found."; | |
180 return false; | |
181 } | 185 } |
182 | 186 |
183 if (!eglChooseConfig(g_display, | 187 if (!eglChooseConfig(g_display, |
184 config_attribs, | 188 config_attribs, |
185 &g_config, | 189 &config, |
186 1, | 190 1, |
187 &num_configs)) { | 191 &num_configs)) { |
188 LOG(ERROR) << "eglChooseConfig failed with error " | 192 LOG(ERROR) << "eglChooseConfig failed with error " |
189 << GetLastEGLErrorString(); | 193 << GetLastEGLErrorString(); |
| 194 return nullptr; |
| 195 } |
| 196 |
| 197 #if defined(USE_X11) |
| 198 if (num_configs) { |
| 199 EGLint config_depth; |
| 200 if (!eglGetConfigAttrib(g_display, |
| 201 config, |
| 202 EGL_BUFFER_SIZE, |
| 203 &config_depth)) { |
| 204 LOG(ERROR) << "eglGetConfigAttrib failed with error " |
| 205 << GetLastEGLErrorString(); |
| 206 return nullptr; |
| 207 } |
| 208 |
| 209 if (config_depth == win_attribs.depth) { |
| 210 return config; |
| 211 } |
| 212 } |
| 213 |
| 214 // Try without an alpha channel. |
| 215 config_attribs[kAlphaSizeOffset] = 0; |
| 216 if (!eglChooseConfig(g_display, |
| 217 config_attribs, |
| 218 &config, |
| 219 1, |
| 220 &num_configs)) { |
| 221 LOG(ERROR) << "eglChooseConfig failed with error " |
| 222 << GetLastEGLErrorString(); |
| 223 return nullptr; |
| 224 } |
| 225 #endif |
| 226 |
| 227 if (num_configs == 0) { |
| 228 LOG(ERROR) << "No suitable EGL configs found."; |
| 229 return nullptr; |
| 230 } |
| 231 |
| 232 return config; |
| 233 } |
| 234 |
| 235 bool GLSurfaceEGL::InitializeOneOff() { |
| 236 if (g_initialized) |
| 237 return true; |
| 238 |
| 239 g_native_display_type = GetPlatformDefaultEGLNativeDisplay(); |
| 240 |
| 241 g_display = eglGetDisplay(g_native_display_type); |
| 242 |
| 243 if (!g_display) { |
| 244 LOG(ERROR) << "eglGetDisplay failed with error " << GetLastEGLErrorString(); |
190 return false; | 245 return false; |
191 } | 246 } |
192 | 247 |
| 248 if (!eglInitialize(g_display, NULL, NULL)) { |
| 249 LOG(ERROR) << "eglInitialize failed with error " << GetLastEGLErrorString(); |
| 250 return false; |
| 251 } |
| 252 |
193 g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS); | 253 g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS); |
194 g_egl_create_context_robustness_supported = | 254 g_egl_create_context_robustness_supported = |
195 HasEGLExtension("EGL_EXT_create_context_robustness"); | 255 HasEGLExtension("EGL_EXT_create_context_robustness"); |
196 g_egl_sync_control_supported = | 256 g_egl_sync_control_supported = |
197 HasEGLExtension("EGL_CHROMIUM_sync_control"); | 257 HasEGLExtension("EGL_CHROMIUM_sync_control"); |
198 g_egl_window_fixed_size_supported = | 258 g_egl_window_fixed_size_supported = |
199 HasEGLExtension("EGL_ANGLE_window_fixed_size"); | 259 HasEGLExtension("EGL_ANGLE_window_fixed_size"); |
200 | 260 |
201 // We always succeed beyond this point so set g_initialized here to avoid | 261 // We always succeed beyond this point so set g_initialized here to avoid |
202 // infinite recursion through CreateGLContext and GetDisplay | 262 // infinite recursion through CreateGLContext and GetDisplay |
203 // if g_egl_surfaceless_context_supported. | 263 // if g_egl_surfaceless_context_supported. |
204 g_initialized = true; | 264 g_initialized = true; |
205 g_terminate_pending = false; | 265 g_terminate_pending = false; |
206 | 266 |
207 // TODO(oetuaho@nvidia.com): Surfaceless is disabled on Android as a temporary | 267 // TODO(oetuaho@nvidia.com): Surfaceless is disabled on Android as a temporary |
208 // workaround, since code written for Android WebView takes different paths | 268 // workaround, since code written for Android WebView takes different paths |
209 // based on whether GL surface objects have underlying EGL surface handles, | 269 // based on whether GL surface objects have underlying EGL surface handles, |
210 // conflicting with the use of surfaceless. See https://crbug.com/382349 | 270 // conflicting with the use of surfaceless. See https://crbug.com/382349 |
211 #if defined(OS_ANDROID) | 271 #if defined(OS_ANDROID) |
212 DCHECK(!g_egl_surfaceless_context_supported); | 272 DCHECK(!g_egl_surfaceless_context_supported); |
213 #else | 273 #else |
214 // Check if SurfacelessEGL is supported. | 274 // Check if SurfacelessEGL is supported. |
215 g_egl_surfaceless_context_supported = | 275 g_egl_surfaceless_context_supported = |
216 HasEGLExtension("EGL_KHR_surfaceless_context"); | 276 HasEGLExtension("EGL_KHR_surfaceless_context"); |
217 if (g_egl_surfaceless_context_supported) { | 277 if (g_egl_surfaceless_context_supported) { |
218 // EGL_KHR_surfaceless_context is supported but ensure | 278 // EGL_KHR_surfaceless_context is supported but ensure |
219 // GL_OES_surfaceless_context is also supported. We need a current context | 279 // GL_OES_surfaceless_context is also supported. We need a current context |
220 // to query for supported GL extensions. | 280 // to query for supported GL extensions. |
221 scoped_refptr<GLSurface> surface = new SurfacelessEGL(Size(1, 1)); | 281 scoped_refptr<GLSurface> surface = new SurfacelessEGL( |
| 282 Size(1, 1), SurfaceConfiguration()); |
222 scoped_refptr<GLContext> context = GLContext::CreateGLContext( | 283 scoped_refptr<GLContext> context = GLContext::CreateGLContext( |
223 NULL, surface.get(), PreferIntegratedGpu); | 284 NULL, surface.get(), PreferIntegratedGpu); |
224 if (!context->MakeCurrent(surface.get())) | 285 if (!context->MakeCurrent(surface.get())) |
225 g_egl_surfaceless_context_supported = false; | 286 g_egl_surfaceless_context_supported = false; |
226 | 287 |
227 // Ensure context supports GL_OES_surfaceless_context. | 288 // Ensure context supports GL_OES_surfaceless_context. |
228 if (g_egl_surfaceless_context_supported) { | 289 if (g_egl_surfaceless_context_supported) { |
229 g_egl_surfaceless_context_supported = context->HasExtension( | 290 g_egl_surfaceless_context_supported = context->HasExtension( |
230 "GL_OES_surfaceless_context"); | 291 "GL_OES_surfaceless_context"); |
231 context->ReleaseCurrent(surface.get()); | 292 context->ReleaseCurrent(surface.get()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 } | 346 } |
286 | 347 |
287 GLSurfaceEGL::~GLSurfaceEGL() { | 348 GLSurfaceEGL::~GLSurfaceEGL() { |
288 DCHECK_GT(g_num_surfaces, 0) << "Bad surface count"; | 349 DCHECK_GT(g_num_surfaces, 0) << "Bad surface count"; |
289 if (--g_num_surfaces == 0 && g_terminate_pending) { | 350 if (--g_num_surfaces == 0 && g_terminate_pending) { |
290 DeinitializeEgl(); | 351 DeinitializeEgl(); |
291 g_terminate_pending = false; | 352 g_terminate_pending = false; |
292 } | 353 } |
293 } | 354 } |
294 | 355 |
295 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(EGLNativeWindowType window) | 356 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL( |
296 : window_(window), | 357 EGLNativeWindowType window, |
| 358 const gfx::SurfaceConfiguration requested_configuration) |
| 359 : GLSurfaceEGL(requested_configuration), |
| 360 window_(window), |
297 surface_(NULL), | 361 surface_(NULL), |
298 supports_post_sub_buffer_(false), | 362 supports_post_sub_buffer_(false), |
299 config_(NULL), | 363 config_(NULL), |
300 size_(1, 1), | 364 size_(1, 1), |
301 swap_interval_(1) { | 365 swap_interval_(1) { |
302 #if defined(OS_ANDROID) | 366 #if defined(OS_ANDROID) |
303 if (window) | 367 if (window) |
304 ANativeWindow_acquire(window); | 368 ANativeWindow_acquire(window); |
305 #endif | 369 #endif |
306 } | 370 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 if (surface_) { | 428 if (surface_) { |
365 if (!eglDestroySurface(GetDisplay(), surface_)) { | 429 if (!eglDestroySurface(GetDisplay(), surface_)) { |
366 LOG(ERROR) << "eglDestroySurface failed with error " | 430 LOG(ERROR) << "eglDestroySurface failed with error " |
367 << GetLastEGLErrorString(); | 431 << GetLastEGLErrorString(); |
368 } | 432 } |
369 surface_ = NULL; | 433 surface_ = NULL; |
370 } | 434 } |
371 } | 435 } |
372 | 436 |
373 EGLConfig NativeViewGLSurfaceEGL::GetConfig() { | 437 EGLConfig NativeViewGLSurfaceEGL::GetConfig() { |
374 #if !defined(USE_X11) | |
375 return g_config; | |
376 #else | |
377 if (!config_) { | 438 if (!config_) { |
378 // Get a config compatible with the window | |
379 DCHECK(window_); | 439 DCHECK(window_); |
380 XWindowAttributes win_attribs; | 440 config_ = GetEGLConfig(window_, this->get_surface_configuration(), true); |
381 if (!XGetWindowAttributes(GetNativeDisplay(), window_, &win_attribs)) { | |
382 return NULL; | |
383 } | |
384 | |
385 // Try matching the window depth with an alpha channel, | |
386 // because we're worried the destination alpha width could | |
387 // constrain blending precision. | |
388 const int kBufferSizeOffset = 1; | |
389 const int kAlphaSizeOffset = 3; | |
390 EGLint config_attribs[] = { | |
391 EGL_BUFFER_SIZE, ~0, | |
392 EGL_ALPHA_SIZE, 8, | |
393 EGL_BLUE_SIZE, 8, | |
394 EGL_GREEN_SIZE, 8, | |
395 EGL_RED_SIZE, 8, | |
396 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, | |
397 EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, | |
398 EGL_NONE | |
399 }; | |
400 config_attribs[kBufferSizeOffset] = win_attribs.depth; | |
401 | |
402 EGLint num_configs; | |
403 if (!eglChooseConfig(g_display, | |
404 config_attribs, | |
405 &config_, | |
406 1, | |
407 &num_configs)) { | |
408 LOG(ERROR) << "eglChooseConfig failed with error " | |
409 << GetLastEGLErrorString(); | |
410 return NULL; | |
411 } | |
412 | |
413 if (num_configs) { | |
414 EGLint config_depth; | |
415 if (!eglGetConfigAttrib(g_display, | |
416 config_, | |
417 EGL_BUFFER_SIZE, | |
418 &config_depth)) { | |
419 LOG(ERROR) << "eglGetConfigAttrib failed with error " | |
420 << GetLastEGLErrorString(); | |
421 return NULL; | |
422 } | |
423 | |
424 if (config_depth == win_attribs.depth) { | |
425 return config_; | |
426 } | |
427 } | |
428 | |
429 // Try without an alpha channel. | |
430 config_attribs[kAlphaSizeOffset] = 0; | |
431 if (!eglChooseConfig(g_display, | |
432 config_attribs, | |
433 &config_, | |
434 1, | |
435 &num_configs)) { | |
436 LOG(ERROR) << "eglChooseConfig failed with error " | |
437 << GetLastEGLErrorString(); | |
438 return NULL; | |
439 } | |
440 | |
441 if (num_configs == 0) { | |
442 LOG(ERROR) << "No suitable EGL configs found."; | |
443 return NULL; | |
444 } | |
445 } | 441 } |
446 return config_; | 442 return config_; |
447 #endif | |
448 } | 443 } |
449 | 444 |
450 bool NativeViewGLSurfaceEGL::IsOffscreen() { | 445 bool NativeViewGLSurfaceEGL::IsOffscreen() { |
451 return false; | 446 return false; |
452 } | 447 } |
453 | 448 |
454 bool NativeViewGLSurfaceEGL::SwapBuffers() { | 449 bool NativeViewGLSurfaceEGL::SwapBuffers() { |
455 TRACE_EVENT2("gpu", "NativeViewGLSurfaceEGL:RealSwapBuffers", | 450 TRACE_EVENT2("gpu", "NativeViewGLSurfaceEGL:RealSwapBuffers", |
456 "width", GetSize().width(), | 451 "width", GetSize().width(), |
457 "height", GetSize().height()); | 452 "height", GetSize().height()); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 } | 536 } |
542 | 537 |
543 NativeViewGLSurfaceEGL::~NativeViewGLSurfaceEGL() { | 538 NativeViewGLSurfaceEGL::~NativeViewGLSurfaceEGL() { |
544 Destroy(); | 539 Destroy(); |
545 #if defined(OS_ANDROID) | 540 #if defined(OS_ANDROID) |
546 if (window_) | 541 if (window_) |
547 ANativeWindow_release(window_); | 542 ANativeWindow_release(window_); |
548 #endif | 543 #endif |
549 } | 544 } |
550 | 545 |
551 PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(const gfx::Size& size) | 546 PbufferGLSurfaceEGL::PbufferGLSurfaceEGL( |
552 : size_(size), | 547 const gfx::Size& size, |
553 surface_(NULL) { | 548 const gfx::SurfaceConfiguration requested_configuration) |
| 549 : GLSurfaceEGL(requested_configuration), |
| 550 size_(size), |
| 551 surface_(nullptr), |
| 552 config_(nullptr) { |
554 // Some implementations of Pbuffer do not support having a 0 size. For such | 553 // Some implementations of Pbuffer do not support having a 0 size. For such |
555 // cases use a (1, 1) surface. | 554 // cases use a (1, 1) surface. |
556 if (size_.GetArea() == 0) | 555 if (size_.GetArea() == 0) |
557 size_.SetSize(1, 1); | 556 size_.SetSize(1, 1); |
558 } | 557 } |
559 | 558 |
560 bool PbufferGLSurfaceEGL::Initialize() { | 559 bool PbufferGLSurfaceEGL::Initialize() { |
561 EGLSurface old_surface = surface_; | 560 EGLSurface old_surface = surface_; |
562 | 561 |
563 EGLDisplay display = GetDisplay(); | 562 EGLDisplay display = GetDisplay(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 if (surface_) { | 595 if (surface_) { |
597 if (!eglDestroySurface(GetDisplay(), surface_)) { | 596 if (!eglDestroySurface(GetDisplay(), surface_)) { |
598 LOG(ERROR) << "eglDestroySurface failed with error " | 597 LOG(ERROR) << "eglDestroySurface failed with error " |
599 << GetLastEGLErrorString(); | 598 << GetLastEGLErrorString(); |
600 } | 599 } |
601 surface_ = NULL; | 600 surface_ = NULL; |
602 } | 601 } |
603 } | 602 } |
604 | 603 |
605 EGLConfig PbufferGLSurfaceEGL::GetConfig() { | 604 EGLConfig PbufferGLSurfaceEGL::GetConfig() { |
606 return g_config; | 605 if (!config_) { |
| 606 config_ = GetEGLConfig((EGLNativeWindowType)nullptr, |
| 607 this->get_surface_configuration(), |
| 608 false); |
| 609 } |
| 610 return config_; |
607 } | 611 } |
608 | 612 |
609 bool PbufferGLSurfaceEGL::IsOffscreen() { | 613 bool PbufferGLSurfaceEGL::IsOffscreen() { |
610 return true; | 614 return true; |
611 } | 615 } |
612 | 616 |
613 bool PbufferGLSurfaceEGL::SwapBuffers() { | 617 bool PbufferGLSurfaceEGL::SwapBuffers() { |
614 NOTREACHED() << "Attempted to call SwapBuffers on a PbufferGLSurfaceEGL."; | 618 NOTREACHED() << "Attempted to call SwapBuffers on a PbufferGLSurfaceEGL."; |
615 return false; | 619 return false; |
616 } | 620 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 } | 670 } |
667 | 671 |
668 return handle; | 672 return handle; |
669 #endif | 673 #endif |
670 } | 674 } |
671 | 675 |
672 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { | 676 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { |
673 Destroy(); | 677 Destroy(); |
674 } | 678 } |
675 | 679 |
676 SurfacelessEGL::SurfacelessEGL(const gfx::Size& size) | 680 SurfacelessEGL::SurfacelessEGL( |
677 : size_(size) { | 681 const gfx::Size& size, |
| 682 const gfx::SurfaceConfiguration requested_configuration) |
| 683 : GLSurfaceEGL(requested_configuration), size_(size) { |
678 } | 684 } |
679 | 685 |
680 bool SurfacelessEGL::Initialize() { | 686 bool SurfacelessEGL::Initialize() { |
681 return true; | 687 return true; |
682 } | 688 } |
683 | 689 |
684 void SurfacelessEGL::Destroy() { | 690 void SurfacelessEGL::Destroy() { |
685 } | 691 } |
686 | 692 |
687 EGLConfig SurfacelessEGL::GetConfig() { | 693 EGLConfig SurfacelessEGL::GetConfig() { |
688 return g_config; | 694 return NULL; |
689 } | 695 } |
690 | 696 |
691 bool SurfacelessEGL::IsOffscreen() { | 697 bool SurfacelessEGL::IsOffscreen() { |
692 return true; | 698 return true; |
693 } | 699 } |
694 | 700 |
695 bool SurfacelessEGL::IsSurfaceless() const { | 701 bool SurfacelessEGL::IsSurfaceless() const { |
696 return true; | 702 return true; |
697 } | 703 } |
698 | 704 |
(...skipping 16 matching lines...) Expand all Loading... |
715 } | 721 } |
716 | 722 |
717 void* SurfacelessEGL::GetShareHandle() { | 723 void* SurfacelessEGL::GetShareHandle() { |
718 return NULL; | 724 return NULL; |
719 } | 725 } |
720 | 726 |
721 SurfacelessEGL::~SurfacelessEGL() { | 727 SurfacelessEGL::~SurfacelessEGL() { |
722 } | 728 } |
723 | 729 |
724 } // namespace gfx | 730 } // namespace gfx |
OLD | NEW |