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/media/gpu_jpeg_decode_accelerator.h" | 5 #include "content/common/gpu/media/gpu_jpeg_decode_accelerator.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <unordered_map> | 9 #include <unordered_map> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/shared_memory.h" | 13 #include "base/memory/shared_memory.h" |
14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
17 #include "content/common/gpu/gpu_channel.h" | 17 #include "content/common/gpu/gpu_channel.h" |
18 #include "content/common/gpu/gpu_messages.h" | 18 #include "content/common/gpu/gpu_messages.h" |
19 #include "ipc/ipc_message_macros.h" | 19 #include "ipc/ipc_message_macros.h" |
20 #include "ipc/message_filter.h" | 20 #include "ipc/message_filter.h" |
21 #include "media/filters/jpeg_parser.h" | 21 #include "media/filters/jpeg_parser.h" |
22 #include "ui/gfx/geometry/size.h" | 22 #include "ui/gfx/geometry/size.h" |
23 | 23 |
24 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 24 #if defined(OS_CHROMEOS) |
| 25 #if defined(ARCH_CPU_X86_FAMILY) |
25 #include "content/common/gpu/media/vaapi_jpeg_decode_accelerator.h" | 26 #include "content/common/gpu/media/vaapi_jpeg_decode_accelerator.h" |
26 #endif | 27 #endif |
| 28 #if defined(USE_V4L2_CODEC) |
| 29 #include "content/common/gpu/media/v4l2_device.h" |
| 30 #include "content/common/gpu/media/v4l2_jpeg_decode_accelerator.h" |
| 31 #endif |
| 32 #endif |
27 | 33 |
28 namespace { | 34 namespace { |
29 | 35 |
30 void DecodeFinished(scoped_ptr<base::SharedMemory> shm) { | 36 void DecodeFinished(scoped_ptr<base::SharedMemory> shm) { |
31 // Do nothing. Because VideoFrame is backed by |shm|, the purpose of this | 37 // Do nothing. Because VideoFrame is backed by |shm|, the purpose of this |
32 // function is to just keep reference of |shm| to make sure it lives util | 38 // function is to just keep reference of |shm| to make sure it lives util |
33 // decode finishes. | 39 // decode finishes. |
34 } | 40 } |
35 | 41 |
36 } // namespace | 42 } // namespace |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 289 |
284 void GpuJpegDecodeAccelerator::AddClient(int32 route_id, | 290 void GpuJpegDecodeAccelerator::AddClient(int32 route_id, |
285 IPC::Message* reply_msg) { | 291 IPC::Message* reply_msg) { |
286 DCHECK(CalledOnValidThread()); | 292 DCHECK(CalledOnValidThread()); |
287 scoped_ptr<media::JpegDecodeAccelerator> accelerator; | 293 scoped_ptr<media::JpegDecodeAccelerator> accelerator; |
288 | 294 |
289 // When adding more platforms, GpuJpegDecoder::Supported need | 295 // When adding more platforms, GpuJpegDecoder::Supported need |
290 // update as well. | 296 // update as well. |
291 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 297 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
292 accelerator.reset(new VaapiJpegDecodeAccelerator(io_task_runner_)); | 298 accelerator.reset(new VaapiJpegDecodeAccelerator(io_task_runner_)); |
| 299 #elif defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) |
| 300 scoped_refptr<V4L2Device> device = V4L2Device::Create( |
| 301 V4L2Device::kJpegDecoder); |
| 302 if (device.get()) { |
| 303 accelerator.reset(new V4L2JpegDecodeAccelerator( |
| 304 device, io_task_runner_)); |
| 305 } |
293 #else | 306 #else |
294 DVLOG(1) << "HW JPEG decode acceleration not available."; | 307 DVLOG(1) << "HW JPEG decode acceleration not available."; |
295 #endif | 308 #endif |
296 | 309 |
297 scoped_ptr<Client> client(new Client(this, route_id)); | 310 scoped_ptr<Client> client(new Client(this, route_id)); |
298 if (!accelerator.get() || !accelerator->Initialize(client.get())) { | 311 if (!accelerator.get() || !accelerator->Initialize(client.get())) { |
299 DLOG(ERROR) << "JPEG accelerator Initialize failed"; | 312 DLOG(ERROR) << "JPEG accelerator Initialize failed"; |
300 GpuMsg_CreateJpegDecoder::WriteReplyParams(reply_msg, false); | 313 GpuMsg_CreateJpegDecoder::WriteReplyParams(reply_msg, false); |
301 Send(reply_msg); | 314 Send(reply_msg); |
302 return; | 315 return; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 filter_ = nullptr; | 351 filter_ = nullptr; |
339 } | 352 } |
340 } | 353 } |
341 | 354 |
342 bool GpuJpegDecodeAccelerator::Send(IPC::Message* message) { | 355 bool GpuJpegDecodeAccelerator::Send(IPC::Message* message) { |
343 DCHECK(CalledOnValidThread()); | 356 DCHECK(CalledOnValidThread()); |
344 return channel_->Send(message); | 357 return channel_->Send(message); |
345 } | 358 } |
346 | 359 |
347 } // namespace content | 360 } // namespace content |
OLD | NEW |