OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gfx/gl/gl_surface_egl.h" | 5 #include "ui/gfx/gl/gl_surface_egl.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #if !defined(OS_ANDROID) | 10 #if !defined(OS_ANDROID) |
11 #include "third_party/angle/include/EGL/egl.h" | 11 #include "third_party/angle/include/EGL/egl.h" |
12 #include "third_party/angle/include/EGL/eglext.h" | 12 #include "third_party/angle/include/EGL/eglext.h" |
13 #endif | 13 #endif |
14 #include "ui/gfx/gl/egl_util.h" | 14 #include "ui/gfx/gl/egl_util.h" |
| 15 #include "ui/gfx/gl/gl_context.h" |
15 | 16 |
16 #if defined(OS_ANDROID) | 17 #if defined(OS_ANDROID) |
17 #include <EGL/egl.h> | 18 #include <EGL/egl.h> |
18 #endif | 19 #endif |
19 | 20 |
20 // This header must come after the above third-party include, as | 21 // This header must come after the above third-party include, as |
21 // it brings in #defines that cause conflicts. | 22 // it brings in #defines that cause conflicts. |
22 #include "ui/gfx/gl/gl_bindings.h" | 23 #include "ui/gfx/gl/gl_bindings.h" |
23 | 24 |
24 #if defined(USE_X11) && !defined(USE_WAYLAND) | 25 #if defined(USE_X11) && !defined(USE_WAYLAND) |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 } | 351 } |
351 | 352 |
352 gfx::Size PbufferGLSurfaceEGL::GetSize() { | 353 gfx::Size PbufferGLSurfaceEGL::GetSize() { |
353 return size_; | 354 return size_; |
354 } | 355 } |
355 | 356 |
356 bool PbufferGLSurfaceEGL::Resize(const gfx::Size& size) { | 357 bool PbufferGLSurfaceEGL::Resize(const gfx::Size& size) { |
357 if (size == size_) | 358 if (size == size_) |
358 return true; | 359 return true; |
359 | 360 |
| 361 GLContext* current_context = GLContext::GetCurrent(); |
| 362 bool was_current = current_context && current_context->IsCurrent(this); |
| 363 if (was_current) |
| 364 current_context->ReleaseCurrent(this); |
| 365 |
360 Destroy(); | 366 Destroy(); |
| 367 |
361 size_ = size; | 368 size_ = size; |
362 return Initialize(); | 369 |
| 370 if (!Initialize()) |
| 371 return false; |
| 372 |
| 373 if (was_current) |
| 374 return current_context->MakeCurrent(this); |
| 375 |
| 376 return true; |
363 } | 377 } |
364 | 378 |
365 EGLSurface PbufferGLSurfaceEGL::GetHandle() { | 379 EGLSurface PbufferGLSurfaceEGL::GetHandle() { |
366 return surface_; | 380 return surface_; |
367 } | 381 } |
368 | 382 |
369 void* PbufferGLSurfaceEGL::GetShareHandle() { | 383 void* PbufferGLSurfaceEGL::GetShareHandle() { |
370 #if defined(OS_ANDROID) | 384 #if defined(OS_ANDROID) |
371 NOTREACHED(); | 385 NOTREACHED(); |
372 return NULL; | 386 return NULL; |
373 #else | 387 #else |
374 const char* extensions = eglQueryString(g_display, EGL_EXTENSIONS); | 388 const char* extensions = eglQueryString(g_display, EGL_EXTENSIONS); |
375 if (!strstr(extensions, "EGL_ANGLE_query_surface_pointer")) | 389 if (!strstr(extensions, "EGL_ANGLE_query_surface_pointer")) |
376 return NULL; | 390 return NULL; |
377 | 391 |
378 void* handle; | 392 void* handle; |
379 if (!eglQuerySurfacePointerANGLE(g_display, | 393 if (!eglQuerySurfacePointerANGLE(g_display, |
380 GetHandle(), | 394 GetHandle(), |
381 EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, | 395 EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, |
382 &handle)) { | 396 &handle)) { |
383 return NULL; | 397 return NULL; |
384 } | 398 } |
385 | 399 |
386 return handle; | 400 return handle; |
387 #endif | 401 #endif |
388 } | 402 } |
389 | 403 |
390 } // namespace gfx | 404 } // namespace gfx |
OLD | NEW |