| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 |  | 
| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 23 | #include <EGL/egl.h> | 
 | 24 | #include <EGL/eglext.h> | 
| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 25 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 26 | #include <utils/RefBase.h> | 
 | 27 | #include <utils/String8.h> | 
 | 28 | #include <utils/Timers.h> | 
 | 29 |  | 
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 30 | #include <ui/FrameStats.h> | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 31 | #include <ui/GraphicBuffer.h> | 
 | 32 | #include <ui/PixelFormat.h> | 
 | 33 | #include <ui/Region.h> | 
 | 34 |  | 
 | 35 | #include <gui/ISurfaceComposerClient.h> | 
| Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 36 | #include <gui/LayerState.h> | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 37 |  | 
| Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 38 | #include <list> | 
 | 39 |  | 
| Jamie Gennis | 82dbc74 | 2012-11-08 19:23:28 -0800 | [diff] [blame] | 40 | #include "FrameTracker.h" | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 41 | #include "Client.h" | 
| Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 42 | #include "LayerVector.h" | 
| Dan Stoza | b9b0883 | 2014-03-13 11:55:57 -0700 | [diff] [blame] | 43 | #include "MonitoredProducer.h" | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 44 | #include "SurfaceFlinger.h" | 
 | 45 | #include "SurfaceFlingerConsumer.h" | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | #include "Transform.h" | 
 | 47 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 48 | #include "DisplayHardware/HWComposer.h" | 
| Chia-I Wu | aaff73f | 2017-02-13 12:28:24 -0800 | [diff] [blame] | 49 | #include "DisplayHardware/HWComposerBufferCache.h" | 
| Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 50 | #include "RenderEngine/Mesh.h" | 
| Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 51 | #include "RenderEngine/Texture.h" | 
| chaviw | 1d04428 | 2017-09-27 12:19:28 -0700 | [diff] [blame] | 52 | #include <layerproto/LayerProtoHeader.h> | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 53 | #include "RenderArea.h" | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 54 |  | 
| chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 55 | #include <math/vec4.h> | 
 | 56 |  | 
| chaviw | 1d04428 | 2017-09-27 12:19:28 -0700 | [diff] [blame] | 57 | using namespace android::surfaceflinger; | 
 | 58 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | namespace android { | 
 | 60 |  | 
 | 61 | // --------------------------------------------------------------------------- | 
 | 62 |  | 
| Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 63 | class Client; | 
| Mathias Agopian | 3e25fd8 | 2013-04-22 17:52:16 +0200 | [diff] [blame] | 64 | class Colorizer; | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 65 | class DisplayDevice; | 
 | 66 | class GraphicBuffer; | 
 | 67 | class SurfaceFlinger; | 
| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 68 | class LayerDebugInfo; | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 69 |  | 
 | 70 | // --------------------------------------------------------------------------- | 
 | 71 |  | 
| Andy McFadden | 882e3a3 | 2013-01-08 16:06:15 -0800 | [diff] [blame] | 72 | /* | 
| Andy McFadden | 882e3a3 | 2013-01-08 16:06:15 -0800 | [diff] [blame] | 73 |  * A new BufferQueue and a new SurfaceFlingerConsumer are created when the | 
 | 74 |  * Layer is first referenced. | 
 | 75 |  * | 
 | 76 |  * This also implements onFrameAvailable(), which notifies SurfaceFlinger | 
 | 77 |  * that new data has arrived. | 
 | 78 |  */ | 
| Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 79 | class Layer : public SurfaceFlingerConsumer::ContentsChangedListener { | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 80 |     static int32_t sSequence; | 
 | 81 |  | 
| Mathias Agopian | d606de6 | 2010-05-10 20:06:11 -0700 | [diff] [blame] | 82 | public: | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 83 |     mutable bool contentDirty; | 
 | 84 |     // regions below are in window-manager space | 
 | 85 |     Region visibleRegion; | 
 | 86 |     Region coveredRegion; | 
 | 87 |     Region visibleNonTransparentRegion; | 
| Dan Stoza | ee44edd | 2015-03-23 15:50:23 -0700 | [diff] [blame] | 88 |     Region surfaceDamageRegion; | 
| Andy McFadden | 4df87bd | 2014-04-21 18:08:54 -0700 | [diff] [blame] | 89 |  | 
 | 90 |     // Layer serial number.  This gives layers an explicit ordering, so we | 
 | 91 |     // have a stable sort order when their layer stack and Z-order are | 
 | 92 |     // the same. | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 93 |     int32_t sequence; | 
 | 94 |  | 
 | 95 |     enum { // flags for doTransaction() | 
 | 96 |         eDontUpdateGeometryState = 0x00000001, | 
 | 97 |         eVisibleRegion = 0x00000002, | 
 | 98 |     }; | 
 | 99 |  | 
 | 100 |     struct Geometry { | 
 | 101 |         uint32_t w; | 
 | 102 |         uint32_t h; | 
| Robert Carr | 3dcabfa | 2016-03-01 18:36:58 -0800 | [diff] [blame] | 103 |         Transform transform; | 
 | 104 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 105 |         inline bool operator ==(const Geometry& rhs) const { | 
| Robert Carr | 99e27f0 | 2016-06-16 15:18:02 -0700 | [diff] [blame] | 106 |             return (w == rhs.w && h == rhs.h) && | 
 | 107 |                     (transform.tx() == rhs.transform.tx()) && | 
 | 108 |                     (transform.ty() == rhs.transform.ty()); | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 109 |         } | 
 | 110 |         inline bool operator !=(const Geometry& rhs) const { | 
 | 111 |             return !operator ==(rhs); | 
 | 112 |         } | 
 | 113 |     }; | 
 | 114 |  | 
 | 115 |     struct State { | 
 | 116 |         Geometry active; | 
 | 117 |         Geometry requested; | 
| Robert Carr | ae06083 | 2016-11-28 10:51:00 -0800 | [diff] [blame] | 118 |         int32_t z; | 
| Fabien Sanglard | f0c53d6 | 2017-03-03 18:58:50 -0800 | [diff] [blame] | 119 |  | 
 | 120 |         // The identifier of the layer stack this layer belongs to. A layer can | 
 | 121 |         // only be associated to a single layer stack. A layer stack is a | 
 | 122 |         // z-ordered group of layers which can be associated to one or more | 
 | 123 |         // displays. Using the same layer stack on different displays is a way | 
 | 124 |         // to achieve mirroring. | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 125 |         uint32_t layerStack; | 
| Fabien Sanglard | f0c53d6 | 2017-03-03 18:58:50 -0800 | [diff] [blame] | 126 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 127 |         uint8_t flags; | 
| Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 128 |         uint8_t mask; | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 129 |         uint8_t reserved[2]; | 
 | 130 |         int32_t sequence; // changes when visible regions can change | 
| Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 131 |         bool modified; | 
 | 132 |  | 
| Fabien Sanglard | 4ed383c | 2016-12-13 14:02:41 -0800 | [diff] [blame] | 133 |         // Crop is expressed in layer space coordinate. | 
| Robert Carr | b5d3d26 | 2016-03-25 15:08:13 -0700 | [diff] [blame] | 134 |         Rect crop; | 
| Robert Carr | 99e27f0 | 2016-06-16 15:18:02 -0700 | [diff] [blame] | 135 |         Rect requestedCrop; | 
 | 136 |  | 
| Fabien Sanglard | 4ed383c | 2016-12-13 14:02:41 -0800 | [diff] [blame] | 137 |         // finalCrop is expressed in display space coordinate. | 
| Robert Carr | b5d3d26 | 2016-03-25 15:08:13 -0700 | [diff] [blame] | 138 |         Rect finalCrop; | 
| Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 139 |         Rect requestedFinalCrop; | 
| Robert Carr | b5d3d26 | 2016-03-25 15:08:13 -0700 | [diff] [blame] | 140 |  | 
| Robert Carr | 0d48072 | 2017-01-10 16:42:54 -0800 | [diff] [blame] | 141 |         // If set, defers this state update until the identified Layer | 
| Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 142 |         // receives a frame with the given frameNumber | 
| Robert Carr | 0d48072 | 2017-01-10 16:42:54 -0800 | [diff] [blame] | 143 |         wp<Layer> barrierLayer; | 
| Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 144 |         uint64_t frameNumber; | 
 | 145 |  | 
| Mathias Agopian | 2ca7939 | 2013-04-02 18:30:32 -0700 | [diff] [blame] | 146 |         // the transparentRegion hint is a bit special, it's latched only | 
 | 147 |         // when we receive a buffer -- this is because it's "content" | 
 | 148 |         // dependent. | 
 | 149 |         Region activeTransparentRegion; | 
 | 150 |         Region requestedTransparentRegion; | 
| Courtney Goeltzenleuchter | bb09b43 | 2016-11-30 13:51:28 -0700 | [diff] [blame] | 151 |         android_dataspace dataSpace; | 
| Daniel Nicoara | 2f5f8a5 | 2016-12-20 16:11:58 -0500 | [diff] [blame] | 152 |  | 
 | 153 |         uint32_t appId; | 
 | 154 |         uint32_t type; | 
| Robert Carr | db66e62 | 2017-04-10 16:55:57 -0700 | [diff] [blame] | 155 |  | 
 | 156 |         // If non-null, a Surface this Surface's Z-order is interpreted relative to. | 
 | 157 |         wp<Layer> zOrderRelativeOf; | 
 | 158 |  | 
 | 159 |         // A list of surfaces whose Z-order is interpreted relative to ours. | 
 | 160 |         SortedVector<wp<Layer>> zOrderRelatives; | 
| chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 161 |  | 
 | 162 |         half4 color; | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 163 |     }; | 
 | 164 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 165 |     // ----------------------------------------------------------------------- | 
 | 166 |  | 
| Mathias Agopian | 4d9b822 | 2013-03-12 17:11:48 -0700 | [diff] [blame] | 167 |     Layer(SurfaceFlinger* flinger, const sp<Client>& client, | 
 | 168 |             const String8& name, uint32_t w, uint32_t h, uint32_t flags); | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 169 |  | 
| Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 170 |     virtual ~Layer(); | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 171 |  | 
| Chia-I Wu | ab0c319 | 2017-08-01 11:29:00 -0700 | [diff] [blame] | 172 |     void setPrimaryDisplayOnly() { mPrimaryDisplayOnly = true; } | 
 | 173 |  | 
| Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 174 |     // the this layer's size and format | 
| Mathias Agopian | 4d9b822 | 2013-03-12 17:11:48 -0700 | [diff] [blame] | 175 |     status_t setBuffers(uint32_t w, uint32_t h, PixelFormat format, uint32_t flags); | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 176 |  | 
| Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 177 |     // ------------------------------------------------------------------------ | 
 | 178 |     // Geometry setting functions. | 
 | 179 |     // | 
 | 180 |     // The following group of functions are used to specify the layers | 
 | 181 |     // bounds, and the mapping of the texture on to those bounds. According | 
 | 182 |     // to various settings changes to them may apply immediately, or be delayed until | 
 | 183 |     // a pending resize is completed by the producer submitting a buffer. For example | 
 | 184 |     // if we were to change the buffer size, and update the matrix ahead of the | 
 | 185 |     // new buffer arriving, then we would be stretching the buffer to a different | 
 | 186 |     // aspect before and after the buffer arriving, which probably isn't what we wanted. | 
 | 187 |     // | 
 | 188 |     // The first set of geometry functions are controlled by the scaling mode, described | 
 | 189 |     // in window.h. The scaling mode may be set by the client, as it submits buffers. | 
 | 190 |     // This value may be overriden through SurfaceControl, with setOverrideScalingMode. | 
 | 191 |     // | 
 | 192 |     // Put simply, if our scaling mode is SCALING_MODE_FREEZE, then | 
 | 193 |     // matrix updates will not be applied while a resize is pending | 
 | 194 |     // and the size and transform will remain in their previous state | 
 | 195 |     // until a new buffer is submitted. If the scaling mode is another value | 
 | 196 |     // then the old-buffer will immediately be scaled to the pending size | 
 | 197 |     // and the new matrix will be immediately applied following this scaling | 
 | 198 |     // transformation. | 
| Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 199 |  | 
| Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 200 |     // Set the default buffer size for the assosciated Producer, in pixels. This is | 
 | 201 |     // also the rendered size of the layer prior to any transformations. Parent | 
 | 202 |     // or local matrix transformations will not affect the size of the buffer, | 
 | 203 |     // but may affect it's on-screen size or clipping. | 
 | 204 |     bool setSize(uint32_t w, uint32_t h); | 
 | 205 |     // Set a 2x2 transformation matrix on the layer. This transform | 
 | 206 |     // will be applied after parent transforms, but before any final | 
 | 207 |     // producer specified transform. | 
 | 208 |     bool setMatrix(const layer_state_t::matrix22_t& matrix); | 
 | 209 |  | 
 | 210 |     // This second set of geometry attributes are controlled by | 
 | 211 |     // setGeometryAppliesWithResize, and their default mode is to be | 
 | 212 |     // immediate. If setGeometryAppliesWithResize is specified | 
 | 213 |     // while a resize is pending, then update of these attributes will | 
 | 214 |     // be delayed until the resize completes. | 
 | 215 |  | 
 | 216 |     // setPosition operates in parent buffer space (pre parent-transform) or display | 
 | 217 |     // space for top-level layers. | 
| Robert Carr | 82364e3 | 2016-05-15 11:27:47 -0700 | [diff] [blame] | 218 |     bool setPosition(float x, float y, bool immediate); | 
| Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 219 |     // Buffer space | 
| Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 220 |     bool setCrop(const Rect& crop, bool immediate); | 
| Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 221 |     // Parent buffer space/display space | 
| Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 222 |     bool setFinalCrop(const Rect& crop, bool immediate); | 
 | 223 |  | 
| Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 224 |     // TODO(b/38182121): Could we eliminate the various latching modes by | 
 | 225 |     // using the layer hierarchy? | 
 | 226 |     // ----------------------------------------------------------------------- | 
| Robert Carr | ae06083 | 2016-11-28 10:51:00 -0800 | [diff] [blame] | 227 |     bool setLayer(int32_t z); | 
| Robert Carr | db66e62 | 2017-04-10 16:55:57 -0700 | [diff] [blame] | 228 |     bool setRelativeLayer(const sp<IBinder>& relativeToHandle, int32_t relativeZ); | 
 | 229 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 230 |     bool setAlpha(float alpha); | 
| chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 231 |     bool setColor(const half3& color); | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 232 |     bool setTransparentRegionHint(const Region& transparent); | 
 | 233 |     bool setFlags(uint8_t flags, uint8_t mask); | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 234 |     bool setLayerStack(uint32_t layerStack); | 
| Courtney Goeltzenleuchter | bb09b43 | 2016-11-30 13:51:28 -0700 | [diff] [blame] | 235 |     bool setDataSpace(android_dataspace dataSpace); | 
| Courtney Goeltzenleuchter | 532b263 | 2017-05-05 16:34:38 -0600 | [diff] [blame] | 236 |     android_dataspace getDataSpace() const; | 
| Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 237 |     uint32_t getLayerStack() const; | 
| Robert Carr | 0d48072 | 2017-01-10 16:42:54 -0800 | [diff] [blame] | 238 |     void deferTransactionUntil(const sp<IBinder>& barrierHandle, uint64_t frameNumber); | 
 | 239 |     void deferTransactionUntil(const sp<Layer>& barrierLayer, uint64_t frameNumber); | 
| Robert Carr | c3574f7 | 2016-03-24 12:19:32 -0700 | [diff] [blame] | 240 |     bool setOverrideScalingMode(int32_t overrideScalingMode); | 
| Daniel Nicoara | 2f5f8a5 | 2016-12-20 16:11:58 -0500 | [diff] [blame] | 241 |     void setInfo(uint32_t type, uint32_t appId); | 
| Robert Carr | 1db73f6 | 2016-12-21 12:58:51 -0800 | [diff] [blame] | 242 |     bool reparentChildren(const sp<IBinder>& layer); | 
| chaviw | f1961f7 | 2017-09-18 16:41:07 -0700 | [diff] [blame] | 243 |     bool reparent(const sp<IBinder>& newParentHandle); | 
| Robert Carr | 9524cb3 | 2017-02-13 11:32:32 -0800 | [diff] [blame] | 244 |     bool detachChildren(); | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 245 |  | 
| Dan Stoza | ee44edd | 2015-03-23 15:50:23 -0700 | [diff] [blame] | 246 |     // If we have received a new buffer this frame, we will pass its surface | 
 | 247 |     // damage down to hardware composer. Otherwise, we must send a region with | 
 | 248 |     // one empty rect. | 
 | 249 |     void useSurfaceDamage(); | 
 | 250 |     void useEmptyDamage(); | 
 | 251 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 252 |     uint32_t getTransactionFlags(uint32_t flags); | 
 | 253 |     uint32_t setTransactionFlags(uint32_t flags); | 
 | 254 |  | 
| Chia-I Wu | ab0c319 | 2017-08-01 11:29:00 -0700 | [diff] [blame] | 255 |     bool belongsToDisplay(uint32_t layerStack, bool isPrimaryDisplay) const { | 
 | 256 |         return getLayerStack() == layerStack && (!mPrimaryDisplayOnly || isPrimaryDisplay); | 
 | 257 |     } | 
 | 258 |  | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 259 |     void computeGeometry(const RenderArea& renderArea, Mesh& mesh, bool useIdentityTransform) const; | 
| Michael Lentine | 6c925ed | 2014-09-26 17:55:01 -0700 | [diff] [blame] | 260 |     Rect computeBounds(const Region& activeTransparentRegion) const; | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 261 |     Rect computeBounds() const; | 
 | 262 |  | 
| Pablo Ceballos | 40845df | 2016-01-25 17:41:15 -0800 | [diff] [blame] | 263 |     int32_t getSequence() const { return sequence; } | 
 | 264 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 265 |     // ----------------------------------------------------------------------- | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 266 |     // Virtuals | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 267 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 268 |     virtual const char* getTypeId() const { return "Layer"; } | 
 | 269 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 270 |     /* | 
 | 271 |      * isOpaque - true if this surface is opaque | 
| Andy McFadden | 4125a4f | 2014-01-29 17:17:11 -0800 | [diff] [blame] | 272 |      * | 
 | 273 |      * This takes into account the buffer format (i.e. whether or not the | 
 | 274 |      * pixel format includes an alpha channel) and the "opaque" flag set | 
 | 275 |      * on the layer.  It does not examine the current plane alpha value. | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 276 |      */ | 
| Andy McFadden | 4125a4f | 2014-01-29 17:17:11 -0800 | [diff] [blame] | 277 |     virtual bool isOpaque(const Layer::State& s) const; | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 278 |  | 
 | 279 |     /* | 
 | 280 |      * isSecure - true if this surface is secure, that is if it prevents | 
 | 281 |      * screenshots or VNC servers. | 
 | 282 |      */ | 
| Dan Stoza | 2311608 | 2015-06-18 14:58:39 -0700 | [diff] [blame] | 283 |     virtual bool isSecure() const; | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 284 |  | 
 | 285 |     /* | 
 | 286 |      * isProtected - true if the layer may contain protected content in the | 
 | 287 |      * GRALLOC_USAGE_PROTECTED sense. | 
 | 288 |      */ | 
| Jamie Gennis | 7a4d0df | 2011-03-09 17:05:02 -0800 | [diff] [blame] | 289 |     virtual bool isProtected() const; | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 290 |  | 
 | 291 |     /* | 
 | 292 |      * isVisible - true if this layer is visible, false otherwise | 
 | 293 |      */ | 
| Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 294 |     virtual bool isVisible() const; | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 295 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 296 |     /* | 
| Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 297 |      * isHiddenByPolicy - true if this layer has been forced invisible. | 
 | 298 |      * just because this is false, doesn't mean isVisible() is true. | 
 | 299 |      * For example if this layer has no active buffer, it may not be hidden by | 
 | 300 |      * policy, but it still can not be visible. | 
 | 301 |      */ | 
 | 302 |     virtual bool isHiddenByPolicy() const; | 
 | 303 |  | 
 | 304 |     /* | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 305 |      * isFixedSize - true if content has a fixed size | 
 | 306 |      */ | 
 | 307 |     virtual bool isFixedSize() const; | 
| Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 308 |  | 
| chaviw | 1d04428 | 2017-09-27 12:19:28 -0700 | [diff] [blame] | 309 |     void writeToProto(LayerProto* layerInfo, LayerVector::StateSet stateSet = LayerVector::StateSet::Drawing); | 
 | 310 |  | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 311 | protected: | 
 | 312 |     /* | 
 | 313 |      * onDraw - draws the surface. | 
 | 314 |      */ | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 315 |     virtual void onDraw(const RenderArea& renderArea, const Region& clip, | 
| Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 316 |             bool useIdentityTransform) const; | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 317 |  | 
 | 318 | public: | 
 | 319 |     // ----------------------------------------------------------------------- | 
 | 320 |  | 
| Fabien Sanglard | 9d96de4 | 2016-10-11 00:15:18 +0000 | [diff] [blame] | 321 | #ifdef USE_HWC2 | 
| Robert Carr | ae06083 | 2016-11-28 10:51:00 -0800 | [diff] [blame] | 322 |     void setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 323 |     void forceClientComposition(int32_t hwcId); | 
 | 324 |     void setPerFrameData(const sp<const DisplayDevice>& displayDevice); | 
 | 325 |  | 
 | 326 |     // callIntoHwc exists so we can update our local state and call | 
 | 327 |     // acceptDisplayChanges without unnecessarily updating the device's state | 
 | 328 |     void setCompositionType(int32_t hwcId, HWC2::Composition type, | 
 | 329 |             bool callIntoHwc = true); | 
 | 330 |     HWC2::Composition getCompositionType(int32_t hwcId) const; | 
 | 331 |  | 
 | 332 |     void setClearClientTarget(int32_t hwcId, bool clear); | 
 | 333 |     bool getClearClientTarget(int32_t hwcId) const; | 
 | 334 |  | 
 | 335 |     void updateCursorPosition(const sp<const DisplayDevice>& hw); | 
| Fabien Sanglard | 9d96de4 | 2016-10-11 00:15:18 +0000 | [diff] [blame] | 336 | #else | 
 | 337 |     void setGeometry(const sp<const DisplayDevice>& hw, | 
 | 338 |             HWComposer::HWCLayerInterface& layer); | 
 | 339 |     void setPerFrameData(const sp<const DisplayDevice>& hw, | 
 | 340 |             HWComposer::HWCLayerInterface& layer); | 
 | 341 |     void setAcquireFence(const sp<const DisplayDevice>& hw, | 
 | 342 |             HWComposer::HWCLayerInterface& layer); | 
 | 343 |  | 
 | 344 |     Rect getPosition(const sp<const DisplayDevice>& hw); | 
 | 345 | #endif | 
| Riley Andrews | 03414a1 | 2014-07-01 14:22:59 -0700 | [diff] [blame] | 346 |  | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 347 |     /* | 
 | 348 |      * called after page-flip | 
 | 349 |      */ | 
| Fabien Sanglard | 9d96de4 | 2016-10-11 00:15:18 +0000 | [diff] [blame] | 350 | #ifdef USE_HWC2 | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 351 |     void onLayerDisplayed(const sp<Fence>& releaseFence); | 
| Fabien Sanglard | 9d96de4 | 2016-10-11 00:15:18 +0000 | [diff] [blame] | 352 | #else | 
 | 353 |     void onLayerDisplayed(const sp<const DisplayDevice>& hw, | 
 | 354 |             HWComposer::HWCLayerInterface* layer); | 
 | 355 | #endif | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 356 |  | 
| Dan Stoza | 6b9454d | 2014-11-07 16:00:59 -0800 | [diff] [blame] | 357 |     bool shouldPresentNow(const DispSync& dispSync) const; | 
 | 358 |  | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 359 |     /* | 
 | 360 |      * called before composition. | 
 | 361 |      * returns true if the layer has pending updates. | 
 | 362 |      */ | 
| Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 363 |     bool onPreComposition(nsecs_t refreshStartTime); | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 364 |  | 
 | 365 |     /* | 
| Dan Stoza | e77c766 | 2016-05-13 11:37:28 -0700 | [diff] [blame] | 366 |      * called after composition. | 
 | 367 |      * returns true if the layer latched a new buffer this frame. | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 368 |      */ | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 369 |     bool onPostComposition(const std::shared_ptr<FenceTime>& glDoneFence, | 
| Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 370 |             const std::shared_ptr<FenceTime>& presentFence, | 
| Brian Anderson | 0a61b0c | 2016-12-07 14:55:56 -0800 | [diff] [blame] | 371 |             const CompositorTiming& compositorTiming); | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 372 |  | 
| Fabien Sanglard | 9d96de4 | 2016-10-11 00:15:18 +0000 | [diff] [blame] | 373 | #ifdef USE_HWC2 | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 374 |     // If a buffer was replaced this frame, release the former buffer | 
| Brian Anderson | f638686 | 2016-10-31 16:34:13 -0700 | [diff] [blame] | 375 |     void releasePendingBuffer(nsecs_t dequeueReadyTime); | 
| Fabien Sanglard | 9d96de4 | 2016-10-11 00:15:18 +0000 | [diff] [blame] | 376 | #endif | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 377 |  | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 378 |     /* | 
 | 379 |      * draw - performs some global clipping optimizations | 
 | 380 |      * and calls onDraw(). | 
 | 381 |      */ | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 382 |     void draw(const RenderArea& renderArea, const Region& clip) const; | 
 | 383 |     void draw(const RenderArea& renderArea, bool useIdentityTransform) const; | 
 | 384 |     void draw(const RenderArea& renderArea) const; | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 385 |  | 
 | 386 |     /* | 
 | 387 |      * doTransaction - process the transaction. This is a good place to figure | 
 | 388 |      * out which attributes of the surface have changed. | 
 | 389 |      */ | 
 | 390 |     uint32_t doTransaction(uint32_t transactionFlags); | 
 | 391 |  | 
 | 392 |     /* | 
 | 393 |      * setVisibleRegion - called to set the new visible region. This gives | 
 | 394 |      * a chance to update the new visible region or record the fact it changed. | 
 | 395 |      */ | 
 | 396 |     void setVisibleRegion(const Region& visibleRegion); | 
 | 397 |  | 
 | 398 |     /* | 
 | 399 |      * setCoveredRegion - called when the covered region changes. The covered | 
 | 400 |      * region corresponds to any area of the surface that is covered | 
 | 401 |      * (transparently or not) by another surface. | 
 | 402 |      */ | 
 | 403 |     void setCoveredRegion(const Region& coveredRegion); | 
 | 404 |  | 
 | 405 |     /* | 
 | 406 |      * setVisibleNonTransparentRegion - called when the visible and | 
 | 407 |      * non-transparent region changes. | 
 | 408 |      */ | 
 | 409 |     void setVisibleNonTransparentRegion(const Region& | 
 | 410 |             visibleNonTransparentRegion); | 
 | 411 |  | 
 | 412 |     /* | 
 | 413 |      * latchBuffer - called each time the screen is redrawn and returns whether | 
 | 414 |      * the visible regions need to be recomputed (this is a fairly heavy | 
 | 415 |      * operation, so this should be set only if needed). Typically this is used | 
 | 416 |      * to figure out if the content or size of a surface has changed. | 
 | 417 |      */ | 
| Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 418 |     Region latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime); | 
| Chia-I Wu | a36bf92 | 2017-06-30 12:51:05 -0700 | [diff] [blame] | 419 |     bool isBufferLatched() const { return mRefreshPending; } | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 420 |  | 
| Riley Andrews | 03414a1 | 2014-07-01 14:22:59 -0700 | [diff] [blame] | 421 |     bool isPotentialCursor() const { return mPotentialCursor;} | 
 | 422 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 423 |     /* | 
| Chia-I Wu | c665702 | 2017-08-15 11:18:17 -0700 | [diff] [blame] | 424 |      * called with the state lock from a binder thread when the layer is | 
 | 425 |      * removed from the current list to the pending removal list | 
 | 426 |      */ | 
 | 427 |     void onRemovedFromCurrentState(); | 
 | 428 |  | 
 | 429 |     /* | 
 | 430 |      * called with the state lock from the main thread when the layer is | 
 | 431 |      * removed from the pending removal list | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 432 |      */ | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 433 |     void onRemoved(); | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 434 |  | 
 | 435 |  | 
| Andy McFadden | bf974ab | 2012-12-04 16:51:15 -0800 | [diff] [blame] | 436 |     // Updates the transform hint in our SurfaceFlingerConsumer to match | 
| Mathias Agopian | 8430095 | 2012-11-21 16:02:13 -0800 | [diff] [blame] | 437 |     // the current orientation of the display device. | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 438 |     void updateTransformHint(const sp<const DisplayDevice>& hw) const; | 
| Andy McFadden | 6905205 | 2012-09-14 16:10:11 -0700 | [diff] [blame] | 439 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 440 |     /* | 
 | 441 |      * returns the rectangle that crops the content of the layer and scales it | 
 | 442 |      * to the layer's size. | 
 | 443 |      */ | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 444 |     Rect getContentCrop() const; | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 445 |  | 
| Eric Penner | 51c59cd | 2014-07-28 19:51:58 -0700 | [diff] [blame] | 446 |     /* | 
 | 447 |      * Returns if a frame is queued. | 
 | 448 |      */ | 
| Pablo Ceballos | 0631218 | 2015-10-07 16:32:12 -0700 | [diff] [blame] | 449 |     bool hasQueuedFrame() const { return mQueuedFrames > 0 || | 
| Pablo Ceballos | ff95aab | 2016-01-13 17:09:58 -0800 | [diff] [blame] | 450 |             mSidebandStreamChanged || mAutoRefresh; } | 
| Eric Penner | 51c59cd | 2014-07-28 19:51:58 -0700 | [diff] [blame] | 451 |  | 
| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 452 |     int32_t getQueuedFrameCount() const { return mQueuedFrames; } | 
 | 453 |  | 
| Fabien Sanglard | 9d96de4 | 2016-10-11 00:15:18 +0000 | [diff] [blame] | 454 | #ifdef USE_HWC2 | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 455 |     // ----------------------------------------------------------------------- | 
 | 456 |  | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 457 |     bool createHwcLayer(HWComposer* hwc, int32_t hwcId); | 
 | 458 |     void destroyHwcLayer(int32_t hwcId); | 
 | 459 |     void destroyAllHwcLayers(); | 
 | 460 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 461 |     bool hasHwcLayer(int32_t hwcId) { | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 462 |         return mHwcLayers.count(hwcId) > 0; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 463 |     } | 
 | 464 |  | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 465 |     HWC2::Layer* getHwcLayer(int32_t hwcId) { | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 466 |         if (mHwcLayers.count(hwcId) == 0) { | 
 | 467 |             return nullptr; | 
 | 468 |         } | 
 | 469 |         return mHwcLayers[hwcId].layer; | 
 | 470 |     } | 
 | 471 |  | 
| Fabien Sanglard | 9d96de4 | 2016-10-11 00:15:18 +0000 | [diff] [blame] | 472 | #endif | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 473 |     // ----------------------------------------------------------------------- | 
 | 474 |  | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 475 |     void clearWithOpenGL(const RenderArea& renderArea) const; | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 476 |     void setFiltering(bool filtering); | 
 | 477 |     bool getFiltering() const; | 
 | 478 |  | 
 | 479 |     // only for debugging | 
 | 480 |     inline const sp<GraphicBuffer>& getActiveBuffer() const { return mActiveBuffer; } | 
 | 481 |  | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 482 |     inline  const State&    getDrawingState() const { return mDrawingState; } | 
 | 483 |     inline  const State&    getCurrentState() const { return mCurrentState; } | 
 | 484 |     inline  State&          getCurrentState()       { return mCurrentState; } | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 485 |  | 
| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 486 |     LayerDebugInfo getLayerDebugInfo() const; | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 487 |  | 
 | 488 |     /* always call base class first */ | 
| Fabien Sanglard | 9d96de4 | 2016-10-11 00:15:18 +0000 | [diff] [blame] | 489 | #ifdef USE_HWC2 | 
| Dan Stoza | e22aec7 | 2016-08-01 13:20:59 -0700 | [diff] [blame] | 490 |     static void miniDumpHeader(String8& result); | 
 | 491 |     void miniDump(String8& result, int32_t hwcId) const; | 
| Fabien Sanglard | 9d96de4 | 2016-10-11 00:15:18 +0000 | [diff] [blame] | 492 | #endif | 
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 493 |     void dumpFrameStats(String8& result) const; | 
| Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 494 |     void dumpFrameEvents(String8& result); | 
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 495 |     void clearFrameStats(); | 
| Jamie Gennis | 6547ff4 | 2013-07-16 20:12:42 -0700 | [diff] [blame] | 496 |     void logFrameStats(); | 
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 497 |     void getFrameStats(FrameStats* outStats) const; | 
| Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 498 |  | 
| Dan Stoza | e77c766 | 2016-05-13 11:37:28 -0700 | [diff] [blame] | 499 |     std::vector<OccupancyTracker::Segment> getOccupancyHistory(bool forceFlush); | 
 | 500 |  | 
| Brian Anderson | 5ea5e59 | 2016-12-01 16:54:33 -0800 | [diff] [blame] | 501 |     void onDisconnect(); | 
| Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 502 |     void addAndGetFrameTimestamps(const NewFrameEventsEntry* newEntry, | 
 | 503 |             FrameEventHistoryDelta* outDelta); | 
| Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 504 |  | 
| Robert Carr | 367c568 | 2016-06-20 11:55:28 -0700 | [diff] [blame] | 505 |     bool getTransformToDisplayInverse() const; | 
 | 506 |  | 
| Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 507 |     Transform getTransform() const; | 
 | 508 |  | 
| Robert Carr | 6452f12 | 2017-03-21 10:41:29 -0700 | [diff] [blame] | 509 |     // Returns the Alpha of the Surface, accounting for the Alpha | 
 | 510 |     // of parent Surfaces in the hierarchy (alpha's will be multiplied | 
 | 511 |     // down the hierarchy). | 
| chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 512 |     half getAlpha() const; | 
 | 513 |     half4 getColor() const; | 
| Robert Carr | 6452f12 | 2017-03-21 10:41:29 -0700 | [diff] [blame] | 514 |  | 
| Dan Stoza | 412903f | 2017-04-27 13:42:17 -0700 | [diff] [blame] | 515 |     void traverseInReverseZOrder(LayerVector::StateSet stateSet, | 
 | 516 |                                  const LayerVector::Visitor& visitor); | 
 | 517 |     void traverseInZOrder(LayerVector::StateSet stateSet, const LayerVector::Visitor& visitor); | 
| Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 518 |  | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 519 |     void traverseChildrenInZOrder(LayerVector::StateSet stateSet, | 
 | 520 |                                   const LayerVector::Visitor& visitor); | 
 | 521 |  | 
| Chia-I Wu | 98f1c10 | 2017-05-30 14:54:08 -0700 | [diff] [blame] | 522 |     size_t getChildrenCount() const; | 
| Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 523 |     void addChild(const sp<Layer>& layer); | 
 | 524 |     // Returns index if removed, or negative value otherwise | 
 | 525 |     // for symmetry with Vector::remove | 
 | 526 |     ssize_t removeChild(const sp<Layer>& layer); | 
| Chia-I Wu | e41dbe6 | 2017-06-13 14:10:56 -0700 | [diff] [blame] | 527 |     sp<Layer> getParent() const { return mCurrentParent.promote(); } | 
| Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 528 |     bool hasParent() const { return getParent() != nullptr; } | 
 | 529 |  | 
 | 530 |     Rect computeScreenBounds(bool reduceTransparentRegion = true) const; | 
 | 531 |     bool setChildLayer(const sp<Layer>& childLayer, int32_t z); | 
 | 532 |  | 
 | 533 |     // Copy the current list of children to the drawing state. Called by | 
 | 534 |     // SurfaceFlinger to complete a transaction. | 
 | 535 |     void commitChildList(); | 
 | 536 |  | 
 | 537 |     int32_t getZ() const; | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 538 | protected: | 
 | 539 |     // constant | 
 | 540 |     sp<SurfaceFlinger> mFlinger; | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 541 |     /* | 
 | 542 |      * Trivial class, used to ensure that mFlinger->onLayerDestroyed(mLayer) | 
 | 543 |      * is called. | 
 | 544 |      */ | 
 | 545 |     class LayerCleaner { | 
 | 546 |         sp<SurfaceFlinger> mFlinger; | 
 | 547 |         wp<Layer> mLayer; | 
 | 548 |     protected: | 
| Irvel | 468051e | 2016-06-13 16:44:44 -0700 | [diff] [blame] | 549 |         ~LayerCleaner() { | 
 | 550 |             // destroy client resources | 
 | 551 |             mFlinger->onLayerDestroyed(mLayer); | 
 | 552 |         } | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 553 |     public: | 
| Irvel | 468051e | 2016-06-13 16:44:44 -0700 | [diff] [blame] | 554 |         LayerCleaner(const sp<SurfaceFlinger>& flinger, | 
 | 555 |                 const sp<Layer>& layer) | 
 | 556 |             : mFlinger(flinger), mLayer(layer) { | 
 | 557 |         } | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 558 |     }; | 
 | 559 |  | 
| Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 560 |  | 
| Irvel | 468051e | 2016-06-13 16:44:44 -0700 | [diff] [blame] | 561 |     virtual void onFirstRef(); | 
 | 562 |  | 
 | 563 |  | 
 | 564 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 565 | private: | 
| Irvel | 468051e | 2016-06-13 16:44:44 -0700 | [diff] [blame] | 566 |     friend class SurfaceInterceptor; | 
| Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 567 |     // Interface implementation for SurfaceFlingerConsumer::ContentsChangedListener | 
| Dan Stoza | dc13c5b | 2015-05-11 15:33:01 -0700 | [diff] [blame] | 568 |     virtual void onFrameAvailable(const BufferItem& item) override; | 
 | 569 |     virtual void onFrameReplaced(const BufferItem& item) override; | 
 | 570 |     virtual void onSidebandStreamChanged() override; | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 571 |  | 
| Pablo Ceballos | 05289c2 | 2016-04-14 15:49:55 -0700 | [diff] [blame] | 572 |     void commitTransaction(const State& stateToCommit); | 
| Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 573 |  | 
 | 574 |     // needsLinearFiltering - true if this surface's state requires filtering | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 575 |     bool needsFiltering(const RenderArea& renderArea) const; | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 576 |  | 
| Mathias Agopian | 3330b20 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 577 |     uint32_t getEffectiveUsage(uint32_t usage) const; | 
| Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 578 |  | 
| Dan Stoza | 5a423ea | 2017-02-16 14:10:39 -0800 | [diff] [blame] | 579 |     FloatRect computeCrop(const sp<const DisplayDevice>& hw) const; | 
| Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 580 |     // Compute the initial crop as specified by parent layers and the SurfaceControl | 
 | 581 |     // for this layer. Does not include buffer crop from the IGraphicBufferProducer | 
 | 582 |     // client, as that should not affect child clipping. Returns in screen space. | 
 | 583 |     Rect computeInitialCrop(const sp<const DisplayDevice>& hw) const; | 
| Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 584 |     bool isCropped() const; | 
 | 585 |     static bool getOpacityForFormat(uint32_t format); | 
| Mathias Agopian | 0aa758d | 2009-04-22 15:23:34 -0700 | [diff] [blame] | 586 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 587 |     // drawing | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 588 |     void clearWithOpenGL(const RenderArea& renderArea, | 
| Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 589 |             float r, float g, float b, float alpha) const; | 
| chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 590 |     void drawWithOpenGL(const RenderArea& renderArea, | 
| Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 591 |             bool useIdentityTransform) const; | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 592 |  | 
| Ruben Brunk | 1681d95 | 2014-06-27 15:51:55 -0700 | [diff] [blame] | 593 |     // Temporary - Used only for LEGACY camera mode. | 
 | 594 |     uint32_t getProducerStickyTransform() const; | 
 | 595 |  | 
| Dan Stoza | c5da271 | 2016-07-20 15:38:12 -0700 | [diff] [blame] | 596 |     // Loads the corresponding system property once per process | 
 | 597 |     static bool latchUnsignaledBuffers(); | 
 | 598 |  | 
| Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 599 |     void setParent(const sp<Layer>& layer); | 
 | 600 |  | 
| Dan Stoza | 412903f | 2017-04-27 13:42:17 -0700 | [diff] [blame] | 601 |     LayerVector makeTraversalList(LayerVector::StateSet stateSet); | 
| Robert Carr | db66e62 | 2017-04-10 16:55:57 -0700 | [diff] [blame] | 602 |     void addZOrderRelative(const wp<Layer>& relative); | 
 | 603 |     void removeZOrderRelative(const wp<Layer>& relative); | 
 | 604 |  | 
| Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 605 |     // ----------------------------------------------------------------------- | 
 | 606 |  | 
 | 607 |     class SyncPoint | 
 | 608 |     { | 
 | 609 |     public: | 
| Chih-Hung Hsieh | 342b760 | 2016-09-01 11:34:16 -0700 | [diff] [blame] | 610 |         explicit SyncPoint(uint64_t frameNumber) : mFrameNumber(frameNumber), | 
| Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 611 |                 mFrameIsAvailable(false), mTransactionIsApplied(false) {} | 
 | 612 |  | 
 | 613 |         uint64_t getFrameNumber() const { | 
 | 614 |             return mFrameNumber; | 
 | 615 |         } | 
 | 616 |  | 
 | 617 |         bool frameIsAvailable() const { | 
 | 618 |             return mFrameIsAvailable; | 
 | 619 |         } | 
 | 620 |  | 
 | 621 |         void setFrameAvailable() { | 
 | 622 |             mFrameIsAvailable = true; | 
 | 623 |         } | 
 | 624 |  | 
 | 625 |         bool transactionIsApplied() const { | 
 | 626 |             return mTransactionIsApplied; | 
 | 627 |         } | 
 | 628 |  | 
 | 629 |         void setTransactionApplied() { | 
 | 630 |             mTransactionIsApplied = true; | 
 | 631 |         } | 
 | 632 |  | 
 | 633 |     private: | 
 | 634 |         const uint64_t mFrameNumber; | 
 | 635 |         std::atomic<bool> mFrameIsAvailable; | 
 | 636 |         std::atomic<bool> mTransactionIsApplied; | 
 | 637 |     }; | 
 | 638 |  | 
| Dan Stoza | cac3538 | 2016-01-27 12:21:06 -0800 | [diff] [blame] | 639 |     // SyncPoints which will be signaled when the correct frame is at the head | 
 | 640 |     // of the queue and dropped after the frame has been latched. Protected by | 
 | 641 |     // mLocalSyncPointMutex. | 
 | 642 |     Mutex mLocalSyncPointMutex; | 
| Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 643 |     std::list<std::shared_ptr<SyncPoint>> mLocalSyncPoints; | 
 | 644 |  | 
| Dan Stoza | cac3538 | 2016-01-27 12:21:06 -0800 | [diff] [blame] | 645 |     // SyncPoints which will be signaled and then dropped when the transaction | 
 | 646 |     // is applied | 
| Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 647 |     std::list<std::shared_ptr<SyncPoint>> mRemoteSyncPoints; | 
 | 648 |  | 
| Dan Stoza | cac3538 | 2016-01-27 12:21:06 -0800 | [diff] [blame] | 649 |     uint64_t getHeadFrameNumber() const; | 
| Dan Stoza | 1ce6581 | 2016-06-15 16:26:27 -0700 | [diff] [blame] | 650 |     bool headFenceHasSignaled() const; | 
| Dan Stoza | cac3538 | 2016-01-27 12:21:06 -0800 | [diff] [blame] | 651 |  | 
 | 652 |     // Returns false if the relevant frame has already been latched | 
 | 653 |     bool addSyncPoint(const std::shared_ptr<SyncPoint>& point); | 
| Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 654 |  | 
 | 655 |     void pushPendingState(); | 
| Pablo Ceballos | 05289c2 | 2016-04-14 15:49:55 -0700 | [diff] [blame] | 656 |     void popPendingState(State* stateToCommit); | 
 | 657 |     bool applyPendingStates(State* stateToCommit); | 
| Robert Carr | c3574f7 | 2016-03-24 12:19:32 -0700 | [diff] [blame] | 658 |  | 
| Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 659 |     void clearSyncPoints(); | 
 | 660 |  | 
| Robert Carr | c3574f7 | 2016-03-24 12:19:32 -0700 | [diff] [blame] | 661 |     // Returns mCurrentScaling mode (originating from the | 
 | 662 |     // Client) or mOverrideScalingMode mode (originating from | 
 | 663 |     // the Surface Controller) if set. | 
 | 664 |     uint32_t getEffectiveScalingMode() const; | 
| Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 665 | public: | 
| Irvel | 468051e | 2016-06-13 16:44:44 -0700 | [diff] [blame] | 666 |     /* | 
 | 667 |      * The layer handle is just a BBinder object passed to the client | 
 | 668 |      * (remote process) -- we don't keep any reference on our side such that | 
 | 669 |      * the dtor is called when the remote side let go of its reference. | 
 | 670 |      * | 
 | 671 |      * LayerCleaner ensures that mFlinger->onLayerDestroyed() is called for | 
 | 672 |      * this layer when the handle is destroyed. | 
 | 673 |      */ | 
 | 674 |     class Handle : public BBinder, public LayerCleaner { | 
 | 675 |         public: | 
 | 676 |             Handle(const sp<SurfaceFlinger>& flinger, const sp<Layer>& layer) | 
 | 677 |                 : LayerCleaner(flinger, layer), owner(layer) {} | 
 | 678 |  | 
 | 679 |             wp<Layer> owner; | 
 | 680 |     }; | 
 | 681 |  | 
 | 682 |     sp<IBinder> getHandle(); | 
 | 683 |     sp<IGraphicBufferProducer> getProducer() const; | 
 | 684 |     const String8& getName() const; | 
| Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 685 |     void notifyAvailableFrames(); | 
| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 686 |     PixelFormat getPixelFormat() const { return mFormat; } | 
| chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 687 |     bool getPremultipledAlpha() const; | 
| Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 688 | private: | 
| Igor Murashkin | a4a3149 | 2012-10-29 13:36:11 -0700 | [diff] [blame] | 689 |  | 
| Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 690 |     // ----------------------------------------------------------------------- | 
 | 691 |  | 
| Fabien Sanglard | cd6fd54 | 2016-10-13 12:47:39 -0700 | [diff] [blame] | 692 |     // Check all of the local sync points to ensure that all transactions | 
 | 693 |     // which need to have been applied prior to the frame which is about to | 
 | 694 |     // be latched have signaled | 
 | 695 |     bool allTransactionsSignaled(); | 
 | 696 |  | 
| Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 697 |     // constants | 
| Andy McFadden | bf974ab | 2012-12-04 16:51:15 -0800 | [diff] [blame] | 698 |     sp<SurfaceFlingerConsumer> mSurfaceFlingerConsumer; | 
| Dan Stoza | b9b0883 | 2014-03-13 11:55:57 -0700 | [diff] [blame] | 699 |     sp<IGraphicBufferProducer> mProducer; | 
| Andy McFadden | 4df87bd | 2014-04-21 18:08:54 -0700 | [diff] [blame] | 700 |     uint32_t mTextureName;      // from GLES | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 701 |     bool mPremultipliedAlpha; | 
 | 702 |     String8 mName; | 
| Dan Stoza | f7ba41a | 2017-05-10 15:11:11 -0700 | [diff] [blame] | 703 |     String8 mTransactionName; // A cached version of "TX - " + mName for systraces | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 704 |     PixelFormat mFormat; | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 705 |  | 
| Chia-I Wu | ab0c319 | 2017-08-01 11:29:00 -0700 | [diff] [blame] | 706 |     bool mPrimaryDisplayOnly = false; | 
 | 707 |  | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 708 |     // these are protected by an external lock | 
 | 709 |     State mCurrentState; | 
 | 710 |     State mDrawingState; | 
 | 711 |     volatile int32_t mTransactionFlags; | 
| Mathias Agopian | d606de6 | 2010-05-10 20:06:11 -0700 | [diff] [blame] | 712 |  | 
| Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 713 |     // Accessed from main thread and binder threads | 
 | 714 |     Mutex mPendingStateMutex; | 
 | 715 |     Vector<State> mPendingStates; | 
 | 716 |  | 
| Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 717 |     // thread-safe | 
| Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 718 |     volatile int32_t mQueuedFrames; | 
| Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 719 |     volatile int32_t mSidebandStreamChanged; // used like an atomic boolean | 
| Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 720 |  | 
 | 721 |     // Timestamp history for UIAutomation. Thread safe. | 
| Jamie Gennis | 4b0eba9 | 2013-02-05 13:30:24 -0800 | [diff] [blame] | 722 |     FrameTracker mFrameTracker; | 
| Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 723 |  | 
| Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 724 |     // Timestamp history for the consumer to query. | 
 | 725 |     // Accessed by both consumer and producer on main and binder threads. | 
 | 726 |     Mutex mFrameEventHistoryMutex; | 
| Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 727 |     ConsumerFrameEventHistory mFrameEventHistory; | 
| Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 728 |     FenceTimeline mAcquireTimeline; | 
 | 729 |     FenceTimeline mReleaseTimeline; | 
| Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 730 |  | 
| Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 731 |     // main thread | 
| Mathias Agopian | a934764 | 2017-02-13 16:42:28 -0800 | [diff] [blame] | 732 |     int mActiveBufferSlot; | 
| Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 733 |     sp<GraphicBuffer> mActiveBuffer; | 
| Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 734 |     sp<NativeHandle> mSidebandStream; | 
| Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 735 |     Rect mCurrentCrop; | 
 | 736 |     uint32_t mCurrentTransform; | 
| Mathias Agopian | 933389f | 2011-07-18 16:15:08 -0700 | [diff] [blame] | 737 |     uint32_t mCurrentScalingMode; | 
| Robert Carr | c3574f7 | 2016-03-24 12:19:32 -0700 | [diff] [blame] | 738 |     // We encode unset as -1. | 
 | 739 |     int32_t mOverrideScalingMode; | 
| Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 740 |     bool mCurrentOpacity; | 
| Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 741 |     bool mBufferLatched = false;  // TODO: Use mActiveBuffer? | 
| Dan Stoza | cac3538 | 2016-01-27 12:21:06 -0800 | [diff] [blame] | 742 |     std::atomic<uint64_t> mCurrentFrameNumber; | 
| Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 743 |     uint64_t mPreviousFrameNumber; // Only accessed on the main thread. | 
| Mathias Agopian | 4d143ee | 2012-02-23 20:05:39 -0800 | [diff] [blame] | 744 |     bool mRefreshPending; | 
| Jamie Gennis | e8696a4 | 2012-01-15 18:54:57 -0800 | [diff] [blame] | 745 |     bool mFrameLatencyNeeded; | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 746 |     // Whether filtering is forced on or not | 
 | 747 |     bool mFiltering; | 
 | 748 |     // Whether filtering is needed b/c of the drawingstate | 
 | 749 |     bool mNeedsFiltering; | 
| Mathias Agopian | 5cdc899 | 2013-08-13 20:51:23 -0700 | [diff] [blame] | 750 |     // The mesh used to draw the layer in GLES composition mode | 
 | 751 |     mutable Mesh mMesh; | 
| Andy McFadden | 4df87bd | 2014-04-21 18:08:54 -0700 | [diff] [blame] | 752 |     // The texture used to draw the layer in GLES composition mode | 
| Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 753 |     mutable Texture mTexture; | 
| Mathias Agopian | d606de6 | 2010-05-10 20:06:11 -0700 | [diff] [blame] | 754 |  | 
| Fabien Sanglard | 9d96de4 | 2016-10-11 00:15:18 +0000 | [diff] [blame] | 755 | #ifdef USE_HWC2 | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 756 |     // HWC items, accessed from the main thread | 
 | 757 |     struct HWCInfo { | 
 | 758 |         HWCInfo() | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 759 |           : hwc(nullptr), | 
 | 760 |             layer(nullptr), | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 761 |             forceClientComposition(false), | 
 | 762 |             compositionType(HWC2::Composition::Invalid), | 
 | 763 |             clearClientTarget(false) {} | 
 | 764 |  | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 765 |         HWComposer* hwc; | 
 | 766 |         HWC2::Layer* layer; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 767 |         bool forceClientComposition; | 
 | 768 |         HWC2::Composition compositionType; | 
 | 769 |         bool clearClientTarget; | 
| Dan Stoza | e22aec7 | 2016-08-01 13:20:59 -0700 | [diff] [blame] | 770 |         Rect displayFrame; | 
| Dan Stoza | 5a423ea | 2017-02-16 14:10:39 -0800 | [diff] [blame] | 771 |         FloatRect sourceCrop; | 
| Chia-I Wu | aaff73f | 2017-02-13 12:28:24 -0800 | [diff] [blame] | 772 |         HWComposerBufferCache bufferCache; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 773 |     }; | 
| Fabien Sanglard | f0c53d6 | 2017-03-03 18:58:50 -0800 | [diff] [blame] | 774 |  | 
 | 775 |     // A layer can be attached to multiple displays when operating in mirror mode | 
 | 776 |     // (a.k.a: when several displays are attached with equal layerStack). In this | 
| Fabien Sanglard | 4afbf41 | 2017-03-08 14:50:11 -0800 | [diff] [blame] | 777 |     // case we need to keep track. In non-mirror mode, a layer will have only one | 
| Fabien Sanglard | f0c53d6 | 2017-03-03 18:58:50 -0800 | [diff] [blame] | 778 |     // HWCInfo. This map key is a display layerStack. | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 779 |     std::unordered_map<int32_t, HWCInfo> mHwcLayers; | 
| Fabien Sanglard | 9d96de4 | 2016-10-11 00:15:18 +0000 | [diff] [blame] | 780 | #else | 
 | 781 |     bool mIsGlesComposition; | 
 | 782 | #endif | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 783 |  | 
| Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 784 |     // page-flip thread (currently main thread) | 
| Glenn Kasten | 16f0453 | 2011-01-19 15:27:27 -0800 | [diff] [blame] | 785 |     bool mProtectedByApp; // application requires protected path to external sink | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 786 |  | 
 | 787 |     // protected by mLock | 
 | 788 |     mutable Mutex mLock; | 
| Mathias Agopian | 4d9b822 | 2013-03-12 17:11:48 -0700 | [diff] [blame] | 789 |     // Set to true once we've returned this surface's handle | 
| Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 790 |     mutable bool mHasSurface; | 
 | 791 |     const wp<Client> mClientRef; | 
| Riley Andrews | 03414a1 | 2014-07-01 14:22:59 -0700 | [diff] [blame] | 792 |  | 
 | 793 |     // This layer can be a cursor on some displays. | 
 | 794 |     bool mPotentialCursor; | 
| Dan Stoza | 6b9454d | 2014-11-07 16:00:59 -0800 | [diff] [blame] | 795 |  | 
 | 796 |     // Local copy of the queued contents of the incoming BufferQueue | 
 | 797 |     mutable Mutex mQueueItemLock; | 
| Dan Stoza | a4650a5 | 2015-05-12 12:56:16 -0700 | [diff] [blame] | 798 |     Condition mQueueItemCondition; | 
| Dan Stoza | 6b9454d | 2014-11-07 16:00:59 -0800 | [diff] [blame] | 799 |     Vector<BufferItem> mQueueItems; | 
| Dan Stoza | cac3538 | 2016-01-27 12:21:06 -0800 | [diff] [blame] | 800 |     std::atomic<uint64_t> mLastFrameNumberReceived; | 
| Brian Anderson | d6927fb | 2016-07-23 23:37:30 -0700 | [diff] [blame] | 801 |     bool mUpdateTexImageFailed; // This is only accessed on the main thread. | 
| Pablo Ceballos | 0631218 | 2015-10-07 16:32:12 -0700 | [diff] [blame] | 802 |  | 
| Pablo Ceballos | ff95aab | 2016-01-13 17:09:58 -0800 | [diff] [blame] | 803 |     bool mAutoRefresh; | 
| Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 804 |     bool mFreezeGeometryUpdates; | 
| Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 805 |  | 
 | 806 |     // Child list about to be committed/used for editing. | 
 | 807 |     LayerVector mCurrentChildren; | 
 | 808 |     // Child list used for rendering. | 
 | 809 |     LayerVector mDrawingChildren; | 
 | 810 |  | 
| Chia-I Wu | e41dbe6 | 2017-06-13 14:10:56 -0700 | [diff] [blame] | 811 |     wp<Layer> mCurrentParent; | 
 | 812 |     wp<Layer> mDrawingParent; | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 813 | }; | 
 | 814 |  | 
 | 815 | // --------------------------------------------------------------------------- | 
 | 816 |  | 
 | 817 | }; // namespace android | 
 | 818 |  | 
 | 819 | #endif // ANDROID_LAYER_H |