• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_SF_COMPOSER_HAL_H
18 #define ANDROID_SF_COMPOSER_HAL_H
19 
20 #include <memory>
21 #include <optional>
22 #include <string>
23 #include <unordered_map>
24 #include <utility>
25 #include <vector>
26 
27 // TODO(b/129481165): remove the #pragma below and fix conversion issues
28 #pragma clang diagnostic push
29 #pragma clang diagnostic ignored "-Wconversion"
30 #pragma clang diagnostic ignored "-Wextra"
31 
32 #include <android/hardware/graphics/common/1.1/types.h>
33 #include <android/hardware/graphics/composer/2.4/IComposer.h>
34 #include <android/hardware/graphics/composer/2.4/IComposerClient.h>
35 #include <composer-command-buffer/2.4/ComposerCommandBuffer.h>
36 #include <gui/BufferQueue.h>
37 #include <gui/HdrMetadata.h>
38 #include <math/mat4.h>
39 #include <ui/DisplayedFrameStats.h>
40 #include <ui/GraphicBuffer.h>
41 #include <utils/StrongPointer.h>
42 
43 // TODO(b/129481165): remove the #pragma below and fix conversion issues
44 #pragma clang diagnostic pop // ignored "-Wconversion -Wextra"
45 
46 namespace android {
47 
48 namespace Hwc2 {
49 
50 namespace types = hardware::graphics::common;
51 
52 namespace V2_1 = hardware::graphics::composer::V2_1;
53 namespace V2_2 = hardware::graphics::composer::V2_2;
54 namespace V2_3 = hardware::graphics::composer::V2_3;
55 namespace V2_4 = hardware::graphics::composer::V2_4;
56 
57 using types::V1_0::ColorTransform;
58 using types::V1_0::Transform;
59 using types::V1_1::RenderIntent;
60 using types::V1_2::ColorMode;
61 using types::V1_2::Dataspace;
62 using types::V1_2::Hdr;
63 using types::V1_2::PixelFormat;
64 
65 using V2_1::Config;
66 using V2_1::Display;
67 using V2_1::Error;
68 using V2_1::Layer;
69 using V2_4::CommandReaderBase;
70 using V2_4::CommandWriterBase;
71 using V2_4::IComposer;
72 using V2_4::IComposerCallback;
73 using V2_4::IComposerClient;
74 using V2_4::VsyncPeriodChangeTimeline;
75 using V2_4::VsyncPeriodNanos;
76 using DisplayCapability = IComposerClient::DisplayCapability;
77 using PerFrameMetadata = IComposerClient::PerFrameMetadata;
78 using PerFrameMetadataKey = IComposerClient::PerFrameMetadataKey;
79 using PerFrameMetadataBlob = IComposerClient::PerFrameMetadataBlob;
80 
81 class Composer {
82 public:
83     virtual ~Composer() = 0;
84 
85     virtual std::vector<IComposer::Capability> getCapabilities() = 0;
86     virtual std::string dumpDebugInfo() = 0;
87 
88     virtual void registerCallback(const sp<IComposerCallback>& callback) = 0;
89 
90     // Reset all pending commands in the command buffer. Useful if you want to
91     // skip a frame but have already queued some commands.
92     virtual void resetCommands() = 0;
93 
94     // Explicitly flush all pending commands in the command buffer.
95     virtual Error executeCommands() = 0;
96 
97     virtual uint32_t getMaxVirtualDisplayCount() = 0;
98     virtual Error createVirtualDisplay(uint32_t width, uint32_t height, PixelFormat*,
99                                        std::optional<Display> mirror, Display* outDisplay) = 0;
100     virtual Error destroyVirtualDisplay(Display display) = 0;
101 
102     virtual Error acceptDisplayChanges(Display display) = 0;
103 
104     virtual Error createLayer(Display display, Layer* outLayer) = 0;
105     virtual Error destroyLayer(Display display, Layer layer) = 0;
106 
107     virtual Error getActiveConfig(Display display, Config* outConfig) = 0;
108     virtual Error getChangedCompositionTypes(
109             Display display, std::vector<Layer>* outLayers,
110             std::vector<IComposerClient::Composition>* outTypes) = 0;
111     virtual Error getColorModes(Display display, std::vector<ColorMode>* outModes) = 0;
112     virtual Error getDisplayAttribute(Display display, Config config,
113                                       IComposerClient::Attribute attribute, int32_t* outValue) = 0;
114     virtual Error getDisplayConfigs(Display display, std::vector<Config>* outConfigs) = 0;
115     virtual Error getDisplayName(Display display, std::string* outName) = 0;
116 
117     virtual Error getDisplayRequests(Display display, uint32_t* outDisplayRequestMask,
118                                      std::vector<Layer>* outLayers,
119                                      std::vector<uint32_t>* outLayerRequestMasks) = 0;
120 
121     virtual Error getDozeSupport(Display display, bool* outSupport) = 0;
122     virtual Error getHdrCapabilities(Display display, std::vector<Hdr>* outTypes,
123                                      float* outMaxLuminance, float* outMaxAverageLuminance,
124                                      float* outMinLuminance) = 0;
125 
126     virtual Error getReleaseFences(Display display, std::vector<Layer>* outLayers,
127                                    std::vector<int>* outReleaseFences) = 0;
128 
129     virtual Error presentDisplay(Display display, int* outPresentFence) = 0;
130 
131     virtual Error setActiveConfig(Display display, Config config) = 0;
132 
133     /*
134      * The composer caches client targets internally.  When target is nullptr,
135      * the composer uses slot to look up the client target from its cache.
136      * When target is not nullptr, the cache is updated with the new target.
137      */
138     virtual Error setClientTarget(Display display, uint32_t slot, const sp<GraphicBuffer>& target,
139                                   int acquireFence, Dataspace dataspace,
140                                   const std::vector<IComposerClient::Rect>& damage) = 0;
141     virtual Error setColorMode(Display display, ColorMode mode, RenderIntent renderIntent) = 0;
142     virtual Error setColorTransform(Display display, const float* matrix, ColorTransform hint) = 0;
143     virtual Error setOutputBuffer(Display display, const native_handle_t* buffer,
144                                   int releaseFence) = 0;
145     virtual Error setPowerMode(Display display, IComposerClient::PowerMode mode) = 0;
146     virtual Error setVsyncEnabled(Display display, IComposerClient::Vsync enabled) = 0;
147 
148     virtual Error setClientTargetSlotCount(Display display) = 0;
149 
150     virtual Error validateDisplay(Display display, uint32_t* outNumTypes,
151                                   uint32_t* outNumRequests) = 0;
152 
153     virtual Error presentOrValidateDisplay(Display display, uint32_t* outNumTypes,
154                                            uint32_t* outNumRequests, int* outPresentFence,
155                                            uint32_t* state) = 0;
156 
157     virtual Error setCursorPosition(Display display, Layer layer, int32_t x, int32_t y) = 0;
158     /* see setClientTarget for the purpose of slot */
159     virtual Error setLayerBuffer(Display display, Layer layer, uint32_t slot,
160                                  const sp<GraphicBuffer>& buffer, int acquireFence) = 0;
161     virtual Error setLayerSurfaceDamage(Display display, Layer layer,
162                                         const std::vector<IComposerClient::Rect>& damage) = 0;
163     virtual Error setLayerBlendMode(Display display, Layer layer,
164                                     IComposerClient::BlendMode mode) = 0;
165     virtual Error setLayerColor(Display display, Layer layer,
166                                 const IComposerClient::Color& color) = 0;
167     virtual Error setLayerCompositionType(Display display, Layer layer,
168                                           IComposerClient::Composition type) = 0;
169     virtual Error setLayerDataspace(Display display, Layer layer, Dataspace dataspace) = 0;
170     virtual Error setLayerDisplayFrame(Display display, Layer layer,
171                                        const IComposerClient::Rect& frame) = 0;
172     virtual Error setLayerPlaneAlpha(Display display, Layer layer, float alpha) = 0;
173     virtual Error setLayerSidebandStream(Display display, Layer layer,
174                                          const native_handle_t* stream) = 0;
175     virtual Error setLayerSourceCrop(Display display, Layer layer,
176                                      const IComposerClient::FRect& crop) = 0;
177     virtual Error setLayerTransform(Display display, Layer layer, Transform transform) = 0;
178     virtual Error setLayerVisibleRegion(Display display, Layer layer,
179                                         const std::vector<IComposerClient::Rect>& visible) = 0;
180     virtual Error setLayerZOrder(Display display, Layer layer, uint32_t z) = 0;
181 
182     // Composer HAL 2.2
183     virtual Error setLayerPerFrameMetadata(
184             Display display, Layer layer,
185             const std::vector<IComposerClient::PerFrameMetadata>& perFrameMetadatas) = 0;
186     virtual std::vector<IComposerClient::PerFrameMetadataKey> getPerFrameMetadataKeys(
187             Display display) = 0;
188     virtual Error getRenderIntents(Display display, ColorMode colorMode,
189             std::vector<RenderIntent>* outRenderIntents) = 0;
190     virtual Error getDataspaceSaturationMatrix(Dataspace dataspace, mat4* outMatrix) = 0;
191 
192     // Composer HAL 2.3
193     virtual Error getDisplayIdentificationData(Display display, uint8_t* outPort,
194                                                std::vector<uint8_t>* outData) = 0;
195     virtual Error setLayerColorTransform(Display display, Layer layer,
196                                          const float* matrix) = 0;
197     virtual Error getDisplayedContentSamplingAttributes(Display display, PixelFormat* outFormat,
198                                                         Dataspace* outDataspace,
199                                                         uint8_t* outComponentMask) = 0;
200     virtual Error setDisplayContentSamplingEnabled(Display display, bool enabled,
201                                                    uint8_t componentMask, uint64_t maxFrames) = 0;
202     virtual Error getDisplayedContentSample(Display display, uint64_t maxFrames, uint64_t timestamp,
203                                             DisplayedFrameStats* outStats) = 0;
204     virtual Error setLayerPerFrameMetadataBlobs(
205             Display display, Layer layer, const std::vector<PerFrameMetadataBlob>& metadata) = 0;
206     virtual Error setDisplayBrightness(Display display, float brightness) = 0;
207 
208     // Composer HAL 2.4
209     virtual bool isVsyncPeriodSwitchSupported() = 0;
210     virtual Error getDisplayCapabilities(Display display,
211                                          std::vector<DisplayCapability>* outCapabilities) = 0;
212     virtual V2_4::Error getDisplayConnectionType(
213             Display display, IComposerClient::DisplayConnectionType* outType) = 0;
214     virtual V2_4::Error getDisplayVsyncPeriod(Display display,
215                                               VsyncPeriodNanos* outVsyncPeriod) = 0;
216     virtual V2_4::Error setActiveConfigWithConstraints(
217             Display display, Config config,
218             const IComposerClient::VsyncPeriodChangeConstraints& vsyncPeriodChangeConstraints,
219             VsyncPeriodChangeTimeline* outTimeline) = 0;
220 
221     virtual V2_4::Error setAutoLowLatencyMode(Display displayId, bool on) = 0;
222     virtual V2_4::Error getSupportedContentTypes(
223             Display displayId,
224             std::vector<IComposerClient::ContentType>* outSupportedContentTypes) = 0;
225     virtual V2_4::Error setContentType(Display displayId,
226                                        IComposerClient::ContentType contentType) = 0;
227     virtual V2_4::Error setLayerGenericMetadata(Display display, Layer layer,
228                                                 const std::string& key, bool mandatory,
229                                                 const std::vector<uint8_t>& value) = 0;
230     virtual V2_4::Error getLayerGenericMetadataKeys(
231             std::vector<IComposerClient::LayerGenericMetadataKey>* outKeys) = 0;
232     virtual Error getClientTargetProperty(
233             Display display, IComposerClient::ClientTargetProperty* outClientTargetProperty) = 0;
234 };
235 
236 namespace impl {
237 
238 class CommandReader : public CommandReaderBase {
239 public:
240     ~CommandReader();
241 
242     // Parse and execute commands from the command queue.  The commands are
243     // actually return values from the server and will be saved in ReturnData.
244     Error parse();
245 
246     // Get and clear saved errors.
247     struct CommandError {
248         uint32_t location;
249         Error error;
250     };
251     std::vector<CommandError> takeErrors();
252 
253     bool hasChanges(Display display, uint32_t* outNumChangedCompositionTypes,
254             uint32_t* outNumLayerRequestMasks) const;
255 
256     // Get and clear saved changed composition types.
257     void takeChangedCompositionTypes(Display display,
258             std::vector<Layer>* outLayers,
259             std::vector<IComposerClient::Composition>* outTypes);
260 
261     // Get and clear saved display requests.
262     void takeDisplayRequests(Display display,
263         uint32_t* outDisplayRequestMask, std::vector<Layer>* outLayers,
264         std::vector<uint32_t>* outLayerRequestMasks);
265 
266     // Get and clear saved release fences.
267     void takeReleaseFences(Display display, std::vector<Layer>* outLayers,
268             std::vector<int>* outReleaseFences);
269 
270     // Get and clear saved present fence.
271     void takePresentFence(Display display, int* outPresentFence);
272 
273     // Get what stage succeeded during PresentOrValidate: Present or Validate
274     void takePresentOrValidateStage(Display display, uint32_t * state);
275 
276     // Get the client target properties requested by hardware composer.
277     void takeClientTargetProperty(Display display,
278                                   IComposerClient::ClientTargetProperty* outClientTargetProperty);
279 
280 private:
281     void resetData();
282 
283     bool parseSelectDisplay(uint16_t length);
284     bool parseSetError(uint16_t length);
285     bool parseSetChangedCompositionTypes(uint16_t length);
286     bool parseSetDisplayRequests(uint16_t length);
287     bool parseSetPresentFence(uint16_t length);
288     bool parseSetReleaseFences(uint16_t length);
289     bool parseSetPresentOrValidateDisplayResult(uint16_t length);
290     bool parseSetClientTargetProperty(uint16_t length);
291 
292     struct ReturnData {
293         uint32_t displayRequests = 0;
294 
295         std::vector<Layer> changedLayers;
296         std::vector<IComposerClient::Composition> compositionTypes;
297 
298         std::vector<Layer> requestedLayers;
299         std::vector<uint32_t> requestMasks;
300 
301         int presentFence = -1;
302 
303         std::vector<Layer> releasedLayers;
304         std::vector<int> releaseFences;
305 
306         uint32_t presentOrValidateState;
307 
308         // Composer 2.4 implementation can return a client target property
309         // structure to indicate the client target properties that hardware
310         // composer requests. The composer client must change the client target
311         // properties to match this request.
312         IComposerClient::ClientTargetProperty clientTargetProperty{PixelFormat::RGBA_8888,
313                                                                    Dataspace::UNKNOWN};
314     };
315 
316     std::vector<CommandError> mErrors;
317     std::unordered_map<Display, ReturnData> mReturnData;
318 
319     // When SELECT_DISPLAY is parsed, this is updated to point to the
320     // display's return data in mReturnData.  We use it to avoid repeated
321     // map lookups.
322     ReturnData* mCurrentReturnData;
323 };
324 
325 // Composer is a wrapper to IComposer, a proxy to server-side composer.
326 class Composer final : public Hwc2::Composer {
327 public:
328     explicit Composer(const std::string& serviceName);
329     ~Composer() override;
330 
331     std::vector<IComposer::Capability> getCapabilities() override;
332     std::string dumpDebugInfo() override;
333 
334     void registerCallback(const sp<IComposerCallback>& callback) override;
335 
336     // Reset all pending commands in the command buffer. Useful if you want to
337     // skip a frame but have already queued some commands.
338     void resetCommands() override;
339 
340     // Explicitly flush all pending commands in the command buffer.
341     Error executeCommands() override;
342 
343     uint32_t getMaxVirtualDisplayCount() override;
344     Error createVirtualDisplay(uint32_t width, uint32_t height, PixelFormat* format,
345                                std::optional<Display> mirror, Display* outDisplay) override;
346     Error destroyVirtualDisplay(Display display) override;
347 
348     Error acceptDisplayChanges(Display display) override;
349 
350     Error createLayer(Display display, Layer* outLayer) override;
351     Error destroyLayer(Display display, Layer layer) override;
352 
353     Error getActiveConfig(Display display, Config* outConfig) override;
354     Error getChangedCompositionTypes(Display display, std::vector<Layer>* outLayers,
355                                      std::vector<IComposerClient::Composition>* outTypes) override;
356     Error getColorModes(Display display, std::vector<ColorMode>* outModes) override;
357     Error getDisplayAttribute(Display display, Config config, IComposerClient::Attribute attribute,
358                               int32_t* outValue) override;
359     Error getDisplayConfigs(Display display, std::vector<Config>* outConfigs);
360     Error getDisplayName(Display display, std::string* outName) override;
361 
362     Error getDisplayRequests(Display display, uint32_t* outDisplayRequestMask,
363                              std::vector<Layer>* outLayers,
364                              std::vector<uint32_t>* outLayerRequestMasks) override;
365 
366     Error getDozeSupport(Display display, bool* outSupport) override;
367     Error getHdrCapabilities(Display display, std::vector<Hdr>* outTypes, float* outMaxLuminance,
368                              float* outMaxAverageLuminance, float* outMinLuminance) override;
369 
370     Error getReleaseFences(Display display, std::vector<Layer>* outLayers,
371                            std::vector<int>* outReleaseFences) override;
372 
373     Error presentDisplay(Display display, int* outPresentFence) override;
374 
375     Error setActiveConfig(Display display, Config config) override;
376 
377     /*
378      * The composer caches client targets internally.  When target is nullptr,
379      * the composer uses slot to look up the client target from its cache.
380      * When target is not nullptr, the cache is updated with the new target.
381      */
382     Error setClientTarget(Display display, uint32_t slot, const sp<GraphicBuffer>& target,
383                           int acquireFence, Dataspace dataspace,
384                           const std::vector<IComposerClient::Rect>& damage) override;
385     Error setColorMode(Display display, ColorMode mode, RenderIntent renderIntent) override;
386     Error setColorTransform(Display display, const float* matrix, ColorTransform hint) override;
387     Error setOutputBuffer(Display display, const native_handle_t* buffer,
388                           int releaseFence) override;
389     Error setPowerMode(Display display, IComposerClient::PowerMode mode) override;
390     Error setVsyncEnabled(Display display, IComposerClient::Vsync enabled) override;
391 
392     Error setClientTargetSlotCount(Display display) override;
393 
394     Error validateDisplay(Display display, uint32_t* outNumTypes,
395                           uint32_t* outNumRequests) override;
396 
397     Error presentOrValidateDisplay(Display display, uint32_t* outNumTypes, uint32_t* outNumRequests,
398                                    int* outPresentFence, uint32_t* state) override;
399 
400     Error setCursorPosition(Display display, Layer layer, int32_t x, int32_t y) override;
401     /* see setClientTarget for the purpose of slot */
402     Error setLayerBuffer(Display display, Layer layer, uint32_t slot,
403                          const sp<GraphicBuffer>& buffer, int acquireFence) override;
404     Error setLayerSurfaceDamage(Display display, Layer layer,
405                                 const std::vector<IComposerClient::Rect>& damage) override;
406     Error setLayerBlendMode(Display display, Layer layer, IComposerClient::BlendMode mode) override;
407     Error setLayerColor(Display display, Layer layer, const IComposerClient::Color& color) override;
408     Error setLayerCompositionType(Display display, Layer layer,
409                                   IComposerClient::Composition type) override;
410     Error setLayerDataspace(Display display, Layer layer, Dataspace dataspace) override;
411     Error setLayerDisplayFrame(Display display, Layer layer,
412                                const IComposerClient::Rect& frame) override;
413     Error setLayerPlaneAlpha(Display display, Layer layer, float alpha) override;
414     Error setLayerSidebandStream(Display display, Layer layer,
415                                  const native_handle_t* stream) override;
416     Error setLayerSourceCrop(Display display, Layer layer,
417                              const IComposerClient::FRect& crop) override;
418     Error setLayerTransform(Display display, Layer layer, Transform transform) override;
419     Error setLayerVisibleRegion(Display display, Layer layer,
420                                 const std::vector<IComposerClient::Rect>& visible) override;
421     Error setLayerZOrder(Display display, Layer layer, uint32_t z) override;
422 
423     // Composer HAL 2.2
424     Error setLayerPerFrameMetadata(
425             Display display, Layer layer,
426             const std::vector<IComposerClient::PerFrameMetadata>& perFrameMetadatas) override;
427     std::vector<IComposerClient::PerFrameMetadataKey> getPerFrameMetadataKeys(
428             Display display) override;
429     Error getRenderIntents(Display display, ColorMode colorMode,
430             std::vector<RenderIntent>* outRenderIntents) override;
431     Error getDataspaceSaturationMatrix(Dataspace dataspace, mat4* outMatrix) override;
432 
433     // Composer HAL 2.3
434     Error getDisplayIdentificationData(Display display, uint8_t* outPort,
435                                        std::vector<uint8_t>* outData) override;
436     Error setLayerColorTransform(Display display, Layer layer, const float* matrix) override;
437     Error getDisplayedContentSamplingAttributes(Display display, PixelFormat* outFormat,
438                                                 Dataspace* outDataspace,
439                                                 uint8_t* outComponentMask) override;
440     Error setDisplayContentSamplingEnabled(Display display, bool enabled, uint8_t componentMask,
441                                            uint64_t maxFrames) override;
442     Error getDisplayedContentSample(Display display, uint64_t maxFrames, uint64_t timestamp,
443                                     DisplayedFrameStats* outStats) override;
444     Error setLayerPerFrameMetadataBlobs(
445             Display display, Layer layer,
446             const std::vector<IComposerClient::PerFrameMetadataBlob>& metadata) override;
447     Error setDisplayBrightness(Display display, float brightness) override;
448 
449     // Composer HAL 2.4
isVsyncPeriodSwitchSupported()450     bool isVsyncPeriodSwitchSupported() override { return mClient_2_4 != nullptr; }
451     Error getDisplayCapabilities(Display display,
452                                  std::vector<DisplayCapability>* outCapabilities) override;
453     V2_4::Error getDisplayConnectionType(Display display,
454                                          IComposerClient::DisplayConnectionType* outType) override;
455     V2_4::Error getDisplayVsyncPeriod(Display display, VsyncPeriodNanos* outVsyncPeriod) override;
456     V2_4::Error setActiveConfigWithConstraints(
457             Display display, Config config,
458             const IComposerClient::VsyncPeriodChangeConstraints& vsyncPeriodChangeConstraints,
459             VsyncPeriodChangeTimeline* outTimeline) override;
460     V2_4::Error setAutoLowLatencyMode(Display displayId, bool on) override;
461     V2_4::Error getSupportedContentTypes(
462             Display displayId,
463             std::vector<IComposerClient::ContentType>* outSupportedContentTypes) override;
464     V2_4::Error setContentType(Display displayId,
465                                IComposerClient::ContentType contentType) override;
466     V2_4::Error setLayerGenericMetadata(Display display, Layer layer, const std::string& key,
467                                         bool mandatory, const std::vector<uint8_t>& value) override;
468     V2_4::Error getLayerGenericMetadataKeys(
469             std::vector<IComposerClient::LayerGenericMetadataKey>* outKeys) override;
470     Error getClientTargetProperty(
471             Display display,
472             IComposerClient::ClientTargetProperty* outClientTargetProperty) override;
473 
474 private:
475     class CommandWriter : public CommandWriterBase {
476     public:
CommandWriter(uint32_t initialMaxSize)477         explicit CommandWriter(uint32_t initialMaxSize) : CommandWriterBase(initialMaxSize) {}
~CommandWriter()478         ~CommandWriter() override {}
479     };
480 
481     // Many public functions above simply write a command into the command
482     // queue to batch the calls.  validateDisplay and presentDisplay will call
483     // this function to execute the command queue.
484     Error execute();
485 
486     sp<V2_1::IComposer> mComposer;
487 
488     sp<V2_1::IComposerClient> mClient;
489     sp<V2_2::IComposerClient> mClient_2_2;
490     sp<V2_3::IComposerClient> mClient_2_3;
491     sp<IComposerClient> mClient_2_4;
492 
493     // 64KiB minus a small space for metadata such as read/write pointers
494     static constexpr size_t kWriterInitialSize =
495         64 * 1024 / sizeof(uint32_t) - 16;
496     // Max number of buffers that may be cached for a given layer
497     // We obtain this number by:
498     // 1. Tightly coupling this cache to the max size of BufferQueue
499     // 2. Adding an additional slot for the layer caching feature in SurfaceFlinger (see: Planner.h)
500     static const constexpr uint32_t kMaxLayerBufferCount = BufferQueue::NUM_BUFFER_SLOTS + 1;
501     CommandWriter mWriter;
502     CommandReader mReader;
503 };
504 
505 } // namespace impl
506 
507 } // namespace Hwc2
508 
509 } // namespace android
510 
511 #endif // ANDROID_SF_COMPOSER_HAL_H
512