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 |
160 if (!helper_->MakeCurrent()) | 165 if (!helper_->MakeCurrent()) |
161 return; | 166 return; |
162 switch (state) { | 167 |
163 case BUFFER_ALLOCATION_FRONT_AND_BACK: | 168 if (backbuffer_suggested_allocation_) |
164 CreateBackTexture(textures_[back()].size); | 169 CreateBackTexture(textures_[back()].size); |
165 break; | 170 else |
166 case BUFFER_ALLOCATION_FRONT_ONLY: | 171 ReleaseBackTexture(); |
167 case BUFFER_ALLOCATION_NONE: | 172 } |
168 ReleaseBackTexture(); | 173 |
169 break; | 174 void TextureImageTransportSurface::SetFrontbufferAllocation(bool allocation) { |
170 }; | 175 if (frontbuffer_suggested_allocation_ == allocation) |
| 176 return; |
| 177 frontbuffer_suggested_allocation_ = allocation; |
171 } | 178 } |
172 | 179 |
173 void* TextureImageTransportSurface::GetShareHandle() { | 180 void* TextureImageTransportSurface::GetShareHandle() { |
174 return GetHandle(); | 181 return GetHandle(); |
175 } | 182 } |
176 | 183 |
177 void* TextureImageTransportSurface::GetDisplay() { | 184 void* TextureImageTransportSurface::GetDisplay() { |
178 return parent_stub_ ? parent_stub_->surface()->GetDisplay() : NULL; | 185 return parent_stub_ ? parent_stub_->surface()->GetDisplay() : NULL; |
179 } | 186 } |
180 | 187 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 Texture& texture = textures_[i]; | 438 Texture& texture = textures_[i]; |
432 texture.info = NULL; | 439 texture.info = NULL; |
433 if (!texture.sent_to_client) | 440 if (!texture.sent_to_client) |
434 continue; | 441 continue; |
435 GpuHostMsg_AcceleratedSurfaceRelease_Params params; | 442 GpuHostMsg_AcceleratedSurfaceRelease_Params params; |
436 params.identifier = texture.client_id; | 443 params.identifier = texture.client_id; |
437 helper_->SendAcceleratedSurfaceRelease(params); | 444 helper_->SendAcceleratedSurfaceRelease(params); |
438 } | 445 } |
439 parent_stub_ = NULL; | 446 parent_stub_ = NULL; |
440 } | 447 } |
OLD | NEW |