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

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

Issue 2923933004: [NotForReview] Move GJDAH and GJDA to media/gpu/mojo
Patch Set: . 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
« no previous file with comments | « media/gpu/mojo/service/BUILD.gn ('k') | media/gpu/mojo/service/gpu_jpeg_decode_accelerator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
15 #include "base/sequence_checker.h" 14 #include "base/sequence_checker.h"
16 #include "base/synchronization/waitable_event.h" 15 #include "media/gpu/mojo/common/jpeg_decoder.mojom.h"
17 #include "ipc/ipc_listener.h"
18 #include "ipc/ipc_sender.h"
19 #include "media/gpu/mojo/jpeg_decoder.mojom.h"
20 #include "media/video/jpeg_decode_accelerator.h" 16 #include "media/video/jpeg_decode_accelerator.h"
21 17
22 namespace base { 18 namespace base {
23 class SingleThreadTaskRunner; 19 class SingleThreadTaskRunner;
24 } 20 }
25 21
26 namespace gpu { 22 namespace service_manager {
27 class FilteredSender; 23 struct BindSourceInfo;
28 } 24 }
29 25
30 namespace media { 26 namespace media {
31 27
32 class GpuJpegDecodeAcceleratorFactoryProvider { 28 class GpuJpegDecodeAcceleratorFactoryProvider {
33 public: 29 public:
34 using CreateAcceleratorCB = 30 using CreateAcceleratorCB =
35 base::Callback<std::unique_ptr<JpegDecodeAccelerator>( 31 base::Callback<std::unique_ptr<JpegDecodeAccelerator>(
36 scoped_refptr<base::SingleThreadTaskRunner>)>; 32 scoped_refptr<base::SingleThreadTaskRunner>)>;
37 33
38 // Static query for JPEG supported. This query calls the appropriate 34 // Static query for JPEG supported. This query calls the appropriate
39 // platform-specific version. 35 // platform-specific version.
40 static bool IsAcceleratedJpegDecodeSupported(); 36 static bool IsAcceleratedJpegDecodeSupported();
41 37
42 static std::vector<CreateAcceleratorCB> GetAcceleratorFactories(); 38 static std::vector<CreateAcceleratorCB> GetAcceleratorFactories();
43 }; 39 };
44 40
45 // TODO(c.padhi): Move GpuJpegDecodeAccelerator to media/gpu/mojo, see 41 class GpuJpegDecodeAccelerator : public mojom::GpuJpegDecodeAccelerator,
46 // http://crbug.com/699255. 42 public JpegDecodeAccelerator::Client {
47 class GpuJpegDecodeAccelerator
48 : public IPC::Sender,
49 public mojom::GpuJpegDecodeAccelerator,
50 public base::SupportsWeakPtr<GpuJpegDecodeAccelerator> {
51 public: 43 public:
52 // |channel| must outlive this object. 44 static void Create(scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
53 // This convenience constructor internally calls 45 const service_manager::BindSourceInfo& source_info,
46 mojom::GpuJpegDecodeAcceleratorRequest request);
47
48 ~GpuJpegDecodeAccelerator() override;
49
50 // JpegDecodeAccelerator::Client implementation.
51 void VideoFrameReady(int32_t buffer_id) override;
52 void NotifyError(int32_t buffer_id,
53 JpegDecodeAccelerator::Error error) override;
54
55 private:
56 // This constructor internally calls
54 // GpuJpegDecodeAcceleratorFactoryProvider::GetAcceleratorFactories() to 57 // GpuJpegDecodeAcceleratorFactoryProvider::GetAcceleratorFactories() to
55 // fill |accelerator_factory_functions_|. 58 // fill |accelerator_factory_functions_|.
56 GpuJpegDecodeAccelerator( 59 GpuJpegDecodeAccelerator(
57 gpu::FilteredSender* channel,
58 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner); 60 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner);
59 61
60 // |channel| must outlive this object.
61 GpuJpegDecodeAccelerator(
62 gpu::FilteredSender* channel,
63 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
64 std::vector<GpuJpegDecodeAcceleratorFactoryProvider::CreateAcceleratorCB>
65 accelerator_factory_functions);
66 ~GpuJpegDecodeAccelerator() override;
67
68 void AddClient(int32_t route_id, base::Callback<void(bool)> response);
69
70 void NotifyDecodeStatus(int32_t route_id,
71 int32_t bitstream_buffer_id,
72 JpegDecodeAccelerator::Error error);
73
74 // mojom::GpuJpegDecodeAccelerator implementation. 62 // mojom::GpuJpegDecodeAccelerator implementation.
75 void Initialize(InitializeCallback callback) override; 63 void Initialize(InitializeCallback callback) override;
76 void Decode(mojom::BitstreamBufferPtr input_buffer, 64 void Decode(mojom::BitstreamBufferPtr input_buffer,
77 const gfx::Size& coded_size, 65 const gfx::Size& coded_size,
78 mojo::ScopedSharedBufferHandle output_handle, 66 mojo::ScopedSharedBufferHandle output_handle,
79 uint32_t output_buffer_size, 67 uint32_t output_buffer_size,
80 DecodeCallback callback) override; 68 DecodeCallback callback) override;
81 void Uninitialize() override; 69 void Uninitialize() override;
82 70
83 // Function to delegate sending to actual sender. 71 void DecodeOnIOThread(mojom::BitstreamBufferPtr input_buffer,
84 bool Send(IPC::Message* message) override; 72 const gfx::Size& coded_size,
85 73 mojo::ScopedSharedBufferHandle output_handle,
86 private: 74 uint32_t output_buffer_size);
87 class Client; 75 void NotifyDecodeStatus(int32_t bitstream_buffer_id, mojom::Error error);
88 class MessageFilter;
89
90 void ClientRemoved();
91 76
92 std::vector<GpuJpegDecodeAcceleratorFactoryProvider::CreateAcceleratorCB> 77 std::vector<GpuJpegDecodeAcceleratorFactoryProvider::CreateAcceleratorCB>
93 accelerator_factory_functions_; 78 accelerator_factory_functions_;
94 79
95 gpu::FilteredSender* channel_;
96
97 // The message filter to run JpegDecodeAccelerator::Decode on IO thread.
98 scoped_refptr<MessageFilter> filter_;
99
100 // GPU child task runner. 80 // GPU child task runner.
101 scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_; 81 scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_;
102 82
103 // GPU IO task runner. 83 // GPU IO task runner.
104 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 84 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
105 85
106 // Number of clients added to |filter_|. 86 DecodeCallback decode_cb_;
107 int client_number_; 87
88 std::unique_ptr<JpegDecodeAccelerator> accelerator_;
108 89
109 SEQUENCE_CHECKER(sequence_checker_); 90 SEQUENCE_CHECKER(sequence_checker_);
110 91
111 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuJpegDecodeAccelerator); 92 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuJpegDecodeAccelerator);
112 }; 93 };
113 94
114 } // namespace media 95 } // namespace media
115 96
116 #endif // MEDIA_GPU_IPC_SERVICE_GPU_JPEG_DECODE_ACCELERATOR_H_ 97 #endif // MEDIA_GPU_IPC_SERVICE_GPU_JPEG_DECODE_ACCELERATOR_H_
OLDNEW
« no previous file with comments | « media/gpu/mojo/service/BUILD.gn ('k') | media/gpu/mojo/service/gpu_jpeg_decode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698