Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: media/filters/gpu_video_decoder.cc

Issue 105743004: Add gpu::MailboxHolder to hold state for a gpu::Mailbox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: c301e01d Rebase. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "media/filters/gpu_video_decoder.h" 5 #include "media/filters/gpu_video_decoder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 436
437 // Update frame's timestamp. 437 // Update frame's timestamp.
438 base::TimeDelta timestamp; 438 base::TimeDelta timestamp;
439 gfx::Rect visible_rect; 439 gfx::Rect visible_rect;
440 gfx::Size natural_size; 440 gfx::Size natural_size;
441 GetBufferData(picture.bitstream_buffer_id(), &timestamp, &visible_rect, 441 GetBufferData(picture.bitstream_buffer_id(), &timestamp, &visible_rect,
442 &natural_size); 442 &natural_size);
443 DCHECK(decoder_texture_target_); 443 DCHECK(decoder_texture_target_);
444 444
445 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTexture( 445 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTexture(
446 make_scoped_ptr(new VideoFrame::MailboxHolder( 446 make_scoped_ptr(new gpu::MailboxHolder(
447 pb.texture_mailbox(), 447 pb.texture_mailbox(), decoder_texture_target_, 0 /* sync_point */)),
448 0, // sync_point 448 BindToCurrentLoop(base::Bind(&GpuVideoDecoder::ReusePictureBuffer,
449 BindToCurrentLoop(base::Bind(&GpuVideoDecoder::ReusePictureBuffer, 449 weak_this_,
450 weak_this_, 450 picture.picture_buffer_id())),
451 picture.picture_buffer_id())))),
452 decoder_texture_target_,
453 pb.size(), 451 pb.size(),
454 visible_rect, 452 visible_rect,
455 natural_size, 453 natural_size,
456 timestamp, 454 timestamp,
457 base::Bind(&GpuVideoAcceleratorFactories::ReadPixels, 455 base::Bind(&GpuVideoAcceleratorFactories::ReadPixels,
458 factories_, 456 factories_,
459 pb.texture_id(), 457 pb.texture_id(),
460 gfx::Size(visible_rect.width(), visible_rect.height())), 458 gfx::Size(visible_rect.width(), visible_rect.height()))));
461 base::Closure()));
462 CHECK_GT(available_pictures_, 0); 459 CHECK_GT(available_pictures_, 0);
463 --available_pictures_; 460 --available_pictures_;
464 bool inserted = 461 bool inserted =
465 picture_buffers_at_display_.insert(picture.picture_buffer_id()).second; 462 picture_buffers_at_display_.insert(picture.picture_buffer_id()).second;
466 DCHECK(inserted); 463 DCHECK(inserted);
467 464
468 EnqueueFrameAndTriggerFrameDelivery(frame); 465 EnqueueFrameAndTriggerFrameDelivery(frame);
469 } 466 }
470 467
471 void GpuVideoDecoder::EnqueueFrameAndTriggerFrameDelivery( 468 void GpuVideoDecoder::EnqueueFrameAndTriggerFrameDelivery(
(...skipping 11 matching lines...) Expand all
483 DCHECK(!ready_video_frames_.empty()); 480 DCHECK(!ready_video_frames_.empty());
484 481
485 if (pending_decode_cb_.is_null()) 482 if (pending_decode_cb_.is_null())
486 return; 483 return;
487 484
488 base::ResetAndReturn(&pending_decode_cb_) 485 base::ResetAndReturn(&pending_decode_cb_)
489 .Run(kOk, ready_video_frames_.front()); 486 .Run(kOk, ready_video_frames_.front());
490 ready_video_frames_.pop_front(); 487 ready_video_frames_.pop_front();
491 } 488 }
492 489
493 void GpuVideoDecoder::ReusePictureBuffer(int64 picture_buffer_id, 490 void GpuVideoDecoder::ReusePictureBuffer(
494 uint32 sync_point) { 491 int64 picture_buffer_id,
492 scoped_ptr<gpu::MailboxHolder> mailbox_holder) {
495 DVLOG(3) << "ReusePictureBuffer(" << picture_buffer_id << ")"; 493 DVLOG(3) << "ReusePictureBuffer(" << picture_buffer_id << ")";
496 DCHECK(gvd_task_runner_->BelongsToCurrentThread()); 494 DCHECK(gvd_task_runner_->BelongsToCurrentThread());
497 495
498 if (!vda_) 496 if (!vda_)
499 return; 497 return;
500 498
501 CHECK(!picture_buffers_at_display_.empty()); 499 CHECK(!picture_buffers_at_display_.empty());
502 500
503 size_t num_erased = picture_buffers_at_display_.erase(picture_buffer_id); 501 size_t num_erased = picture_buffers_at_display_.erase(picture_buffer_id);
504 DCHECK(num_erased); 502 DCHECK(num_erased);
505 503
506 PictureBufferMap::iterator it = 504 PictureBufferMap::iterator it =
507 assigned_picture_buffers_.find(picture_buffer_id); 505 assigned_picture_buffers_.find(picture_buffer_id);
508 506
509 if (it == assigned_picture_buffers_.end()) { 507 if (it == assigned_picture_buffers_.end()) {
510 // This picture was dismissed while in display, so we postponed deletion. 508 // This picture was dismissed while in display, so we postponed deletion.
511 it = dismissed_picture_buffers_.find(picture_buffer_id); 509 it = dismissed_picture_buffers_.find(picture_buffer_id);
512 DCHECK(it != dismissed_picture_buffers_.end()); 510 DCHECK(it != dismissed_picture_buffers_.end());
513 factories_->DeleteTexture(it->second.texture_id()); 511 factories_->DeleteTexture(it->second.texture_id());
514 dismissed_picture_buffers_.erase(it); 512 dismissed_picture_buffers_.erase(it);
515 return; 513 return;
516 } 514 }
517 515
518 factories_->WaitSyncPoint(sync_point); 516 factories_->WaitSyncPoint(mailbox_holder->sync_point);
519 ++available_pictures_; 517 ++available_pictures_;
520 518
521 vda_->ReusePictureBuffer(picture_buffer_id); 519 vda_->ReusePictureBuffer(picture_buffer_id);
522 } 520 }
523 521
524 GpuVideoDecoder::SHMBuffer* GpuVideoDecoder::GetSHM(size_t min_size) { 522 GpuVideoDecoder::SHMBuffer* GpuVideoDecoder::GetSHM(size_t min_size) {
525 DCHECK(gvd_task_runner_->BelongsToCurrentThread()); 523 DCHECK(gvd_task_runner_->BelongsToCurrentThread());
526 if (available_shm_segments_.empty() || 524 if (available_shm_segments_.empty() ||
527 available_shm_segments_.back()->size < min_size) { 525 available_shm_segments_.back()->size < min_size) {
528 size_t size_to_allocate = std::max(min_size, kSharedMemorySegmentBytes); 526 size_t size_to_allocate = std::max(min_size, kSharedMemorySegmentBytes);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 615
618 state_ = kError; 616 state_ = kError;
619 617
620 if (!pending_decode_cb_.is_null()) { 618 if (!pending_decode_cb_.is_null()) {
621 base::ResetAndReturn(&pending_decode_cb_).Run(kDecodeError, NULL); 619 base::ResetAndReturn(&pending_decode_cb_).Run(kDecodeError, NULL);
622 return; 620 return;
623 } 621 }
624 } 622 }
625 623
626 } // namespace media 624 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698