Chromium Code Reviews| Index: content/common/gpu/image_transport_surface_mac.cc |
| diff --git a/content/common/gpu/image_transport_surface_mac.cc b/content/common/gpu/image_transport_surface_mac.cc |
| index c6511046901ff3f949b1168f058c10dd8d717a5f..80378b8d96d0388d3eb81dc3685add9f5889b603 100644 |
| --- a/content/common/gpu/image_transport_surface_mac.cc |
| +++ b/content/common/gpu/image_transport_surface_mac.cc |
| @@ -6,6 +6,7 @@ |
| #include "base/mac/scoped_cftyperef.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "content/common/gpu/gpu_command_buffer_stub.h" |
| #include "content/common/gpu/gpu_messages.h" |
| #include "ui/gfx/native_widget_types.h" |
| #include "ui/gl/gl_bindings.h" |
| @@ -33,8 +34,10 @@ int RoundUpSurfaceDimension(int number) { |
| // We are backed by an offscreen surface for the purposes of creating |
| // a context, but use FBOs to render to texture backed IOSurface |
| -class IOSurfaceImageTransportSurface : public gfx::NoOpGLSurfaceCGL, |
| - public ImageTransportSurface { |
| +class IOSurfaceImageTransportSurface |
| + : public gfx::NoOpGLSurfaceCGL, |
| + public ImageTransportSurface, |
| + public GpuCommandBufferStub::DestructionObserver { |
| public: |
| IOSurfaceImageTransportSurface(GpuChannelManager* manager, |
| GpuCommandBufferStub* stub, |
| @@ -62,6 +65,9 @@ class IOSurfaceImageTransportSurface : public gfx::NoOpGLSurfaceCGL, |
| virtual void OnResize(gfx::Size size, float scale_factor) OVERRIDE; |
| virtual void SetLatencyInfo(const ui::LatencyInfo&) OVERRIDE; |
| + // GpuCommandBufferStub::DestructionObserver implementation. |
| + virtual void OnWillDestroyStub() OVERRIDE; |
| + |
| private: |
| virtual ~IOSurfaceImageTransportSurface() OVERRIDE; |
| @@ -138,7 +144,6 @@ IOSurfaceImageTransportSurface::IOSurfaceImageTransportSurface( |
| } |
| IOSurfaceImageTransportSurface::~IOSurfaceImageTransportSurface() { |
| - Destroy(); |
| } |
| bool IOSurfaceImageTransportSurface::Initialize() { |
| @@ -151,7 +156,12 @@ bool IOSurfaceImageTransportSurface::Initialize() { |
| if (!helper_->Initialize()) |
| return false; |
| - return NoOpGLSurfaceCGL::Initialize(); |
| + |
| + if (!NoOpGLSurfaceCGL::Initialize()) |
|
no sievers
2013/06/05 00:21:16
I guess for correctness it should call helper_->De
piman
2013/06/05 00:33:32
You're probably right, though it's a NOOP anyway.
no sievers
2013/06/05 00:38:04
Done.
|
| + return false; |
| + |
| + helper_->stub()->AddDestructionObserver(this); |
| + return true; |
| } |
| void IOSurfaceImageTransportSurface::Destroy() { |
| @@ -313,6 +323,11 @@ void IOSurfaceImageTransportSurface::SetLatencyInfo( |
| latency_info_ = latency_info; |
| } |
| +void IOSurfaceImageTransportSurface::OnWillDestroyStub() { |
| + helper_->stub()->RemoveDestructionObserver(this); |
| + Destroy(); |
| +} |
| + |
| void IOSurfaceImageTransportSurface::UnrefIOSurface() { |
| // If we have resources to destroy, then make sure that we have a current |
| // context which we can use to delete the resources. |