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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 return g_egl_create_context_robustness_supported; | 214 return g_egl_create_context_robustness_supported; |
215 } | 215 } |
216 | 216 |
217 GLSurfaceEGL::~GLSurfaceEGL() {} | 217 GLSurfaceEGL::~GLSurfaceEGL() {} |
218 | 218 |
219 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software, | 219 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software, |
220 gfx::AcceleratedWidget window) | 220 gfx::AcceleratedWidget window) |
221 : window_(window), | 221 : window_(window), |
222 surface_(NULL), | 222 surface_(NULL), |
223 supports_post_sub_buffer_(false), | 223 supports_post_sub_buffer_(false), |
224 config_(NULL), | 224 config_(NULL) { |
225 recreate_on_make_current_(false) { | |
226 software_ = software; | 225 software_ = software; |
227 #if defined(OS_ANDROID) | 226 #if defined(OS_ANDROID) |
228 if (window) | 227 if (window) |
229 ANativeWindow_acquire(window); | 228 ANativeWindow_acquire(window); |
230 #endif | 229 #endif |
231 } | 230 } |
232 | 231 |
233 bool NativeViewGLSurfaceEGL::Initialize() { | 232 bool NativeViewGLSurfaceEGL::Initialize() { |
234 DCHECK(!surface_); | 233 DCHECK(!surface_); |
235 | 234 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 | 392 |
394 bool NativeViewGLSurfaceEGL::Resize(const gfx::Size& size) { | 393 bool NativeViewGLSurfaceEGL::Resize(const gfx::Size& size) { |
395 if (size == GetSize()) | 394 if (size == GetSize()) |
396 return true; | 395 return true; |
397 | 396 |
398 GLContext* current_context = GLContext::GetCurrent(); | 397 GLContext* current_context = GLContext::GetCurrent(); |
399 bool was_current = current_context && current_context->IsCurrent(this); | 398 bool was_current = current_context && current_context->IsCurrent(this); |
400 if (was_current) | 399 if (was_current) |
401 current_context->ReleaseCurrent(this); | 400 current_context->ReleaseCurrent(this); |
402 | 401 |
403 Recreate(); | 402 Destroy(); |
| 403 |
| 404 if (!Initialize()) { |
| 405 LOG(ERROR) << "Failed to resize pbuffer."; |
| 406 return false; |
| 407 } |
404 | 408 |
405 if (was_current) | 409 if (was_current) |
406 return current_context->MakeCurrent(this); | 410 return current_context->MakeCurrent(this); |
407 return true; | 411 return true; |
408 } | 412 } |
409 | 413 |
410 bool NativeViewGLSurfaceEGL::Recreate() { | |
411 Destroy(); | |
412 if (!Initialize()) { | |
413 LOG(ERROR) << "Failed to create surface."; | |
414 return false; | |
415 } | |
416 return true; | |
417 } | |
418 | |
419 bool NativeViewGLSurfaceEGL::RecreateOnMakeCurrent() { | |
420 return recreate_on_make_current_; | |
421 } | |
422 | |
423 void NativeViewGLSurfaceEGL::SetRecreateOnMakeCurrent(bool recreate) { | |
424 recreate_on_make_current_ = recreate; | |
425 } | |
426 | |
427 EGLSurface NativeViewGLSurfaceEGL::GetHandle() { | 414 EGLSurface NativeViewGLSurfaceEGL::GetHandle() { |
428 return surface_; | 415 return surface_; |
429 } | 416 } |
430 | 417 |
431 std::string NativeViewGLSurfaceEGL::GetExtensions() { | 418 std::string NativeViewGLSurfaceEGL::GetExtensions() { |
432 std::string extensions = GLSurface::GetExtensions(); | 419 std::string extensions = GLSurface::GetExtensions(); |
433 if (supports_post_sub_buffer_) { | 420 if (supports_post_sub_buffer_) { |
434 extensions += extensions.empty() ? "" : " "; | 421 extensions += extensions.empty() ? "" : " "; |
435 extensions += "GL_CHROMIUM_post_sub_buffer"; | 422 extensions += "GL_CHROMIUM_post_sub_buffer"; |
436 } | 423 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 | 570 |
584 return handle; | 571 return handle; |
585 #endif | 572 #endif |
586 } | 573 } |
587 | 574 |
588 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { | 575 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { |
589 Destroy(); | 576 Destroy(); |
590 } | 577 } |
591 | 578 |
592 } // namespace gfx | 579 } // namespace gfx |
OLD | NEW |