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 15 matching lines...) Expand all Loading... | |
196 // resources we allocated in the stub's context. | 203 // resources we allocated in the stub's context. |
197 glDeleteFramebuffersEXT(1, &fbo_id_); | 204 glDeleteFramebuffersEXT(1, &fbo_id_); |
198 CHECK_GL_ERROR(); | 205 CHECK_GL_ERROR(); |
199 fbo_id_ = 0; | 206 fbo_id_ = 0; |
200 | 207 |
201 stub_destroyed_ = true; | 208 stub_destroyed_ = true; |
202 } | 209 } |
203 } | 210 } |
204 | 211 |
205 bool TextureImageTransportSurface::SwapBuffers() { | 212 bool TextureImageTransportSurface::SwapBuffers() { |
213 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
| |
206 if (!parent_stub_) { | 214 if (!parent_stub_) { |
207 LOG(ERROR) << "SwapBuffers failed because no parent stub."; | 215 LOG(ERROR) << "SwapBuffers failed because no parent stub."; |
208 return false; | 216 return false; |
209 } | 217 } |
210 | 218 |
211 glFlush(); | 219 glFlush(); |
212 front_ = back(); | 220 front_ = back(); |
213 previous_damage_rect_ = gfx::Rect(textures_[front_].size); | 221 previous_damage_rect_ = gfx::Rect(textures_[front_].size); |
214 | 222 |
215 DCHECK(textures_[front_].client_id != 0); | 223 DCHECK(textures_[front_].client_id != 0); |
216 | 224 |
217 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 225 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
218 params.surface_handle = textures_[front_].client_id; | 226 params.surface_handle = textures_[front_].client_id; |
219 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 227 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
220 helper_->SetScheduled(false); | 228 helper_->SetScheduled(false); |
221 return true; | 229 return true; |
222 } | 230 } |
223 | 231 |
224 bool TextureImageTransportSurface::PostSubBuffer( | 232 bool TextureImageTransportSurface::PostSubBuffer( |
225 int x, int y, int width, int height) { | 233 int x, int y, int width, int height) { |
234 DCHECK(backbuffer_suggested_allocation_); | |
jonathan.backer
2012/05/15 15:53:31
Same as above.
| |
226 if (!parent_stub_) { | 235 if (!parent_stub_) { |
227 LOG(ERROR) << "PostSubBuffer failed because no parent stub."; | 236 LOG(ERROR) << "PostSubBuffer failed because no parent stub."; |
228 return false; | 237 return false; |
229 } | 238 } |
230 | 239 |
231 DCHECK(textures_[back()].info); | 240 DCHECK(textures_[back()].info); |
232 int back_texture_service_id = textures_[back()].info->service_id(); | 241 int back_texture_service_id = textures_[back()].info->service_id(); |
233 | 242 |
234 DCHECK(textures_[front_].info); | 243 DCHECK(textures_[front_].info); |
235 int front_texture_service_id = textures_[front_].info->service_id(); | 244 int front_texture_service_id = textures_[front_].info->service_id(); |
(...skipping 195 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 |