1*38e8c45fSAndroid Build Coastguard Worker /*
2*38e8c45fSAndroid Build Coastguard Worker * Copyright (C) 2008 The Android Open Source Project
3*38e8c45fSAndroid Build Coastguard Worker *
4*38e8c45fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*38e8c45fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*38e8c45fSAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*38e8c45fSAndroid Build Coastguard Worker *
8*38e8c45fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
9*38e8c45fSAndroid Build Coastguard Worker *
10*38e8c45fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*38e8c45fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*38e8c45fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*38e8c45fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*38e8c45fSAndroid Build Coastguard Worker * limitations under the License.
15*38e8c45fSAndroid Build Coastguard Worker */
16*38e8c45fSAndroid Build Coastguard Worker
17*38e8c45fSAndroid Build Coastguard Worker #ifndef ANDROID_SF_LAYER_STATE_H
18*38e8c45fSAndroid Build Coastguard Worker #define ANDROID_SF_LAYER_STATE_H
19*38e8c45fSAndroid Build Coastguard Worker
20*38e8c45fSAndroid Build Coastguard Worker
21*38e8c45fSAndroid Build Coastguard Worker #include <stdint.h>
22*38e8c45fSAndroid Build Coastguard Worker #include <sys/types.h>
23*38e8c45fSAndroid Build Coastguard Worker
24*38e8c45fSAndroid Build Coastguard Worker #include <android/gui/DisplayCaptureArgs.h>
25*38e8c45fSAndroid Build Coastguard Worker #include <android/gui/IWindowInfosReportedListener.h>
26*38e8c45fSAndroid Build Coastguard Worker #include <android/gui/LayerCaptureArgs.h>
27*38e8c45fSAndroid Build Coastguard Worker #include <android/gui/TrustedPresentationThresholds.h>
28*38e8c45fSAndroid Build Coastguard Worker #include <android/native_window.h>
29*38e8c45fSAndroid Build Coastguard Worker #include <gui/DisplayLuts.h>
30*38e8c45fSAndroid Build Coastguard Worker #include <gui/IGraphicBufferProducer.h>
31*38e8c45fSAndroid Build Coastguard Worker #include <gui/ITransactionCompletedListener.h>
32*38e8c45fSAndroid Build Coastguard Worker #include <math/mat4.h>
33*38e8c45fSAndroid Build Coastguard Worker
34*38e8c45fSAndroid Build Coastguard Worker #include <android/gui/DropInputMode.h>
35*38e8c45fSAndroid Build Coastguard Worker #include <android/gui/EdgeExtensionParameters.h>
36*38e8c45fSAndroid Build Coastguard Worker #include <android/gui/FocusRequest.h>
37*38e8c45fSAndroid Build Coastguard Worker #include <android/gui/TrustedOverlay.h>
38*38e8c45fSAndroid Build Coastguard Worker
39*38e8c45fSAndroid Build Coastguard Worker #include <ftl/flags.h>
40*38e8c45fSAndroid Build Coastguard Worker #include <gui/BufferReleaseChannel.h>
41*38e8c45fSAndroid Build Coastguard Worker #include <gui/ISurfaceComposer.h>
42*38e8c45fSAndroid Build Coastguard Worker #include <gui/LayerMetadata.h>
43*38e8c45fSAndroid Build Coastguard Worker #include <gui/SpHash.h>
44*38e8c45fSAndroid Build Coastguard Worker #include <gui/SurfaceControl.h>
45*38e8c45fSAndroid Build Coastguard Worker #include <gui/WindowInfo.h>
46*38e8c45fSAndroid Build Coastguard Worker #include <math/vec3.h>
47*38e8c45fSAndroid Build Coastguard Worker #include <ui/BlurRegion.h>
48*38e8c45fSAndroid Build Coastguard Worker #include <ui/GraphicTypes.h>
49*38e8c45fSAndroid Build Coastguard Worker #include <ui/LayerStack.h>
50*38e8c45fSAndroid Build Coastguard Worker #include <ui/PictureProfileHandle.h>
51*38e8c45fSAndroid Build Coastguard Worker #include <ui/Rect.h>
52*38e8c45fSAndroid Build Coastguard Worker #include <ui/Region.h>
53*38e8c45fSAndroid Build Coastguard Worker #include <ui/Rotation.h>
54*38e8c45fSAndroid Build Coastguard Worker #include <ui/StretchEffect.h>
55*38e8c45fSAndroid Build Coastguard Worker #include <ui/Transform.h>
56*38e8c45fSAndroid Build Coastguard Worker #include <utils/Errors.h>
57*38e8c45fSAndroid Build Coastguard Worker
58*38e8c45fSAndroid Build Coastguard Worker namespace android {
59*38e8c45fSAndroid Build Coastguard Worker
60*38e8c45fSAndroid Build Coastguard Worker class Parcel;
61*38e8c45fSAndroid Build Coastguard Worker
62*38e8c45fSAndroid Build Coastguard Worker using gui::ISurfaceComposerClient;
63*38e8c45fSAndroid Build Coastguard Worker using gui::LayerMetadata;
64*38e8c45fSAndroid Build Coastguard Worker
65*38e8c45fSAndroid Build Coastguard Worker using gui::TrustedPresentationThresholds;
66*38e8c45fSAndroid Build Coastguard Worker
67*38e8c45fSAndroid Build Coastguard Worker struct client_cache_t {
68*38e8c45fSAndroid Build Coastguard Worker wp<IBinder> token = nullptr;
69*38e8c45fSAndroid Build Coastguard Worker uint64_t id;
70*38e8c45fSAndroid Build Coastguard Worker
71*38e8c45fSAndroid Build Coastguard Worker bool operator==(const client_cache_t& other) const { return id == other.id; }
72*38e8c45fSAndroid Build Coastguard Worker
isValidclient_cache_t73*38e8c45fSAndroid Build Coastguard Worker bool isValid() const { return token != nullptr; }
74*38e8c45fSAndroid Build Coastguard Worker };
75*38e8c45fSAndroid Build Coastguard Worker
76*38e8c45fSAndroid Build Coastguard Worker class TrustedPresentationListener : public Parcelable {
77*38e8c45fSAndroid Build Coastguard Worker public:
78*38e8c45fSAndroid Build Coastguard Worker sp<ITransactionCompletedListener> callbackInterface;
79*38e8c45fSAndroid Build Coastguard Worker int callbackId = -1;
80*38e8c45fSAndroid Build Coastguard Worker
invoke(bool presentedWithinThresholds)81*38e8c45fSAndroid Build Coastguard Worker void invoke(bool presentedWithinThresholds) {
82*38e8c45fSAndroid Build Coastguard Worker callbackInterface->onTrustedPresentationChanged(callbackId, presentedWithinThresholds);
83*38e8c45fSAndroid Build Coastguard Worker }
84*38e8c45fSAndroid Build Coastguard Worker
85*38e8c45fSAndroid Build Coastguard Worker status_t writeToParcel(Parcel* parcel) const;
86*38e8c45fSAndroid Build Coastguard Worker status_t readFromParcel(const Parcel* parcel);
87*38e8c45fSAndroid Build Coastguard Worker };
88*38e8c45fSAndroid Build Coastguard Worker
89*38e8c45fSAndroid Build Coastguard Worker class BufferData : public Parcelable {
90*38e8c45fSAndroid Build Coastguard Worker public:
91*38e8c45fSAndroid Build Coastguard Worker virtual ~BufferData() = default;
hasBuffer()92*38e8c45fSAndroid Build Coastguard Worker virtual bool hasBuffer() const { return buffer != nullptr; }
hasSameBuffer(const BufferData & other)93*38e8c45fSAndroid Build Coastguard Worker virtual bool hasSameBuffer(const BufferData& other) const {
94*38e8c45fSAndroid Build Coastguard Worker return buffer == other.buffer && frameNumber == other.frameNumber;
95*38e8c45fSAndroid Build Coastguard Worker }
getWidth()96*38e8c45fSAndroid Build Coastguard Worker virtual uint32_t getWidth() const { return buffer->getWidth(); }
getHeight()97*38e8c45fSAndroid Build Coastguard Worker virtual uint32_t getHeight() const { return buffer->getHeight(); }
getBounds()98*38e8c45fSAndroid Build Coastguard Worker Rect getBounds() const {
99*38e8c45fSAndroid Build Coastguard Worker return {0, 0, static_cast<int32_t>(getWidth()), static_cast<int32_t>(getHeight())};
100*38e8c45fSAndroid Build Coastguard Worker }
getId()101*38e8c45fSAndroid Build Coastguard Worker virtual uint64_t getId() const { return buffer->getId(); }
getPixelFormat()102*38e8c45fSAndroid Build Coastguard Worker virtual PixelFormat getPixelFormat() const { return buffer->getPixelFormat(); }
getUsage()103*38e8c45fSAndroid Build Coastguard Worker virtual uint64_t getUsage() const { return buffer->getUsage(); }
104*38e8c45fSAndroid Build Coastguard Worker
105*38e8c45fSAndroid Build Coastguard Worker enum class BufferDataChange : uint32_t {
106*38e8c45fSAndroid Build Coastguard Worker fenceChanged = 0x01,
107*38e8c45fSAndroid Build Coastguard Worker frameNumberChanged = 0x02,
108*38e8c45fSAndroid Build Coastguard Worker cachedBufferChanged = 0x04,
109*38e8c45fSAndroid Build Coastguard Worker };
110*38e8c45fSAndroid Build Coastguard Worker
111*38e8c45fSAndroid Build Coastguard Worker sp<GraphicBuffer> buffer;
112*38e8c45fSAndroid Build Coastguard Worker sp<Fence> acquireFence;
113*38e8c45fSAndroid Build Coastguard Worker
114*38e8c45fSAndroid Build Coastguard Worker // Used by BlastBufferQueue to forward the framenumber generated by the
115*38e8c45fSAndroid Build Coastguard Worker // graphics producer.
116*38e8c45fSAndroid Build Coastguard Worker uint64_t frameNumber = 0;
117*38e8c45fSAndroid Build Coastguard Worker bool hasBarrier = false;
118*38e8c45fSAndroid Build Coastguard Worker uint64_t barrierFrameNumber = 0;
119*38e8c45fSAndroid Build Coastguard Worker uint32_t producerId = 0;
120*38e8c45fSAndroid Build Coastguard Worker
121*38e8c45fSAndroid Build Coastguard Worker // Listens to when the buffer is safe to be released. This is used for blast
122*38e8c45fSAndroid Build Coastguard Worker // layers only. The callback includes a release fence as well as the graphic
123*38e8c45fSAndroid Build Coastguard Worker // buffer id to identify the buffer.
124*38e8c45fSAndroid Build Coastguard Worker sp<ITransactionCompletedListener> releaseBufferListener = nullptr;
125*38e8c45fSAndroid Build Coastguard Worker
126*38e8c45fSAndroid Build Coastguard Worker // Stores which endpoint the release information should be sent to. We don't want to send the
127*38e8c45fSAndroid Build Coastguard Worker // releaseCallbackId and release fence to all listeners so we store which listener the setBuffer
128*38e8c45fSAndroid Build Coastguard Worker // was called with.
129*38e8c45fSAndroid Build Coastguard Worker sp<IBinder> releaseBufferEndpoint;
130*38e8c45fSAndroid Build Coastguard Worker
131*38e8c45fSAndroid Build Coastguard Worker ftl::Flags<BufferDataChange> flags;
132*38e8c45fSAndroid Build Coastguard Worker
133*38e8c45fSAndroid Build Coastguard Worker client_cache_t cachedBuffer;
134*38e8c45fSAndroid Build Coastguard Worker
135*38e8c45fSAndroid Build Coastguard Worker nsecs_t dequeueTime;
136*38e8c45fSAndroid Build Coastguard Worker
137*38e8c45fSAndroid Build Coastguard Worker // Generates the release callback id based on the buffer id and frame number.
138*38e8c45fSAndroid Build Coastguard Worker // This is used as an identifier when release callbacks are invoked.
139*38e8c45fSAndroid Build Coastguard Worker ReleaseCallbackId generateReleaseCallbackId() const;
140*38e8c45fSAndroid Build Coastguard Worker
141*38e8c45fSAndroid Build Coastguard Worker status_t writeToParcel(Parcel* parcel) const override;
142*38e8c45fSAndroid Build Coastguard Worker status_t readFromParcel(const Parcel* parcel) override;
143*38e8c45fSAndroid Build Coastguard Worker };
144*38e8c45fSAndroid Build Coastguard Worker
145*38e8c45fSAndroid Build Coastguard Worker /*
146*38e8c45fSAndroid Build Coastguard Worker * Used to communicate layer information between SurfaceFlinger and its clients.
147*38e8c45fSAndroid Build Coastguard Worker */
148*38e8c45fSAndroid Build Coastguard Worker struct layer_state_t {
149*38e8c45fSAndroid Build Coastguard Worker enum Permission {
150*38e8c45fSAndroid Build Coastguard Worker ACCESS_SURFACE_FLINGER = 0x1,
151*38e8c45fSAndroid Build Coastguard Worker ROTATE_SURFACE_FLINGER = 0x2,
152*38e8c45fSAndroid Build Coastguard Worker INTERNAL_SYSTEM_WINDOW = 0x4,
153*38e8c45fSAndroid Build Coastguard Worker };
154*38e8c45fSAndroid Build Coastguard Worker
155*38e8c45fSAndroid Build Coastguard Worker enum {
156*38e8c45fSAndroid Build Coastguard Worker eLayerHidden = 0x01, // SURFACE_HIDDEN in SurfaceControl.java
157*38e8c45fSAndroid Build Coastguard Worker eLayerOpaque = 0x02, // SURFACE_OPAQUE
158*38e8c45fSAndroid Build Coastguard Worker eLayerSkipScreenshot = 0x40, // SKIP_SCREENSHOT
159*38e8c45fSAndroid Build Coastguard Worker eLayerSecure = 0x80, // SECURE
160*38e8c45fSAndroid Build Coastguard Worker // Queue up layer buffers instead of dropping the oldest buffer when this flag is
161*38e8c45fSAndroid Build Coastguard Worker // set. This blocks the client until all the buffers have been presented. If the buffers
162*38e8c45fSAndroid Build Coastguard Worker // have presentation timestamps, then we may drop buffers.
163*38e8c45fSAndroid Build Coastguard Worker eEnableBackpressure = 0x100, // ENABLE_BACKPRESSURE
164*38e8c45fSAndroid Build Coastguard Worker eLayerIsDisplayDecoration = 0x200, // DISPLAY_DECORATION
165*38e8c45fSAndroid Build Coastguard Worker // Ignore any destination frame set on the layer. This is used when the buffer scaling mode
166*38e8c45fSAndroid Build Coastguard Worker // is freeze and the destination frame is applied asynchronously with the buffer submission.
167*38e8c45fSAndroid Build Coastguard Worker // This is needed to maintain compatibility for SurfaceView scaling behavior.
168*38e8c45fSAndroid Build Coastguard Worker // See SurfaceView scaling behavior for more details.
169*38e8c45fSAndroid Build Coastguard Worker eIgnoreDestinationFrame = 0x400,
170*38e8c45fSAndroid Build Coastguard Worker eLayerIsRefreshRateIndicator = 0x800, // REFRESH_RATE_INDICATOR
171*38e8c45fSAndroid Build Coastguard Worker // Sets a property on this layer indicating that its visible region should be considered
172*38e8c45fSAndroid Build Coastguard Worker // when computing TrustedPresentation Thresholds.
173*38e8c45fSAndroid Build Coastguard Worker eCanOccludePresentation = 0x1000,
174*38e8c45fSAndroid Build Coastguard Worker // Indicates that the SurfaceControl should recover from buffer stuffing when
175*38e8c45fSAndroid Build Coastguard Worker // possible. This is the case when the SurfaceControl is the root SurfaceControl
176*38e8c45fSAndroid Build Coastguard Worker // owned by ViewRootImpl.
177*38e8c45fSAndroid Build Coastguard Worker eRecoverableFromBufferStuffing = 0x2000,
178*38e8c45fSAndroid Build Coastguard Worker };
179*38e8c45fSAndroid Build Coastguard Worker
180*38e8c45fSAndroid Build Coastguard Worker enum {
181*38e8c45fSAndroid Build Coastguard Worker ePositionChanged = 0x00000001,
182*38e8c45fSAndroid Build Coastguard Worker eLayerChanged = 0x00000002,
183*38e8c45fSAndroid Build Coastguard Worker eTrustedPresentationInfoChanged = 0x00000004,
184*38e8c45fSAndroid Build Coastguard Worker eAlphaChanged = 0x00000008,
185*38e8c45fSAndroid Build Coastguard Worker eMatrixChanged = 0x00000010,
186*38e8c45fSAndroid Build Coastguard Worker eTransparentRegionChanged = 0x00000020,
187*38e8c45fSAndroid Build Coastguard Worker eFlagsChanged = 0x00000040,
188*38e8c45fSAndroid Build Coastguard Worker eLayerStackChanged = 0x00000080,
189*38e8c45fSAndroid Build Coastguard Worker eFlushJankData = 0x00000100,
190*38e8c45fSAndroid Build Coastguard Worker eCachingHintChanged = 0x00000200,
191*38e8c45fSAndroid Build Coastguard Worker eDimmingEnabledChanged = 0x00000400,
192*38e8c45fSAndroid Build Coastguard Worker eShadowRadiusChanged = 0x00000800,
193*38e8c45fSAndroid Build Coastguard Worker eLutsChanged = 0x00001000,
194*38e8c45fSAndroid Build Coastguard Worker eBufferCropChanged = 0x00002000,
195*38e8c45fSAndroid Build Coastguard Worker eRelativeLayerChanged = 0x00004000,
196*38e8c45fSAndroid Build Coastguard Worker eReparent = 0x00008000,
197*38e8c45fSAndroid Build Coastguard Worker eColorChanged = 0x00010000,
198*38e8c45fSAndroid Build Coastguard Worker eFrameRateCategoryChanged = 0x00020000,
199*38e8c45fSAndroid Build Coastguard Worker eBufferTransformChanged = 0x00040000,
200*38e8c45fSAndroid Build Coastguard Worker eTransformToDisplayInverseChanged = 0x00080000,
201*38e8c45fSAndroid Build Coastguard Worker eCropChanged = 0x00100000,
202*38e8c45fSAndroid Build Coastguard Worker eBufferChanged = 0x00200000,
203*38e8c45fSAndroid Build Coastguard Worker eDefaultFrameRateCompatibilityChanged = 0x00400000,
204*38e8c45fSAndroid Build Coastguard Worker eDataspaceChanged = 0x00800000,
205*38e8c45fSAndroid Build Coastguard Worker eHdrMetadataChanged = 0x01000000,
206*38e8c45fSAndroid Build Coastguard Worker eSurfaceDamageRegionChanged = 0x02000000,
207*38e8c45fSAndroid Build Coastguard Worker eApiChanged = 0x04000000,
208*38e8c45fSAndroid Build Coastguard Worker eSidebandStreamChanged = 0x08000000,
209*38e8c45fSAndroid Build Coastguard Worker eColorTransformChanged = 0x10000000,
210*38e8c45fSAndroid Build Coastguard Worker eHasListenerCallbacksChanged = 0x20000000,
211*38e8c45fSAndroid Build Coastguard Worker eInputInfoChanged = 0x40000000,
212*38e8c45fSAndroid Build Coastguard Worker eCornerRadiusChanged = 0x80000000,
213*38e8c45fSAndroid Build Coastguard Worker eDestinationFrameChanged = 0x1'00000000,
214*38e8c45fSAndroid Build Coastguard Worker eFrameRateSelectionStrategyChanged = 0x2'00000000,
215*38e8c45fSAndroid Build Coastguard Worker eBackgroundColorChanged = 0x4'00000000,
216*38e8c45fSAndroid Build Coastguard Worker eMetadataChanged = 0x8'00000000,
217*38e8c45fSAndroid Build Coastguard Worker eColorSpaceAgnosticChanged = 0x10'00000000,
218*38e8c45fSAndroid Build Coastguard Worker eFrameRateSelectionPriority = 0x20'00000000,
219*38e8c45fSAndroid Build Coastguard Worker eFrameRateChanged = 0x40'00000000,
220*38e8c45fSAndroid Build Coastguard Worker eBackgroundBlurRadiusChanged = 0x80'00000000,
221*38e8c45fSAndroid Build Coastguard Worker eProducerDisconnect = 0x100'00000000,
222*38e8c45fSAndroid Build Coastguard Worker eFixedTransformHintChanged = 0x200'00000000,
223*38e8c45fSAndroid Build Coastguard Worker eDesiredHdrHeadroomChanged = 0x400'00000000,
224*38e8c45fSAndroid Build Coastguard Worker eBlurRegionsChanged = 0x800'00000000,
225*38e8c45fSAndroid Build Coastguard Worker eAutoRefreshChanged = 0x1000'00000000,
226*38e8c45fSAndroid Build Coastguard Worker eStretchChanged = 0x2000'00000000,
227*38e8c45fSAndroid Build Coastguard Worker eTrustedOverlayChanged = 0x4000'00000000,
228*38e8c45fSAndroid Build Coastguard Worker eDropInputModeChanged = 0x8000'00000000,
229*38e8c45fSAndroid Build Coastguard Worker eExtendedRangeBrightnessChanged = 0x10000'00000000,
230*38e8c45fSAndroid Build Coastguard Worker eEdgeExtensionChanged = 0x20000'00000000,
231*38e8c45fSAndroid Build Coastguard Worker eBufferReleaseChannelChanged = 0x40000'00000000,
232*38e8c45fSAndroid Build Coastguard Worker ePictureProfileHandleChanged = 0x80000'00000000,
233*38e8c45fSAndroid Build Coastguard Worker eAppContentPriorityChanged = 0x100000'00000000,
234*38e8c45fSAndroid Build Coastguard Worker };
235*38e8c45fSAndroid Build Coastguard Worker
236*38e8c45fSAndroid Build Coastguard Worker layer_state_t();
237*38e8c45fSAndroid Build Coastguard Worker
238*38e8c45fSAndroid Build Coastguard Worker void merge(const layer_state_t& other);
239*38e8c45fSAndroid Build Coastguard Worker status_t write(Parcel& output) const;
240*38e8c45fSAndroid Build Coastguard Worker status_t read(const Parcel& input);
241*38e8c45fSAndroid Build Coastguard Worker // Compares two layer_state_t structs and returns a set of change flags describing all the
242*38e8c45fSAndroid Build Coastguard Worker // states that are different.
243*38e8c45fSAndroid Build Coastguard Worker uint64_t diff(const layer_state_t& other) const;
244*38e8c45fSAndroid Build Coastguard Worker bool hasBufferChanges() const;
245*38e8c45fSAndroid Build Coastguard Worker
246*38e8c45fSAndroid Build Coastguard Worker // Layer hierarchy updates.
247*38e8c45fSAndroid Build Coastguard Worker static constexpr uint64_t HIERARCHY_CHANGES = layer_state_t::eLayerChanged |
248*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eRelativeLayerChanged | layer_state_t::eReparent |
249*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eLayerStackChanged;
250*38e8c45fSAndroid Build Coastguard Worker
251*38e8c45fSAndroid Build Coastguard Worker // Geometry updates.
252*38e8c45fSAndroid Build Coastguard Worker static constexpr uint64_t GEOMETRY_CHANGES = layer_state_t::eBufferCropChanged |
253*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eBufferTransformChanged | layer_state_t::eCornerRadiusChanged |
254*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eCropChanged | layer_state_t::eDestinationFrameChanged |
255*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eMatrixChanged | layer_state_t::ePositionChanged |
256*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eTransformToDisplayInverseChanged |
257*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eTransparentRegionChanged | layer_state_t::eEdgeExtensionChanged;
258*38e8c45fSAndroid Build Coastguard Worker
259*38e8c45fSAndroid Build Coastguard Worker // Buffer and related updates.
260*38e8c45fSAndroid Build Coastguard Worker static constexpr uint64_t BUFFER_CHANGES = layer_state_t::eApiChanged |
261*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eBufferChanged | layer_state_t::eBufferCropChanged |
262*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eBufferTransformChanged | layer_state_t::eDataspaceChanged |
263*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eSidebandStreamChanged | layer_state_t::eSurfaceDamageRegionChanged |
264*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eTransformToDisplayInverseChanged |
265*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eTransparentRegionChanged |
266*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eExtendedRangeBrightnessChanged |
267*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eDesiredHdrHeadroomChanged | layer_state_t::eLutsChanged;
268*38e8c45fSAndroid Build Coastguard Worker
269*38e8c45fSAndroid Build Coastguard Worker // Content updates.
270*38e8c45fSAndroid Build Coastguard Worker static constexpr uint64_t CONTENT_CHANGES = layer_state_t::BUFFER_CHANGES |
271*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eAlphaChanged | layer_state_t::eAutoRefreshChanged |
272*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eBackgroundBlurRadiusChanged | layer_state_t::eBackgroundColorChanged |
273*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eBlurRegionsChanged | layer_state_t::eColorChanged |
274*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eColorSpaceAgnosticChanged | layer_state_t::eColorTransformChanged |
275*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eCornerRadiusChanged | layer_state_t::eDimmingEnabledChanged |
276*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eHdrMetadataChanged | layer_state_t::eShadowRadiusChanged |
277*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eStretchChanged | layer_state_t::ePictureProfileHandleChanged |
278*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eAppContentPriorityChanged;
279*38e8c45fSAndroid Build Coastguard Worker
280*38e8c45fSAndroid Build Coastguard Worker // Changes which invalidates the layer's visible region in CE.
281*38e8c45fSAndroid Build Coastguard Worker static constexpr uint64_t CONTENT_DIRTY = layer_state_t::CONTENT_CHANGES |
282*38e8c45fSAndroid Build Coastguard Worker layer_state_t::GEOMETRY_CHANGES | layer_state_t::HIERARCHY_CHANGES;
283*38e8c45fSAndroid Build Coastguard Worker
284*38e8c45fSAndroid Build Coastguard Worker // Changes affecting child states.
285*38e8c45fSAndroid Build Coastguard Worker static constexpr uint64_t AFFECTS_CHILDREN = layer_state_t::GEOMETRY_CHANGES |
286*38e8c45fSAndroid Build Coastguard Worker layer_state_t::HIERARCHY_CHANGES | layer_state_t::eAlphaChanged |
287*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eBackgroundBlurRadiusChanged | layer_state_t::eBlurRegionsChanged |
288*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eColorTransformChanged | layer_state_t::eCornerRadiusChanged |
289*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eFlagsChanged | layer_state_t::eTrustedOverlayChanged |
290*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eFrameRateChanged | layer_state_t::eFrameRateCategoryChanged |
291*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eFrameRateSelectionStrategyChanged |
292*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eFrameRateSelectionPriority | layer_state_t::eFixedTransformHintChanged;
293*38e8c45fSAndroid Build Coastguard Worker
294*38e8c45fSAndroid Build Coastguard Worker // Changes affecting data sent to input.
295*38e8c45fSAndroid Build Coastguard Worker static constexpr uint64_t INPUT_CHANGES = layer_state_t::eAlphaChanged |
296*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eInputInfoChanged | layer_state_t::eDropInputModeChanged |
297*38e8c45fSAndroid Build Coastguard Worker layer_state_t::eTrustedOverlayChanged | layer_state_t::eLayerStackChanged;
298*38e8c45fSAndroid Build Coastguard Worker
299*38e8c45fSAndroid Build Coastguard Worker // Changes that affect the visible region on a display.
300*38e8c45fSAndroid Build Coastguard Worker static constexpr uint64_t VISIBLE_REGION_CHANGES = layer_state_t::GEOMETRY_CHANGES |
301*38e8c45fSAndroid Build Coastguard Worker layer_state_t::HIERARCHY_CHANGES | layer_state_t::eAlphaChanged;
302*38e8c45fSAndroid Build Coastguard Worker
303*38e8c45fSAndroid Build Coastguard Worker bool hasValidBuffer() const;
304*38e8c45fSAndroid Build Coastguard Worker void sanitize(int32_t permissions);
305*38e8c45fSAndroid Build Coastguard Worker
306*38e8c45fSAndroid Build Coastguard Worker struct matrix22_t {
307*38e8c45fSAndroid Build Coastguard Worker float dsdx{0};
308*38e8c45fSAndroid Build Coastguard Worker float dtdx{0};
309*38e8c45fSAndroid Build Coastguard Worker float dtdy{0};
310*38e8c45fSAndroid Build Coastguard Worker float dsdy{0};
311*38e8c45fSAndroid Build Coastguard Worker status_t write(Parcel& output) const;
312*38e8c45fSAndroid Build Coastguard Worker status_t read(const Parcel& input);
313*38e8c45fSAndroid Build Coastguard Worker inline bool operator==(const matrix22_t& other) const {
314*38e8c45fSAndroid Build Coastguard Worker return std::tie(dsdx, dtdx, dtdy, dsdy) ==
315*38e8c45fSAndroid Build Coastguard Worker std::tie(other.dsdx, other.dtdx, other.dtdy, other.dsdy);
316*38e8c45fSAndroid Build Coastguard Worker }
317*38e8c45fSAndroid Build Coastguard Worker inline bool operator!=(const matrix22_t& other) const { return !(*this == other); }
318*38e8c45fSAndroid Build Coastguard Worker };
319*38e8c45fSAndroid Build Coastguard Worker sp<IBinder> surface;
320*38e8c45fSAndroid Build Coastguard Worker int32_t layerId;
321*38e8c45fSAndroid Build Coastguard Worker uint64_t what;
322*38e8c45fSAndroid Build Coastguard Worker float x;
323*38e8c45fSAndroid Build Coastguard Worker float y;
324*38e8c45fSAndroid Build Coastguard Worker int32_t z;
325*38e8c45fSAndroid Build Coastguard Worker ui::LayerStack layerStack = ui::DEFAULT_LAYER_STACK;
326*38e8c45fSAndroid Build Coastguard Worker uint32_t flags;
327*38e8c45fSAndroid Build Coastguard Worker uint32_t mask;
328*38e8c45fSAndroid Build Coastguard Worker uint8_t reserved;
329*38e8c45fSAndroid Build Coastguard Worker matrix22_t matrix;
330*38e8c45fSAndroid Build Coastguard Worker float cornerRadius;
331*38e8c45fSAndroid Build Coastguard Worker uint32_t backgroundBlurRadius;
332*38e8c45fSAndroid Build Coastguard Worker
333*38e8c45fSAndroid Build Coastguard Worker sp<SurfaceControl> relativeLayerSurfaceControl;
334*38e8c45fSAndroid Build Coastguard Worker
335*38e8c45fSAndroid Build Coastguard Worker sp<SurfaceControl> parentSurfaceControlForChild;
336*38e8c45fSAndroid Build Coastguard Worker
337*38e8c45fSAndroid Build Coastguard Worker half4 color;
338*38e8c45fSAndroid Build Coastguard Worker
339*38e8c45fSAndroid Build Coastguard Worker // non POD must be last. see write/read
340*38e8c45fSAndroid Build Coastguard Worker Region transparentRegion;
341*38e8c45fSAndroid Build Coastguard Worker uint32_t bufferTransform;
342*38e8c45fSAndroid Build Coastguard Worker bool transformToDisplayInverse;
343*38e8c45fSAndroid Build Coastguard Worker FloatRect crop;
344*38e8c45fSAndroid Build Coastguard Worker std::shared_ptr<BufferData> bufferData = nullptr;
345*38e8c45fSAndroid Build Coastguard Worker ui::Dataspace dataspace;
346*38e8c45fSAndroid Build Coastguard Worker HdrMetadata hdrMetadata;
347*38e8c45fSAndroid Build Coastguard Worker Region surfaceDamageRegion;
348*38e8c45fSAndroid Build Coastguard Worker int32_t api;
349*38e8c45fSAndroid Build Coastguard Worker sp<NativeHandle> sidebandStream;
350*38e8c45fSAndroid Build Coastguard Worker mat4 colorTransform;
351*38e8c45fSAndroid Build Coastguard Worker std::vector<BlurRegion> blurRegions;
352*38e8c45fSAndroid Build Coastguard Worker
353*38e8c45fSAndroid Build Coastguard Worker sp<gui::WindowInfoHandle> windowInfoHandle = sp<gui::WindowInfoHandle>::make();
354*38e8c45fSAndroid Build Coastguard Worker
355*38e8c45fSAndroid Build Coastguard Worker LayerMetadata metadata;
356*38e8c45fSAndroid Build Coastguard Worker
357*38e8c45fSAndroid Build Coastguard Worker // The following refer to the alpha, and dataspace, respectively of
358*38e8c45fSAndroid Build Coastguard Worker // the background color layer
359*38e8c45fSAndroid Build Coastguard Worker half4 bgColor;
360*38e8c45fSAndroid Build Coastguard Worker ui::Dataspace bgColorDataspace;
361*38e8c45fSAndroid Build Coastguard Worker
362*38e8c45fSAndroid Build Coastguard Worker // A color space agnostic layer means the color of this layer can be
363*38e8c45fSAndroid Build Coastguard Worker // interpreted in any color space.
364*38e8c45fSAndroid Build Coastguard Worker bool colorSpaceAgnostic;
365*38e8c45fSAndroid Build Coastguard Worker
366*38e8c45fSAndroid Build Coastguard Worker std::vector<ListenerCallbacks> listeners;
367*38e8c45fSAndroid Build Coastguard Worker
368*38e8c45fSAndroid Build Coastguard Worker // Draws a shadow around the surface.
369*38e8c45fSAndroid Build Coastguard Worker float shadowRadius;
370*38e8c45fSAndroid Build Coastguard Worker
371*38e8c45fSAndroid Build Coastguard Worker // Priority of the layer assigned by Window Manager.
372*38e8c45fSAndroid Build Coastguard Worker int32_t frameRateSelectionPriority;
373*38e8c45fSAndroid Build Coastguard Worker
374*38e8c45fSAndroid Build Coastguard Worker // Layer frame rate and compatibility. See ANativeWindow_setFrameRate().
375*38e8c45fSAndroid Build Coastguard Worker float frameRate;
376*38e8c45fSAndroid Build Coastguard Worker int8_t frameRateCompatibility;
377*38e8c45fSAndroid Build Coastguard Worker int8_t changeFrameRateStrategy;
378*38e8c45fSAndroid Build Coastguard Worker
379*38e8c45fSAndroid Build Coastguard Worker // Default frame rate compatibility used to set the layer refresh rate votetype.
380*38e8c45fSAndroid Build Coastguard Worker int8_t defaultFrameRateCompatibility;
381*38e8c45fSAndroid Build Coastguard Worker
382*38e8c45fSAndroid Build Coastguard Worker // Frame rate category to suggest what frame rate range a surface should run.
383*38e8c45fSAndroid Build Coastguard Worker int8_t frameRateCategory;
384*38e8c45fSAndroid Build Coastguard Worker bool frameRateCategorySmoothSwitchOnly;
385*38e8c45fSAndroid Build Coastguard Worker
386*38e8c45fSAndroid Build Coastguard Worker // Strategy of the layer for frame rate selection.
387*38e8c45fSAndroid Build Coastguard Worker int8_t frameRateSelectionStrategy;
388*38e8c45fSAndroid Build Coastguard Worker
389*38e8c45fSAndroid Build Coastguard Worker // Set by window manager indicating the layer and all its children are
390*38e8c45fSAndroid Build Coastguard Worker // in a different orientation than the display. The hint suggests that
391*38e8c45fSAndroid Build Coastguard Worker // the graphic producers should receive a transform hint as if the
392*38e8c45fSAndroid Build Coastguard Worker // display was in this orientation. When the display changes to match
393*38e8c45fSAndroid Build Coastguard Worker // the layer orientation, the graphic producer may not need to allocate
394*38e8c45fSAndroid Build Coastguard Worker // a buffer of a different size. -1 means the transform hint is not set,
395*38e8c45fSAndroid Build Coastguard Worker // otherwise the value will be a valid ui::Rotation.
396*38e8c45fSAndroid Build Coastguard Worker ui::Transform::RotationFlags fixedTransformHint;
397*38e8c45fSAndroid Build Coastguard Worker
398*38e8c45fSAndroid Build Coastguard Worker // Indicates that the consumer should acquire the next frame as soon as it
399*38e8c45fSAndroid Build Coastguard Worker // can and not wait for a frame to become available. This is only relevant
400*38e8c45fSAndroid Build Coastguard Worker // in shared buffer mode.
401*38e8c45fSAndroid Build Coastguard Worker bool autoRefresh;
402*38e8c45fSAndroid Build Coastguard Worker
403*38e8c45fSAndroid Build Coastguard Worker // An inherited state that indicates that this surface control and its children
404*38e8c45fSAndroid Build Coastguard Worker // should be trusted for input occlusion detection purposes
405*38e8c45fSAndroid Build Coastguard Worker gui::TrustedOverlay trustedOverlay;
406*38e8c45fSAndroid Build Coastguard Worker
407*38e8c45fSAndroid Build Coastguard Worker // Stretch effect to be applied to this layer
408*38e8c45fSAndroid Build Coastguard Worker StretchEffect stretchEffect;
409*38e8c45fSAndroid Build Coastguard Worker
410*38e8c45fSAndroid Build Coastguard Worker // Edge extension effect to be applied to this layer
411*38e8c45fSAndroid Build Coastguard Worker gui::EdgeExtensionParameters edgeExtensionParameters;
412*38e8c45fSAndroid Build Coastguard Worker
413*38e8c45fSAndroid Build Coastguard Worker Rect bufferCrop;
414*38e8c45fSAndroid Build Coastguard Worker Rect destinationFrame;
415*38e8c45fSAndroid Build Coastguard Worker
416*38e8c45fSAndroid Build Coastguard Worker // Force inputflinger to drop all input events for the layer and its children.
417*38e8c45fSAndroid Build Coastguard Worker gui::DropInputMode dropInputMode;
418*38e8c45fSAndroid Build Coastguard Worker
419*38e8c45fSAndroid Build Coastguard Worker bool dimmingEnabled;
420*38e8c45fSAndroid Build Coastguard Worker float currentHdrSdrRatio = 1.f;
421*38e8c45fSAndroid Build Coastguard Worker float desiredHdrSdrRatio = 1.f;
422*38e8c45fSAndroid Build Coastguard Worker
423*38e8c45fSAndroid Build Coastguard Worker // Enhance the quality of the buffer contents by configurating a picture processing pipeline
424*38e8c45fSAndroid Build Coastguard Worker // with values as specified by this picture profile.
425*38e8c45fSAndroid Build Coastguard Worker PictureProfileHandle pictureProfileHandle{PictureProfileHandle::NONE};
426*38e8c45fSAndroid Build Coastguard Worker
427*38e8c45fSAndroid Build Coastguard Worker // A value indicating the significance of the layer's content to the app's desired user
428*38e8c45fSAndroid Build Coastguard Worker // experience. A lower priority will result in more likelihood of getting access to limited
429*38e8c45fSAndroid Build Coastguard Worker // resources, such as picture processing hardware.
430*38e8c45fSAndroid Build Coastguard Worker int32_t appContentPriority = 0;
431*38e8c45fSAndroid Build Coastguard Worker
432*38e8c45fSAndroid Build Coastguard Worker gui::CachingHint cachingHint = gui::CachingHint::Enabled;
433*38e8c45fSAndroid Build Coastguard Worker
434*38e8c45fSAndroid Build Coastguard Worker TrustedPresentationThresholds trustedPresentationThresholds;
435*38e8c45fSAndroid Build Coastguard Worker TrustedPresentationListener trustedPresentationListener;
436*38e8c45fSAndroid Build Coastguard Worker
437*38e8c45fSAndroid Build Coastguard Worker std::shared_ptr<gui::BufferReleaseChannel::ProducerEndpoint> bufferReleaseChannel;
438*38e8c45fSAndroid Build Coastguard Worker
439*38e8c45fSAndroid Build Coastguard Worker std::shared_ptr<gui::DisplayLuts> luts;
440*38e8c45fSAndroid Build Coastguard Worker };
441*38e8c45fSAndroid Build Coastguard Worker
442*38e8c45fSAndroid Build Coastguard Worker class ComposerState {
443*38e8c45fSAndroid Build Coastguard Worker public:
444*38e8c45fSAndroid Build Coastguard Worker layer_state_t state;
445*38e8c45fSAndroid Build Coastguard Worker status_t write(Parcel& output) const;
446*38e8c45fSAndroid Build Coastguard Worker status_t read(const Parcel& input);
447*38e8c45fSAndroid Build Coastguard Worker };
448*38e8c45fSAndroid Build Coastguard Worker
449*38e8c45fSAndroid Build Coastguard Worker struct DisplayState {
450*38e8c45fSAndroid Build Coastguard Worker enum : uint32_t {
451*38e8c45fSAndroid Build Coastguard Worker eSurfaceChanged = 0x01,
452*38e8c45fSAndroid Build Coastguard Worker eLayerStackChanged = 0x02,
453*38e8c45fSAndroid Build Coastguard Worker eDisplayProjectionChanged = 0x04,
454*38e8c45fSAndroid Build Coastguard Worker eDisplaySizeChanged = 0x08,
455*38e8c45fSAndroid Build Coastguard Worker eFlagsChanged = 0x10,
456*38e8c45fSAndroid Build Coastguard Worker
457*38e8c45fSAndroid Build Coastguard Worker eAllChanged = ~0u
458*38e8c45fSAndroid Build Coastguard Worker };
459*38e8c45fSAndroid Build Coastguard Worker
460*38e8c45fSAndroid Build Coastguard Worker // Not for direct use. Prefer constructor below for new displays.
461*38e8c45fSAndroid Build Coastguard Worker DisplayState();
462*38e8c45fSAndroid Build Coastguard Worker
DisplayStateDisplayState463*38e8c45fSAndroid Build Coastguard Worker DisplayState(sp<IBinder> token, ui::LayerStack layerStack)
464*38e8c45fSAndroid Build Coastguard Worker : what(eAllChanged),
465*38e8c45fSAndroid Build Coastguard Worker token(std::move(token)),
466*38e8c45fSAndroid Build Coastguard Worker layerStack(layerStack),
467*38e8c45fSAndroid Build Coastguard Worker layerStackSpaceRect(Rect::INVALID_RECT),
468*38e8c45fSAndroid Build Coastguard Worker orientedDisplaySpaceRect(Rect::INVALID_RECT) {}
469*38e8c45fSAndroid Build Coastguard Worker
470*38e8c45fSAndroid Build Coastguard Worker void merge(const DisplayState& other);
471*38e8c45fSAndroid Build Coastguard Worker void sanitize(int32_t permissions);
472*38e8c45fSAndroid Build Coastguard Worker
473*38e8c45fSAndroid Build Coastguard Worker uint32_t what = 0;
474*38e8c45fSAndroid Build Coastguard Worker uint32_t flags = 0;
475*38e8c45fSAndroid Build Coastguard Worker sp<IBinder> token;
476*38e8c45fSAndroid Build Coastguard Worker
477*38e8c45fSAndroid Build Coastguard Worker ui::LayerStack layerStack = ui::DEFAULT_LAYER_STACK;
478*38e8c45fSAndroid Build Coastguard Worker
479*38e8c45fSAndroid Build Coastguard Worker // These states define how layers are projected onto the physical or virtual display.
480*38e8c45fSAndroid Build Coastguard Worker //
481*38e8c45fSAndroid Build Coastguard Worker // Layers are first clipped to `layerStackSpaceRect'. They are then translated and
482*38e8c45fSAndroid Build Coastguard Worker // scaled from `layerStackSpaceRect' to `orientedDisplaySpaceRect'. Finally, they are rotated
483*38e8c45fSAndroid Build Coastguard Worker // according to `orientation', `width', and `height'.
484*38e8c45fSAndroid Build Coastguard Worker //
485*38e8c45fSAndroid Build Coastguard Worker // For example, assume layerStackSpaceRect is Rect(0, 0, 200, 100), orientedDisplaySpaceRect is
486*38e8c45fSAndroid Build Coastguard Worker // Rect(20, 10, 420, 210), and the size of the display is WxH. When orientation is 0, layers
487*38e8c45fSAndroid Build Coastguard Worker // will be scaled by a factor of 2 and translated by (20, 10). When orientation is 1, layers
488*38e8c45fSAndroid Build Coastguard Worker // will be additionally rotated by 90 degrees around the origin clockwise and translated by (W,
489*38e8c45fSAndroid Build Coastguard Worker // 0).
490*38e8c45fSAndroid Build Coastguard Worker //
491*38e8c45fSAndroid Build Coastguard Worker // Rect::INVALID_RECT sizes the space to the active resolution of the physical display, or the
492*38e8c45fSAndroid Build Coastguard Worker // default dimensions of the virtual display surface.
493*38e8c45fSAndroid Build Coastguard Worker //
494*38e8c45fSAndroid Build Coastguard Worker ui::Rotation orientation = ui::ROTATION_0;
495*38e8c45fSAndroid Build Coastguard Worker Rect layerStackSpaceRect = Rect::EMPTY_RECT;
496*38e8c45fSAndroid Build Coastguard Worker Rect orientedDisplaySpaceRect = Rect::EMPTY_RECT;
497*38e8c45fSAndroid Build Coastguard Worker
498*38e8c45fSAndroid Build Coastguard Worker // Exclusive to virtual displays: The sink surface into which the virtual display is rendered,
499*38e8c45fSAndroid Build Coastguard Worker // and an optional resolution that overrides its default dimensions.
500*38e8c45fSAndroid Build Coastguard Worker sp<IGraphicBufferProducer> surface;
501*38e8c45fSAndroid Build Coastguard Worker uint32_t width = 0;
502*38e8c45fSAndroid Build Coastguard Worker uint32_t height = 0;
503*38e8c45fSAndroid Build Coastguard Worker
504*38e8c45fSAndroid Build Coastguard Worker status_t write(Parcel& output) const;
505*38e8c45fSAndroid Build Coastguard Worker status_t read(const Parcel& input);
506*38e8c45fSAndroid Build Coastguard Worker };
507*38e8c45fSAndroid Build Coastguard Worker
508*38e8c45fSAndroid Build Coastguard Worker struct InputWindowCommands {
509*38e8c45fSAndroid Build Coastguard Worker std::vector<gui::FocusRequest> focusRequests;
510*38e8c45fSAndroid Build Coastguard Worker std::unordered_set<sp<gui::IWindowInfosReportedListener>,
511*38e8c45fSAndroid Build Coastguard Worker SpHash<gui::IWindowInfosReportedListener>>
512*38e8c45fSAndroid Build Coastguard Worker windowInfosReportedListeners;
513*38e8c45fSAndroid Build Coastguard Worker
514*38e8c45fSAndroid Build Coastguard Worker // Merges the passed in commands and returns true if there were any changes.
515*38e8c45fSAndroid Build Coastguard Worker bool merge(const InputWindowCommands& other);
516*38e8c45fSAndroid Build Coastguard Worker bool empty() const;
517*38e8c45fSAndroid Build Coastguard Worker void clear();
518*38e8c45fSAndroid Build Coastguard Worker status_t write(Parcel& output) const;
519*38e8c45fSAndroid Build Coastguard Worker status_t read(const Parcel& input);
520*38e8c45fSAndroid Build Coastguard Worker };
521*38e8c45fSAndroid Build Coastguard Worker
compare_type(const ComposerState & lhs,const ComposerState & rhs)522*38e8c45fSAndroid Build Coastguard Worker static inline int compare_type(const ComposerState& lhs, const ComposerState& rhs) {
523*38e8c45fSAndroid Build Coastguard Worker if (lhs.state.surface < rhs.state.surface) return -1;
524*38e8c45fSAndroid Build Coastguard Worker if (lhs.state.surface > rhs.state.surface) return 1;
525*38e8c45fSAndroid Build Coastguard Worker return 0;
526*38e8c45fSAndroid Build Coastguard Worker }
527*38e8c45fSAndroid Build Coastguard Worker
compare_type(const DisplayState & lhs,const DisplayState & rhs)528*38e8c45fSAndroid Build Coastguard Worker static inline int compare_type(const DisplayState& lhs, const DisplayState& rhs) {
529*38e8c45fSAndroid Build Coastguard Worker return compare_type(lhs.token, rhs.token);
530*38e8c45fSAndroid Build Coastguard Worker }
531*38e8c45fSAndroid Build Coastguard Worker
532*38e8c45fSAndroid Build Coastguard Worker }; // namespace android
533*38e8c45fSAndroid Build Coastguard Worker
534*38e8c45fSAndroid Build Coastguard Worker #endif // ANDROID_SF_LAYER_STATE_H
535