| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/gpu/texture_image_transport_surface.h" | 5 #include "content/common/gpu/texture_image_transport_surface.h" |
| 6 | 6 |
| 7 #include "content/common/gpu/gpu_channel.h" | 7 #include "content/common/gpu/gpu_channel.h" |
| 8 #include "content/common/gpu/gpu_channel_manager.h" | 8 #include "content/common/gpu/gpu_channel_manager.h" |
| 9 #include "content/common/gpu/gpu_messages.h" | 9 #include "content/common/gpu/gpu_messages.h" |
| 10 #include "gpu/command_buffer/service/context_group.h" | 10 #include "gpu/command_buffer/service/context_group.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 TextureImageTransportSurface::Texture::~Texture() { | 58 TextureImageTransportSurface::Texture::~Texture() { |
| 59 } | 59 } |
| 60 | 60 |
| 61 TextureImageTransportSurface::TextureImageTransportSurface( | 61 TextureImageTransportSurface::TextureImageTransportSurface( |
| 62 GpuChannelManager* manager, | 62 GpuChannelManager* manager, |
| 63 GpuCommandBufferStub* stub, | 63 GpuCommandBufferStub* stub, |
| 64 const gfx::GLSurfaceHandle& handle) | 64 const gfx::GLSurfaceHandle& handle) |
| 65 : fbo_id_(0), | 65 : fbo_id_(0), |
| 66 front_(0), | 66 front_(0), |
| 67 stub_destroyed_(false), | 67 stub_destroyed_(false), |
| 68 backbuffer_suggested_allocation_(true), |
| 69 frontbuffer_suggested_allocation_(true), |
| 68 parent_stub_(NULL) { | 70 parent_stub_(NULL) { |
| 69 GpuChannel* parent_channel = manager->LookupChannel(handle.parent_client_id); | 71 GpuChannel* parent_channel = manager->LookupChannel(handle.parent_client_id); |
| 70 DCHECK(parent_channel); | 72 DCHECK(parent_channel); |
| 71 parent_stub_ = parent_channel->LookupCommandBuffer(handle.parent_context_id); | 73 parent_stub_ = parent_channel->LookupCommandBuffer(handle.parent_context_id); |
| 72 DCHECK(parent_stub_); | 74 DCHECK(parent_stub_); |
| 73 parent_stub_->AddDestructionObserver(this); | 75 parent_stub_->AddDestructionObserver(this); |
| 74 TextureManager* texture_manager = | 76 TextureManager* texture_manager = |
| 75 parent_stub_->decoder()->GetContextGroup()->texture_manager(); | 77 parent_stub_->decoder()->GetContextGroup()->texture_manager(); |
| 76 DCHECK(texture_manager); | 78 DCHECK(texture_manager); |
| 77 | 79 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 #endif | 150 #endif |
| 149 } | 151 } |
| 150 | 152 |
| 151 return true; | 153 return true; |
| 152 } | 154 } |
| 153 | 155 |
| 154 unsigned int TextureImageTransportSurface::GetBackingFrameBufferObject() { | 156 unsigned int TextureImageTransportSurface::GetBackingFrameBufferObject() { |
| 155 return fbo_id_; | 157 return fbo_id_; |
| 156 } | 158 } |
| 157 | 159 |
| 158 void TextureImageTransportSurface::SetBufferAllocation( | 160 void TextureImageTransportSurface::SetBackbufferAllocation(bool allocation) { |
| 159 BufferAllocationState state) { | 161 if (backbuffer_suggested_allocation_ == allocation) |
| 162 return; |
| 163 backbuffer_suggested_allocation_ = allocation; |
| 164 AdjustBufferAllocations(); |
| 165 } |
| 166 |
| 167 void TextureImageTransportSurface::SetFrontbufferAllocation(bool allocation) { |
| 168 if (frontbuffer_suggested_allocation_ == allocation) |
| 169 return; |
| 170 frontbuffer_suggested_allocation_ = allocation; |
| 171 } |
| 172 |
| 173 void TextureImageTransportSurface::AdjustBufferAllocations() { |
| 160 if (!helper_->MakeCurrent()) | 174 if (!helper_->MakeCurrent()) |
| 161 return; | 175 return; |
| 162 switch (state) { | 176 if (backbuffer_suggested_allocation_) |
| 163 case BUFFER_ALLOCATION_FRONT_AND_BACK: | 177 CreateBackTexture(textures_[back()].size); |
| 164 CreateBackTexture(textures_[back()].size); | 178 else |
| 165 break; | 179 ReleaseBackTexture(); |
| 166 case BUFFER_ALLOCATION_FRONT_ONLY: | |
| 167 case BUFFER_ALLOCATION_NONE: | |
| 168 ReleaseBackTexture(); | |
| 169 break; | |
| 170 }; | |
| 171 } | 180 } |
| 172 | 181 |
| 173 void* TextureImageTransportSurface::GetShareHandle() { | 182 void* TextureImageTransportSurface::GetShareHandle() { |
| 174 return GetHandle(); | 183 return GetHandle(); |
| 175 } | 184 } |
| 176 | 185 |
| 177 void* TextureImageTransportSurface::GetDisplay() { | 186 void* TextureImageTransportSurface::GetDisplay() { |
| 178 return parent_stub_ ? parent_stub_->surface()->GetDisplay() : NULL; | 187 return parent_stub_ ? parent_stub_->surface()->GetDisplay() : NULL; |
| 179 } | 188 } |
| 180 | 189 |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 Texture& texture = textures_[i]; | 440 Texture& texture = textures_[i]; |
| 432 texture.info = NULL; | 441 texture.info = NULL; |
| 433 if (!texture.sent_to_client) | 442 if (!texture.sent_to_client) |
| 434 continue; | 443 continue; |
| 435 GpuHostMsg_AcceleratedSurfaceRelease_Params params; | 444 GpuHostMsg_AcceleratedSurfaceRelease_Params params; |
| 436 params.identifier = texture.client_id; | 445 params.identifier = texture.client_id; |
| 437 helper_->SendAcceleratedSurfaceRelease(params); | 446 helper_->SendAcceleratedSurfaceRelease(params); |
| 438 } | 447 } |
| 439 parent_stub_ = NULL; | 448 parent_stub_ = NULL; |
| 440 } | 449 } |
| OLD | NEW |