blob: 47924ae877b2a83bd97e158b27a9c37bd9637de4 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
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
Mathias Agopian076b1cc2009-04-10 14:24:30 -070023#include <EGL/egl.h>
24#include <EGL/eglext.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070025
Mathias Agopian13127d82013-03-05 17:47:11 -080026#include <utils/RefBase.h>
27#include <utils/String8.h>
28#include <utils/Timers.h>
29
Svetoslavd85084b2014-03-20 10:28:31 -070030#include <ui/FrameStats.h>
Mathias Agopian13127d82013-03-05 17:47:11 -080031#include <ui/GraphicBuffer.h>
32#include <ui/PixelFormat.h>
33#include <ui/Region.h>
34
35#include <gui/ISurfaceComposerClient.h>
Robert Carr4cdc58f2017-08-23 14:22:20 -070036#include <gui/LayerState.h>
Mathias Agopian13127d82013-03-05 17:47:11 -080037
Dan Stoza7dde5992015-05-22 09:51:44 -070038#include <list>
39
Jamie Gennis82dbc742012-11-08 19:23:28 -080040#include "FrameTracker.h"
Mathias Agopian13127d82013-03-05 17:47:11 -080041#include "Client.h"
Robert Carr1f0a16a2016-10-24 16:27:39 -070042#include "LayerVector.h"
Dan Stozab9b08832014-03-13 11:55:57 -070043#include "MonitoredProducer.h"
Mathias Agopian13127d82013-03-05 17:47:11 -080044#include "SurfaceFlinger.h"
45#include "SurfaceFlingerConsumer.h"
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080046#include "Transform.h"
47
Mathias Agopian13127d82013-03-05 17:47:11 -080048#include "DisplayHardware/HWComposer.h"
Chia-I Wuaaff73f2017-02-13 12:28:24 -080049#include "DisplayHardware/HWComposerBufferCache.h"
Mathias Agopian3f844832013-08-07 21:24:32 -070050#include "RenderEngine/Mesh.h"
Mathias Agopian49457ac2013-08-14 18:20:17 -070051#include "RenderEngine/Texture.h"
Mathias Agopian13127d82013-03-05 17:47:11 -080052
chaviw13fdc492017-06-27 12:40:18 -070053#include <math/vec4.h>
54
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080055namespace android {
56
57// ---------------------------------------------------------------------------
58
Mathias Agopian1f7bec62010-06-25 18:02:21 -070059class Client;
Mathias Agopian3e25fd82013-04-22 17:52:16 +020060class Colorizer;
Mathias Agopian13127d82013-03-05 17:47:11 -080061class DisplayDevice;
62class GraphicBuffer;
63class SurfaceFlinger;
Kalle Raitaa099a242017-01-11 11:17:29 -080064class LayerDebugInfo;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080065
66// ---------------------------------------------------------------------------
67
Andy McFadden882e3a32013-01-08 16:06:15 -080068/*
Andy McFadden882e3a32013-01-08 16:06:15 -080069 * A new BufferQueue and a new SurfaceFlingerConsumer are created when the
70 * Layer is first referenced.
71 *
72 * This also implements onFrameAvailable(), which notifies SurfaceFlinger
73 * that new data has arrived.
74 */
Jesse Hall399184a2014-03-03 15:42:54 -080075class Layer : public SurfaceFlingerConsumer::ContentsChangedListener {
Mathias Agopian13127d82013-03-05 17:47:11 -080076 static int32_t sSequence;
77
Mathias Agopiand606de62010-05-10 20:06:11 -070078public:
Mathias Agopian13127d82013-03-05 17:47:11 -080079 mutable bool contentDirty;
80 // regions below are in window-manager space
81 Region visibleRegion;
82 Region coveredRegion;
83 Region visibleNonTransparentRegion;
Dan Stozaee44edd2015-03-23 15:50:23 -070084 Region surfaceDamageRegion;
Andy McFadden4df87bd2014-04-21 18:08:54 -070085
86 // Layer serial number. This gives layers an explicit ordering, so we
87 // have a stable sort order when their layer stack and Z-order are
88 // the same.
Mathias Agopian13127d82013-03-05 17:47:11 -080089 int32_t sequence;
90
91 enum { // flags for doTransaction()
92 eDontUpdateGeometryState = 0x00000001,
93 eVisibleRegion = 0x00000002,
94 };
95
96 struct Geometry {
97 uint32_t w;
98 uint32_t h;
Robert Carr3dcabfa2016-03-01 18:36:58 -080099 Transform transform;
100
Mathias Agopian13127d82013-03-05 17:47:11 -0800101 inline bool operator ==(const Geometry& rhs) const {
Robert Carr99e27f02016-06-16 15:18:02 -0700102 return (w == rhs.w && h == rhs.h) &&
103 (transform.tx() == rhs.transform.tx()) &&
104 (transform.ty() == rhs.transform.ty());
Mathias Agopian13127d82013-03-05 17:47:11 -0800105 }
106 inline bool operator !=(const Geometry& rhs) const {
107 return !operator ==(rhs);
108 }
109 };
110
111 struct State {
112 Geometry active;
113 Geometry requested;
Robert Carrae060832016-11-28 10:51:00 -0800114 int32_t z;
Fabien Sanglardf0c53d62017-03-03 18:58:50 -0800115
116 // The identifier of the layer stack this layer belongs to. A layer can
117 // only be associated to a single layer stack. A layer stack is a
118 // z-ordered group of layers which can be associated to one or more
119 // displays. Using the same layer stack on different displays is a way
120 // to achieve mirroring.
Mathias Agopian13127d82013-03-05 17:47:11 -0800121 uint32_t layerStack;
Fabien Sanglardf0c53d62017-03-03 18:58:50 -0800122
Mathias Agopian13127d82013-03-05 17:47:11 -0800123 uint8_t flags;
Dan Stoza7dde5992015-05-22 09:51:44 -0700124 uint8_t mask;
Mathias Agopian13127d82013-03-05 17:47:11 -0800125 uint8_t reserved[2];
126 int32_t sequence; // changes when visible regions can change
Dan Stoza7dde5992015-05-22 09:51:44 -0700127 bool modified;
128
Fabien Sanglard4ed383c2016-12-13 14:02:41 -0800129 // Crop is expressed in layer space coordinate.
Robert Carrb5d3d262016-03-25 15:08:13 -0700130 Rect crop;
Robert Carr99e27f02016-06-16 15:18:02 -0700131 Rect requestedCrop;
132
Fabien Sanglard4ed383c2016-12-13 14:02:41 -0800133 // finalCrop is expressed in display space coordinate.
Robert Carrb5d3d262016-03-25 15:08:13 -0700134 Rect finalCrop;
Robert Carr8d5227b2017-03-16 15:41:03 -0700135 Rect requestedFinalCrop;
Robert Carrb5d3d262016-03-25 15:08:13 -0700136
Robert Carr0d480722017-01-10 16:42:54 -0800137 // If set, defers this state update until the identified Layer
Dan Stoza7dde5992015-05-22 09:51:44 -0700138 // receives a frame with the given frameNumber
Robert Carr0d480722017-01-10 16:42:54 -0800139 wp<Layer> barrierLayer;
Dan Stoza7dde5992015-05-22 09:51:44 -0700140 uint64_t frameNumber;
141
Mathias Agopian2ca79392013-04-02 18:30:32 -0700142 // the transparentRegion hint is a bit special, it's latched only
143 // when we receive a buffer -- this is because it's "content"
144 // dependent.
145 Region activeTransparentRegion;
146 Region requestedTransparentRegion;
Courtney Goeltzenleuchterbb09b432016-11-30 13:51:28 -0700147 android_dataspace dataSpace;
Daniel Nicoara2f5f8a52016-12-20 16:11:58 -0500148
149 uint32_t appId;
150 uint32_t type;
Robert Carrdb66e622017-04-10 16:55:57 -0700151
152 // If non-null, a Surface this Surface's Z-order is interpreted relative to.
153 wp<Layer> zOrderRelativeOf;
154
155 // A list of surfaces whose Z-order is interpreted relative to ours.
156 SortedVector<wp<Layer>> zOrderRelatives;
chaviw13fdc492017-06-27 12:40:18 -0700157
158 half4 color;
Mathias Agopian13127d82013-03-05 17:47:11 -0800159 };
160
Mathias Agopian13127d82013-03-05 17:47:11 -0800161 // -----------------------------------------------------------------------
162
Mathias Agopian4d9b8222013-03-12 17:11:48 -0700163 Layer(SurfaceFlinger* flinger, const sp<Client>& client,
164 const String8& name, uint32_t w, uint32_t h, uint32_t flags);
Mathias Agopian1eae0ee2013-06-05 16:59:15 -0700165
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700166 virtual ~Layer();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800167
Chia-I Wuab0c3192017-08-01 11:29:00 -0700168 void setPrimaryDisplayOnly() { mPrimaryDisplayOnly = true; }
169
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700170 // the this layer's size and format
Mathias Agopian4d9b8222013-03-12 17:11:48 -0700171 status_t setBuffers(uint32_t w, uint32_t h, PixelFormat format, uint32_t flags);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800172
Robert Carr7bf247e2017-05-18 14:02:49 -0700173 // ------------------------------------------------------------------------
174 // Geometry setting functions.
175 //
176 // The following group of functions are used to specify the layers
177 // bounds, and the mapping of the texture on to those bounds. According
178 // to various settings changes to them may apply immediately, or be delayed until
179 // a pending resize is completed by the producer submitting a buffer. For example
180 // if we were to change the buffer size, and update the matrix ahead of the
181 // new buffer arriving, then we would be stretching the buffer to a different
182 // aspect before and after the buffer arriving, which probably isn't what we wanted.
183 //
184 // The first set of geometry functions are controlled by the scaling mode, described
185 // in window.h. The scaling mode may be set by the client, as it submits buffers.
186 // This value may be overriden through SurfaceControl, with setOverrideScalingMode.
187 //
188 // Put simply, if our scaling mode is SCALING_MODE_FREEZE, then
189 // matrix updates will not be applied while a resize is pending
190 // and the size and transform will remain in their previous state
191 // until a new buffer is submitted. If the scaling mode is another value
192 // then the old-buffer will immediately be scaled to the pending size
193 // and the new matrix will be immediately applied following this scaling
194 // transformation.
Robert Carr8d5227b2017-03-16 15:41:03 -0700195
Robert Carr7bf247e2017-05-18 14:02:49 -0700196 // Set the default buffer size for the assosciated Producer, in pixels. This is
197 // also the rendered size of the layer prior to any transformations. Parent
198 // or local matrix transformations will not affect the size of the buffer,
199 // but may affect it's on-screen size or clipping.
200 bool setSize(uint32_t w, uint32_t h);
201 // Set a 2x2 transformation matrix on the layer. This transform
202 // will be applied after parent transforms, but before any final
203 // producer specified transform.
204 bool setMatrix(const layer_state_t::matrix22_t& matrix);
205
206 // This second set of geometry attributes are controlled by
207 // setGeometryAppliesWithResize, and their default mode is to be
208 // immediate. If setGeometryAppliesWithResize is specified
209 // while a resize is pending, then update of these attributes will
210 // be delayed until the resize completes.
211
212 // setPosition operates in parent buffer space (pre parent-transform) or display
213 // space for top-level layers.
Robert Carr82364e32016-05-15 11:27:47 -0700214 bool setPosition(float x, float y, bool immediate);
Robert Carr7bf247e2017-05-18 14:02:49 -0700215 // Buffer space
Robert Carr8d5227b2017-03-16 15:41:03 -0700216 bool setCrop(const Rect& crop, bool immediate);
Robert Carr7bf247e2017-05-18 14:02:49 -0700217 // Parent buffer space/display space
Robert Carr8d5227b2017-03-16 15:41:03 -0700218 bool setFinalCrop(const Rect& crop, bool immediate);
219
Robert Carr7bf247e2017-05-18 14:02:49 -0700220 // TODO(b/38182121): Could we eliminate the various latching modes by
221 // using the layer hierarchy?
222 // -----------------------------------------------------------------------
Robert Carrae060832016-11-28 10:51:00 -0800223 bool setLayer(int32_t z);
Robert Carrdb66e622017-04-10 16:55:57 -0700224 bool setRelativeLayer(const sp<IBinder>& relativeToHandle, int32_t relativeZ);
225
Dan Stoza9e56aa02015-11-02 13:00:03 -0800226 bool setAlpha(float alpha);
chaviw13fdc492017-06-27 12:40:18 -0700227 bool setColor(const half3& color);
Mathias Agopian13127d82013-03-05 17:47:11 -0800228 bool setTransparentRegionHint(const Region& transparent);
229 bool setFlags(uint8_t flags, uint8_t mask);
Mathias Agopian13127d82013-03-05 17:47:11 -0800230 bool setLayerStack(uint32_t layerStack);
Courtney Goeltzenleuchterbb09b432016-11-30 13:51:28 -0700231 bool setDataSpace(android_dataspace dataSpace);
Courtney Goeltzenleuchter532b2632017-05-05 16:34:38 -0600232 android_dataspace getDataSpace() const;
Robert Carr1f0a16a2016-10-24 16:27:39 -0700233 uint32_t getLayerStack() const;
Robert Carr0d480722017-01-10 16:42:54 -0800234 void deferTransactionUntil(const sp<IBinder>& barrierHandle, uint64_t frameNumber);
235 void deferTransactionUntil(const sp<Layer>& barrierLayer, uint64_t frameNumber);
Robert Carrc3574f72016-03-24 12:19:32 -0700236 bool setOverrideScalingMode(int32_t overrideScalingMode);
Daniel Nicoara2f5f8a52016-12-20 16:11:58 -0500237 void setInfo(uint32_t type, uint32_t appId);
Robert Carr1db73f62016-12-21 12:58:51 -0800238 bool reparentChildren(const sp<IBinder>& layer);
chaviwf1961f72017-09-18 16:41:07 -0700239 bool reparent(const sp<IBinder>& newParentHandle);
Robert Carr9524cb32017-02-13 11:32:32 -0800240 bool detachChildren();
Mathias Agopian13127d82013-03-05 17:47:11 -0800241
Dan Stozaee44edd2015-03-23 15:50:23 -0700242 // If we have received a new buffer this frame, we will pass its surface
243 // damage down to hardware composer. Otherwise, we must send a region with
244 // one empty rect.
245 void useSurfaceDamage();
246 void useEmptyDamage();
247
Mathias Agopian13127d82013-03-05 17:47:11 -0800248 uint32_t getTransactionFlags(uint32_t flags);
249 uint32_t setTransactionFlags(uint32_t flags);
250
Chia-I Wuab0c3192017-08-01 11:29:00 -0700251 bool belongsToDisplay(uint32_t layerStack, bool isPrimaryDisplay) const {
252 return getLayerStack() == layerStack && (!mPrimaryDisplayOnly || isPrimaryDisplay);
253 }
254
Dan Stozac7014012014-02-14 15:03:43 -0800255 void computeGeometry(const sp<const DisplayDevice>& hw, Mesh& mesh,
256 bool useIdentityTransform) const;
Michael Lentine6c925ed2014-09-26 17:55:01 -0700257 Rect computeBounds(const Region& activeTransparentRegion) const;
Mathias Agopian13127d82013-03-05 17:47:11 -0800258 Rect computeBounds() const;
259
Pablo Ceballos40845df2016-01-25 17:41:15 -0800260 int32_t getSequence() const { return sequence; }
261
Mathias Agopian13127d82013-03-05 17:47:11 -0800262 // -----------------------------------------------------------------------
Mathias Agopian1eae0ee2013-06-05 16:59:15 -0700263 // Virtuals
Mathias Agopian13127d82013-03-05 17:47:11 -0800264
Mathias Agopian13127d82013-03-05 17:47:11 -0800265 virtual const char* getTypeId() const { return "Layer"; }
266
Mathias Agopian13127d82013-03-05 17:47:11 -0800267 /*
268 * isOpaque - true if this surface is opaque
Andy McFadden4125a4f2014-01-29 17:17:11 -0800269 *
270 * This takes into account the buffer format (i.e. whether or not the
271 * pixel format includes an alpha channel) and the "opaque" flag set
272 * on the layer. It does not examine the current plane alpha value.
Mathias Agopian13127d82013-03-05 17:47:11 -0800273 */
Andy McFadden4125a4f2014-01-29 17:17:11 -0800274 virtual bool isOpaque(const Layer::State& s) const;
Mathias Agopian13127d82013-03-05 17:47:11 -0800275
276 /*
277 * isSecure - true if this surface is secure, that is if it prevents
278 * screenshots or VNC servers.
279 */
Dan Stoza23116082015-06-18 14:58:39 -0700280 virtual bool isSecure() const;
Mathias Agopian13127d82013-03-05 17:47:11 -0800281
282 /*
283 * isProtected - true if the layer may contain protected content in the
284 * GRALLOC_USAGE_PROTECTED sense.
285 */
Jamie Gennis7a4d0df2011-03-09 17:05:02 -0800286 virtual bool isProtected() const;
Mathias Agopian13127d82013-03-05 17:47:11 -0800287
288 /*
289 * isVisible - true if this layer is visible, false otherwise
290 */
Mathias Agopianda27af92012-09-13 18:17:13 -0700291 virtual bool isVisible() const;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800292
Mathias Agopian13127d82013-03-05 17:47:11 -0800293 /*
Robert Carr1f0a16a2016-10-24 16:27:39 -0700294 * isHiddenByPolicy - true if this layer has been forced invisible.
295 * just because this is false, doesn't mean isVisible() is true.
296 * For example if this layer has no active buffer, it may not be hidden by
297 * policy, but it still can not be visible.
298 */
299 virtual bool isHiddenByPolicy() const;
300
301 /*
Mathias Agopian13127d82013-03-05 17:47:11 -0800302 * isFixedSize - true if content has a fixed size
303 */
304 virtual bool isFixedSize() const;
Jamie Gennis582270d2011-08-17 18:19:00 -0700305
Mathias Agopian1eae0ee2013-06-05 16:59:15 -0700306protected:
307 /*
308 * onDraw - draws the surface.
309 */
Dan Stozac7014012014-02-14 15:03:43 -0800310 virtual void onDraw(const sp<const DisplayDevice>& hw, const Region& clip,
311 bool useIdentityTransform) const;
Mathias Agopian1eae0ee2013-06-05 16:59:15 -0700312
313public:
314 // -----------------------------------------------------------------------
315
Fabien Sanglard9d96de42016-10-11 00:15:18 +0000316#ifdef USE_HWC2
Robert Carrae060832016-11-28 10:51:00 -0800317 void setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800318 void forceClientComposition(int32_t hwcId);
319 void setPerFrameData(const sp<const DisplayDevice>& displayDevice);
320
321 // callIntoHwc exists so we can update our local state and call
322 // acceptDisplayChanges without unnecessarily updating the device's state
323 void setCompositionType(int32_t hwcId, HWC2::Composition type,
324 bool callIntoHwc = true);
325 HWC2::Composition getCompositionType(int32_t hwcId) const;
326
327 void setClearClientTarget(int32_t hwcId, bool clear);
328 bool getClearClientTarget(int32_t hwcId) const;
329
330 void updateCursorPosition(const sp<const DisplayDevice>& hw);
Fabien Sanglard9d96de42016-10-11 00:15:18 +0000331#else
332 void setGeometry(const sp<const DisplayDevice>& hw,
333 HWComposer::HWCLayerInterface& layer);
334 void setPerFrameData(const sp<const DisplayDevice>& hw,
335 HWComposer::HWCLayerInterface& layer);
336 void setAcquireFence(const sp<const DisplayDevice>& hw,
337 HWComposer::HWCLayerInterface& layer);
338
339 Rect getPosition(const sp<const DisplayDevice>& hw);
340#endif
Riley Andrews03414a12014-07-01 14:22:59 -0700341
Mathias Agopian1eae0ee2013-06-05 16:59:15 -0700342 /*
343 * called after page-flip
344 */
Fabien Sanglard9d96de42016-10-11 00:15:18 +0000345#ifdef USE_HWC2
Dan Stoza9e56aa02015-11-02 13:00:03 -0800346 void onLayerDisplayed(const sp<Fence>& releaseFence);
Fabien Sanglard9d96de42016-10-11 00:15:18 +0000347#else
348 void onLayerDisplayed(const sp<const DisplayDevice>& hw,
349 HWComposer::HWCLayerInterface* layer);
350#endif
Mathias Agopian1eae0ee2013-06-05 16:59:15 -0700351
Dan Stoza6b9454d2014-11-07 16:00:59 -0800352 bool shouldPresentNow(const DispSync& dispSync) const;
353
Mathias Agopian1eae0ee2013-06-05 16:59:15 -0700354 /*
355 * called before composition.
356 * returns true if the layer has pending updates.
357 */
Brian Andersond6927fb2016-07-23 23:37:30 -0700358 bool onPreComposition(nsecs_t refreshStartTime);
Mathias Agopian1eae0ee2013-06-05 16:59:15 -0700359
360 /*
Dan Stozae77c7662016-05-13 11:37:28 -0700361 * called after composition.
362 * returns true if the layer latched a new buffer this frame.
Mathias Agopian1eae0ee2013-06-05 16:59:15 -0700363 */
Brian Anderson0a61b0c2016-12-07 14:55:56 -0800364 bool onPostComposition(const std::shared_ptr<FenceTime>& glDoneFence,
Brian Anderson3d4039d2016-09-23 16:31:30 -0700365 const std::shared_ptr<FenceTime>& presentFence,
Brian Anderson0a61b0c2016-12-07 14:55:56 -0800366 const CompositorTiming& compositorTiming);
Mathias Agopian1eae0ee2013-06-05 16:59:15 -0700367
Fabien Sanglard9d96de42016-10-11 00:15:18 +0000368#ifdef USE_HWC2
Dan Stoza9e56aa02015-11-02 13:00:03 -0800369 // If a buffer was replaced this frame, release the former buffer
Brian Andersonf6386862016-10-31 16:34:13 -0700370 void releasePendingBuffer(nsecs_t dequeueReadyTime);
Fabien Sanglard9d96de42016-10-11 00:15:18 +0000371#endif
Dan Stoza9e56aa02015-11-02 13:00:03 -0800372
Mathias Agopian1eae0ee2013-06-05 16:59:15 -0700373 /*
374 * draw - performs some global clipping optimizations
375 * and calls onDraw().
376 */
377 void draw(const sp<const DisplayDevice>& hw, const Region& clip) const;
Dan Stozac7014012014-02-14 15:03:43 -0800378 void draw(const sp<const DisplayDevice>& hw, bool useIdentityTransform) const;
379 void draw(const sp<const DisplayDevice>& hw) const;
Mathias Agopian1eae0ee2013-06-05 16:59:15 -0700380
381 /*
382 * doTransaction - process the transaction. This is a good place to figure
383 * out which attributes of the surface have changed.
384 */
385 uint32_t doTransaction(uint32_t transactionFlags);
386
387 /*
388 * setVisibleRegion - called to set the new visible region. This gives
389 * a chance to update the new visible region or record the fact it changed.
390 */
391 void setVisibleRegion(const Region& visibleRegion);
392
393 /*
394 * setCoveredRegion - called when the covered region changes. The covered
395 * region corresponds to any area of the surface that is covered
396 * (transparently or not) by another surface.
397 */
398 void setCoveredRegion(const Region& coveredRegion);
399
400 /*
401 * setVisibleNonTransparentRegion - called when the visible and
402 * non-transparent region changes.
403 */
404 void setVisibleNonTransparentRegion(const Region&
405 visibleNonTransparentRegion);
406
407 /*
408 * latchBuffer - called each time the screen is redrawn and returns whether
409 * the visible regions need to be recomputed (this is a fairly heavy
410 * operation, so this should be set only if needed). Typically this is used
411 * to figure out if the content or size of a surface has changed.
412 */
Brian Andersond6927fb2016-07-23 23:37:30 -0700413 Region latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime);
Chia-I Wua36bf922017-06-30 12:51:05 -0700414 bool isBufferLatched() const { return mRefreshPending; }
Mathias Agopian1eae0ee2013-06-05 16:59:15 -0700415
Riley Andrews03414a12014-07-01 14:22:59 -0700416 bool isPotentialCursor() const { return mPotentialCursor;}
417
Mathias Agopian13127d82013-03-05 17:47:11 -0800418 /*
Chia-I Wuc6657022017-08-15 11:18:17 -0700419 * 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
Mathias Agopian13127d82013-03-05 17:47:11 -0800427 */
Mathias Agopian1eae0ee2013-06-05 16:59:15 -0700428 void onRemoved();
Mathias Agopian13127d82013-03-05 17:47:11 -0800429
430
Andy McFaddenbf974ab2012-12-04 16:51:15 -0800431 // Updates the transform hint in our SurfaceFlingerConsumer to match
Mathias Agopian84300952012-11-21 16:02:13 -0800432 // the current orientation of the display device.
Mathias Agopian1eae0ee2013-06-05 16:59:15 -0700433 void updateTransformHint(const sp<const DisplayDevice>& hw) const;
Andy McFadden69052052012-09-14 16:10:11 -0700434
Mathias Agopian13127d82013-03-05 17:47:11 -0800435 /*
436 * returns the rectangle that crops the content of the layer and scales it
437 * to the layer's size.
438 */
Mathias Agopian1eae0ee2013-06-05 16:59:15 -0700439 Rect getContentCrop() const;
Mathias Agopian13127d82013-03-05 17:47:11 -0800440
Eric Penner51c59cd2014-07-28 19:51:58 -0700441 /*
442 * Returns if a frame is queued.
443 */
Pablo Ceballos06312182015-10-07 16:32:12 -0700444 bool hasQueuedFrame() const { return mQueuedFrames > 0 ||
Pablo Ceballosff95aab2016-01-13 17:09:58 -0800445 mSidebandStreamChanged || mAutoRefresh; }
Eric Penner51c59cd2014-07-28 19:51:58 -0700446
Kalle Raitaa099a242017-01-11 11:17:29 -0800447 int32_t getQueuedFrameCount() const { return mQueuedFrames; }
448
Fabien Sanglard9d96de42016-10-11 00:15:18 +0000449#ifdef USE_HWC2
Dan Stoza9e56aa02015-11-02 13:00:03 -0800450 // -----------------------------------------------------------------------
451
Steven Thomasb02664d2017-07-26 18:48:28 -0700452 bool createHwcLayer(HWComposer* hwc, int32_t hwcId);
453 void destroyHwcLayer(int32_t hwcId);
454 void destroyAllHwcLayers();
455
Dan Stoza9e56aa02015-11-02 13:00:03 -0800456 bool hasHwcLayer(int32_t hwcId) {
Steven Thomasb02664d2017-07-26 18:48:28 -0700457 return mHwcLayers.count(hwcId) > 0;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800458 }
459
Steven Thomasb02664d2017-07-26 18:48:28 -0700460 HWC2::Layer* getHwcLayer(int32_t hwcId) {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800461 if (mHwcLayers.count(hwcId) == 0) {
462 return nullptr;
463 }
464 return mHwcLayers[hwcId].layer;
465 }
466
Fabien Sanglard9d96de42016-10-11 00:15:18 +0000467#endif
Mathias Agopian13127d82013-03-05 17:47:11 -0800468 // -----------------------------------------------------------------------
469
Fabien Sanglard17487192016-12-07 13:03:32 -0800470 void clearWithOpenGL(const sp<const DisplayDevice>& hw) const;
Mathias Agopian13127d82013-03-05 17:47:11 -0800471 void setFiltering(bool filtering);
472 bool getFiltering() const;
473
474 // only for debugging
475 inline const sp<GraphicBuffer>& getActiveBuffer() const { return mActiveBuffer; }
476
Mathias Agopian1eae0ee2013-06-05 16:59:15 -0700477 inline const State& getDrawingState() const { return mDrawingState; }
478 inline const State& getCurrentState() const { return mCurrentState; }
479 inline State& getCurrentState() { return mCurrentState; }
Mathias Agopian13127d82013-03-05 17:47:11 -0800480
Kalle Raitaa099a242017-01-11 11:17:29 -0800481 LayerDebugInfo getLayerDebugInfo() const;
Mathias Agopian13127d82013-03-05 17:47:11 -0800482
483 /* always call base class first */
Fabien Sanglard9d96de42016-10-11 00:15:18 +0000484#ifdef USE_HWC2
Dan Stozae22aec72016-08-01 13:20:59 -0700485 static void miniDumpHeader(String8& result);
486 void miniDump(String8& result, int32_t hwcId) const;
Fabien Sanglard9d96de42016-10-11 00:15:18 +0000487#endif
Svetoslavd85084b2014-03-20 10:28:31 -0700488 void dumpFrameStats(String8& result) const;
Brian Andersond6927fb2016-07-23 23:37:30 -0700489 void dumpFrameEvents(String8& result);
Svetoslavd85084b2014-03-20 10:28:31 -0700490 void clearFrameStats();
Jamie Gennis6547ff42013-07-16 20:12:42 -0700491 void logFrameStats();
Svetoslavd85084b2014-03-20 10:28:31 -0700492 void getFrameStats(FrameStats* outStats) const;
Mathias Agopian1b5e1022010-04-20 17:55:49 -0700493
Dan Stozae77c7662016-05-13 11:37:28 -0700494 std::vector<OccupancyTracker::Segment> getOccupancyHistory(bool forceFlush);
495
Brian Anderson5ea5e592016-12-01 16:54:33 -0800496 void onDisconnect();
Brian Anderson3890c392016-07-25 12:48:08 -0700497 void addAndGetFrameTimestamps(const NewFrameEventsEntry* newEntry,
498 FrameEventHistoryDelta* outDelta);
Pablo Ceballosce796e72016-02-04 19:10:51 -0800499
Robert Carr367c5682016-06-20 11:55:28 -0700500 bool getTransformToDisplayInverse() const;
501
Robert Carr1f0a16a2016-10-24 16:27:39 -0700502 Transform getTransform() const;
503
Robert Carr6452f122017-03-21 10:41:29 -0700504 // Returns the Alpha of the Surface, accounting for the Alpha
505 // of parent Surfaces in the hierarchy (alpha's will be multiplied
506 // down the hierarchy).
chaviw13fdc492017-06-27 12:40:18 -0700507 half getAlpha() const;
508 half4 getColor() const;
Robert Carr6452f122017-03-21 10:41:29 -0700509
Dan Stoza412903f2017-04-27 13:42:17 -0700510 void traverseInReverseZOrder(LayerVector::StateSet stateSet,
511 const LayerVector::Visitor& visitor);
512 void traverseInZOrder(LayerVector::StateSet stateSet, const LayerVector::Visitor& visitor);
Robert Carr1f0a16a2016-10-24 16:27:39 -0700513
Chia-I Wu98f1c102017-05-30 14:54:08 -0700514 size_t getChildrenCount() const;
Robert Carr1f0a16a2016-10-24 16:27:39 -0700515 void addChild(const sp<Layer>& layer);
516 // Returns index if removed, or negative value otherwise
517 // for symmetry with Vector::remove
518 ssize_t removeChild(const sp<Layer>& layer);
Chia-I Wue41dbe62017-06-13 14:10:56 -0700519 sp<Layer> getParent() const { return mCurrentParent.promote(); }
Robert Carr1f0a16a2016-10-24 16:27:39 -0700520 bool hasParent() const { return getParent() != nullptr; }
521
522 Rect computeScreenBounds(bool reduceTransparentRegion = true) const;
523 bool setChildLayer(const sp<Layer>& childLayer, int32_t z);
524
525 // Copy the current list of children to the drawing state. Called by
526 // SurfaceFlinger to complete a transaction.
527 void commitChildList();
528
529 int32_t getZ() const;
Mathias Agopian13127d82013-03-05 17:47:11 -0800530protected:
531 // constant
532 sp<SurfaceFlinger> mFlinger;
Mathias Agopian13127d82013-03-05 17:47:11 -0800533 /*
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 protected:
Irvel468051e2016-06-13 16:44:44 -0700541 ~LayerCleaner() {
542 // destroy client resources
543 mFlinger->onLayerDestroyed(mLayer);
544 }
Mathias Agopian13127d82013-03-05 17:47:11 -0800545 public:
Irvel468051e2016-06-13 16:44:44 -0700546 LayerCleaner(const sp<SurfaceFlinger>& flinger,
547 const sp<Layer>& layer)
548 : mFlinger(flinger), mLayer(layer) {
549 }
Mathias Agopian13127d82013-03-05 17:47:11 -0800550 };
551
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800552
Irvel468051e2016-06-13 16:44:44 -0700553 virtual void onFirstRef();
554
555
556
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800557private:
Irvel468051e2016-06-13 16:44:44 -0700558 friend class SurfaceInterceptor;
Jesse Hall399184a2014-03-03 15:42:54 -0800559 // Interface implementation for SurfaceFlingerConsumer::ContentsChangedListener
Dan Stozadc13c5b2015-05-11 15:33:01 -0700560 virtual void onFrameAvailable(const BufferItem& item) override;
561 virtual void onFrameReplaced(const BufferItem& item) override;
562 virtual void onSidebandStreamChanged() override;
Mathias Agopian13127d82013-03-05 17:47:11 -0800563
Pablo Ceballos05289c22016-04-14 15:49:55 -0700564 void commitTransaction(const State& stateToCommit);
Mathias Agopian1eae0ee2013-06-05 16:59:15 -0700565
566 // needsLinearFiltering - true if this surface's state requires filtering
567 bool needsFiltering(const sp<const DisplayDevice>& hw) const;
Mathias Agopian13127d82013-03-05 17:47:11 -0800568
Mathias Agopian3330b202009-10-05 17:07:12 -0700569 uint32_t getEffectiveUsage(uint32_t usage) const;
Robert Carr1f0a16a2016-10-24 16:27:39 -0700570
Dan Stoza5a423ea2017-02-16 14:10:39 -0800571 FloatRect computeCrop(const sp<const DisplayDevice>& hw) const;
Robert Carr1f0a16a2016-10-24 16:27:39 -0700572 // Compute the initial crop as specified by parent layers and the SurfaceControl
573 // for this layer. Does not include buffer crop from the IGraphicBufferProducer
574 // client, as that should not affect child clipping. Returns in screen space.
575 Rect computeInitialCrop(const sp<const DisplayDevice>& hw) const;
Mathias Agopiana67932f2011-04-20 14:20:59 -0700576 bool isCropped() const;
577 static bool getOpacityForFormat(uint32_t format);
Mathias Agopian0aa758d2009-04-22 15:23:34 -0700578
Mathias Agopian13127d82013-03-05 17:47:11 -0800579 // drawing
Fabien Sanglard17487192016-12-07 13:03:32 -0800580 void clearWithOpenGL(const sp<const DisplayDevice>& hw,
Mathias Agopian3f844832013-08-07 21:24:32 -0700581 float r, float g, float b, float alpha) const;
Fabien Sanglard85789802016-12-07 13:08:24 -0800582 void drawWithOpenGL(const sp<const DisplayDevice>& hw,
Dan Stozac7014012014-02-14 15:03:43 -0800583 bool useIdentityTransform) const;
Mathias Agopian13127d82013-03-05 17:47:11 -0800584
Ruben Brunk1681d952014-06-27 15:51:55 -0700585 // Temporary - Used only for LEGACY camera mode.
586 uint32_t getProducerStickyTransform() const;
587
Dan Stozac5da2712016-07-20 15:38:12 -0700588 // Loads the corresponding system property once per process
589 static bool latchUnsignaledBuffers();
590
Robert Carr1f0a16a2016-10-24 16:27:39 -0700591 void setParent(const sp<Layer>& layer);
592
Dan Stoza412903f2017-04-27 13:42:17 -0700593 LayerVector makeTraversalList(LayerVector::StateSet stateSet);
Robert Carrdb66e622017-04-10 16:55:57 -0700594 void addZOrderRelative(const wp<Layer>& relative);
595 void removeZOrderRelative(const wp<Layer>& relative);
596
Dan Stoza7dde5992015-05-22 09:51:44 -0700597 // -----------------------------------------------------------------------
598
599 class SyncPoint
600 {
601 public:
Chih-Hung Hsieh342b7602016-09-01 11:34:16 -0700602 explicit SyncPoint(uint64_t frameNumber) : mFrameNumber(frameNumber),
Dan Stoza7dde5992015-05-22 09:51:44 -0700603 mFrameIsAvailable(false), mTransactionIsApplied(false) {}
604
605 uint64_t getFrameNumber() const {
606 return mFrameNumber;
607 }
608
609 bool frameIsAvailable() const {
610 return mFrameIsAvailable;
611 }
612
613 void setFrameAvailable() {
614 mFrameIsAvailable = true;
615 }
616
617 bool transactionIsApplied() const {
618 return mTransactionIsApplied;
619 }
620
621 void setTransactionApplied() {
622 mTransactionIsApplied = true;
623 }
624
625 private:
626 const uint64_t mFrameNumber;
627 std::atomic<bool> mFrameIsAvailable;
628 std::atomic<bool> mTransactionIsApplied;
629 };
630
Dan Stozacac35382016-01-27 12:21:06 -0800631 // SyncPoints which will be signaled when the correct frame is at the head
632 // of the queue and dropped after the frame has been latched. Protected by
633 // mLocalSyncPointMutex.
634 Mutex mLocalSyncPointMutex;
Dan Stoza7dde5992015-05-22 09:51:44 -0700635 std::list<std::shared_ptr<SyncPoint>> mLocalSyncPoints;
636
Dan Stozacac35382016-01-27 12:21:06 -0800637 // SyncPoints which will be signaled and then dropped when the transaction
638 // is applied
Dan Stoza7dde5992015-05-22 09:51:44 -0700639 std::list<std::shared_ptr<SyncPoint>> mRemoteSyncPoints;
640
Dan Stozacac35382016-01-27 12:21:06 -0800641 uint64_t getHeadFrameNumber() const;
Dan Stoza1ce65812016-06-15 16:26:27 -0700642 bool headFenceHasSignaled() const;
Dan Stozacac35382016-01-27 12:21:06 -0800643
644 // Returns false if the relevant frame has already been latched
645 bool addSyncPoint(const std::shared_ptr<SyncPoint>& point);
Dan Stoza7dde5992015-05-22 09:51:44 -0700646
647 void pushPendingState();
Pablo Ceballos05289c22016-04-14 15:49:55 -0700648 void popPendingState(State* stateToCommit);
649 bool applyPendingStates(State* stateToCommit);
Robert Carrc3574f72016-03-24 12:19:32 -0700650
Robert Carr1f0a16a2016-10-24 16:27:39 -0700651 void clearSyncPoints();
652
Robert Carrc3574f72016-03-24 12:19:32 -0700653 // Returns mCurrentScaling mode (originating from the
654 // Client) or mOverrideScalingMode mode (originating from
655 // the Surface Controller) if set.
656 uint32_t getEffectiveScalingMode() const;
Dan Stoza7dde5992015-05-22 09:51:44 -0700657public:
Irvel468051e2016-06-13 16:44:44 -0700658 /*
659 * The layer handle is just a BBinder object passed to the client
660 * (remote process) -- we don't keep any reference on our side such that
661 * the dtor is called when the remote side let go of its reference.
662 *
663 * LayerCleaner ensures that mFlinger->onLayerDestroyed() is called for
664 * this layer when the handle is destroyed.
665 */
666 class Handle : public BBinder, public LayerCleaner {
667 public:
668 Handle(const sp<SurfaceFlinger>& flinger, const sp<Layer>& layer)
669 : LayerCleaner(flinger, layer), owner(layer) {}
670
671 wp<Layer> owner;
672 };
673
674 sp<IBinder> getHandle();
675 sp<IGraphicBufferProducer> getProducer() const;
676 const String8& getName() const;
Dan Stoza7dde5992015-05-22 09:51:44 -0700677 void notifyAvailableFrames();
Kalle Raitaa099a242017-01-11 11:17:29 -0800678 PixelFormat getPixelFormat() const { return mFormat; }
chaviw13fdc492017-06-27 12:40:18 -0700679 bool getPremultipledAlpha() const;
Dan Stoza7dde5992015-05-22 09:51:44 -0700680private:
Igor Murashkina4a31492012-10-29 13:36:11 -0700681
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700682 // -----------------------------------------------------------------------
683
Fabien Sanglardcd6fd542016-10-13 12:47:39 -0700684 // Check all of the local sync points to ensure that all transactions
685 // which need to have been applied prior to the frame which is about to
686 // be latched have signaled
687 bool allTransactionsSignaled();
688
Mathias Agopiana67932f2011-04-20 14:20:59 -0700689 // constants
Andy McFaddenbf974ab2012-12-04 16:51:15 -0800690 sp<SurfaceFlingerConsumer> mSurfaceFlingerConsumer;
Dan Stozab9b08832014-03-13 11:55:57 -0700691 sp<IGraphicBufferProducer> mProducer;
Andy McFadden4df87bd2014-04-21 18:08:54 -0700692 uint32_t mTextureName; // from GLES
Mathias Agopian13127d82013-03-05 17:47:11 -0800693 bool mPremultipliedAlpha;
694 String8 mName;
Dan Stozaf7ba41a2017-05-10 15:11:11 -0700695 String8 mTransactionName; // A cached version of "TX - " + mName for systraces
Mathias Agopian13127d82013-03-05 17:47:11 -0800696 PixelFormat mFormat;
Mathias Agopian13127d82013-03-05 17:47:11 -0800697
Chia-I Wuab0c3192017-08-01 11:29:00 -0700698 bool mPrimaryDisplayOnly = false;
699
Mathias Agopian13127d82013-03-05 17:47:11 -0800700 // these are protected by an external lock
701 State mCurrentState;
702 State mDrawingState;
703 volatile int32_t mTransactionFlags;
Mathias Agopiand606de62010-05-10 20:06:11 -0700704
Dan Stoza7dde5992015-05-22 09:51:44 -0700705 // Accessed from main thread and binder threads
706 Mutex mPendingStateMutex;
707 Vector<State> mPendingStates;
708
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700709 // thread-safe
Mathias Agopiana67932f2011-04-20 14:20:59 -0700710 volatile int32_t mQueuedFrames;
Jesse Hall399184a2014-03-03 15:42:54 -0800711 volatile int32_t mSidebandStreamChanged; // used like an atomic boolean
Brian Andersond6927fb2016-07-23 23:37:30 -0700712
713 // Timestamp history for UIAutomation. Thread safe.
Jamie Gennis4b0eba92013-02-05 13:30:24 -0800714 FrameTracker mFrameTracker;
Mathias Agopiana67932f2011-04-20 14:20:59 -0700715
Brian Andersond6927fb2016-07-23 23:37:30 -0700716 // Timestamp history for the consumer to query.
717 // Accessed by both consumer and producer on main and binder threads.
718 Mutex mFrameEventHistoryMutex;
Brian Anderson3890c392016-07-25 12:48:08 -0700719 ConsumerFrameEventHistory mFrameEventHistory;
Brian Anderson3d4039d2016-09-23 16:31:30 -0700720 FenceTimeline mAcquireTimeline;
721 FenceTimeline mReleaseTimeline;
Brian Andersond6927fb2016-07-23 23:37:30 -0700722
Mathias Agopiana67932f2011-04-20 14:20:59 -0700723 // main thread
Mathias Agopiana9347642017-02-13 16:42:28 -0800724 int mActiveBufferSlot;
Mathias Agopiana67932f2011-04-20 14:20:59 -0700725 sp<GraphicBuffer> mActiveBuffer;
Jesse Hall399184a2014-03-03 15:42:54 -0800726 sp<NativeHandle> mSidebandStream;
Mathias Agopiana67932f2011-04-20 14:20:59 -0700727 Rect mCurrentCrop;
728 uint32_t mCurrentTransform;
Mathias Agopian933389f2011-07-18 16:15:08 -0700729 uint32_t mCurrentScalingMode;
Robert Carrc3574f72016-03-24 12:19:32 -0700730 // We encode unset as -1.
731 int32_t mOverrideScalingMode;
Mathias Agopiana67932f2011-04-20 14:20:59 -0700732 bool mCurrentOpacity;
Brian Andersond6927fb2016-07-23 23:37:30 -0700733 bool mBufferLatched = false; // TODO: Use mActiveBuffer?
Dan Stozacac35382016-01-27 12:21:06 -0800734 std::atomic<uint64_t> mCurrentFrameNumber;
Brian Andersond6927fb2016-07-23 23:37:30 -0700735 uint64_t mPreviousFrameNumber; // Only accessed on the main thread.
Mathias Agopian4d143ee2012-02-23 20:05:39 -0800736 bool mRefreshPending;
Jamie Gennise8696a42012-01-15 18:54:57 -0800737 bool mFrameLatencyNeeded;
Mathias Agopian13127d82013-03-05 17:47:11 -0800738 // Whether filtering is forced on or not
739 bool mFiltering;
740 // Whether filtering is needed b/c of the drawingstate
741 bool mNeedsFiltering;
Mathias Agopian5cdc8992013-08-13 20:51:23 -0700742 // The mesh used to draw the layer in GLES composition mode
743 mutable Mesh mMesh;
Andy McFadden4df87bd2014-04-21 18:08:54 -0700744 // The texture used to draw the layer in GLES composition mode
Mathias Agopian49457ac2013-08-14 18:20:17 -0700745 mutable Texture mTexture;
Mathias Agopiand606de62010-05-10 20:06:11 -0700746
Fabien Sanglard9d96de42016-10-11 00:15:18 +0000747#ifdef USE_HWC2
Dan Stoza9e56aa02015-11-02 13:00:03 -0800748 // HWC items, accessed from the main thread
749 struct HWCInfo {
750 HWCInfo()
Steven Thomasb02664d2017-07-26 18:48:28 -0700751 : hwc(nullptr),
752 layer(nullptr),
Dan Stoza9e56aa02015-11-02 13:00:03 -0800753 forceClientComposition(false),
754 compositionType(HWC2::Composition::Invalid),
755 clearClientTarget(false) {}
756
Steven Thomasb02664d2017-07-26 18:48:28 -0700757 HWComposer* hwc;
758 HWC2::Layer* layer;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800759 bool forceClientComposition;
760 HWC2::Composition compositionType;
761 bool clearClientTarget;
Dan Stozae22aec72016-08-01 13:20:59 -0700762 Rect displayFrame;
Dan Stoza5a423ea2017-02-16 14:10:39 -0800763 FloatRect sourceCrop;
Chia-I Wuaaff73f2017-02-13 12:28:24 -0800764 HWComposerBufferCache bufferCache;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800765 };
Fabien Sanglardf0c53d62017-03-03 18:58:50 -0800766
767 // A layer can be attached to multiple displays when operating in mirror mode
768 // (a.k.a: when several displays are attached with equal layerStack). In this
Fabien Sanglard4afbf412017-03-08 14:50:11 -0800769 // case we need to keep track. In non-mirror mode, a layer will have only one
Fabien Sanglardf0c53d62017-03-03 18:58:50 -0800770 // HWCInfo. This map key is a display layerStack.
Dan Stoza9e56aa02015-11-02 13:00:03 -0800771 std::unordered_map<int32_t, HWCInfo> mHwcLayers;
Fabien Sanglard9d96de42016-10-11 00:15:18 +0000772#else
773 bool mIsGlesComposition;
774#endif
Dan Stoza9e56aa02015-11-02 13:00:03 -0800775
Mathias Agopianb7e930d2010-06-01 15:12:58 -0700776 // page-flip thread (currently main thread)
Glenn Kasten16f04532011-01-19 15:27:27 -0800777 bool mProtectedByApp; // application requires protected path to external sink
Mathias Agopian13127d82013-03-05 17:47:11 -0800778
779 // protected by mLock
780 mutable Mutex mLock;
Mathias Agopian4d9b8222013-03-12 17:11:48 -0700781 // Set to true once we've returned this surface's handle
Mathias Agopian13127d82013-03-05 17:47:11 -0800782 mutable bool mHasSurface;
783 const wp<Client> mClientRef;
Riley Andrews03414a12014-07-01 14:22:59 -0700784
785 // This layer can be a cursor on some displays.
786 bool mPotentialCursor;
Dan Stoza6b9454d2014-11-07 16:00:59 -0800787
788 // Local copy of the queued contents of the incoming BufferQueue
789 mutable Mutex mQueueItemLock;
Dan Stozaa4650a52015-05-12 12:56:16 -0700790 Condition mQueueItemCondition;
Dan Stoza6b9454d2014-11-07 16:00:59 -0800791 Vector<BufferItem> mQueueItems;
Dan Stozacac35382016-01-27 12:21:06 -0800792 std::atomic<uint64_t> mLastFrameNumberReceived;
Brian Andersond6927fb2016-07-23 23:37:30 -0700793 bool mUpdateTexImageFailed; // This is only accessed on the main thread.
Pablo Ceballos06312182015-10-07 16:32:12 -0700794
Pablo Ceballosff95aab2016-01-13 17:09:58 -0800795 bool mAutoRefresh;
Robert Carr7bf247e2017-05-18 14:02:49 -0700796 bool mFreezeGeometryUpdates;
Robert Carr1f0a16a2016-10-24 16:27:39 -0700797
798 // Child list about to be committed/used for editing.
799 LayerVector mCurrentChildren;
800 // Child list used for rendering.
801 LayerVector mDrawingChildren;
802
Chia-I Wue41dbe62017-06-13 14:10:56 -0700803 wp<Layer> mCurrentParent;
804 wp<Layer> mDrawingParent;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800805};
806
807// ---------------------------------------------------------------------------
808
809}; // namespace android
810
811#endif // ANDROID_LAYER_H