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