| 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 #if defined(ENABLE_GPU) | 5 #if defined(ENABLE_GPU) |
| 6 | 6 |
| 7 #include "content/common/gpu/image_transport_surface.h" | 7 #include "content/common/gpu/image_transport_surface.h" |
| 8 | 8 |
| 9 // This conflicts with the defines in Xlib.h and must come first. | 9 // This conflicts with the defines in Xlib.h and must come first. |
| 10 #include "content/common/gpu/gpu_messages.h" | 10 #include "content/common/gpu/gpu_messages.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 virtual gfx::Size GetSize() OVERRIDE; | 69 virtual gfx::Size GetSize() OVERRIDE; |
| 70 virtual void OnMakeCurrent(gfx::GLContext* context) OVERRIDE; | 70 virtual void OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
| 71 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; | 71 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; |
| 72 | 72 |
| 73 protected: | 73 protected: |
| 74 // ImageTransportSurface implementation | 74 // ImageTransportSurface implementation |
| 75 virtual void OnNewSurfaceACK( | 75 virtual void OnNewSurfaceACK( |
| 76 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; | 76 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; |
| 77 virtual void OnBuffersSwappedACK() OVERRIDE; | 77 virtual void OnBuffersSwappedACK() OVERRIDE; |
| 78 virtual void OnResize(gfx::Size size) OVERRIDE; | 78 virtual void OnResize(gfx::Size size) OVERRIDE; |
| 79 virtual void OnSetSurfaceVisible(bool visible) OVERRIDE; |
| 79 | 80 |
| 80 private: | 81 private: |
| 81 virtual ~EGLImageTransportSurface() OVERRIDE; | 82 virtual ~EGLImageTransportSurface() OVERRIDE; |
| 82 void ReleaseSurface(scoped_refptr<EGLAcceleratedSurface>* surface); | 83 void ReleaseSurface(scoped_refptr<EGLAcceleratedSurface>* surface); |
| 83 | 84 |
| 84 uint32 fbo_id_; | 85 uint32 fbo_id_; |
| 85 | 86 |
| 86 scoped_refptr<EGLAcceleratedSurface> back_surface_; | 87 scoped_refptr<EGLAcceleratedSurface> back_surface_; |
| 87 scoped_refptr<EGLAcceleratedSurface> front_surface_; | 88 scoped_refptr<EGLAcceleratedSurface> front_surface_; |
| 88 | 89 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 302 |
| 302 GpuHostMsg_AcceleratedSurfaceNew_Params params; | 303 GpuHostMsg_AcceleratedSurfaceNew_Params params; |
| 303 params.width = size.width(); | 304 params.width = size.width(); |
| 304 params.height = size.height(); | 305 params.height = size.height(); |
| 305 params.surface_id = back_surface_->pixmap(); | 306 params.surface_id = back_surface_->pixmap(); |
| 306 helper_->SendAcceleratedSurfaceNew(params); | 307 helper_->SendAcceleratedSurfaceNew(params); |
| 307 | 308 |
| 308 helper_->SetScheduled(false); | 309 helper_->SetScheduled(false); |
| 309 } | 310 } |
| 310 | 311 |
| 312 void EGLImageTransportSurface::OnSetSurfaceVisible(bool visible) { |
| 313 if (!visible && back_surface_.get() && front_surface_.get()) { |
| 314 ReleaseSurface(&back_surface_); |
| 315 } else if (visible && !back_surface_.get() && front_surface_.get()) { |
| 316 // Leverage the OnResize hook because it does exactly what we want |
| 317 OnResize(front_surface_->size()); |
| 318 } |
| 319 } |
| 320 |
| 311 bool EGLImageTransportSurface::SwapBuffers() { | 321 bool EGLImageTransportSurface::SwapBuffers() { |
| 312 front_surface_.swap(back_surface_); | 322 front_surface_.swap(back_surface_); |
| 313 DCHECK_NE(front_surface_.get(), static_cast<EGLAcceleratedSurface*>(NULL)); | 323 DCHECK_NE(front_surface_.get(), static_cast<EGLAcceleratedSurface*>(NULL)); |
| 314 glFlush(); | 324 glFlush(); |
| 315 | 325 |
| 316 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 326 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
| 317 params.surface_id = front_surface_->pixmap(); | 327 params.surface_id = front_surface_->pixmap(); |
| 318 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 328 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
| 319 | 329 |
| 320 gfx::Size expected_size = front_surface_->size(); | 330 gfx::Size expected_size = front_surface_->size(); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 NOTREACHED(); | 629 NOTREACHED(); |
| 620 return NULL; | 630 return NULL; |
| 621 } | 631 } |
| 622 if (surface->Initialize()) | 632 if (surface->Initialize()) |
| 623 return surface; | 633 return surface; |
| 624 else | 634 else |
| 625 return NULL; | 635 return NULL; |
| 626 } | 636 } |
| 627 | 637 |
| 628 #endif // defined(USE_GPU) | 638 #endif // defined(USE_GPU) |
| OLD | NEW |