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

Side by Side Diff: chrome/gpu/arc_video_accelerator.h

Issue 2513973002: Use mojo typemap to simplify the code using DmabufPlane (Closed)
Patch Set: Addressed comments Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_ 5 #ifndef CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_
6 #define CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_ 6 #define CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/files/scoped_file.h" 10 #include "base/files/scoped_file.h"
11 #include "components/arc/video_accelerator/video_accelerator.h"
11 12
12 namespace chromeos { 13 namespace chromeos {
13 namespace arc { 14 namespace arc {
14 15
15 enum HalPixelFormatExtension { 16 enum HalPixelFormatExtension {
16 // The pixel formats defined in Android but are used here. They are defined 17 // The pixel formats defined in Android but are used here. They are defined
17 // in "system/core/include/system/graphics.h" 18 // in "system/core/include/system/graphics.h"
18 HAL_PIXEL_FORMAT_BGRA_8888 = 5, 19 HAL_PIXEL_FORMAT_BGRA_8888 = 5,
19 HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23, 20 HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23,
20 21
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 DEVICE_DECODER = 1, 71 DEVICE_DECODER = 1,
71 }; 72 };
72 73
73 DeviceType device_type = DEVICE_DECODER; 74 DeviceType device_type = DEVICE_DECODER;
74 size_t num_input_buffers = 0; 75 size_t num_input_buffers = 0;
75 uint32_t input_pixel_format = 0; 76 uint32_t input_pixel_format = 0;
76 // TODO(owenlin): Add output_pixel_format. For now only the native pixel 77 // TODO(owenlin): Add output_pixel_format. For now only the native pixel
77 // format of each VDA on Chromium is supported. 78 // format of each VDA on Chromium is supported.
78 }; 79 };
79 80
80 struct DmabufPlane {
81 DmabufPlane(int32_t offset, int32_t stride)
82 : offset(offset), stride(stride) {}
83 int32_t offset; // in bytes
84 int32_t stride; // in bytes
85 };
86
87 // The callbacks of the ArcVideoAccelerator. The user of this class should 81 // The callbacks of the ArcVideoAccelerator. The user of this class should
88 // implement this interface. 82 // implement this interface.
89 class Client { 83 class Client {
90 public: 84 public:
91 virtual ~Client() {} 85 virtual ~Client() {}
92 86
93 // Called when an asynchronous error happens. The errors in Initialize() 87 // Called when an asynchronous error happens. The errors in Initialize()
94 // will not be reported here, but will be indicated by a return value 88 // will not be reported here, but will be indicated by a return value
95 // there. 89 // there.
96 virtual void OnError(Result error) = 0; 90 virtual void OnError(Result error) = 0;
(...skipping 29 matching lines...) Expand all
126 virtual void BindSharedMemory(PortType port, 120 virtual void BindSharedMemory(PortType port,
127 uint32_t index, 121 uint32_t index,
128 base::ScopedFD ashmem_fd, 122 base::ScopedFD ashmem_fd,
129 off_t offset, 123 off_t offset,
130 size_t length) = 0; 124 size_t length) = 0;
131 125
132 // Assigns a buffer to be used for the accelerator at the specified 126 // Assigns a buffer to be used for the accelerator at the specified
133 // port and index. A buffer must be successfully bound before it can be 127 // port and index. A buffer must be successfully bound before it can be
134 // passed to the accelerator via UseBuffer(). Already bound buffers may be 128 // passed to the accelerator via UseBuffer(). Already bound buffers may be
135 // reused multiple times without additional bindings. 129 // reused multiple times without additional bindings.
136 virtual void BindDmabuf(PortType port, 130 virtual void BindDmabuf(
137 uint32_t index, 131 PortType port,
138 base::ScopedFD dmabuf_fd, 132 uint32_t index,
139 const std::vector<DmabufPlane>& dmabuf_planes) = 0; 133 base::ScopedFD dmabuf_fd,
134 const std::vector<::arc::ArcVideoAcceleratorDmabufPlane>&
135 dmabuf_planes) = 0;
140 136
141 // Passes a buffer to the accelerator. For input buffer, the accelerator 137 // Passes a buffer to the accelerator. For input buffer, the accelerator
142 // will process it. For output buffer, the accelerator will output content 138 // will process it. For output buffer, the accelerator will output content
143 // to it. 139 // to it.
144 virtual void UseBuffer(PortType port, 140 virtual void UseBuffer(PortType port,
145 uint32_t index, 141 uint32_t index,
146 const BufferMetadata& metadata) = 0; 142 const BufferMetadata& metadata) = 0;
147 143
148 // Sets the number of output buffers. When it fails, Client::OnError() will 144 // Sets the number of output buffers. When it fails, Client::OnError() will
149 // be called. 145 // be called.
150 virtual void SetNumberOfOutputBuffers(size_t number) = 0; 146 virtual void SetNumberOfOutputBuffers(size_t number) = 0;
151 147
152 // Resets the accelerator. When it is done, Client::OnResetDone() will 148 // Resets the accelerator. When it is done, Client::OnResetDone() will
153 // be called. Afterwards, all buffers won't be accessed by the accelerator 149 // be called. Afterwards, all buffers won't be accessed by the accelerator
154 // and there won't be more callbacks. 150 // and there won't be more callbacks.
155 virtual void Reset() = 0; 151 virtual void Reset() = 0;
156 152
157 // Flushes the accelerator. After all the output buffers pending decode have 153 // Flushes the accelerator. After all the output buffers pending decode have
158 // been returned to client by OnBufferDone(), Client::OnFlushDone() will be 154 // been returned to client by OnBufferDone(), Client::OnFlushDone() will be
159 // called. 155 // called.
160 virtual void Flush() = 0; 156 virtual void Flush() = 0;
161 157
162 virtual ~ArcVideoAccelerator() {} 158 virtual ~ArcVideoAccelerator() {}
163 }; 159 };
164 160
165 } // namespace arc 161 } // namespace arc
166 } // namespace chromeos 162 } // namespace chromeos
167 163
168 #endif // CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_ 164 #endif // CHROME_GPU_ARC_VIDEO_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698