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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 211 |
212 if (!backbuffer_.get()) { | 212 if (!backbuffer_.get()) { |
213 LOG(ERROR) << "Swap without valid backing."; | 213 LOG(ERROR) << "Swap without valid backing."; |
214 return true; | 214 return true; |
215 } | 215 } |
216 | 216 |
217 DCHECK(backbuffer_size() == current_size_); | 217 DCHECK(backbuffer_size() == current_size_); |
218 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 218 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
219 params.size = backbuffer_size(); | 219 params.size = backbuffer_size(); |
220 params.scale_factor = scale_factor_; | 220 params.scale_factor = scale_factor_; |
221 params.mailbox = back_mailbox_; | 221 params.mailbox_name.assign( |
| 222 reinterpret_cast<const char*>(&back_mailbox_), |
| 223 sizeof(back_mailbox_)); |
222 | 224 |
223 glFlush(); | 225 glFlush(); |
224 | 226 |
225 params.latency_info.swap(latency_info_); | 227 params.latency_info.swap(latency_info_); |
226 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 228 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
227 | 229 |
228 DCHECK(!is_swap_buffers_pending_); | 230 DCHECK(!is_swap_buffers_pending_); |
229 is_swap_buffers_pending_ = true; | 231 is_swap_buffers_pending_ = true; |
230 return true; | 232 return true; |
231 } | 233 } |
(...skipping 17 matching lines...) Expand all Loading... |
249 } | 251 } |
250 | 252 |
251 DCHECK(current_size_ == backbuffer_size()); | 253 DCHECK(current_size_ == backbuffer_size()); |
252 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; | 254 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; |
253 params.surface_size = backbuffer_size(); | 255 params.surface_size = backbuffer_size(); |
254 params.surface_scale_factor = scale_factor_; | 256 params.surface_scale_factor = scale_factor_; |
255 params.x = x; | 257 params.x = x; |
256 params.y = y; | 258 params.y = y; |
257 params.width = width; | 259 params.width = width; |
258 params.height = height; | 260 params.height = height; |
259 params.mailbox = back_mailbox_; | 261 params.mailbox_name.assign( |
| 262 reinterpret_cast<const char*>(&back_mailbox_), |
| 263 sizeof(back_mailbox_)); |
260 | 264 |
261 glFlush(); | 265 glFlush(); |
262 | 266 |
263 params.latency_info.swap(latency_info_); | 267 params.latency_info.swap(latency_info_); |
264 helper_->SendAcceleratedSurfacePostSubBuffer(params); | 268 helper_->SendAcceleratedSurfacePostSubBuffer(params); |
265 | 269 |
266 DCHECK(!is_swap_buffers_pending_); | 270 DCHECK(!is_swap_buffers_pending_); |
267 is_swap_buffers_pending_ = true; | 271 is_swap_buffers_pending_ = true; |
268 return true; | 272 return true; |
269 } | 273 } |
(...skipping 13 matching lines...) Expand all Loading... |
283 return surface_.get() ? surface_->GetHandle() : NULL; | 287 return surface_.get() ? surface_->GetHandle() : NULL; |
284 } | 288 } |
285 | 289 |
286 unsigned TextureImageTransportSurface::GetFormat() { | 290 unsigned TextureImageTransportSurface::GetFormat() { |
287 return surface_.get() ? surface_->GetFormat() : 0; | 291 return surface_.get() ? surface_->GetFormat() : 0; |
288 } | 292 } |
289 | 293 |
290 void TextureImageTransportSurface::OnBufferPresented( | 294 void TextureImageTransportSurface::OnBufferPresented( |
291 const AcceleratedSurfaceMsg_BufferPresented_Params& params) { | 295 const AcceleratedSurfaceMsg_BufferPresented_Params& params) { |
292 if (params.sync_point == 0) { | 296 if (params.sync_point == 0) { |
293 BufferPresentedImpl(params.mailbox); | 297 BufferPresentedImpl(params.mailbox_name); |
294 } else { | 298 } else { |
295 helper_->manager()->sync_point_manager()->AddSyncPointCallback( | 299 helper_->manager()->sync_point_manager()->AddSyncPointCallback( |
296 params.sync_point, | 300 params.sync_point, |
297 base::Bind(&TextureImageTransportSurface::BufferPresentedImpl, | 301 base::Bind(&TextureImageTransportSurface::BufferPresentedImpl, |
298 this, | 302 this, |
299 params.mailbox)); | 303 params.mailbox_name)); |
300 } | 304 } |
301 } | 305 } |
302 | 306 |
303 void TextureImageTransportSurface::BufferPresentedImpl(const Mailbox& mailbox) { | 307 void TextureImageTransportSurface::BufferPresentedImpl( |
| 308 const std::string& mailbox_name) { |
304 DCHECK(is_swap_buffers_pending_); | 309 DCHECK(is_swap_buffers_pending_); |
305 is_swap_buffers_pending_ = false; | 310 is_swap_buffers_pending_ = false; |
306 | 311 |
307 // When we wait for a sync point, we may get called back after the stub is | 312 // When we wait for a sync point, we may get called back after the stub is |
308 // destroyed. In that case there's no need to do anything with the returned | 313 // destroyed. In that case there's no need to do anything with the returned |
309 // mailbox. | 314 // mailbox. |
310 if (stub_destroyed_) | 315 if (stub_destroyed_) |
311 return; | 316 return; |
312 | 317 |
313 // We should not have allowed the backbuffer to be discarded while the ack | 318 // We should not have allowed the backbuffer to be discarded while the ack |
314 // was pending. | 319 // was pending. |
315 DCHECK(backbuffer_suggested_allocation_); | 320 DCHECK(backbuffer_suggested_allocation_); |
316 DCHECK(backbuffer_.get()); | 321 DCHECK(backbuffer_.get()); |
317 | 322 |
318 bool swap = true; | 323 bool swap = true; |
319 if (!mailbox.IsZero()) { | 324 if (!mailbox_name.empty()) { |
320 if (mailbox != back_mailbox_) { | 325 DCHECK(mailbox_name.length() == GL_MAILBOX_SIZE_CHROMIUM); |
| 326 if (!memcmp(mailbox_name.data(), |
| 327 &back_mailbox_, |
| 328 mailbox_name.length())) { |
321 // The browser has skipped the frame to unblock the GPU process, waiting | 329 // The browser has skipped the frame to unblock the GPU process, waiting |
322 // for one of the right size, and returned the back buffer, so don't swap. | 330 // for one of the right size, and returned the back buffer, so don't swap. |
323 swap = false; | 331 swap = false; |
324 } | 332 } |
325 } | 333 } |
326 if (swap) { | 334 if (swap) { |
327 std::swap(backbuffer_, frontbuffer_); | 335 std::swap(backbuffer_, frontbuffer_); |
328 std::swap(back_mailbox_, front_mailbox_); | 336 std::swap(back_mailbox_, front_mailbox_); |
329 } | 337 } |
330 | 338 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 459 |
452 #ifndef NDEBUG | 460 #ifndef NDEBUG |
453 GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); | 461 GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); |
454 if (status != GL_FRAMEBUFFER_COMPLETE) { | 462 if (status != GL_FRAMEBUFFER_COMPLETE) { |
455 DLOG(FATAL) << "Framebuffer incomplete: " << status; | 463 DLOG(FATAL) << "Framebuffer incomplete: " << status; |
456 } | 464 } |
457 #endif | 465 #endif |
458 } | 466 } |
459 | 467 |
460 } // namespace content | 468 } // namespace content |
OLD | NEW |