OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "gpu/command_buffer/service/async_pixel_transfer_manager_share_group.h" | 5 #include "gpu/command_buffer/service/async_pixel_transfer_manager_share_group.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "base/debug/trace_event_synthetic_delay.h" |
11 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
15 #include "base/synchronization/cancellation_flag.h" | 16 #include "base/synchronization/cancellation_flag.h" |
16 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
17 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" |
18 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
19 #include "base/threading/thread_checker.h" | 20 #include "base/threading/thread_checker.h" |
20 #include "gpu/command_buffer/service/async_pixel_transfer_delegate.h" | 21 #include "gpu/command_buffer/service/async_pixel_transfer_delegate.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 if (pending_upload_task_.get()) | 245 if (pending_upload_task_.get()) |
245 pending_upload_task_->Cancel(); | 246 pending_upload_task_->Cancel(); |
246 pending_upload_task_ = NULL; | 247 pending_upload_task_ = NULL; |
247 } | 248 } |
248 | 249 |
249 void ScheduleAsyncTexImage2D( | 250 void ScheduleAsyncTexImage2D( |
250 const AsyncTexImage2DParams tex_params, | 251 const AsyncTexImage2DParams tex_params, |
251 const AsyncMemoryParams mem_params, | 252 const AsyncMemoryParams mem_params, |
252 scoped_refptr<AsyncPixelTransferUploadStats> texture_upload_stats, | 253 scoped_refptr<AsyncPixelTransferUploadStats> texture_upload_stats, |
253 const base::Closure& bind_callback) { | 254 const base::Closure& bind_callback) { |
| 255 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("gpu.AsyncTexImage"); |
254 pending_upload_task_ = new PendingTask(base::Bind( | 256 pending_upload_task_ = new PendingTask(base::Bind( |
255 &TransferStateInternal::PerformAsyncTexImage2D, | 257 &TransferStateInternal::PerformAsyncTexImage2D, |
256 this, | 258 this, |
257 tex_params, | 259 tex_params, |
258 mem_params, | 260 mem_params, |
259 // Duplicate the shared memory so there is no way we can get | 261 // Duplicate the shared memory so there is no way we can get |
260 // a use-after-free of the raw pixels. | 262 // a use-after-free of the raw pixels. |
261 base::Owned(new ScopedSafeSharedMemory(safe_shared_memory_pool(), | 263 base::Owned(new ScopedSafeSharedMemory(safe_shared_memory_pool(), |
262 mem_params.shared_memory, | 264 mem_params.shared_memory, |
263 mem_params.shm_size)), | 265 mem_params.shm_size)), |
264 texture_upload_stats)); | 266 texture_upload_stats)); |
265 transfer_message_loop_proxy()->PostTask( | 267 transfer_message_loop_proxy()->PostTask( |
266 FROM_HERE, | 268 FROM_HERE, |
267 base::Bind( | 269 base::Bind( |
268 &PendingTask::BindAndRun, pending_upload_task_, texture_id_)); | 270 &PendingTask::BindAndRun, pending_upload_task_, texture_id_)); |
269 | 271 |
270 // Save the late bind callback, so we can notify the client when it is | 272 // Save the late bind callback, so we can notify the client when it is |
271 // bound. | 273 // bound. |
272 bind_callback_ = bind_callback; | 274 bind_callback_ = bind_callback; |
273 } | 275 } |
274 | 276 |
275 void ScheduleAsyncTexSubImage2D( | 277 void ScheduleAsyncTexSubImage2D( |
276 AsyncTexSubImage2DParams tex_params, | 278 AsyncTexSubImage2DParams tex_params, |
277 AsyncMemoryParams mem_params, | 279 AsyncMemoryParams mem_params, |
278 scoped_refptr<AsyncPixelTransferUploadStats> texture_upload_stats) { | 280 scoped_refptr<AsyncPixelTransferUploadStats> texture_upload_stats) { |
| 281 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("gpu.AsyncTexImage"); |
279 pending_upload_task_ = new PendingTask(base::Bind( | 282 pending_upload_task_ = new PendingTask(base::Bind( |
280 &TransferStateInternal::PerformAsyncTexSubImage2D, | 283 &TransferStateInternal::PerformAsyncTexSubImage2D, |
281 this, | 284 this, |
282 tex_params, | 285 tex_params, |
283 mem_params, | 286 mem_params, |
284 base::Owned(new ScopedSafeSharedMemory(safe_shared_memory_pool(), | 287 base::Owned(new ScopedSafeSharedMemory(safe_shared_memory_pool(), |
285 mem_params.shared_memory, | 288 mem_params.shared_memory, |
286 mem_params.shm_size)), | 289 mem_params.shm_size)), |
287 texture_upload_stats)); | 290 texture_upload_stats)); |
288 transfer_message_loop_proxy()->PostTask( | 291 transfer_message_loop_proxy()->PostTask( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 TRACE_EVENT0("gpu", "glTexImage2D"); | 324 TRACE_EVENT0("gpu", "glTexImage2D"); |
322 glTexImage2D(GL_TEXTURE_2D, | 325 glTexImage2D(GL_TEXTURE_2D, |
323 tex_params.level, | 326 tex_params.level, |
324 tex_params.internal_format, | 327 tex_params.internal_format, |
325 tex_params.width, | 328 tex_params.width, |
326 tex_params.height, | 329 tex_params.height, |
327 tex_params.border, | 330 tex_params.border, |
328 tex_params.format, | 331 tex_params.format, |
329 tex_params.type, | 332 tex_params.type, |
330 data); | 333 data); |
| 334 TRACE_EVENT_SYNTHETIC_DELAY_END("gpu.AsyncTexImage"); |
331 } | 335 } |
332 | 336 |
333 if (texture_upload_stats.get()) { | 337 if (texture_upload_stats.get()) { |
334 texture_upload_stats->AddUpload(base::TimeTicks::HighResNow() - | 338 texture_upload_stats->AddUpload(base::TimeTicks::HighResNow() - |
335 begin_time); | 339 begin_time); |
336 } | 340 } |
337 } | 341 } |
338 | 342 |
339 void PerformAsyncTexSubImage2D( | 343 void PerformAsyncTexSubImage2D( |
340 AsyncTexSubImage2DParams tex_params, | 344 AsyncTexSubImage2DParams tex_params, |
(...skipping 19 matching lines...) Expand all Loading... |
360 TRACE_EVENT0("gpu", "glTexSubImage2D"); | 364 TRACE_EVENT0("gpu", "glTexSubImage2D"); |
361 glTexSubImage2D(GL_TEXTURE_2D, | 365 glTexSubImage2D(GL_TEXTURE_2D, |
362 tex_params.level, | 366 tex_params.level, |
363 tex_params.xoffset, | 367 tex_params.xoffset, |
364 tex_params.yoffset, | 368 tex_params.yoffset, |
365 tex_params.width, | 369 tex_params.width, |
366 tex_params.height, | 370 tex_params.height, |
367 tex_params.format, | 371 tex_params.format, |
368 tex_params.type, | 372 tex_params.type, |
369 data); | 373 data); |
| 374 TRACE_EVENT_SYNTHETIC_DELAY_END("gpu.AsyncTexImage"); |
370 } | 375 } |
371 | 376 |
372 if (texture_upload_stats.get()) { | 377 if (texture_upload_stats.get()) { |
373 texture_upload_stats->AddUpload(base::TimeTicks::HighResNow() - | 378 texture_upload_stats->AddUpload(base::TimeTicks::HighResNow() - |
374 begin_time); | 379 begin_time); |
375 } | 380 } |
376 } | 381 } |
377 | 382 |
378 scoped_refptr<PendingTask> pending_upload_task_; | 383 scoped_refptr<PendingTask> pending_upload_task_; |
379 | 384 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 | 575 |
571 AsyncPixelTransferDelegate* | 576 AsyncPixelTransferDelegate* |
572 AsyncPixelTransferManagerShareGroup::CreatePixelTransferDelegateImpl( | 577 AsyncPixelTransferManagerShareGroup::CreatePixelTransferDelegateImpl( |
573 gles2::TextureRef* ref, | 578 gles2::TextureRef* ref, |
574 const AsyncTexImage2DParams& define_params) { | 579 const AsyncTexImage2DParams& define_params) { |
575 return new AsyncPixelTransferDelegateShareGroup( | 580 return new AsyncPixelTransferDelegateShareGroup( |
576 &shared_state_, ref->service_id(), define_params); | 581 &shared_state_, ref->service_id(), define_params); |
577 } | 582 } |
578 | 583 |
579 } // namespace gpu | 584 } // namespace gpu |
OLD | NEW |