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..6bb3015b86404b04002fba408f2b1295c61b3b1c 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 |
@@ -55,9 +56,11 @@ class PbufferImageTransportSurface |
virtual ~PbufferImageTransportSurface(); |
void SendBuffersSwapped(); |
void DestroySurface(); |
+ void AdjustBufferAllocations(); |
// 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 +74,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,28 +126,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; |
- |
- switch (state) { |
- case BUFFER_ALLOCATION_FRONT_AND_BACK: |
- Resize(visible_size_); |
- break; |
+ backbuffer_suggested_allocation_ = allocation; |
jonathan.backer
2012/05/10 21:37:48
Resize here accordingly.
|
+ AdjustBufferAllocations(); |
+} |
- case BUFFER_ALLOCATION_FRONT_ONLY: |
- Resize(gfx::Size(1, 1)); |
- break; |
+void PbufferImageTransportSurface::SetFrontbufferAllocation(bool allocation) { |
+ if (frontbuffer_suggested_allocation_ == allocation) |
+ return; |
+ frontbuffer_suggested_allocation_ = allocation; |
+ AdjustBufferAllocations(); |
jonathan.backer
2012/05/10 21:37:48
Suspend here accordingly.
|
+} |
- case BUFFER_ALLOCATION_NONE: |
- Resize(gfx::Size(1, 1)); |
+void PbufferImageTransportSurface::AdjustBufferAllocations() { |
jonathan.backer
2012/05/10 21:37:48
nix this.
|
+ if (backbuffer_suggested_allocation_) { |
+ Resize(visible_size_); |
+ } else { |
+ Resize(gfx::Size(1, 1)); |
+ if (!frontbuffer_suggested_allocation_) |
helper_->Suspend(); |
- break; |
- |
- default: |
- NOTREACHED(); |
} |
DestroySurface(); |
} |
@@ -188,8 +191,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(); |