Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Unified Diff: content/common/gpu/image_transport_surface_mac.cc

Issue 10388010: Decoupling backbuffer allocation suggestion from frontbuffer allocation suggestion. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reset previous damage at time of swap. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 6628098d2f822218698a25759260611ffddcdcb9..3c710f05cbb75f50b7e4858498c6cc9d92048f5b 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
@@ -54,7 +55,9 @@ class IOSurfaceImageTransportSurface : public gfx::NoOpGLSurfaceCGL,
void UnrefIOSurface();
void CreateIOSurface();
- 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 +100,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,31 +162,32 @@ 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;
+ backbuffer_suggested_allocation_ = allocation;
- switch (state) {
- case BUFFER_ALLOCATION_FRONT_AND_BACK:
- CreateIOSurface();
- break;
-
- case BUFFER_ALLOCATION_FRONT_ONLY:
- break;
+ if (backbuffer_suggested_allocation_)
+ CreateIOSurface();
+ else
+ UnrefIOSurface();
+}
- case BUFFER_ALLOCATION_NONE:
- UnrefIOSurface();
- helper_->Suspend();
- break;
+void IOSurfaceImageTransportSurface::SetFrontbufferAllocation(bool allocation) {
+ if (frontbuffer_suggested_allocation_ == allocation)
+ return;
+ frontbuffer_suggested_allocation_ = allocation;
- default:
- NOTREACHED();
- }
+ // 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();
}
bool IOSurfaceImageTransportSurface::SwapBuffers() {
+ DCHECK(backbuffer_suggested_allocation_);
+ if (!frontbuffer_suggested_allocation_)
+ return true;
glFlush();
GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
@@ -195,6 +200,9 @@ bool IOSurfaceImageTransportSurface::SwapBuffers() {
bool IOSurfaceImageTransportSurface::PostSubBuffer(
int x, int y, int width, int height) {
+ DCHECK(backbuffer_suggested_allocation_);
+ if (!frontbuffer_suggested_allocation_)
+ return true;
glFlush();
GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params;
« no previous file with comments | « content/common/gpu/image_transport_surface_linux.cc ('k') | content/common/gpu/image_transport_surface_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698