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

Side by Side Diff: media/gpu/ipc/service/gpu_jpeg_decode_accelerator.h

Issue 2905823002: Add Mojo interfaces for GpuJpegDecodeAccelerator and GpuJpegDecodeAcceleratorHost (Closed)
Patch Set: mojo interface Created 3 years, 6 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 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 MEDIA_GPU_IPC_SERVICE_GPU_JPEG_DECODE_ACCELERATOR_H_ 5 #ifndef MEDIA_GPU_IPC_SERVICE_GPU_JPEG_DECODE_ACCELERATOR_H_
6 #define MEDIA_GPU_IPC_SERVICE_GPU_JPEG_DECODE_ACCELERATOR_H_ 6 #define MEDIA_GPU_IPC_SERVICE_GPU_JPEG_DECODE_ACCELERATOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/synchronization/waitable_event.h" 15 #include "base/synchronization/waitable_event.h"
16 #include "base/threading/non_thread_safe.h" 16 #include "base/threading/thread_checker.h"
17 #include "ipc/ipc_listener.h" 17 #include "ipc/ipc_listener.h"
18 #include "ipc/ipc_sender.h" 18 #include "ipc/ipc_sender.h"
19 #include "media/gpu/mojo/jpeg_decoder.mojom.h"
19 #include "media/video/jpeg_decode_accelerator.h" 20 #include "media/video/jpeg_decode_accelerator.h"
20 21
21 namespace base { 22 namespace base {
22 class SingleThreadTaskRunner; 23 class SingleThreadTaskRunner;
23 } 24 }
24 25
25 namespace gpu { 26 namespace gpu {
26 class FilteredSender; 27 class FilteredSender;
27 } 28 }
28 29
29 namespace media { 30 namespace media {
30 31
31 class GpuJpegDecodeAcceleratorFactoryProvider { 32 class GpuJpegDecodeAcceleratorFactoryProvider {
32 public: 33 public:
33 using CreateAcceleratorCB = 34 using CreateAcceleratorCB =
34 base::Callback<std::unique_ptr<JpegDecodeAccelerator>( 35 base::Callback<std::unique_ptr<JpegDecodeAccelerator>(
35 scoped_refptr<base::SingleThreadTaskRunner>)>; 36 scoped_refptr<base::SingleThreadTaskRunner>)>;
36 37
37 // Static query for JPEG supported. This query calls the appropriate 38 // Static query for JPEG supported. This query calls the appropriate
38 // platform-specific version. 39 // platform-specific version.
39 static bool IsAcceleratedJpegDecodeSupported(); 40 static bool IsAcceleratedJpegDecodeSupported();
40 41
41 static std::vector<CreateAcceleratorCB> GetAcceleratorFactories(); 42 static std::vector<CreateAcceleratorCB> GetAcceleratorFactories();
42 }; 43 };
43 44
44 class GpuJpegDecodeAccelerator 45 class GpuJpegDecodeAccelerator
45 : public IPC::Sender, 46 : public mojom::GpuJpegDecodeAccelerator,
46 public base::NonThreadSafe, 47 public IPC::Sender,
47 public base::SupportsWeakPtr<GpuJpegDecodeAccelerator> { 48 public base::SupportsWeakPtr<GpuJpegDecodeAccelerator> {
48 public: 49 public:
49 // |channel| must outlive this object. 50 // |channel| must outlive this object.
50 // This convenience constructor internally calls 51 // This convenience constructor internally calls
51 // GpuJpegDecodeAcceleratorFactoryProvider::GetAcceleratorFactories() to 52 // GpuJpegDecodeAcceleratorFactoryProvider::GetAcceleratorFactories() to
52 // fill |accelerator_factory_functions_|. 53 // fill |accelerator_factory_functions_|.
53 GpuJpegDecodeAccelerator( 54 GpuJpegDecodeAccelerator(
54 gpu::FilteredSender* channel, 55 gpu::FilteredSender* channel,
55 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner); 56 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner);
56 57
57 // |channel| must outlive this object. 58 // |channel| must outlive this object.
58 GpuJpegDecodeAccelerator( 59 GpuJpegDecodeAccelerator(
59 gpu::FilteredSender* channel, 60 gpu::FilteredSender* channel,
60 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, 61 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
61 std::vector<GpuJpegDecodeAcceleratorFactoryProvider::CreateAcceleratorCB> 62 std::vector<GpuJpegDecodeAcceleratorFactoryProvider::CreateAcceleratorCB>
62 accelerator_factory_functions); 63 accelerator_factory_functions);
63 ~GpuJpegDecodeAccelerator() override; 64 ~GpuJpegDecodeAccelerator() override;
64 65
65 void AddClient(int32_t route_id, base::Callback<void(bool)> response); 66 void AddClient(int32_t route_id, base::Callback<void(bool)> response);
66 67
67 void NotifyDecodeStatus(int32_t route_id, 68 void NotifyDecodeStatus(int32_t route_id,
68 int32_t bitstream_buffer_id, 69 int32_t bitstream_buffer_id,
69 JpegDecodeAccelerator::Error error); 70 JpegDecodeAccelerator::Error error);
70 71
72 // mojom::GpuJpegDecodeAccelerator implementation.
73 void CreateJpegDecoder(mojom::GpuJpegDecodeAcceleratorClientPtr client,
74 CreateJpegDecoderCallback callback) override;
75 void Decode(mojom::JpegDecodeInfoPtr info) override;
76 void Destroy() override;
77
71 // Function to delegate sending to actual sender. 78 // Function to delegate sending to actual sender.
72 bool Send(IPC::Message* message) override; 79 bool Send(IPC::Message* message) override;
73 80
74 private: 81 private:
75 class Client; 82 class Client;
76 class MessageFilter; 83 class MessageFilter;
77 84
78 void ClientRemoved(); 85 void ClientRemoved();
79 86
80 std::vector<GpuJpegDecodeAcceleratorFactoryProvider::CreateAcceleratorCB> 87 std::vector<GpuJpegDecodeAcceleratorFactoryProvider::CreateAcceleratorCB>
81 accelerator_factory_functions_; 88 accelerator_factory_functions_;
82 89
83 gpu::FilteredSender* channel_; 90 gpu::FilteredSender* channel_;
84 91
85 // The message filter to run JpegDecodeAccelerator::Decode on IO thread. 92 // The message filter to run JpegDecodeAccelerator::Decode on IO thread.
86 scoped_refptr<MessageFilter> filter_; 93 scoped_refptr<MessageFilter> filter_;
87 94
88 // GPU child task runner. 95 // GPU child task runner.
89 scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_; 96 scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_;
90 97
91 // GPU IO task runner. 98 // GPU IO task runner.
92 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 99 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
93 100
94 // Number of clients added to |filter_|. 101 // Number of clients added to |filter_|.
95 int client_number_; 102 int client_number_;
96 103
104 THREAD_CHECKER(thread_checker_);
97 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuJpegDecodeAccelerator); 105 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuJpegDecodeAccelerator);
98 }; 106 };
99 107
100 } // namespace media 108 } // namespace media
101 109
102 #endif // MEDIA_GPU_IPC_SERVICE_GPU_JPEG_DECODE_ACCELERATOR_H_ 110 #endif // MEDIA_GPU_IPC_SERVICE_GPU_JPEG_DECODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698