Chromium Code Reviews| Index: content/common/gpu/texture_image_transport_surface.cc |
| diff --git a/content/common/gpu/texture_image_transport_surface.cc b/content/common/gpu/texture_image_transport_surface.cc |
| index a19a743a7994295ff728c07803b42bb759224392..dd55326b54b03bd92b31839c66aa7d1ecd369d69 100644 |
| --- a/content/common/gpu/texture_image_transport_surface.cc |
| +++ b/content/common/gpu/texture_image_transport_surface.cc |
| @@ -65,6 +65,8 @@ TextureImageTransportSurface::TextureImageTransportSurface( |
| : fbo_id_(0), |
| front_(0), |
| stub_destroyed_(false), |
| + backbuffer_suggested_allocation_(true), |
| + frontbuffer_suggested_allocation_(true), |
| parent_stub_(NULL) { |
| GpuChannel* parent_channel = manager->LookupChannel(handle.parent_client_id); |
| DCHECK(parent_channel); |
| @@ -155,19 +157,24 @@ unsigned int TextureImageTransportSurface::GetBackingFrameBufferObject() { |
| return fbo_id_; |
| } |
| -void TextureImageTransportSurface::SetBufferAllocation( |
| - BufferAllocationState state) { |
| +void TextureImageTransportSurface::SetBackbufferAllocation(bool allocation) { |
| + if (backbuffer_suggested_allocation_ == allocation) |
| + return; |
| + backbuffer_suggested_allocation_ = allocation; |
| + |
| if (!helper_->MakeCurrent()) |
| return; |
| - switch (state) { |
| - case BUFFER_ALLOCATION_FRONT_AND_BACK: |
| - CreateBackTexture(textures_[back()].size); |
| - break; |
| - case BUFFER_ALLOCATION_FRONT_ONLY: |
| - case BUFFER_ALLOCATION_NONE: |
| - ReleaseBackTexture(); |
| - break; |
| - }; |
| + |
| + if (backbuffer_suggested_allocation_) |
| + CreateBackTexture(textures_[back()].size); |
| + else |
| + ReleaseBackTexture(); |
| +} |
| + |
| +void TextureImageTransportSurface::SetFrontbufferAllocation(bool allocation) { |
| + if (frontbuffer_suggested_allocation_ == allocation) |
| + return; |
| + frontbuffer_suggested_allocation_ = allocation; |
| } |
| void* TextureImageTransportSurface::GetShareHandle() { |
| @@ -203,6 +210,7 @@ void TextureImageTransportSurface::OnWillDestroyStub( |
| } |
| bool TextureImageTransportSurface::SwapBuffers() { |
| + DCHECK(backbuffer_suggested_allocation_); |
|
jonathan.backer
2012/05/15 15:53:31
Why not exit early if no frontbuffer (I realize it
mmocny
2012/05/15 20:02:28
Fair point, I prefer to add it here than remove it
|
| if (!parent_stub_) { |
| LOG(ERROR) << "SwapBuffers failed because no parent stub."; |
| return false; |
| @@ -223,6 +231,7 @@ bool TextureImageTransportSurface::SwapBuffers() { |
| bool TextureImageTransportSurface::PostSubBuffer( |
| int x, int y, int width, int height) { |
| + DCHECK(backbuffer_suggested_allocation_); |
|
jonathan.backer
2012/05/15 15:53:31
Same as above.
|
| if (!parent_stub_) { |
| LOG(ERROR) << "PostSubBuffer failed because no parent stub."; |
| return false; |