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 5223ce14b76bae380fbff0e042efa9f443de3df1..8b1e8bc3a8015768f82732be8dc70ba37156b646 100644 |
--- a/content/common/gpu/image_transport_surface_mac.cc |
+++ b/content/common/gpu/image_transport_surface_mac.cc |
@@ -37,7 +37,8 @@ class IOSurfaceImageTransportSurface : public gfx::NoOpGLSurfaceCGL, |
virtual gfx::Size GetSize() OVERRIDE; |
virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; |
- virtual void SetBufferAllocation(BufferAllocationState state) OVERRIDE; |
+ virtual void SetBackbufferAllocation(bool allocated) OVERRIDE; |
+ virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE; |
protected: |
// ImageTransportSurface implementation |
@@ -53,8 +54,11 @@ class IOSurfaceImageTransportSurface : public gfx::NoOpGLSurfaceCGL, |
void UnrefIOSurface(); |
void CreateIOSurface(); |
+ void AdjustBufferAllocations(); |
- BufferAllocationState buffer_allocation_state_; |
+ // Tracks the current buffer allocation state. |
+ bool backbuffer_suggested_allocation_; |
+ bool frontbuffer_suggested_allocation_; |
uint32 fbo_id_; |
GLuint texture_id_; |
@@ -97,7 +101,8 @@ IOSurfaceImageTransportSurface::IOSurfaceImageTransportSurface( |
GpuCommandBufferStub* stub, |
gfx::PluginWindowHandle handle) |
: gfx::NoOpGLSurfaceCGL(gfx::Size(1, 1)), |
- buffer_allocation_state_(BUFFER_ALLOCATION_FRONT_AND_BACK), |
+ backbuffer_suggested_allocation_(true), |
+ frontbuffer_suggested_allocation_(true), |
fbo_id_(0), |
texture_id_(0), |
io_surface_handle_(0), |
@@ -158,27 +163,26 @@ unsigned int IOSurfaceImageTransportSurface::GetBackingFrameBufferObject() { |
return fbo_id_; |
} |
-void IOSurfaceImageTransportSurface::SetBufferAllocation( |
- BufferAllocationState state) { |
- if (buffer_allocation_state_ == state) |
+void IOSurfaceImageTransportSurface::SetBackbufferAllocation(bool allocation) { |
+ if (backbuffer_suggested_allocation_ == allocation) |
return; |
- buffer_allocation_state_ = state; |
- |
- switch (state) { |
- case BUFFER_ALLOCATION_FRONT_AND_BACK: |
- CreateIOSurface(); |
- break; |
- |
- case BUFFER_ALLOCATION_FRONT_ONLY: |
- break; |
+ backbuffer_suggested_allocation_ = allocation; |
+ AdjustBufferAllocations(); |
+} |
- case BUFFER_ALLOCATION_NONE: |
- UnrefIOSurface(); |
- helper_->Suspend(); |
- break; |
+void IOSurfaceImageTransportSurface::SetFrontbufferAllocation(bool allocation) { |
+ if (frontbuffer_suggested_allocation_ == allocation) |
+ return; |
+ frontbuffer_suggested_allocation_ = allocation; |
+ AdjustBufferAllocations(); |
+} |
- default: |
- NOTREACHED(); |
+void IOSurfaceImageTransportSurface::AdjustBufferAllocations() { |
+ if (backbuffer_suggested_allocation_) { |
+ CreateIOSurface(); |
jonathan.backer
2012/05/10 21:37:48
Should only be called for BB allocation. AFAIK, th
|
+ } else if (!frontbuffer_suggested_allocation_) { |
+ UnrefIOSurface(); |
jonathan.backer
2012/05/10 21:37:48
I think that we can unref for the BB dealloc.
|
+ helper_->Suspend(); |
jonathan.backer
2012/05/10 21:37:48
AFAIK, this causes the browser to drop the front b
jonathan.backer
2012/05/10 21:37:48
I Think that this causes FB dealloc in the browser
|
} |
} |