| 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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 392 |
| 393 bool NativeViewGLSurfaceEGL::Resize(const gfx::Size& size) { | 393 bool NativeViewGLSurfaceEGL::Resize(const gfx::Size& size) { |
| 394 if (size == GetSize()) | 394 if (size == GetSize()) |
| 395 return true; | 395 return true; |
| 396 | 396 |
| 397 GLContext* current_context = GLContext::GetCurrent(); | 397 GLContext* current_context = GLContext::GetCurrent(); |
| 398 bool was_current = current_context && current_context->IsCurrent(this); | 398 bool was_current = current_context && current_context->IsCurrent(this); |
| 399 if (was_current) | 399 if (was_current) |
| 400 current_context->ReleaseCurrent(this); | 400 current_context->ReleaseCurrent(this); |
| 401 | 401 |
| 402 Destroy(); | 402 Recreate(); |
| 403 | |
| 404 if (!Initialize()) { | |
| 405 LOG(ERROR) << "Failed to resize pbuffer."; | |
| 406 return false; | |
| 407 } | |
| 408 | 403 |
| 409 if (was_current) | 404 if (was_current) |
| 410 return current_context->MakeCurrent(this); | 405 return current_context->MakeCurrent(this); |
| 411 return true; | 406 return true; |
| 412 } | 407 } |
| 413 | 408 |
| 409 bool NativeViewGLSurfaceEGL::Recreate() { |
| 410 Destroy(); |
| 411 if (!Initialize()) { |
| 412 LOG(ERROR) << "Failed to create surface."; |
| 413 return false; |
| 414 } |
| 415 return true; |
| 416 } |
| 417 |
| 418 bool NativeViewGLSurfaceEGL::RecreateOnMakeCurrent() { |
| 419 return recreate_on_make_current_; |
| 420 } |
| 421 |
| 422 void NativeViewGLSurfaceEGL::SetRecreateOnMakeCurrent(bool recreate) { |
| 423 recreate_on_make_current_ = recreate; |
| 424 } |
| 425 |
| 414 EGLSurface NativeViewGLSurfaceEGL::GetHandle() { | 426 EGLSurface NativeViewGLSurfaceEGL::GetHandle() { |
| 415 return surface_; | 427 return surface_; |
| 416 } | 428 } |
| 417 | 429 |
| 418 std::string NativeViewGLSurfaceEGL::GetExtensions() { | 430 std::string NativeViewGLSurfaceEGL::GetExtensions() { |
| 419 std::string extensions = GLSurface::GetExtensions(); | 431 std::string extensions = GLSurface::GetExtensions(); |
| 420 if (supports_post_sub_buffer_) { | 432 if (supports_post_sub_buffer_) { |
| 421 extensions += extensions.empty() ? "" : " "; | 433 extensions += extensions.empty() ? "" : " "; |
| 422 extensions += "GL_CHROMIUM_post_sub_buffer"; | 434 extensions += "GL_CHROMIUM_post_sub_buffer"; |
| 423 } | 435 } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 | 582 |
| 571 return handle; | 583 return handle; |
| 572 #endif | 584 #endif |
| 573 } | 585 } |
| 574 | 586 |
| 575 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { | 587 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { |
| 576 Destroy(); | 588 Destroy(); |
| 577 } | 589 } |
| 578 | 590 |
| 579 } // namespace gfx | 591 } // namespace gfx |
| OLD | NEW |