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

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

Issue 27420004: Remove threading from RendererGpuVideoAcceleratorFactories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dthread
Patch Set: 2d3efbfa Rebase. Created 7 years, 1 month 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
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"
11 #include "base/cpu.h" 11 #include "base/cpu.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/task_runner_util.h" 14 #include "base/task_runner_util.h"
15 #include "media/base/bind_to_loop.h" 15 #include "media/base/bind_to_loop.h"
16 #include "media/base/decoder_buffer.h" 16 #include "media/base/decoder_buffer.h"
17 #include "media/base/media_log.h" 17 #include "media/base/media_log.h"
18 #include "media/base/pipeline.h" 18 #include "media/base/pipeline.h"
19 #include "media/base/pipeline_status.h" 19 #include "media/base/pipeline_status.h"
20 #include "media/base/video_decoder_config.h" 20 #include "media/base/video_decoder_config.h"
21 #include "media/filters/gpu_video_accelerator_factories.h" 21 #include "media/filters/gpu_video_accelerator_factories.h"
22 #include "third_party/skia/include/core/SkBitmap.h"
22 23
23 namespace media { 24 namespace media {
24 25
25 // Maximum number of concurrent VDA::Decode() operations GVD will maintain. 26 // Maximum number of concurrent VDA::Decode() operations GVD will maintain.
26 // Higher values allow better pipelining in the GPU, but also require more 27 // Higher values allow better pipelining in the GPU, but also require more
27 // resources. 28 // resources.
28 enum { kMaxInFlightDecodes = 4 }; 29 enum { kMaxInFlightDecodes = 4 };
29 30
30 // Size of shared-memory segments we allocate. Since we reuse them we let them 31 // Size of shared-memory segments we allocate. Since we reuse them we let them
31 // be on the beefy side. 32 // be on the beefy side.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 next_picture_buffer_id_(0), 66 next_picture_buffer_id_(0),
66 next_bitstream_buffer_id_(0), 67 next_bitstream_buffer_id_(0),
67 available_pictures_(0) { 68 available_pictures_(0) {
68 DCHECK(factories_.get()); 69 DCHECK(factories_.get());
69 } 70 }
70 71
71 void GpuVideoDecoder::Reset(const base::Closure& closure) { 72 void GpuVideoDecoder::Reset(const base::Closure& closure) {
72 DVLOG(3) << "Reset()"; 73 DVLOG(3) << "Reset()";
73 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread()); 74 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread());
74 75
75 if (state_ == kDrainingDecoder && !factories_->IsAborted()) { 76 if (state_ == kDrainingDecoder) {
76 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( 77 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind(
77 &GpuVideoDecoder::Reset, weak_this_, closure)); 78 &GpuVideoDecoder::Reset, weak_this_, closure));
78 // NOTE: if we're deferring Reset() until a Flush() completes, return 79 // NOTE: if we're deferring Reset() until a Flush() completes, return
79 // queued pictures to the VDA so they can be used to finish that Flush(). 80 // queued pictures to the VDA so they can be used to finish that Flush().
80 if (pending_decode_cb_.is_null()) 81 if (pending_decode_cb_.is_null())
81 ready_video_frames_.clear(); 82 ready_video_frames_.clear();
82 return; 83 return;
83 } 84 }
84 85
85 // Throw away any already-decoded, not-yet-delivered frames. 86 // Throw away any already-decoded, not-yet-delivered frames.
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 pb.texture_mailbox(), 434 pb.texture_mailbox(),
434 0, // sync_point 435 0, // sync_point
435 BindToCurrentLoop(base::Bind(&GpuVideoDecoder::ReusePictureBuffer, 436 BindToCurrentLoop(base::Bind(&GpuVideoDecoder::ReusePictureBuffer,
436 weak_this_, 437 weak_this_,
437 picture.picture_buffer_id()))), 438 picture.picture_buffer_id()))),
438 decoder_texture_target_, 439 decoder_texture_target_,
439 pb.size(), 440 pb.size(),
440 visible_rect, 441 visible_rect,
441 natural_size, 442 natural_size,
442 timestamp, 443 timestamp,
443 base::Bind(&GpuVideoAcceleratorFactories::ReadPixels, 444 media::BindToLoopSync(
444 factories_, 445 factories_->GetMessageLoop(), base::Bind(
445 pb.texture_id(), 446 &GpuVideoAcceleratorFactories::ReadPixels,
446 gfx::Size(visible_rect.width(), visible_rect.height())), 447 factories_,
448 pb.texture_id(),
449 gfx::Size(visible_rect.width(), visible_rect.height()))),
447 base::Closure())); 450 base::Closure()));
448 CHECK_GT(available_pictures_, 0); 451 CHECK_GT(available_pictures_, 0);
449 --available_pictures_; 452 --available_pictures_;
450 bool inserted = 453 bool inserted =
451 picture_buffers_at_display_.insert(picture.picture_buffer_id()).second; 454 picture_buffers_at_display_.insert(picture.picture_buffer_id()).second;
452 DCHECK(inserted); 455 DCHECK(inserted);
453 456
454 EnqueueFrameAndTriggerFrameDelivery(frame); 457 EnqueueFrameAndTriggerFrameDelivery(frame);
455 } 458 }
456 459
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 606
604 state_ = kError; 607 state_ = kError;
605 608
606 if (!pending_decode_cb_.is_null()) { 609 if (!pending_decode_cb_.is_null()) {
607 base::ResetAndReturn(&pending_decode_cb_).Run(kDecodeError, NULL); 610 base::ResetAndReturn(&pending_decode_cb_).Run(kDecodeError, NULL);
608 return; 611 return;
609 } 612 }
610 } 613 }
611 614
612 } // namespace media 615 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698