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/client/gpu_video_decode_accelerator_host.h" | 5 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "content/common/gpu/client/gpu_channel_host.h" | 10 #include "content/common/gpu/client/gpu_channel_host.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 decoder_route_id_, handle, bitstream_buffer.id(), | 96 decoder_route_id_, handle, bitstream_buffer.id(), |
97 bitstream_buffer.size())); | 97 bitstream_buffer.size())); |
98 } | 98 } |
99 | 99 |
100 void GpuVideoDecodeAcceleratorHost::AssignPictureBuffers( | 100 void GpuVideoDecodeAcceleratorHost::AssignPictureBuffers( |
101 const std::vector<media::PictureBuffer>& buffers) { | 101 const std::vector<media::PictureBuffer>& buffers) { |
102 DCHECK(CalledOnValidThread()); | 102 DCHECK(CalledOnValidThread()); |
103 // Rearrange data for IPC command. | 103 // Rearrange data for IPC command. |
104 std::vector<int32> buffer_ids; | 104 std::vector<int32> buffer_ids; |
105 std::vector<uint32> texture_ids; | 105 std::vector<uint32> texture_ids; |
106 std::vector<gfx::Size> sizes; | |
107 for (uint32 i = 0; i < buffers.size(); i++) { | 106 for (uint32 i = 0; i < buffers.size(); i++) { |
108 const media::PictureBuffer& buffer = buffers[i]; | 107 const media::PictureBuffer& buffer = buffers[i]; |
| 108 if (buffer.size() != picture_buffer_dimensions_) { |
| 109 OnErrorNotification(INVALID_ARGUMENT); |
| 110 return; |
| 111 } |
109 texture_ids.push_back(buffer.texture_id()); | 112 texture_ids.push_back(buffer.texture_id()); |
110 buffer_ids.push_back(buffer.id()); | 113 buffer_ids.push_back(buffer.id()); |
111 sizes.push_back(buffer.size()); | |
112 } | 114 } |
113 Send(new AcceleratedVideoDecoderMsg_AssignPictureBuffers( | 115 Send(new AcceleratedVideoDecoderMsg_AssignPictureBuffers( |
114 decoder_route_id_, buffer_ids, texture_ids, sizes)); | 116 decoder_route_id_, buffer_ids, texture_ids)); |
115 } | 117 } |
116 | 118 |
117 void GpuVideoDecodeAcceleratorHost::ReusePictureBuffer( | 119 void GpuVideoDecodeAcceleratorHost::ReusePictureBuffer( |
118 int32 picture_buffer_id) { | 120 int32 picture_buffer_id) { |
119 DCHECK(CalledOnValidThread()); | 121 DCHECK(CalledOnValidThread()); |
120 Send(new AcceleratedVideoDecoderMsg_ReusePictureBuffer( | 122 Send(new AcceleratedVideoDecoderMsg_ReusePictureBuffer( |
121 decoder_route_id_, picture_buffer_id)); | 123 decoder_route_id_, picture_buffer_id)); |
122 } | 124 } |
123 | 125 |
124 void GpuVideoDecodeAcceleratorHost::Flush() { | 126 void GpuVideoDecodeAcceleratorHost::Flush() { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 179 |
178 void GpuVideoDecodeAcceleratorHost::OnBitstreamBufferProcessed( | 180 void GpuVideoDecodeAcceleratorHost::OnBitstreamBufferProcessed( |
179 int32 bitstream_buffer_id) { | 181 int32 bitstream_buffer_id) { |
180 DCHECK(CalledOnValidThread()); | 182 DCHECK(CalledOnValidThread()); |
181 if (client_) | 183 if (client_) |
182 client_->NotifyEndOfBitstreamBuffer(bitstream_buffer_id); | 184 client_->NotifyEndOfBitstreamBuffer(bitstream_buffer_id); |
183 } | 185 } |
184 | 186 |
185 void GpuVideoDecodeAcceleratorHost::OnProvidePictureBuffer( | 187 void GpuVideoDecodeAcceleratorHost::OnProvidePictureBuffer( |
186 uint32 num_requested_buffers, | 188 uint32 num_requested_buffers, |
187 const gfx::Size& buffer_size, | 189 const gfx::Size& dimensions, |
188 uint32 texture_target) { | 190 uint32 texture_target) { |
189 DCHECK(CalledOnValidThread()); | 191 DCHECK(CalledOnValidThread()); |
| 192 picture_buffer_dimensions_ = dimensions; |
190 if (client_) { | 193 if (client_) { |
191 client_->ProvidePictureBuffers( | 194 client_->ProvidePictureBuffers( |
192 num_requested_buffers, buffer_size, texture_target); | 195 num_requested_buffers, dimensions, texture_target); |
193 } | 196 } |
194 } | 197 } |
195 | 198 |
196 void GpuVideoDecodeAcceleratorHost::OnDismissPictureBuffer( | 199 void GpuVideoDecodeAcceleratorHost::OnDismissPictureBuffer( |
197 int32 picture_buffer_id) { | 200 int32 picture_buffer_id) { |
198 DCHECK(CalledOnValidThread()); | 201 DCHECK(CalledOnValidThread()); |
199 if (client_) | 202 if (client_) |
200 client_->DismissPictureBuffer(picture_buffer_id); | 203 client_->DismissPictureBuffer(picture_buffer_id); |
201 } | 204 } |
202 | 205 |
(...skipping 25 matching lines...) Expand all Loading... |
228 | 231 |
229 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the | 232 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the |
230 // last thing done on this stack! | 233 // last thing done on this stack! |
231 media::VideoDecodeAccelerator::Client* client = NULL; | 234 media::VideoDecodeAccelerator::Client* client = NULL; |
232 std::swap(client, client_); | 235 std::swap(client, client_); |
233 client->NotifyError( | 236 client->NotifyError( |
234 static_cast<media::VideoDecodeAccelerator::Error>(error)); | 237 static_cast<media::VideoDecodeAccelerator::Error>(error)); |
235 } | 238 } |
236 | 239 |
237 } // namespace content | 240 } // namespace content |
OLD | NEW |