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