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..358e12575ca5fc89d954f263ea3d406b80254d6c 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; |
+ 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(); |
+} |
- case BUFFER_ALLOCATION_NONE: |
- Resize(gfx::Size(1, 1)); |
+void PbufferImageTransportSurface::AdjustBufferAllocations() { |
+ if (backbuffer_suggested_allocation_) { |
+ Resize(visible_size_); |
jonathan.backer
2012/05/09 18:13:01
DCHECK that we should have a front buffer?
mmocny
2012/05/09 18:59:15
Again, I don't think so.
Previously we would set B
|
+ } else { |
+ Resize(gfx::Size(1, 1)); |
+ if (!frontbuffer_suggested_allocation_) |
helper_->Suspend(); |
- break; |
- |
- default: |
- NOTREACHED(); |
} |
DestroySurface(); |
} |
@@ -188,7 +191,7 @@ void PbufferImageTransportSurface::OnResizeViewACK() { |
} |
void PbufferImageTransportSurface::OnResize(gfx::Size size) { |
- if (buffer_allocation_state_ == BUFFER_ALLOCATION_FRONT_AND_BACK) |
+ if (backbuffer_suggested_allocation_ && frontbuffer_suggested_allocation_) |
jonathan.backer
2012/05/09 18:13:01
I think that it may make more sense to DCHECK that
mmocny
2012/05/09 18:59:15
Fair enough. Shouldn't we DCHECK for both?
Will w
jonathan.backer
2012/05/10 21:37:48
AFAIK, we shouldn't resize when not visible. I thi
|
Resize(size); |
DestroySurface(); |