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> |
| 36 | |
| 37 | #include <private/gui/LayerState.h> |
| 38 | |
Jamie Gennis | 82dbc74 | 2012-11-08 19:23:28 -0800 | [diff] [blame] | 39 | #include "FrameTracker.h" |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 40 | #include "Client.h" |
Dan Stoza | b9b0883 | 2014-03-13 11:55:57 -0700 | [diff] [blame] | 41 | #include "MonitoredProducer.h" |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 42 | #include "SurfaceFlinger.h" |
| 43 | #include "SurfaceFlingerConsumer.h" |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | #include "Transform.h" |
| 45 | |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 46 | #include "DisplayHardware/HWComposer.h" |
Mathias Agopian | 6b44267 | 2013-07-09 21:24:52 -0700 | [diff] [blame] | 47 | #include "DisplayHardware/FloatRect.h" |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 48 | #include "RenderEngine/Mesh.h" |
Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 49 | #include "RenderEngine/Texture.h" |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 50 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | namespace android { |
| 52 | |
| 53 | // --------------------------------------------------------------------------- |
| 54 | |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 55 | class Client; |
Mathias Agopian | 3e25fd8 | 2013-04-22 17:52:16 +0200 | [diff] [blame] | 56 | class Colorizer; |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 57 | class DisplayDevice; |
| 58 | class GraphicBuffer; |
| 59 | class SurfaceFlinger; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | |
| 61 | // --------------------------------------------------------------------------- |
| 62 | |
Andy McFadden | 882e3a3 | 2013-01-08 16:06:15 -0800 | [diff] [blame] | 63 | /* |
Andy McFadden | 882e3a3 | 2013-01-08 16:06:15 -0800 | [diff] [blame] | 64 | * A new BufferQueue and a new SurfaceFlingerConsumer are created when the |
| 65 | * Layer is first referenced. |
| 66 | * |
| 67 | * This also implements onFrameAvailable(), which notifies SurfaceFlinger |
| 68 | * that new data has arrived. |
| 69 | */ |
Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 70 | class Layer : public SurfaceFlingerConsumer::ContentsChangedListener { |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 71 | static int32_t sSequence; |
| 72 | |
Mathias Agopian | d606de6 | 2010-05-10 20:06:11 -0700 | [diff] [blame] | 73 | public: |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 74 | mutable bool contentDirty; |
| 75 | // regions below are in window-manager space |
| 76 | Region visibleRegion; |
| 77 | Region coveredRegion; |
| 78 | Region visibleNonTransparentRegion; |
Andy McFadden | 4df87bd | 2014-04-21 18:08:54 -0700 | [diff] [blame] | 79 | |
| 80 | // Layer serial number. This gives layers an explicit ordering, so we |
| 81 | // have a stable sort order when their layer stack and Z-order are |
| 82 | // the same. |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 83 | int32_t sequence; |
| 84 | |
| 85 | enum { // flags for doTransaction() |
| 86 | eDontUpdateGeometryState = 0x00000001, |
| 87 | eVisibleRegion = 0x00000002, |
| 88 | }; |
| 89 | |
| 90 | struct Geometry { |
| 91 | uint32_t w; |
| 92 | uint32_t h; |
| 93 | Rect crop; |
| 94 | inline bool operator ==(const Geometry& rhs) const { |
| 95 | return (w == rhs.w && h == rhs.h && crop == rhs.crop); |
| 96 | } |
| 97 | inline bool operator !=(const Geometry& rhs) const { |
| 98 | return !operator ==(rhs); |
| 99 | } |
| 100 | }; |
| 101 | |
| 102 | struct State { |
| 103 | Geometry active; |
| 104 | Geometry requested; |
| 105 | uint32_t z; |
| 106 | uint32_t layerStack; |
| 107 | uint8_t alpha; |
| 108 | uint8_t flags; |
| 109 | uint8_t reserved[2]; |
| 110 | int32_t sequence; // changes when visible regions can change |
| 111 | Transform transform; |
Mathias Agopian | 2ca7939 | 2013-04-02 18:30:32 -0700 | [diff] [blame] | 112 | // the transparentRegion hint is a bit special, it's latched only |
| 113 | // when we receive a buffer -- this is because it's "content" |
| 114 | // dependent. |
| 115 | Region activeTransparentRegion; |
| 116 | Region requestedTransparentRegion; |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 117 | }; |
| 118 | |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 119 | // ----------------------------------------------------------------------- |
| 120 | |
Mathias Agopian | 4d9b822 | 2013-03-12 17:11:48 -0700 | [diff] [blame] | 121 | Layer(SurfaceFlinger* flinger, const sp<Client>& client, |
| 122 | const String8& name, uint32_t w, uint32_t h, uint32_t flags); |
Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 123 | |
Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 124 | virtual ~Layer(); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 125 | |
Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 126 | // the this layer's size and format |
Mathias Agopian | 4d9b822 | 2013-03-12 17:11:48 -0700 | [diff] [blame] | 127 | 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] | 128 | |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 129 | // modify current state |
| 130 | bool setPosition(float x, float y); |
| 131 | bool setLayer(uint32_t z); |
| 132 | bool setSize(uint32_t w, uint32_t h); |
| 133 | bool setAlpha(uint8_t alpha); |
| 134 | bool setMatrix(const layer_state_t::matrix22_t& matrix); |
| 135 | bool setTransparentRegionHint(const Region& transparent); |
| 136 | bool setFlags(uint8_t flags, uint8_t mask); |
| 137 | bool setCrop(const Rect& crop); |
| 138 | bool setLayerStack(uint32_t layerStack); |
| 139 | |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 140 | uint32_t getTransactionFlags(uint32_t flags); |
| 141 | uint32_t setTransactionFlags(uint32_t flags); |
| 142 | |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 143 | void computeGeometry(const sp<const DisplayDevice>& hw, Mesh& mesh, |
| 144 | bool useIdentityTransform) const; |
Michael Lentine | 6c925ed | 2014-09-26 17:55:01 -0700 | [diff] [blame] | 145 | Rect computeBounds(const Region& activeTransparentRegion) const; |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 146 | Rect computeBounds() const; |
| 147 | |
Mathias Agopian | 4d9b822 | 2013-03-12 17:11:48 -0700 | [diff] [blame] | 148 | sp<IBinder> getHandle(); |
Dan Stoza | b9b0883 | 2014-03-13 11:55:57 -0700 | [diff] [blame] | 149 | sp<IGraphicBufferProducer> getProducer() const; |
Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 150 | const String8& getName() const; |
Mathias Agopian | 4d9b822 | 2013-03-12 17:11:48 -0700 | [diff] [blame] | 151 | |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 152 | // ----------------------------------------------------------------------- |
Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 153 | // Virtuals |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 154 | |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 155 | virtual const char* getTypeId() const { return "Layer"; } |
| 156 | |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 157 | /* |
| 158 | * isOpaque - true if this surface is opaque |
Andy McFadden | 4125a4f | 2014-01-29 17:17:11 -0800 | [diff] [blame] | 159 | * |
| 160 | * This takes into account the buffer format (i.e. whether or not the |
| 161 | * pixel format includes an alpha channel) and the "opaque" flag set |
| 162 | * on the layer. It does not examine the current plane alpha value. |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 163 | */ |
Andy McFadden | 4125a4f | 2014-01-29 17:17:11 -0800 | [diff] [blame] | 164 | virtual bool isOpaque(const Layer::State& s) const; |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 165 | |
| 166 | /* |
| 167 | * isSecure - true if this surface is secure, that is if it prevents |
| 168 | * screenshots or VNC servers. |
| 169 | */ |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 170 | virtual bool isSecure() const { return mSecure; } |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 171 | |
| 172 | /* |
| 173 | * isProtected - true if the layer may contain protected content in the |
| 174 | * GRALLOC_USAGE_PROTECTED sense. |
| 175 | */ |
Jamie Gennis | 7a4d0df | 2011-03-09 17:05:02 -0800 | [diff] [blame] | 176 | virtual bool isProtected() const; |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 177 | |
| 178 | /* |
| 179 | * isVisible - true if this layer is visible, false otherwise |
| 180 | */ |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 181 | virtual bool isVisible() const; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 182 | |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 183 | /* |
| 184 | * isFixedSize - true if content has a fixed size |
| 185 | */ |
| 186 | virtual bool isFixedSize() const; |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 187 | |
Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 188 | protected: |
| 189 | /* |
| 190 | * onDraw - draws the surface. |
| 191 | */ |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 192 | virtual void onDraw(const sp<const DisplayDevice>& hw, const Region& clip, |
| 193 | bool useIdentityTransform) const; |
Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 194 | |
| 195 | public: |
| 196 | // ----------------------------------------------------------------------- |
| 197 | |
| 198 | void setGeometry(const sp<const DisplayDevice>& hw, |
| 199 | HWComposer::HWCLayerInterface& layer); |
| 200 | void setPerFrameData(const sp<const DisplayDevice>& hw, |
| 201 | HWComposer::HWCLayerInterface& layer); |
| 202 | void setAcquireFence(const sp<const DisplayDevice>& hw, |
| 203 | HWComposer::HWCLayerInterface& layer); |
| 204 | |
Riley Andrews | 03414a1 | 2014-07-01 14:22:59 -0700 | [diff] [blame] | 205 | Rect getPosition(const sp<const DisplayDevice>& hw); |
| 206 | |
Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 207 | /* |
| 208 | * called after page-flip |
| 209 | */ |
| 210 | void onLayerDisplayed(const sp<const DisplayDevice>& hw, |
| 211 | HWComposer::HWCLayerInterface* layer); |
| 212 | |
| 213 | /* |
| 214 | * called before composition. |
| 215 | * returns true if the layer has pending updates. |
| 216 | */ |
| 217 | bool onPreComposition(); |
| 218 | |
| 219 | /* |
| 220 | * called after composition. |
| 221 | */ |
| 222 | void onPostComposition(); |
| 223 | |
| 224 | /* |
| 225 | * draw - performs some global clipping optimizations |
| 226 | * and calls onDraw(). |
| 227 | */ |
| 228 | void draw(const sp<const DisplayDevice>& hw, const Region& clip) const; |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 229 | void draw(const sp<const DisplayDevice>& hw, bool useIdentityTransform) const; |
| 230 | void draw(const sp<const DisplayDevice>& hw) const; |
Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 231 | |
| 232 | /* |
| 233 | * doTransaction - process the transaction. This is a good place to figure |
| 234 | * out which attributes of the surface have changed. |
| 235 | */ |
| 236 | uint32_t doTransaction(uint32_t transactionFlags); |
| 237 | |
| 238 | /* |
| 239 | * setVisibleRegion - called to set the new visible region. This gives |
| 240 | * a chance to update the new visible region or record the fact it changed. |
| 241 | */ |
| 242 | void setVisibleRegion(const Region& visibleRegion); |
| 243 | |
| 244 | /* |
| 245 | * setCoveredRegion - called when the covered region changes. The covered |
| 246 | * region corresponds to any area of the surface that is covered |
| 247 | * (transparently or not) by another surface. |
| 248 | */ |
| 249 | void setCoveredRegion(const Region& coveredRegion); |
| 250 | |
| 251 | /* |
| 252 | * setVisibleNonTransparentRegion - called when the visible and |
| 253 | * non-transparent region changes. |
| 254 | */ |
| 255 | void setVisibleNonTransparentRegion(const Region& |
| 256 | visibleNonTransparentRegion); |
| 257 | |
| 258 | /* |
| 259 | * latchBuffer - called each time the screen is redrawn and returns whether |
| 260 | * the visible regions need to be recomputed (this is a fairly heavy |
| 261 | * operation, so this should be set only if needed). Typically this is used |
| 262 | * to figure out if the content or size of a surface has changed. |
| 263 | */ |
| 264 | Region latchBuffer(bool& recomputeVisibleRegions); |
| 265 | |
Riley Andrews | 03414a1 | 2014-07-01 14:22:59 -0700 | [diff] [blame] | 266 | bool isPotentialCursor() const { return mPotentialCursor;} |
| 267 | |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 268 | /* |
| 269 | * called with the state lock when the surface is removed from the |
| 270 | * current list |
| 271 | */ |
Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 272 | void onRemoved(); |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 273 | |
| 274 | |
Andy McFadden | bf974ab | 2012-12-04 16:51:15 -0800 | [diff] [blame] | 275 | // Updates the transform hint in our SurfaceFlingerConsumer to match |
Mathias Agopian | 8430095 | 2012-11-21 16:02:13 -0800 | [diff] [blame] | 276 | // the current orientation of the display device. |
Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 277 | void updateTransformHint(const sp<const DisplayDevice>& hw) const; |
Andy McFadden | 6905205 | 2012-09-14 16:10:11 -0700 | [diff] [blame] | 278 | |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 279 | /* |
| 280 | * returns the rectangle that crops the content of the layer and scales it |
| 281 | * to the layer's size. |
| 282 | */ |
Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 283 | Rect getContentCrop() const; |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 284 | |
Eric Penner | 51c59cd | 2014-07-28 19:51:58 -0700 | [diff] [blame] | 285 | /* |
| 286 | * Returns if a frame is queued. |
| 287 | */ |
chenhg | 0ea1cb9 | 2014-09-23 10:52:25 +0800 | [diff] [blame] | 288 | bool hasQueuedFrame() const { return mQueuedFrames > 0 || mSidebandStreamChanged; } |
Eric Penner | 51c59cd | 2014-07-28 19:51:58 -0700 | [diff] [blame] | 289 | |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 290 | // ----------------------------------------------------------------------- |
| 291 | |
| 292 | void clearWithOpenGL(const sp<const DisplayDevice>& hw, const Region& clip) const; |
| 293 | void setFiltering(bool filtering); |
| 294 | bool getFiltering() const; |
| 295 | |
| 296 | // only for debugging |
| 297 | inline const sp<GraphicBuffer>& getActiveBuffer() const { return mActiveBuffer; } |
| 298 | |
Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 299 | inline const State& getDrawingState() const { return mDrawingState; } |
| 300 | inline const State& getCurrentState() const { return mCurrentState; } |
| 301 | inline State& getCurrentState() { return mCurrentState; } |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 302 | |
| 303 | |
| 304 | /* always call base class first */ |
Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 305 | void dump(String8& result, Colorizer& colorizer) const; |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 306 | void dumpFrameStats(String8& result) const; |
| 307 | void clearFrameStats(); |
Jamie Gennis | 6547ff4 | 2013-07-16 20:12:42 -0700 | [diff] [blame] | 308 | void logFrameStats(); |
Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 309 | void getFrameStats(FrameStats* outStats) const; |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 310 | |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 311 | protected: |
| 312 | // constant |
| 313 | sp<SurfaceFlinger> mFlinger; |
| 314 | |
| 315 | virtual void onFirstRef(); |
| 316 | |
| 317 | /* |
| 318 | * Trivial class, used to ensure that mFlinger->onLayerDestroyed(mLayer) |
| 319 | * is called. |
| 320 | */ |
| 321 | class LayerCleaner { |
| 322 | sp<SurfaceFlinger> mFlinger; |
| 323 | wp<Layer> mLayer; |
| 324 | protected: |
| 325 | ~LayerCleaner(); |
| 326 | public: |
| 327 | LayerCleaner(const sp<SurfaceFlinger>& flinger, const sp<Layer>& layer); |
| 328 | }; |
| 329 | |
Mathias Agopian | 2a9fc49 | 2013-03-01 13:42:57 -0800 | [diff] [blame] | 330 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 331 | private: |
Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 332 | // Interface implementation for SurfaceFlingerConsumer::ContentsChangedListener |
Dan Stoza | 8dc5539 | 2014-11-04 11:37:46 -0800 | [diff] [blame^] | 333 | virtual void onFrameAvailable(const BufferItem& item); |
Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 334 | virtual void onSidebandStreamChanged(); |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 335 | |
Mathias Agopian | 1eae0ee | 2013-06-05 16:59:15 -0700 | [diff] [blame] | 336 | void commitTransaction(); |
| 337 | |
| 338 | // needsLinearFiltering - true if this surface's state requires filtering |
| 339 | bool needsFiltering(const sp<const DisplayDevice>& hw) const; |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 340 | |
Mathias Agopian | 3330b20 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 341 | uint32_t getEffectiveUsage(uint32_t usage) const; |
Mathias Agopian | 6b44267 | 2013-07-09 21:24:52 -0700 | [diff] [blame] | 342 | FloatRect computeCrop(const sp<const DisplayDevice>& hw) const; |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 343 | bool isCropped() const; |
| 344 | static bool getOpacityForFormat(uint32_t format); |
Mathias Agopian | 0aa758d | 2009-04-22 15:23:34 -0700 | [diff] [blame] | 345 | |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 346 | // drawing |
| 347 | void clearWithOpenGL(const sp<const DisplayDevice>& hw, const Region& clip, |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 348 | float r, float g, float b, float alpha) const; |
Dan Stoza | c701401 | 2014-02-14 15:03:43 -0800 | [diff] [blame] | 349 | void drawWithOpenGL(const sp<const DisplayDevice>& hw, const Region& clip, |
| 350 | bool useIdentityTransform) const; |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 351 | |
Ruben Brunk | 1681d95 | 2014-06-27 15:51:55 -0700 | [diff] [blame] | 352 | // Temporary - Used only for LEGACY camera mode. |
| 353 | uint32_t getProducerStickyTransform() const; |
| 354 | |
Igor Murashkin | a4a3149 | 2012-10-29 13:36:11 -0700 | [diff] [blame] | 355 | |
Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 356 | // ----------------------------------------------------------------------- |
| 357 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 358 | // constants |
Andy McFadden | bf974ab | 2012-12-04 16:51:15 -0800 | [diff] [blame] | 359 | sp<SurfaceFlingerConsumer> mSurfaceFlingerConsumer; |
Dan Stoza | b9b0883 | 2014-03-13 11:55:57 -0700 | [diff] [blame] | 360 | sp<IGraphicBufferProducer> mProducer; |
Andy McFadden | 4df87bd | 2014-04-21 18:08:54 -0700 | [diff] [blame] | 361 | uint32_t mTextureName; // from GLES |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 362 | bool mPremultipliedAlpha; |
| 363 | String8 mName; |
| 364 | mutable bool mDebug; |
| 365 | PixelFormat mFormat; |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 366 | |
| 367 | // these are protected by an external lock |
| 368 | State mCurrentState; |
| 369 | State mDrawingState; |
| 370 | volatile int32_t mTransactionFlags; |
Mathias Agopian | d606de6 | 2010-05-10 20:06:11 -0700 | [diff] [blame] | 371 | |
Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 372 | // thread-safe |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 373 | volatile int32_t mQueuedFrames; |
Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 374 | volatile int32_t mSidebandStreamChanged; // used like an atomic boolean |
Jamie Gennis | 4b0eba9 | 2013-02-05 13:30:24 -0800 | [diff] [blame] | 375 | FrameTracker mFrameTracker; |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 376 | |
| 377 | // main thread |
| 378 | sp<GraphicBuffer> mActiveBuffer; |
Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 379 | sp<NativeHandle> mSidebandStream; |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 380 | Rect mCurrentCrop; |
| 381 | uint32_t mCurrentTransform; |
Mathias Agopian | 933389f | 2011-07-18 16:15:08 -0700 | [diff] [blame] | 382 | uint32_t mCurrentScalingMode; |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 383 | bool mCurrentOpacity; |
Mathias Agopian | 4d143ee | 2012-02-23 20:05:39 -0800 | [diff] [blame] | 384 | bool mRefreshPending; |
Jamie Gennis | e8696a4 | 2012-01-15 18:54:57 -0800 | [diff] [blame] | 385 | bool mFrameLatencyNeeded; |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 386 | // Whether filtering is forced on or not |
| 387 | bool mFiltering; |
| 388 | // Whether filtering is needed b/c of the drawingstate |
| 389 | bool mNeedsFiltering; |
Mathias Agopian | 5cdc899 | 2013-08-13 20:51:23 -0700 | [diff] [blame] | 390 | // The mesh used to draw the layer in GLES composition mode |
| 391 | mutable Mesh mMesh; |
Andy McFadden | 4df87bd | 2014-04-21 18:08:54 -0700 | [diff] [blame] | 392 | // The texture used to draw the layer in GLES composition mode |
Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 393 | mutable Texture mTexture; |
Mathias Agopian | d606de6 | 2010-05-10 20:06:11 -0700 | [diff] [blame] | 394 | |
Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 395 | // page-flip thread (currently main thread) |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 396 | bool mSecure; // no screenshots |
Glenn Kasten | 16f0453 | 2011-01-19 15:27:27 -0800 | [diff] [blame] | 397 | bool mProtectedByApp; // application requires protected path to external sink |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 398 | |
| 399 | // protected by mLock |
| 400 | mutable Mutex mLock; |
Mathias Agopian | 4d9b822 | 2013-03-12 17:11:48 -0700 | [diff] [blame] | 401 | // Set to true once we've returned this surface's handle |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 402 | mutable bool mHasSurface; |
| 403 | const wp<Client> mClientRef; |
Riley Andrews | 03414a1 | 2014-07-01 14:22:59 -0700 | [diff] [blame] | 404 | |
| 405 | // This layer can be a cursor on some displays. |
| 406 | bool mPotentialCursor; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 407 | }; |
| 408 | |
| 409 | // --------------------------------------------------------------------------- |
| 410 | |
| 411 | }; // namespace android |
| 412 | |
| 413 | #endif // ANDROID_LAYER_H |