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_); |
| 214 if (!frontbuffer_suggested_allocation_) { |
| 215 previous_damage_rect_ = gfx::Rect(textures_[front_].size); |
| 216 return true; |
| 217 } |
206 if (!parent_stub_) { | 218 if (!parent_stub_) { |
207 LOG(ERROR) << "SwapBuffers failed because no parent stub."; | 219 LOG(ERROR) << "SwapBuffers failed because no parent stub."; |
208 return false; | 220 return false; |
209 } | 221 } |
210 | 222 |
211 glFlush(); | 223 glFlush(); |
212 front_ = back(); | 224 front_ = back(); |
213 previous_damage_rect_ = gfx::Rect(textures_[front_].size); | 225 previous_damage_rect_ = gfx::Rect(textures_[front_].size); |
214 | 226 |
215 DCHECK(textures_[front_].client_id != 0); | 227 DCHECK(textures_[front_].client_id != 0); |
216 | 228 |
217 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 229 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
218 params.surface_handle = textures_[front_].client_id; | 230 params.surface_handle = textures_[front_].client_id; |
219 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 231 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
220 helper_->SetScheduled(false); | 232 helper_->SetScheduled(false); |
221 return true; | 233 return true; |
222 } | 234 } |
223 | 235 |
224 bool TextureImageTransportSurface::PostSubBuffer( | 236 bool TextureImageTransportSurface::PostSubBuffer( |
225 int x, int y, int width, int height) { | 237 int x, int y, int width, int height) { |
| 238 DCHECK(backbuffer_suggested_allocation_); |
| 239 if (!frontbuffer_suggested_allocation_) { |
| 240 previous_damage_rect_ = gfx::Rect(textures_[front_].size); |
| 241 return true; |
| 242 } |
226 if (!parent_stub_) { | 243 if (!parent_stub_) { |
227 LOG(ERROR) << "PostSubBuffer failed because no parent stub."; | 244 LOG(ERROR) << "PostSubBuffer failed because no parent stub."; |
228 return false; | 245 return false; |
229 } | 246 } |
230 | 247 |
231 DCHECK(textures_[back()].info); | 248 DCHECK(textures_[back()].info); |
232 int back_texture_service_id = textures_[back()].info->service_id(); | 249 int back_texture_service_id = textures_[back()].info->service_id(); |
233 | 250 |
234 DCHECK(textures_[front_].info); | 251 DCHECK(textures_[front_].info); |
235 int front_texture_service_id = textures_[front_].info->service_id(); | 252 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]; | 448 Texture& texture = textures_[i]; |
432 texture.info = NULL; | 449 texture.info = NULL; |
433 if (!texture.sent_to_client) | 450 if (!texture.sent_to_client) |
434 continue; | 451 continue; |
435 GpuHostMsg_AcceleratedSurfaceRelease_Params params; | 452 GpuHostMsg_AcceleratedSurfaceRelease_Params params; |
436 params.identifier = texture.client_id; | 453 params.identifier = texture.client_id; |
437 helper_->SendAcceleratedSurfaceRelease(params); | 454 helper_->SendAcceleratedSurfaceRelease(params); |
438 } | 455 } |
439 parent_stub_ = NULL; | 456 parent_stub_ = NULL; |
440 } | 457 } |
OLD | NEW |