Chromium Code Reviews| 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) | |
| 8 #include <android/native_window_jni.h> | |
| 9 #endif | |
| 10 | |
| 7 #include "base/logging.h" | 11 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 10 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 11 #include "ui/gl/egl_util.h" | 15 #include "ui/gl/egl_util.h" |
| 12 #include "ui/gl/gl_context.h" | 16 #include "ui/gl/gl_context.h" |
| 13 | 17 |
| 14 #if defined(USE_X11) | 18 #if defined(USE_X11) |
| 15 extern "C" { | 19 extern "C" { |
| 16 #include <X11/Xlib.h> | 20 #include <X11/Xlib.h> |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 | 216 |
| 213 GLSurfaceEGL::~GLSurfaceEGL() {} | 217 GLSurfaceEGL::~GLSurfaceEGL() {} |
| 214 | 218 |
| 215 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software, | 219 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software, |
| 216 gfx::AcceleratedWidget window) | 220 gfx::AcceleratedWidget window) |
| 217 : window_(window), | 221 : window_(window), |
| 218 surface_(NULL), | 222 surface_(NULL), |
| 219 supports_post_sub_buffer_(false), | 223 supports_post_sub_buffer_(false), |
| 220 config_(NULL) { | 224 config_(NULL) { |
| 221 software_ = software; | 225 software_ = software; |
| 226 #if defined(OS_ANDROID) | |
| 227 if (window) | |
|
no sievers
2013/03/05 21:47:02
The extra ref is for NativeViewGLSurfaceEGL::Resiz
| |
| 228 ANativeWindow_acquire(window); | |
| 229 #endif | |
| 222 } | 230 } |
| 223 | 231 |
| 224 bool NativeViewGLSurfaceEGL::Initialize() { | 232 bool NativeViewGLSurfaceEGL::Initialize() { |
| 225 DCHECK(!surface_); | 233 DCHECK(!surface_); |
| 226 | 234 |
| 227 if (window_ == kNullAcceleratedWidget) { | 235 if (window_ == kNullAcceleratedWidget) { |
| 228 LOG(ERROR) << "Trying to create surface without window."; | 236 LOG(ERROR) << "Trying to create surface without window."; |
| 229 return false; | 237 return false; |
| 230 } | 238 } |
| 231 | 239 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 } | 434 } |
| 427 return true; | 435 return true; |
| 428 } | 436 } |
| 429 | 437 |
| 430 VSyncProvider* NativeViewGLSurfaceEGL::GetVSyncProvider() { | 438 VSyncProvider* NativeViewGLSurfaceEGL::GetVSyncProvider() { |
| 431 return vsync_provider_.get(); | 439 return vsync_provider_.get(); |
| 432 } | 440 } |
| 433 | 441 |
| 434 NativeViewGLSurfaceEGL::~NativeViewGLSurfaceEGL() { | 442 NativeViewGLSurfaceEGL::~NativeViewGLSurfaceEGL() { |
| 435 Destroy(); | 443 Destroy(); |
| 444 #if defined(OS_ANDROID) | |
| 445 if (window_) | |
| 446 ANativeWindow_release(window_); | |
| 447 #endif | |
| 436 } | 448 } |
| 437 | 449 |
| 438 void NativeViewGLSurfaceEGL::SetHandle(EGLSurface surface) { | 450 void NativeViewGLSurfaceEGL::SetHandle(EGLSurface surface) { |
| 439 surface_ = surface; | 451 surface_ = surface; |
| 440 } | 452 } |
| 441 | 453 |
| 442 PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(bool software, const gfx::Size& size) | 454 PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(bool software, const gfx::Size& size) |
| 443 : size_(size), | 455 : size_(size), |
| 444 surface_(NULL) { | 456 surface_(NULL) { |
| 445 software_ = software; | 457 software_ = software; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 558 | 570 |
| 559 return handle; | 571 return handle; |
| 560 #endif | 572 #endif |
| 561 } | 573 } |
| 562 | 574 |
| 563 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { | 575 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { |
| 564 Destroy(); | 576 Destroy(); |
| 565 } | 577 } |
| 566 | 578 |
| 567 } // namespace gfx | 579 } // namespace gfx |
| OLD | NEW |