Index: content/common/gpu/image_transport_surface_linux.cc |
diff --git a/content/common/gpu/image_transport_surface_linux.cc b/content/common/gpu/image_transport_surface_linux.cc |
index 8dd31fa35a038baf916f9c142bb25ef7066c3cb5..6486718d3084673889841b9a774bf3a4fb4becd0 100644 |
--- a/content/common/gpu/image_transport_surface_linux.cc |
+++ b/content/common/gpu/image_transport_surface_linux.cc |
@@ -93,12 +93,14 @@ class EGLImageTransportSurface |
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 |
virtual void OnNewSurfaceACK( |
uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; |
+ virtual void OnReleaseSurfaceACK(uint64 surface_id, bool success) OVERRIDE; |
virtual void OnBuffersSwappedACK() OVERRIDE; |
virtual void OnPostSubBufferACK() OVERRIDE; |
virtual void OnResizeViewACK() OVERRIDE; |
@@ -111,7 +113,8 @@ class EGLImageTransportSurface |
void SendPostSubBuffer(int x, int y, int width, int height); |
// Tracks the current buffer allocation state. |
- BufferAllocationState buffer_allocation_state_; |
+ bool backbuffer_allocated_; |
+ bool frontbuffer_allocated_; |
uint32 fbo_id_; |
@@ -145,12 +148,14 @@ class GLXImageTransportSurface |
virtual std::string GetExtensions(); |
virtual gfx::Size GetSize() OVERRIDE; |
virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
- virtual void SetBufferAllocation(BufferAllocationState state) OVERRIDE; |
+ virtual void SetBackbufferAllocation(bool allocated) OVERRIDE; |
+ virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE; |
protected: |
// ImageTransportSurface implementation: |
virtual void OnNewSurfaceACK( |
uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; |
+ virtual void OnReleaseSurfaceACK(uint64 surface_id, bool success) OVERRIDE; |
virtual void OnBuffersSwappedACK() OVERRIDE; |
virtual void OnPostSubBufferACK() OVERRIDE; |
virtual void OnResizeViewACK() OVERRIDE; |
@@ -168,7 +173,8 @@ class GLXImageTransportSurface |
void ResizeSurface(gfx::Size size); |
// Tracks the current buffer allocation state. |
- BufferAllocationState buffer_allocation_state_; |
+ bool backbuffer_allocated_; |
+ bool frontbuffer_allocated_; |
XID dummy_parent_; |
gfx::Size size_; |
@@ -209,6 +215,7 @@ class OSMesaImageTransportSurface : public ImageTransportSurface, |
// ImageTransportSurface implementation: |
virtual void OnNewSurfaceACK( |
uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; |
+ virtual void OnReleaseSurfaceACK(uint64 surface_id, bool success) OVERRIDE; |
virtual void OnBuffersSwappedACK() OVERRIDE; |
virtual void OnPostSubBufferACK() OVERRIDE; |
virtual void OnResizeViewACK() OVERRIDE; |
@@ -270,7 +277,8 @@ EGLImageTransportSurface::EGLImageTransportSurface( |
GpuChannelManager* manager, |
GpuCommandBufferStub* stub) |
: gfx::PbufferGLSurfaceEGL(false, gfx::Size(1, 1)), |
- buffer_allocation_state_(BUFFER_ALLOCATION_FRONT_AND_BACK), |
+ backbuffer_allocated_(true), |
+ frontbuffer_allocated_(true), |
fbo_id_(0), |
made_current_(false) { |
helper_.reset(new ImageTransportHelper(this, |
@@ -333,33 +341,28 @@ unsigned int EGLImageTransportSurface::GetBackingFrameBufferObject() { |
return fbo_id_; |
} |
-void EGLImageTransportSurface::SetBufferAllocation( |
- BufferAllocationState state) { |
- if (buffer_allocation_state_ == state) |
+void EGLImageTransportSurface::SetBackbufferAllocation(bool allocated) { |
+ if (backbuffer_allocated_ == allocated) |
+ return; |
+ // TODO(mmocny): Remove dependancy on front_surface_->size() |
+ if (!front_surface_.get()) |
return; |
- buffer_allocation_state_ = state; |
- |
- switch (state) { |
- case BUFFER_ALLOCATION_FRONT_AND_BACK: |
- if (!back_surface_.get() && front_surface_.get()) |
- OnResize(front_surface_->size()); |
- break; |
- |
- case BUFFER_ALLOCATION_FRONT_ONLY: |
- if (back_surface_.get() && front_surface_.get()) |
- ReleaseSurface(&back_surface_); |
- break; |
- |
- case BUFFER_ALLOCATION_NONE: |
- if (back_surface_.get() && front_surface_.get()) |
- ReleaseSurface(&back_surface_); |
- break; |
- default: |
- NOTREACHED(); |
+ if (allocated) { |
+ if (!back_surface_.get()) |
+ OnResize(front_surface_->size()); |
+ backbuffer_allocated_ = true; |
+ } else { |
+ if (back_surface_.get()) |
+ ReleaseSurface(&back_surface_); |
+ backbuffer_allocated_ = false; |
} |
} |
+void EGLImageTransportSurface::SetFrontbufferAllocation(bool allocated) { |
+ // TODO(mmocny): Copy logic from texture image transport. |
+} |
+ |
void EGLImageTransportSurface::ReleaseSurface( |
scoped_refptr<EGLAcceleratedSurface>* surface) { |
if (surface->get()) { |
@@ -396,6 +399,8 @@ void EGLImageTransportSurface::OnResize(gfx::Size size) { |
} |
bool EGLImageTransportSurface::SwapBuffers() { |
+ DCHECK(backbuffer_allocated_); |
+ DCHECK(frontbuffer_allocated_); |
front_surface_.swap(back_surface_); |
DCHECK_NE(front_surface_.get(), static_cast<EGLAcceleratedSurface*>(NULL)); |
helper_->DeferToFence(base::Bind( |
@@ -425,7 +430,8 @@ void EGLImageTransportSurface::SendBuffersSwapped() { |
bool EGLImageTransportSurface::PostSubBuffer( |
int x, int y, int width, int height) { |
- |
+ DCHECK(backbuffer_allocated_); |
+ DCHECK(frontbuffer_allocated_); |
DCHECK_NE(back_surface_.get(), static_cast<EGLAcceleratedSurface*>(NULL)); |
gfx::Size expected_size = back_surface_->size(); |
bool surfaces_same_size = front_surface_.get() && |
@@ -508,6 +514,10 @@ void EGLImageTransportSurface::OnNewSurfaceACK( |
helper_->SetScheduled(true); |
} |
+void EGLImageTransportSurface::OnReleaseSurfaceACK( |
+ uint64 surface_id, bool success) { |
+} |
+ |
void EGLImageTransportSurface::OnBuffersSwappedACK() { |
helper_->SetScheduled(true); |
} |
@@ -524,7 +534,8 @@ GLXImageTransportSurface::GLXImageTransportSurface( |
GpuChannelManager* manager, |
GpuCommandBufferStub* stub) |
: gfx::NativeViewGLSurfaceGLX(), |
- buffer_allocation_state_(BUFFER_ALLOCATION_FRONT_AND_BACK), |
+ backbuffer_allocated_(true), |
+ frontbuffer_allocated_(true), |
dummy_parent_(0), |
size_(1, 1), |
bound_(false), |
@@ -608,32 +619,24 @@ void GLXImageTransportSurface::ReleaseSurface() { |
bound_ = false; |
} |
-void GLXImageTransportSurface::SetBufferAllocation( |
- BufferAllocationState state) { |
- if (buffer_allocation_state_ == state) |
+void GLXImageTransportSurface::SetBackbufferAllocation(bool allocated) { |
+ if (backbuffer_allocated_ == allocated) |
return; |
- buffer_allocation_state_ = state; |
- switch (state) { |
- case BUFFER_ALLOCATION_FRONT_AND_BACK: { |
- ResizeSurface(size_); |
- break; |
- } |
- case BUFFER_ALLOCATION_FRONT_ONLY: { |
- ResizeSurface(gfx::Size(1,1)); |
- break; |
- } |
- case BUFFER_ALLOCATION_NONE: { |
- ResizeSurface(gfx::Size(1,1)); |
- if (bound_) |
- ReleaseSurface(); |
- break; |
- } |
- default: |
- NOTREACHED(); |
+ if (allocated) { |
+ // cannot allocate backbuffer without also allocating a frontbuffer. |
+ ResizeSurface(size_); |
+ backbuffer_allocated_ = true; |
+ frontbuffer_allocated_ = true; |
+ } else { |
+ ResizeSurface(gfx::Size(1,1)); |
+ backbuffer_allocated_ = false; |
} |
} |
+void GLXImageTransportSurface::SetFrontbufferAllocation(bool allocated) { |
+} |
+ |
void GLXImageTransportSurface::ResizeSurface(gfx::Size size) { |
Display* dpy = static_cast<Display*>(GetDisplay()); |
XResizeWindow(dpy, window_, size.width(), size.height()); |
@@ -653,6 +656,8 @@ void GLXImageTransportSurface::OnResize(gfx::Size size) { |
} |
bool GLXImageTransportSurface::SwapBuffers() { |
+ DCHECK(backbuffer_allocated_); |
+ DCHECK(frontbuffer_allocated_); |
gfx::NativeViewGLSurfaceGLX::SwapBuffers(); |
helper_->DeferToFence(base::Bind( |
&GLXImageTransportSurface::SendBuffersSwapped, |
@@ -679,6 +684,8 @@ void GLXImageTransportSurface::SendBuffersSwapped() { |
bool GLXImageTransportSurface::PostSubBuffer( |
int x, int y, int width, int height) { |
+ DCHECK(backbuffer_allocated_); |
+ DCHECK(frontbuffer_allocated_); |
gfx::NativeViewGLSurfaceGLX::PostSubBuffer(x, y, width, height); |
helper_->DeferToFence(base::Bind( |
&GLXImageTransportSurface::SendPostSubBuffer, |
@@ -746,6 +753,10 @@ void GLXImageTransportSurface::OnNewSurfaceACK( |
uint64 surface_handle, TransportDIB::Handle /*shm_handle*/) { |
} |
+void GLXImageTransportSurface::OnReleaseSurfaceACK( |
+ uint64 surface_id, bool success) { |
+} |
+ |
void GLXImageTransportSurface::OnBuffersSwappedACK() { |
helper_->SetScheduled(true); |
} |
@@ -832,6 +843,10 @@ void OSMesaImageTransportSurface::OnNewSurfaceACK( |
helper_->SetScheduled(true); |
} |
+void OSMesaImageTransportSurface::OnReleaseSurfaceACK( |
+ uint64 surface_id, bool success) { |
+} |
+ |
void OSMesaImageTransportSurface::OnResizeViewACK() { |
NOTREACHED(); |
} |