Layer.h revision 1e24ccebeeb6798afce2730a120abcf9927960fa
1/*
2 * Copyright (C) 2007 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_LAYER_H
18#define ANDROID_LAYER_H
19
20#include <stdint.h>
21#include <sys/types.h>
22
23#include <utils/RefBase.h>
24#include <utils/String8.h>
25#include <utils/Timers.h>
26
27#include <ui/FrameStats.h>
28#include <ui/GraphicBuffer.h>
29#include <ui/PixelFormat.h>
30#include <ui/Region.h>
31
32#include <gui/ISurfaceComposerClient.h>
33#include <gui/LayerState.h>
34
35#include <list>
36
37#include "Client.h"
38#include "FrameTracker.h"
39#include "LayerVector.h"
40#include "MonitoredProducer.h"
41#include "SurfaceFlinger.h"
42#include "Transform.h"
43
44#include <layerproto/LayerProtoHeader.h>
45#include "DisplayHardware/HWComposer.h"
46#include "DisplayHardware/HWComposerBufferCache.h"
47#include "RenderArea.h"
48#include "RenderEngine/Mesh.h"
49#include "RenderEngine/Texture.h"
50
51#include <math/vec4.h>
52
53using namespace android::surfaceflinger;
54
55namespace android {
56
57// ---------------------------------------------------------------------------
58
59class Client;
60class Colorizer;
61class DisplayDevice;
62class GraphicBuffer;
63class SurfaceFlinger;
64class LayerDebugInfo;
65class LayerBE;
66
67// ---------------------------------------------------------------------------
68
69class LayerBE {
70public:
71    LayerBE();
72
73    sp<NativeHandle> mSidebandStream;
74
75    // The mesh used to draw the layer in GLES composition mode
76    Mesh mMesh;
77
78    // HWC items, accessed from the main thread
79    struct HWCInfo {
80        HWCInfo()
81              : hwc(nullptr),
82                layer(nullptr),
83                forceClientComposition(false),
84                compositionType(HWC2::Composition::Invalid),
85                clearClientTarget(false) {}
86
87        HWComposer* hwc;
88        HWC2::Layer* layer;
89        bool forceClientComposition;
90        HWC2::Composition compositionType;
91        bool clearClientTarget;
92        Rect displayFrame;
93        FloatRect sourceCrop;
94        HWComposerBufferCache bufferCache;
95    };
96
97    // A layer can be attached to multiple displays when operating in mirror mode
98    // (a.k.a: when several displays are attached with equal layerStack). In this
99    // case we need to keep track. In non-mirror mode, a layer will have only one
100    // HWCInfo. This map key is a display layerStack.
101    std::unordered_map<int32_t, HWCInfo> mHwcLayers;
102};
103
104class Layer : public virtual RefBase {
105    static int32_t sSequence;
106
107public:
108    LayerBE& getBE() { return mBE; }
109    LayerBE& getBE() const { return mBE; }
110    mutable bool contentDirty;
111    // regions below are in window-manager space
112    Region visibleRegion;
113    Region coveredRegion;
114    Region visibleNonTransparentRegion;
115    Region surfaceDamageRegion;
116
117    // Layer serial number.  This gives layers an explicit ordering, so we
118    // have a stable sort order when their layer stack and Z-order are
119    // the same.
120    int32_t sequence;
121
122    enum { // flags for doTransaction()
123        eDontUpdateGeometryState = 0x00000001,
124        eVisibleRegion = 0x00000002,
125    };
126
127    struct Geometry {
128        uint32_t w;
129        uint32_t h;
130        Transform transform;
131
132        inline bool operator==(const Geometry& rhs) const {
133            return (w == rhs.w && h == rhs.h) && (transform.tx() == rhs.transform.tx()) &&
134                    (transform.ty() == rhs.transform.ty());
135        }
136        inline bool operator!=(const Geometry& rhs) const { return !operator==(rhs); }
137    };
138
139    struct State {
140        Geometry active;
141        Geometry requested;
142        int32_t z;
143
144        // The identifier of the layer stack this layer belongs to. A layer can
145        // only be associated to a single layer stack. A layer stack is a
146        // z-ordered group of layers which can be associated to one or more
147        // displays. Using the same layer stack on different displays is a way
148        // to achieve mirroring.
149        uint32_t layerStack;
150
151        uint8_t flags;
152        uint8_t mask;
153        uint8_t reserved[2];
154        int32_t sequence; // changes when visible regions can change
155        bool modified;
156
157        // Crop is expressed in layer space coordinate.
158        Rect crop;
159        Rect requestedCrop;
160
161        // finalCrop is expressed in display space coordinate.
162        Rect finalCrop;
163        Rect requestedFinalCrop;
164
165        // If set, defers this state update until the identified Layer
166        // receives a frame with the given frameNumber
167        wp<Layer> barrierLayer;
168        uint64_t frameNumber;
169
170        // the transparentRegion hint is a bit special, it's latched only
171        // when we receive a buffer -- this is because it's "content"
172        // dependent.
173        Region activeTransparentRegion;
174        Region requestedTransparentRegion;
175        android_dataspace dataSpace;
176
177        uint32_t appId;
178        uint32_t type;
179
180        // If non-null, a Surface this Surface's Z-order is interpreted relative to.
181        wp<Layer> zOrderRelativeOf;
182
183        // A list of surfaces whose Z-order is interpreted relative to ours.
184        SortedVector<wp<Layer>> zOrderRelatives;
185
186        half4 color;
187    };
188
189    Layer(SurfaceFlinger* flinger, const sp<Client>& client, const String8& name, uint32_t w,
190          uint32_t h, uint32_t flags);
191    virtual ~Layer();
192
193    void setPrimaryDisplayOnly() { mPrimaryDisplayOnly = true; }
194
195    // ------------------------------------------------------------------------
196    // Geometry setting functions.
197    //
198    // The following group of functions are used to specify the layers
199    // bounds, and the mapping of the texture on to those bounds. According
200    // to various settings changes to them may apply immediately, or be delayed until
201    // a pending resize is completed by the producer submitting a buffer. For example
202    // if we were to change the buffer size, and update the matrix ahead of the
203    // new buffer arriving, then we would be stretching the buffer to a different
204    // aspect before and after the buffer arriving, which probably isn't what we wanted.
205    //
206    // The first set of geometry functions are controlled by the scaling mode, described
207    // in window.h. The scaling mode may be set by the client, as it submits buffers.
208    // This value may be overriden through SurfaceControl, with setOverrideScalingMode.
209    //
210    // Put simply, if our scaling mode is SCALING_MODE_FREEZE, then
211    // matrix updates will not be applied while a resize is pending
212    // and the size and transform will remain in their previous state
213    // until a new buffer is submitted. If the scaling mode is another value
214    // then the old-buffer will immediately be scaled to the pending size
215    // and the new matrix will be immediately applied following this scaling
216    // transformation.
217
218    // Set the default buffer size for the assosciated Producer, in pixels. This is
219    // also the rendered size of the layer prior to any transformations. Parent
220    // or local matrix transformations will not affect the size of the buffer,
221    // but may affect it's on-screen size or clipping.
222    bool setSize(uint32_t w, uint32_t h);
223    // Set a 2x2 transformation matrix on the layer. This transform
224    // will be applied after parent transforms, but before any final
225    // producer specified transform.
226    bool setMatrix(const layer_state_t::matrix22_t& matrix);
227
228    // This second set of geometry attributes are controlled by
229    // setGeometryAppliesWithResize, and their default mode is to be
230    // immediate. If setGeometryAppliesWithResize is specified
231    // while a resize is pending, then update of these attributes will
232    // be delayed until the resize completes.
233
234    // setPosition operates in parent buffer space (pre parent-transform) or display
235    // space for top-level layers.
236    bool setPosition(float x, float y, bool immediate);
237    // Buffer space
238    bool setCrop(const Rect& crop, bool immediate);
239    // Parent buffer space/display space
240    bool setFinalCrop(const Rect& crop, bool immediate);
241
242    // TODO(b/38182121): Could we eliminate the various latching modes by
243    // using the layer hierarchy?
244    // -----------------------------------------------------------------------
245    bool setLayer(int32_t z);
246    bool setRelativeLayer(const sp<IBinder>& relativeToHandle, int32_t relativeZ);
247
248    bool setAlpha(float alpha);
249    bool setColor(const half3& color);
250    bool setTransparentRegionHint(const Region& transparent);
251    bool setFlags(uint8_t flags, uint8_t mask);
252    bool setLayerStack(uint32_t layerStack);
253    bool setDataSpace(android_dataspace dataSpace);
254    android_dataspace getDataSpace() const;
255    uint32_t getLayerStack() const;
256    void deferTransactionUntil(const sp<IBinder>& barrierHandle, uint64_t frameNumber);
257    void deferTransactionUntil(const sp<Layer>& barrierLayer, uint64_t frameNumber);
258    bool setOverrideScalingMode(int32_t overrideScalingMode);
259    void setInfo(uint32_t type, uint32_t appId);
260    bool reparentChildren(const sp<IBinder>& layer);
261    bool reparent(const sp<IBinder>& newParentHandle);
262    bool detachChildren();
263
264    // If we have received a new buffer this frame, we will pass its surface
265    // damage down to hardware composer. Otherwise, we must send a region with
266    // one empty rect.
267    virtual void useSurfaceDamage() = 0;
268    virtual void useEmptyDamage() = 0;
269
270    uint32_t getTransactionFlags(uint32_t flags);
271    uint32_t setTransactionFlags(uint32_t flags);
272
273    bool belongsToDisplay(uint32_t layerStack, bool isPrimaryDisplay) const {
274        return getLayerStack() == layerStack && (!mPrimaryDisplayOnly || isPrimaryDisplay);
275    }
276
277    void computeGeometry(const RenderArea& renderArea, Mesh& mesh, bool useIdentityTransform) const;
278    Rect computeBounds(const Region& activeTransparentRegion) const;
279    Rect computeBounds() const;
280
281    int32_t getSequence() const { return sequence; }
282
283    // -----------------------------------------------------------------------
284    // Virtuals
285    virtual const char* getTypeId() const = 0;
286
287    /*
288     * isOpaque - true if this surface is opaque
289     *
290     * This takes into account the buffer format (i.e. whether or not the
291     * pixel format includes an alpha channel) and the "opaque" flag set
292     * on the layer.  It does not examine the current plane alpha value.
293     */
294    virtual bool isOpaque(const Layer::State& s) const = 0;
295
296    /*
297     * isSecure - true if this surface is secure, that is if it prevents
298     * screenshots or VNC servers.
299     */
300    bool isSecure() const;
301
302    /*
303     * isVisible - true if this layer is visible, false otherwise
304     */
305    virtual bool isVisible() const = 0;
306
307    /*
308     * isHiddenByPolicy - true if this layer has been forced invisible.
309     * just because this is false, doesn't mean isVisible() is true.
310     * For example if this layer has no active buffer, it may not be hidden by
311     * policy, but it still can not be visible.
312     */
313    bool isHiddenByPolicy() const;
314
315    /*
316     * isFixedSize - true if content has a fixed size
317     */
318    virtual bool isFixedSize() const = 0;
319
320    bool isPendingRemoval() const { return mPendingRemoval; }
321
322    void writeToProto(LayerProto* layerInfo,
323                      LayerVector::StateSet stateSet = LayerVector::StateSet::Drawing);
324
325protected:
326    /*
327     * onDraw - draws the surface.
328     */
329    virtual void onDraw(const RenderArea& renderArea, const Region& clip,
330                        bool useIdentityTransform) const = 0;
331
332public:
333    virtual void setDefaultBufferSize(uint32_t w, uint32_t h) = 0;
334
335    void setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z);
336    void forceClientComposition(int32_t hwcId);
337    bool getForceClientComposition(int32_t hwcId);
338    virtual void setPerFrameData(const sp<const DisplayDevice>& displayDevice) = 0;
339
340    // callIntoHwc exists so we can update our local state and call
341    // acceptDisplayChanges without unnecessarily updating the device's state
342    void setCompositionType(int32_t hwcId, HWC2::Composition type, bool callIntoHwc = true);
343    HWC2::Composition getCompositionType(int32_t hwcId) const;
344    void setClearClientTarget(int32_t hwcId, bool clear);
345    bool getClearClientTarget(int32_t hwcId) const;
346    void updateCursorPosition(const sp<const DisplayDevice>& hw);
347
348    /*
349     * called after page-flip
350     */
351    virtual void onLayerDisplayed(const sp<Fence>& releaseFence);
352
353    virtual void abandon() = 0;
354
355    virtual bool shouldPresentNow(const DispSync& dispSync) const = 0;
356    virtual void setTransformHint(uint32_t orientation) const = 0;
357
358    /*
359     * called before composition.
360     * returns true if the layer has pending updates.
361     */
362    virtual bool onPreComposition(nsecs_t refreshStartTime) = 0;
363
364    /*
365     * called after composition.
366     * returns true if the layer latched a new buffer this frame.
367     */
368    virtual bool onPostComposition(const std::shared_ptr<FenceTime>& glDoneFence,
369                                   const std::shared_ptr<FenceTime>& presentFence,
370                                   const CompositorTiming& compositorTiming) = 0;
371
372    // If a buffer was replaced this frame, release the former buffer
373    virtual void releasePendingBuffer(nsecs_t dequeueReadyTime) = 0;
374
375    /*
376     * draw - performs some global clipping optimizations
377     * and calls onDraw().
378     */
379    void draw(const RenderArea& renderArea, const Region& clip) const;
380    void draw(const RenderArea& renderArea, bool useIdentityTransform) const;
381    void draw(const RenderArea& renderArea) const;
382
383    /*
384     * doTransaction - process the transaction. This is a good place to figure
385     * out which attributes of the surface have changed.
386     */
387    uint32_t doTransaction(uint32_t transactionFlags);
388
389    /*
390     * setVisibleRegion - called to set the new visible region. This gives
391     * a chance to update the new visible region or record the fact it changed.
392     */
393    void setVisibleRegion(const Region& visibleRegion);
394
395    /*
396     * setCoveredRegion - called when the covered region changes. The covered
397     * region corresponds to any area of the surface that is covered
398     * (transparently or not) by another surface.
399     */
400    void setCoveredRegion(const Region& coveredRegion);
401
402    /*
403     * setVisibleNonTransparentRegion - called when the visible and
404     * non-transparent region changes.
405     */
406    void setVisibleNonTransparentRegion(const Region& visibleNonTransparentRegion);
407
408    /*
409     * latchBuffer - called each time the screen is redrawn and returns whether
410     * the visible regions need to be recomputed (this is a fairly heavy
411     * operation, so this should be set only if needed). Typically this is used
412     * to figure out if the content or size of a surface has changed.
413     */
414    virtual Region latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime) = 0;
415    virtual bool isBufferLatched() const = 0;
416
417    bool isPotentialCursor() const { return mPotentialCursor; }
418    /*
419     * called with the state lock from a binder thread when the layer is
420     * removed from the current list to the pending removal list
421     */
422    void onRemovedFromCurrentState();
423
424    /*
425     * called with the state lock from the main thread when the layer is
426     * removed from the pending removal list
427     */
428    void onRemoved();
429
430    // Updates the transform hint in our SurfaceFlingerConsumer to match
431    // the current orientation of the display device.
432    void updateTransformHint(const sp<const DisplayDevice>& hw) const;
433
434    /*
435     * returns the rectangle that crops the content of the layer and scales it
436     * to the layer's size.
437     */
438    Rect getContentCrop() const;
439
440    /*
441     * Returns if a frame is queued.
442     */
443    bool hasQueuedFrame() const {
444        return mQueuedFrames > 0 || mSidebandStreamChanged || mAutoRefresh;
445    }
446
447    int32_t getQueuedFrameCount() const { return mQueuedFrames; }
448
449    // -----------------------------------------------------------------------
450
451    bool createHwcLayer(HWComposer* hwc, int32_t hwcId);
452    bool destroyHwcLayer(int32_t hwcId);
453    void destroyAllHwcLayers();
454
455    bool hasHwcLayer(int32_t hwcId) {
456        return getBE().mHwcLayers.count(hwcId) > 0;
457    }
458
459    HWC2::Layer* getHwcLayer(int32_t hwcId) {
460        if (getBE().mHwcLayers.count(hwcId) == 0) {
461            return nullptr;
462        }
463        return getBE().mHwcLayers[hwcId].layer;
464    }
465
466    // -----------------------------------------------------------------------
467
468    void clearWithOpenGL(const RenderArea& renderArea) const;
469    void setFiltering(bool filtering);
470    bool getFiltering() const;
471
472    // only for debugging
473    inline const sp<GraphicBuffer>& getActiveBuffer() const { return mActiveBuffer; }
474
475    inline const State& getDrawingState() const { return mDrawingState; }
476    inline const State& getCurrentState() const { return mCurrentState; }
477    inline State& getCurrentState() { return mCurrentState; }
478
479    LayerDebugInfo getLayerDebugInfo() const;
480
481    /* always call base class first */
482    static void miniDumpHeader(String8& result);
483    void miniDump(String8& result, int32_t hwcId) const;
484    void dumpFrameStats(String8& result) const;
485    void dumpFrameEvents(String8& result);
486    void clearFrameStats();
487    void logFrameStats();
488    void getFrameStats(FrameStats* outStats) const;
489
490    virtual std::vector<OccupancyTracker::Segment> getOccupancyHistory(bool forceFlush) = 0;
491
492    void onDisconnect();
493    void addAndGetFrameTimestamps(const NewFrameEventsEntry* newEntry,
494                                  FrameEventHistoryDelta* outDelta);
495
496    virtual bool getTransformToDisplayInverse() const = 0;
497
498    Transform getTransform() const;
499
500    // Returns the Alpha of the Surface, accounting for the Alpha
501    // of parent Surfaces in the hierarchy (alpha's will be multiplied
502    // down the hierarchy).
503    half getAlpha() const;
504    half4 getColor() const;
505
506    void traverseInReverseZOrder(LayerVector::StateSet stateSet,
507                                 const LayerVector::Visitor& visitor);
508    void traverseInZOrder(LayerVector::StateSet stateSet, const LayerVector::Visitor& visitor);
509
510    void traverseChildrenInZOrder(LayerVector::StateSet stateSet,
511                                  const LayerVector::Visitor& visitor);
512
513    size_t getChildrenCount() const;
514    void addChild(const sp<Layer>& layer);
515    // Returns index if removed, or negative value otherwise
516    // for symmetry with Vector::remove
517    ssize_t removeChild(const sp<Layer>& layer);
518    sp<Layer> getParent() const { return mCurrentParent.promote(); }
519    bool hasParent() const { return getParent() != nullptr; }
520    Rect computeScreenBounds(bool reduceTransparentRegion = true) const;
521    bool setChildLayer(const sp<Layer>& childLayer, int32_t z);
522    bool setChildRelativeLayer(const sp<Layer>& childLayer,
523            const sp<IBinder>& relativeToHandle, int32_t relativeZ);
524
525    // Copy the current list of children to the drawing state. Called by
526    // SurfaceFlinger to complete a transaction.
527    void commitChildList();
528    int32_t getZ() const;
529
530protected:
531    // constant
532    sp<SurfaceFlinger> mFlinger;
533    /*
534     * Trivial class, used to ensure that mFlinger->onLayerDestroyed(mLayer)
535     * is called.
536     */
537    class LayerCleaner {
538        sp<SurfaceFlinger> mFlinger;
539        wp<Layer> mLayer;
540
541    protected:
542        ~LayerCleaner() {
543            // destroy client resources
544            mFlinger->onLayerDestroyed(mLayer);
545        }
546
547    public:
548        LayerCleaner(const sp<SurfaceFlinger>& flinger, const sp<Layer>& layer)
549              : mFlinger(flinger), mLayer(layer) {}
550    };
551
552    virtual void onFirstRef();
553
554    friend class SurfaceInterceptor;
555
556    void commitTransaction(const State& stateToCommit);
557
558    uint32_t getEffectiveUsage(uint32_t usage) const;
559
560    FloatRect computeCrop(const sp<const DisplayDevice>& hw) const;
561    // Compute the initial crop as specified by parent layers and the
562    // SurfaceControl for this layer. Does not include buffer crop from the
563    // IGraphicBufferProducer client, as that should not affect child clipping.
564    // Returns in screen space.
565    Rect computeInitialCrop(const sp<const DisplayDevice>& hw) const;
566
567    // drawing
568    void clearWithOpenGL(const RenderArea& renderArea, float r, float g, float b,
569                         float alpha) const;
570
571    void setParent(const sp<Layer>& layer);
572
573    LayerVector makeTraversalList(LayerVector::StateSet stateSet);
574    void addZOrderRelative(const wp<Layer>& relative);
575    void removeZOrderRelative(const wp<Layer>& relative);
576
577    class SyncPoint {
578    public:
579        explicit SyncPoint(uint64_t frameNumber)
580              : mFrameNumber(frameNumber), mFrameIsAvailable(false), mTransactionIsApplied(false) {}
581
582        uint64_t getFrameNumber() const { return mFrameNumber; }
583
584        bool frameIsAvailable() const { return mFrameIsAvailable; }
585
586        void setFrameAvailable() { mFrameIsAvailable = true; }
587
588        bool transactionIsApplied() const { return mTransactionIsApplied; }
589
590        void setTransactionApplied() { mTransactionIsApplied = true; }
591
592    private:
593        const uint64_t mFrameNumber;
594        std::atomic<bool> mFrameIsAvailable;
595        std::atomic<bool> mTransactionIsApplied;
596    };
597
598    // SyncPoints which will be signaled when the correct frame is at the head
599    // of the queue and dropped after the frame has been latched. Protected by
600    // mLocalSyncPointMutex.
601    Mutex mLocalSyncPointMutex;
602    std::list<std::shared_ptr<SyncPoint>> mLocalSyncPoints;
603
604    // SyncPoints which will be signaled and then dropped when the transaction
605    // is applied
606    std::list<std::shared_ptr<SyncPoint>> mRemoteSyncPoints;
607
608    // Returns false if the relevant frame has already been latched
609    bool addSyncPoint(const std::shared_ptr<SyncPoint>& point);
610
611    void pushPendingState();
612    void popPendingState(State* stateToCommit);
613    bool applyPendingStates(State* stateToCommit);
614
615    void clearSyncPoints();
616
617    // Returns mCurrentScaling mode (originating from the
618    // Client) or mOverrideScalingMode mode (originating from
619    // the Surface Controller) if set.
620    virtual uint32_t getEffectiveScalingMode() const = 0;
621
622public:
623    /*
624     * The layer handle is just a BBinder object passed to the client
625     * (remote process) -- we don't keep any reference on our side such that
626     * the dtor is called when the remote side let go of its reference.
627     *
628     * LayerCleaner ensures that mFlinger->onLayerDestroyed() is called for
629     * this layer when the handle is destroyed.
630     */
631    class Handle : public BBinder, public LayerCleaner {
632    public:
633        Handle(const sp<SurfaceFlinger>& flinger, const sp<Layer>& layer)
634              : LayerCleaner(flinger, layer), owner(layer) {}
635
636        wp<Layer> owner;
637    };
638
639    sp<IBinder> getHandle();
640    const String8& getName() const;
641    virtual void notifyAvailableFrames() = 0;
642    virtual PixelFormat getPixelFormat() const = 0;
643    bool getPremultipledAlpha() const;
644
645protected:
646    // -----------------------------------------------------------------------
647
648    bool mPremultipliedAlpha;
649    String8 mName;
650    String8 mTransactionName; // A cached version of "TX - " + mName for systraces
651
652    bool mPrimaryDisplayOnly = false;
653
654    // these are protected by an external lock
655    State mCurrentState;
656    State mDrawingState;
657    volatile int32_t mTransactionFlags;
658
659    // Accessed from main thread and binder threads
660    Mutex mPendingStateMutex;
661    Vector<State> mPendingStates;
662
663    // thread-safe
664    volatile int32_t mQueuedFrames;
665    volatile int32_t mSidebandStreamChanged; // used like an atomic boolean
666
667    // Timestamp history for UIAutomation. Thread safe.
668    FrameTracker mFrameTracker;
669
670    // Timestamp history for the consumer to query.
671    // Accessed by both consumer and producer on main and binder threads.
672    Mutex mFrameEventHistoryMutex;
673    ConsumerFrameEventHistory mFrameEventHistory;
674    FenceTimeline mAcquireTimeline;
675    FenceTimeline mReleaseTimeline;
676
677    // main thread
678    int mActiveBufferSlot;
679    sp<GraphicBuffer> mActiveBuffer;
680    sp<NativeHandle> mSidebandStream;
681    Rect mCurrentCrop;
682    uint32_t mCurrentTransform;
683    // We encode unset as -1.
684    int32_t mOverrideScalingMode;
685    bool mCurrentOpacity;
686    std::atomic<uint64_t> mCurrentFrameNumber;
687    bool mFrameLatencyNeeded;
688    // Whether filtering is forced on or not
689    bool mFiltering;
690    // Whether filtering is needed b/c of the drawingstate
691    bool mNeedsFiltering;
692
693    bool mPendingRemoval = false;
694
695    // page-flip thread (currently main thread)
696    bool mProtectedByApp; // application requires protected path to external sink
697
698    // protected by mLock
699    mutable Mutex mLock;
700
701    const wp<Client> mClientRef;
702
703    // This layer can be a cursor on some displays.
704    bool mPotentialCursor;
705
706    // Local copy of the queued contents of the incoming BufferQueue
707    mutable Mutex mQueueItemLock;
708    Condition mQueueItemCondition;
709    Vector<BufferItem> mQueueItems;
710    std::atomic<uint64_t> mLastFrameNumberReceived;
711    bool mAutoRefresh;
712    bool mFreezeGeometryUpdates;
713
714    // Child list about to be committed/used for editing.
715    LayerVector mCurrentChildren;
716    // Child list used for rendering.
717    LayerVector mDrawingChildren;
718
719    wp<Layer> mCurrentParent;
720    wp<Layer> mDrawingParent;
721
722    mutable LayerBE mBE;
723};
724
725// ---------------------------------------------------------------------------
726
727}; // namespace android
728
729#endif // ANDROID_LAYER_H
730