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

Side by Side Diff: content/common/gpu/media/fake_video_decode_accelerator.cc

Issue 1134113002: content/common: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix CrOS build. Created 5 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/media/fake_video_decode_accelerator.h" 5 #include "content/common/gpu/media/fake_video_decode_accelerator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/thread_task_runner_handle.h"
9 #include "media/base/bitstream_buffer.h" 10 #include "media/base/bitstream_buffer.h"
10 #include "media/base/limits.h" 11 #include "media/base/limits.h"
11 #include "ui/gl/gl_context.h" 12 #include "ui/gl/gl_context.h"
12 #include "ui/gl/gl_implementation.h" 13 #include "ui/gl/gl_implementation.h"
13 #include "ui/gl/gl_surface.h" 14 #include "ui/gl/gl_surface.h"
14 #include "ui/gl/gl_surface_egl.h" 15 #include "ui/gl/gl_surface_egl.h"
15 #include "ui/gl/gl_surface_glx.h" 16 #include "ui/gl/gl_surface_glx.h"
16 17
17 namespace content { 18 namespace content {
18 19
19 static const uint32 kDefaultTextureTarget = GL_TEXTURE_2D; 20 static const uint32 kDefaultTextureTarget = GL_TEXTURE_2D;
20 // Must be at least 2 since the rendering helper will switch between textures 21 // Must be at least 2 since the rendering helper will switch between textures
21 // and if there is only one, it will wait for the next one that will never come. 22 // and if there is only one, it will wait for the next one that will never come.
22 // Must also be an even number as otherwise there won't be the same amount of 23 // Must also be an even number as otherwise there won't be the same amount of
23 // white and black frames. 24 // white and black frames.
24 static const unsigned int kNumBuffers = media::limits::kMaxVideoFrames + 25 static const unsigned int kNumBuffers = media::limits::kMaxVideoFrames +
25 (media::limits::kMaxVideoFrames & 1u); 26 (media::limits::kMaxVideoFrames & 1u);
26 27
27 FakeVideoDecodeAccelerator::FakeVideoDecodeAccelerator( 28 FakeVideoDecodeAccelerator::FakeVideoDecodeAccelerator(
28 gfx::GLContext* gl, 29 gfx::GLContext* gl,
29 gfx::Size size, 30 gfx::Size size,
30 const base::Callback<bool(void)>& make_context_current) 31 const base::Callback<bool(void)>& make_context_current)
31 : child_message_loop_proxy_(base::MessageLoopProxy::current()), 32 : child_task_runner_(base::ThreadTaskRunnerHandle::Get()),
32 client_(NULL), 33 client_(NULL),
33 make_context_current_(make_context_current), 34 make_context_current_(make_context_current),
34 gl_(gl), 35 gl_(gl),
35 frame_buffer_size_(size), 36 frame_buffer_size_(size),
36 flushing_(false), 37 flushing_(false),
37 weak_this_factory_(this) { 38 weak_this_factory_(this) {
38 } 39 }
39 40
40 FakeVideoDecodeAccelerator::~FakeVideoDecodeAccelerator() { 41 FakeVideoDecodeAccelerator::~FakeVideoDecodeAccelerator() {
41 } 42 }
42 43
43 bool FakeVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile, 44 bool FakeVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile,
44 Client* client) { 45 Client* client) {
45 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); 46 DCHECK(child_task_runner_->BelongsToCurrentThread());
46 if (profile == media::VIDEO_CODEC_PROFILE_UNKNOWN) { 47 if (profile == media::VIDEO_CODEC_PROFILE_UNKNOWN) {
47 LOG(ERROR) << "unknown codec profile"; 48 LOG(ERROR) << "unknown codec profile";
48 return false; 49 return false;
49 } 50 }
50 // V4L2VideoDecodeAccelerator waits until first decode call to ask for buffers 51 // V4L2VideoDecodeAccelerator waits until first decode call to ask for buffers
51 // This class asks for it on initialization instead. 52 // This class asks for it on initialization instead.
52 client_ = client; 53 client_ = client;
53 client_->ProvidePictureBuffers(kNumBuffers, 54 client_->ProvidePictureBuffers(kNumBuffers,
54 frame_buffer_size_, 55 frame_buffer_size_,
55 kDefaultTextureTarget); 56 kDefaultTextureTarget);
56 return true; 57 return true;
57 } 58 }
58 59
59 void FakeVideoDecodeAccelerator::Decode( 60 void FakeVideoDecodeAccelerator::Decode(
60 const media::BitstreamBuffer& bitstream_buffer) { 61 const media::BitstreamBuffer& bitstream_buffer) {
61 int bitstream_buffer_id = bitstream_buffer.id(); 62 int bitstream_buffer_id = bitstream_buffer.id();
62 queued_bitstream_ids_.push(bitstream_buffer_id); 63 queued_bitstream_ids_.push(bitstream_buffer_id);
63 child_message_loop_proxy_->PostTask( 64 child_task_runner_->PostTask(
64 FROM_HERE, 65 FROM_HERE, base::Bind(&FakeVideoDecodeAccelerator::DoPictureReady,
65 base::Bind(&FakeVideoDecodeAccelerator::DoPictureReady, 66 weak_this_factory_.GetWeakPtr()));
66 weak_this_factory_.GetWeakPtr()));
67 } 67 }
68 68
69 // Similar to UseOutputBitstreamBuffer for the encode accelerator. 69 // Similar to UseOutputBitstreamBuffer for the encode accelerator.
70 void FakeVideoDecodeAccelerator::AssignPictureBuffers( 70 void FakeVideoDecodeAccelerator::AssignPictureBuffers(
71 const std::vector<media::PictureBuffer>& buffers) { 71 const std::vector<media::PictureBuffer>& buffers) {
72 DCHECK(buffers.size() == kNumBuffers); 72 DCHECK(buffers.size() == kNumBuffers);
73 DCHECK(!(buffers.size()%2)); 73 DCHECK(!(buffers.size()%2));
74 74
75 // Save buffers and mark all buffers as ready for use. 75 // Save buffers and mark all buffers as ready for use.
76 scoped_ptr<uint8[]> white_data( 76 scoped_ptr<uint8[]> white_data(
(...skipping 23 matching lines...) Expand all
100 GL_RGBA, 100 GL_RGBA,
101 GL_UNSIGNED_BYTE, 101 GL_UNSIGNED_BYTE,
102 data); 102 data);
103 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 103 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
104 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 104 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
105 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 105 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
106 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 106 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
107 glBindTexture(GL_TEXTURE_2D, 0); 107 glBindTexture(GL_TEXTURE_2D, 0);
108 free_output_buffers_.push(buffers[index].id()); 108 free_output_buffers_.push(buffers[index].id());
109 } 109 }
110 child_message_loop_proxy_->PostTask( 110 child_task_runner_->PostTask(
111 FROM_HERE, 111 FROM_HERE, base::Bind(&FakeVideoDecodeAccelerator::DoPictureReady,
112 base::Bind(&FakeVideoDecodeAccelerator::DoPictureReady, 112 weak_this_factory_.GetWeakPtr()));
113 weak_this_factory_.GetWeakPtr()));
114 } 113 }
115 114
116 void FakeVideoDecodeAccelerator::ReusePictureBuffer(int32 picture_buffer_id) { 115 void FakeVideoDecodeAccelerator::ReusePictureBuffer(int32 picture_buffer_id) {
117 free_output_buffers_.push(picture_buffer_id); 116 free_output_buffers_.push(picture_buffer_id);
118 child_message_loop_proxy_->PostTask( 117 child_task_runner_->PostTask(
119 FROM_HERE, 118 FROM_HERE, base::Bind(&FakeVideoDecodeAccelerator::DoPictureReady,
120 base::Bind(&FakeVideoDecodeAccelerator::DoPictureReady, 119 weak_this_factory_.GetWeakPtr()));
121 weak_this_factory_.GetWeakPtr()));
122 } 120 }
123 121
124 void FakeVideoDecodeAccelerator::Flush() { 122 void FakeVideoDecodeAccelerator::Flush() {
125 flushing_ = true; 123 flushing_ = true;
126 child_message_loop_proxy_->PostTask( 124 child_task_runner_->PostTask(
127 FROM_HERE, 125 FROM_HERE, base::Bind(&FakeVideoDecodeAccelerator::DoPictureReady,
128 base::Bind(&FakeVideoDecodeAccelerator::DoPictureReady, 126 weak_this_factory_.GetWeakPtr()));
129 weak_this_factory_.GetWeakPtr()));
130 } 127 }
131 128
132 void FakeVideoDecodeAccelerator::Reset() { 129 void FakeVideoDecodeAccelerator::Reset() {
133 while (!queued_bitstream_ids_.empty()) { 130 while (!queued_bitstream_ids_.empty()) {
134 client_->NotifyEndOfBitstreamBuffer(queued_bitstream_ids_.front()); 131 client_->NotifyEndOfBitstreamBuffer(queued_bitstream_ids_.front());
135 queued_bitstream_ids_.pop(); 132 queued_bitstream_ids_.pop();
136 } 133 }
137 client_->NotifyResetDone(); 134 client_->NotifyResetDone();
138 } 135 }
139 136
(...skipping 29 matching lines...) Expand all
169 // Bitstream no longer needed. 166 // Bitstream no longer needed.
170 client_->NotifyEndOfBitstreamBuffer(bitstream_id); 167 client_->NotifyEndOfBitstreamBuffer(bitstream_id);
171 if (flushing_ && queued_bitstream_ids_.empty()) { 168 if (flushing_ && queued_bitstream_ids_.empty()) {
172 flushing_ = false; 169 flushing_ = false;
173 client_->NotifyFlushDone(); 170 client_->NotifyFlushDone();
174 } 171 }
175 } 172 }
176 } 173 }
177 174
178 } // namespace content 175 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/fake_video_decode_accelerator.h ('k') | content/common/gpu/media/gpu_video_decode_accelerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698