OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_jpeg_decode_accelerator_host.h" | 5 #include "content/common/gpu/client/gpu_jpeg_decode_accelerator_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 } | 145 } |
146 | 146 |
147 void GpuJpegDecodeAcceleratorHost::Decode( | 147 void GpuJpegDecodeAcceleratorHost::Decode( |
148 const media::BitstreamBuffer& bitstream_buffer, | 148 const media::BitstreamBuffer& bitstream_buffer, |
149 const scoped_refptr<media::VideoFrame>& video_frame) { | 149 const scoped_refptr<media::VideoFrame>& video_frame) { |
150 DCHECK(CalledOnValidThread()); | 150 DCHECK(CalledOnValidThread()); |
151 | 151 |
152 DCHECK( | 152 DCHECK( |
153 base::SharedMemory::IsHandleValid(video_frame->shared_memory_handle())); | 153 base::SharedMemory::IsHandleValid(video_frame->shared_memory_handle())); |
154 | 154 |
| 155 AcceleratedJpegDecoderMsg_Decode_Params decode_params; |
| 156 decode_params.input_buffer = bitstream_buffer; |
155 base::SharedMemoryHandle input_handle = | 157 base::SharedMemoryHandle input_handle = |
156 channel_->ShareToGpuProcess(bitstream_buffer.handle()); | 158 channel_->ShareToGpuProcess(bitstream_buffer.handle()); |
157 if (!base::SharedMemory::IsHandleValid(input_handle)) { | 159 if (!base::SharedMemory::IsHandleValid(input_handle)) { |
158 DLOG(ERROR) << "Failed to duplicate handle of BitstreamBuffer"; | 160 DLOG(ERROR) << "Failed to duplicate handle of BitstreamBuffer"; |
159 return; | 161 return; |
160 } | 162 } |
| 163 decode_params.input_buffer.set_handle(input_handle); |
161 base::SharedMemoryHandle output_handle = | 164 base::SharedMemoryHandle output_handle = |
162 channel_->ShareToGpuProcess(video_frame->shared_memory_handle()); | 165 channel_->ShareToGpuProcess(video_frame->shared_memory_handle()); |
163 if (!base::SharedMemory::IsHandleValid(output_handle)) { | 166 if (!base::SharedMemory::IsHandleValid(output_handle)) { |
164 DLOG(ERROR) << "Failed to duplicate handle of VideoFrame"; | 167 DLOG(ERROR) << "Failed to duplicate handle of VideoFrame"; |
165 #if defined(OS_POSIX) && !(defined(OS_MACOSX) && !defined(OS_IOS)) | 168 #if defined(OS_POSIX) && !(defined(OS_MACOSX) && !defined(OS_IOS)) |
166 if (input_handle.auto_close) { | 169 if (input_handle.auto_close) { |
167 // Defer closing task to the ScopedFD. | 170 // Defer closing task to the ScopedFD. |
168 base::ScopedFD(input_handle.fd); | 171 base::ScopedFD(input_handle.fd); |
169 } | 172 } |
170 #else | 173 #else |
171 // TODO(kcwu) fix the handle leak after crbug.com/493414 resolved. | 174 // TODO(kcwu) fix the handle leak after crbug.com/493414 resolved. |
172 #endif | 175 #endif |
173 return; | 176 return; |
174 } | 177 } |
175 | 178 |
176 size_t output_buffer_size = media::VideoFrame::AllocationSize( | 179 size_t output_buffer_size = media::VideoFrame::AllocationSize( |
177 video_frame->format(), video_frame->coded_size()); | 180 video_frame->format(), video_frame->coded_size()); |
178 | 181 |
179 AcceleratedJpegDecoderMsg_Decode_Params decode_params; | |
180 decode_params.coded_size = video_frame->coded_size(); | 182 decode_params.coded_size = video_frame->coded_size(); |
181 decode_params.input_buffer_id = bitstream_buffer.id(); | |
182 decode_params.input_buffer_handle = input_handle; | |
183 decode_params.input_buffer_size = bitstream_buffer.size(); | |
184 decode_params.output_video_frame_handle = output_handle; | 183 decode_params.output_video_frame_handle = output_handle; |
185 decode_params.output_buffer_size = output_buffer_size; | 184 decode_params.output_buffer_size = output_buffer_size; |
186 Send(new AcceleratedJpegDecoderMsg_Decode(decoder_route_id_, decode_params)); | 185 Send(new AcceleratedJpegDecoderMsg_Decode(decoder_route_id_, decode_params)); |
187 } | 186 } |
188 | 187 |
189 bool GpuJpegDecodeAcceleratorHost::IsSupported() { | 188 bool GpuJpegDecodeAcceleratorHost::IsSupported() { |
190 return channel_->gpu_info().jpeg_decode_accelerator_supported; | 189 return channel_->gpu_info().jpeg_decode_accelerator_supported; |
191 } | 190 } |
192 | 191 |
193 void GpuJpegDecodeAcceleratorHost::Send(IPC::Message* message) { | 192 void GpuJpegDecodeAcceleratorHost::Send(IPC::Message* message) { |
194 DCHECK(CalledOnValidThread()); | 193 DCHECK(CalledOnValidThread()); |
195 | 194 |
196 if (!channel_->Send(message)) { | 195 if (!channel_->Send(message)) { |
197 DLOG(ERROR) << "Send(" << message->type() << ") failed"; | 196 DLOG(ERROR) << "Send(" << message->type() << ") failed"; |
198 } | 197 } |
199 } | 198 } |
200 | 199 |
201 base::WeakPtr<IPC::Listener> GpuJpegDecodeAcceleratorHost::GetReceiver() { | 200 base::WeakPtr<IPC::Listener> GpuJpegDecodeAcceleratorHost::GetReceiver() { |
202 return receiver_->AsWeakPtrForIO(); | 201 return receiver_->AsWeakPtrForIO(); |
203 } | 202 } |
204 | 203 |
205 } // namespace content | 204 } // namespace content |
OLD | NEW |