Index: content/common/gpu/image_transport_surface_win.cc |
diff --git a/content/common/gpu/image_transport_surface_win.cc b/content/common/gpu/image_transport_surface_win.cc |
index 32e9d8a45b69b51c30135856dbbe3e53ad0dad61..ecc92656454ea53c5829632d95e65051ed282eb2 100644 |
--- a/content/common/gpu/image_transport_surface_win.cc |
+++ b/content/common/gpu/image_transport_surface_win.cc |
@@ -40,7 +40,8 @@ class PbufferImageTransportSurface |
virtual bool SwapBuffers() OVERRIDE; |
virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; |
virtual std::string GetExtensions() OVERRIDE; |
- virtual void SetBufferAllocation(BufferAllocationState state) OVERRIDE; |
+ virtual void SetBackbufferAllocation(bool allocated) OVERRIDE; |
+ virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE; |
protected: |
// ImageTransportSurface implementation |
@@ -57,7 +58,8 @@ class PbufferImageTransportSurface |
void DestroySurface(); |
// Tracks the current buffer allocation state. |
- BufferAllocationState buffer_allocation_state_; |
+ bool backbuffer_suggested_allocation_; |
+ bool frontbuffer_suggested_allocation_; |
// Size to resize to when the surface becomes visible. |
gfx::Size visible_size_; |
@@ -71,7 +73,8 @@ PbufferImageTransportSurface::PbufferImageTransportSurface( |
GpuChannelManager* manager, |
GpuCommandBufferStub* stub) |
: GLSurfaceAdapter(new gfx::PbufferGLSurfaceEGL(false, gfx::Size(1, 1))), |
- buffer_allocation_state_(BUFFER_ALLOCATION_FRONT_AND_BACK) { |
+ backbuffer_suggested_allocation_(true), |
+ frontbuffer_suggested_allocation_(true) { |
helper_.reset(new ImageTransportHelper(this, |
manager, |
stub, |
@@ -122,30 +125,27 @@ bool PbufferImageTransportSurface::PostSubBuffer( |
return false; |
} |
-void PbufferImageTransportSurface::SetBufferAllocation( |
- BufferAllocationState state) { |
- if (buffer_allocation_state_ == state) |
+void PbufferImageTransportSurface::SetBackbufferAllocation(bool allocation) { |
+ if (backbuffer_suggested_allocation_ == allocation) |
return; |
- buffer_allocation_state_ = state; |
+ backbuffer_suggested_allocation_ = allocation; |
- switch (state) { |
- case BUFFER_ALLOCATION_FRONT_AND_BACK: |
- Resize(visible_size_); |
- break; |
- |
- case BUFFER_ALLOCATION_FRONT_ONLY: |
- Resize(gfx::Size(1, 1)); |
- break; |
+ if (backbuffer_suggested_allocation_) |
+ Resize(visible_size_); |
+ else |
+ Resize(gfx::Size(1, 1)); |
+ DestroySurface(); |
+} |
- case BUFFER_ALLOCATION_NONE: |
- Resize(gfx::Size(1, 1)); |
- helper_->Suspend(); |
- break; |
+void PbufferImageTransportSurface::SetFrontbufferAllocation(bool allocation) { |
+ if (frontbuffer_suggested_allocation_ == allocation) |
+ return; |
+ frontbuffer_suggested_allocation_ = allocation; |
- default: |
- NOTREACHED(); |
- } |
- DestroySurface(); |
+ // We recreate frontbuffer by recreating backbuffer and swapping. |
+ // But we release frontbuffer by telling UI to release its handle on it. |
+ if (!frontbuffer_suggested_allocation_) |
+ helper_->Suspend(); |
} |
void PbufferImageTransportSurface::DestroySurface() { |
@@ -188,8 +188,9 @@ void PbufferImageTransportSurface::OnResizeViewACK() { |
} |
void PbufferImageTransportSurface::OnResize(gfx::Size size) { |
- if (buffer_allocation_state_ == BUFFER_ALLOCATION_FRONT_AND_BACK) |
- Resize(size); |
+ DCHECK(backbuffer_suggested_allocation_); |
+ DCHECK(frontbuffer_suggested_allocation_); |
+ Resize(size); |
DestroySurface(); |