| 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 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ | 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ |
| 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ | 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
| 13 #include "media/video/jpeg_decode_accelerator.h" | 13 #include "media/video/jpeg_decode_accelerator.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class SingleThreadTaskRunner; | 16 class SingleThreadTaskRunner; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace gpu { |
| 20 class GpuChannelHost; |
| 21 } |
| 22 |
| 19 namespace IPC { | 23 namespace IPC { |
| 20 class Listener; | 24 class Listener; |
| 21 class Message; | 25 class Message; |
| 22 } | 26 } |
| 23 | 27 |
| 24 namespace content { | 28 namespace content { |
| 25 class GpuChannelHost; | |
| 26 | 29 |
| 27 // This class is used to talk to JpegDecodeAccelerator in the GPU process | 30 // This class is used to talk to JpegDecodeAccelerator in the GPU process |
| 28 // through IPC messages. | 31 // through IPC messages. |
| 29 class GpuJpegDecodeAcceleratorHost : public media::JpegDecodeAccelerator, | 32 class GpuJpegDecodeAcceleratorHost : public media::JpegDecodeAccelerator, |
| 30 public base::NonThreadSafe { | 33 public base::NonThreadSafe { |
| 31 public: | 34 public: |
| 32 // VideoCaptureGpuJpegDecoder owns |this| and |channel|. And | 35 // VideoCaptureGpuJpegDecoder owns |this| and |channel|. And |
| 33 // VideoCaptureGpuJpegDecoder delete |this| before |channel|. So |this| is | 36 // VideoCaptureGpuJpegDecoder delete |this| before |channel|. So |this| is |
| 34 // guaranteed not to outlive |channel|. | 37 // guaranteed not to outlive |channel|. |
| 35 GpuJpegDecodeAcceleratorHost( | 38 GpuJpegDecodeAcceleratorHost( |
| 36 GpuChannelHost* channel, | 39 gpu::GpuChannelHost* channel, |
| 37 int32_t route_id, | 40 int32_t route_id, |
| 38 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | 41 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); |
| 39 ~GpuJpegDecodeAcceleratorHost() override; | 42 ~GpuJpegDecodeAcceleratorHost() override; |
| 40 | 43 |
| 41 // media::JpegDecodeAccelerator implementation. | 44 // media::JpegDecodeAccelerator implementation. |
| 42 // |client| is called on the IO thread, but is never called into after the | 45 // |client| is called on the IO thread, but is never called into after the |
| 43 // GpuJpegDecodeAcceleratorHost is destroyed. | 46 // GpuJpegDecodeAcceleratorHost is destroyed. |
| 44 bool Initialize(media::JpegDecodeAccelerator::Client* client) override; | 47 bool Initialize(media::JpegDecodeAccelerator::Client* client) override; |
| 45 void Decode(const media::BitstreamBuffer& bitstream_buffer, | 48 void Decode(const media::BitstreamBuffer& bitstream_buffer, |
| 46 const scoped_refptr<media::VideoFrame>& video_frame) override; | 49 const scoped_refptr<media::VideoFrame>& video_frame) override; |
| 47 bool IsSupported() override; | 50 bool IsSupported() override; |
| 48 | 51 |
| 49 base::WeakPtr<IPC::Listener> GetReceiver(); | 52 base::WeakPtr<IPC::Listener> GetReceiver(); |
| 50 | 53 |
| 51 private: | 54 private: |
| 52 class Receiver; | 55 class Receiver; |
| 53 | 56 |
| 54 void Send(IPC::Message* message); | 57 void Send(IPC::Message* message); |
| 55 | 58 |
| 56 // Unowned reference to the GpuChannelHost to send IPC messages to the GPU | 59 // Unowned reference to the GpuChannelHost to send IPC messages to the GPU |
| 57 // process. | 60 // process. |
| 58 GpuChannelHost* channel_; | 61 gpu::GpuChannelHost* channel_; |
| 59 | 62 |
| 60 // Route ID for the associated decoder in the GPU process. | 63 // Route ID for the associated decoder in the GPU process. |
| 61 int32_t decoder_route_id_; | 64 int32_t decoder_route_id_; |
| 62 | 65 |
| 63 // GPU IO task runner. | 66 // GPU IO task runner. |
| 64 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 67 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 65 | 68 |
| 66 scoped_ptr<Receiver> receiver_; | 69 scoped_ptr<Receiver> receiver_; |
| 67 | 70 |
| 68 DISALLOW_COPY_AND_ASSIGN(GpuJpegDecodeAcceleratorHost); | 71 DISALLOW_COPY_AND_ASSIGN(GpuJpegDecodeAcceleratorHost); |
| 69 }; | 72 }; |
| 70 | 73 |
| 71 } // namespace content | 74 } // namespace content |
| 72 | 75 |
| 73 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ | 76 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_JPEG_DECODE_ACCELERATOR_HOST_H_ |
| OLD | NEW |