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_BASE_H |
| 18 | #define ANDROID_LAYER_BASE_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
Mathias Agopian | 1fed11c | 2009-06-23 18:08:22 -0700 | [diff] [blame] | 23 | #include <EGL/egl.h> |
| 24 | #include <EGL/eglext.h> |
Mathias Agopian | eda6540 | 2010-02-22 03:15:57 -0800 | [diff] [blame] | 25 | #include <GLES/gl.h> |
Mathias Agopian | 1fed11c | 2009-06-23 18:08:22 -0700 | [diff] [blame] | 26 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 27 | #include <utils/RefBase.h> |
Mathias Agopian | a491260 | 2012-07-12 14:25:33 -0700 | [diff] [blame] | 28 | #include <utils/String8.h> |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 29 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | #include <ui/Region.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | |
Mathias Agopian | 90ac799 | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 32 | #include <gui/ISurfaceComposerClient.h> |
Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 33 | |
Mathias Agopian | 90ac799 | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 34 | #include <private/gui/LayerState.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | |
| 36 | #include "Transform.h" |
Mathias Agopian | 8630320 | 2012-07-24 22:46:10 -0700 | [diff] [blame] | 37 | #include "DisplayHardware/HWComposer.h" |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | |
| 39 | namespace android { |
| 40 | |
| 41 | // --------------------------------------------------------------------------- |
| 42 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | class Client; |
Mathias Agopian | 0f2f5ff | 2012-07-31 23:09:07 -0700 | [diff] [blame] | 44 | class DisplayDevice; |
Mathias Agopian | 3330b20 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 45 | class GraphicBuffer; |
Mathias Agopian | 670a899 | 2011-09-20 15:13:14 -0700 | [diff] [blame] | 46 | class Layer; |
Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 47 | class LayerBaseClient; |
Mathias Agopian | 3330b20 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 48 | class SurfaceFlinger; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | |
| 50 | // --------------------------------------------------------------------------- |
| 51 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 52 | class LayerBase : public RefBase |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | { |
Mathias Agopian | f6679fc | 2010-08-10 18:09:09 -0700 | [diff] [blame] | 54 | static int32_t sSequence; |
| 55 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 56 | public: |
Mathias Agopian | 3ee454a | 2012-08-27 16:28:24 -0700 | [diff] [blame^] | 57 | LayerBase(SurfaceFlinger* flinger); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 58 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | mutable bool contentDirty; |
Mathias Agopian | 4fec873 | 2012-06-29 14:12:52 -0700 | [diff] [blame] | 60 | // regions below are in window-manager space |
| 61 | Region visibleRegion; |
| 62 | Region coveredRegion; |
Mathias Agopian | f6679fc | 2010-08-10 18:09:09 -0700 | [diff] [blame] | 63 | int32_t sequence; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 64 | |
Mathias Agopian | 93ffb86 | 2012-05-16 17:07:49 -0700 | [diff] [blame] | 65 | struct Geometry { |
Mathias Agopian | b30c415 | 2012-05-16 18:21:32 -0700 | [diff] [blame] | 66 | uint32_t w; |
| 67 | uint32_t h; |
| 68 | Rect crop; |
| 69 | inline bool operator == (const Geometry& rhs) const { |
| 70 | return (w==rhs.w && h==rhs.h && crop==rhs.crop); |
| 71 | } |
| 72 | inline bool operator != (const Geometry& rhs) const { |
| 73 | return !operator == (rhs); |
| 74 | } |
Mathias Agopian | 93ffb86 | 2012-05-16 17:07:49 -0700 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | struct State { |
| 78 | Geometry active; |
| 79 | Geometry requested; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | uint32_t z; |
Mathias Agopian | 8785578 | 2012-07-24 21:41:09 -0700 | [diff] [blame] | 81 | uint32_t layerStack; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 82 | uint8_t alpha; |
| 83 | uint8_t flags; |
| 84 | uint8_t reserved[2]; |
| 85 | int32_t sequence; // changes when visible regions can change |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | Transform transform; |
| 87 | Region transparentRegion; |
| 88 | }; |
| 89 | |
Mathias Agopian | 4fec873 | 2012-06-29 14:12:52 -0700 | [diff] [blame] | 90 | class LayerMesh { |
| 91 | friend class LayerBase; |
| 92 | GLfloat mVertices[4][2]; |
| 93 | size_t mNumVertices; |
| 94 | public: |
| 95 | LayerMesh() : mNumVertices(4) { } |
| 96 | GLfloat const* getVertices() const { |
| 97 | return &mVertices[0][0]; |
| 98 | } |
| 99 | size_t getVertexCount() const { |
| 100 | return mNumVertices; |
| 101 | } |
| 102 | }; |
| 103 | |
Jamie Gennis | a249f2d | 2011-09-16 17:31:54 -0700 | [diff] [blame] | 104 | virtual void setName(const String8& name); |
Mathias Agopian | d129659 | 2010-03-09 19:17:47 -0800 | [diff] [blame] | 105 | String8 getName() const; |
| 106 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 107 | // modify current state |
Mathias Agopian | 41b6aab | 2011-08-30 18:51:54 -0700 | [diff] [blame] | 108 | bool setPosition(float x, float y); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 109 | bool setLayer(uint32_t z); |
| 110 | bool setSize(uint32_t w, uint32_t h); |
| 111 | bool setAlpha(uint8_t alpha); |
| 112 | bool setMatrix(const layer_state_t::matrix22_t& matrix); |
| 113 | bool setTransparentRegionHint(const Region& opaque); |
| 114 | bool setFlags(uint8_t flags, uint8_t mask); |
Jamie Gennis | f15a83f | 2012-05-10 20:43:55 -0700 | [diff] [blame] | 115 | bool setCrop(const Rect& crop); |
Mathias Agopian | 8785578 | 2012-07-24 21:41:09 -0700 | [diff] [blame] | 116 | bool setLayerStack(uint32_t layerStack); |
| 117 | |
Mathias Agopian | ba6be54 | 2009-09-29 22:32:36 -0700 | [diff] [blame] | 118 | void commitTransaction(); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 119 | bool requestTransaction(); |
| 120 | void forceVisibilityTransaction(); |
| 121 | |
| 122 | uint32_t getTransactionFlags(uint32_t flags); |
| 123 | uint32_t setTransactionFlags(uint32_t flags); |
Mathias Agopian | 4fec873 | 2012-06-29 14:12:52 -0700 | [diff] [blame] | 124 | |
Mathias Agopian | 4297734 | 2012-08-05 00:40:46 -0700 | [diff] [blame] | 125 | void computeGeometry(const sp<const DisplayDevice>& hw, LayerMesh* mesh) const; |
Mathias Agopian | 4fec873 | 2012-06-29 14:12:52 -0700 | [diff] [blame] | 126 | Rect computeBounds() const; |
| 127 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 128 | |
Mathias Agopian | 921e6ac | 2012-07-23 23:11:29 -0700 | [diff] [blame] | 129 | virtual sp<LayerBaseClient> getLayerBaseClient() const; |
| 130 | virtual sp<Layer> getLayer() const; |
Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 131 | |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 132 | virtual const char* getTypeId() const { return "LayerBase"; } |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 133 | |
Mathias Agopian | 4297734 | 2012-08-05 00:40:46 -0700 | [diff] [blame] | 134 | virtual void setGeometry(const sp<const DisplayDevice>& hw, |
Mathias Agopian | 4fec873 | 2012-06-29 14:12:52 -0700 | [diff] [blame] | 135 | HWComposer::HWCLayerInterface& layer); |
Mathias Agopian | 4297734 | 2012-08-05 00:40:46 -0700 | [diff] [blame] | 136 | virtual void setPerFrameData(const sp<const DisplayDevice>& hw, |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 137 | HWComposer::HWCLayerInterface& layer); |
Mathias Agopian | 4297734 | 2012-08-05 00:40:46 -0700 | [diff] [blame] | 138 | virtual void setAcquireFence(const sp<const DisplayDevice>& hw, |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 139 | HWComposer::HWCLayerInterface& layer); |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 140 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 141 | /** |
| 142 | * draw - performs some global clipping optimizations |
| 143 | * and calls onDraw(). |
| 144 | * Typically this method is not overridden, instead implement onDraw() |
| 145 | * to perform the actual drawing. |
| 146 | */ |
Mathias Agopian | 4297734 | 2012-08-05 00:40:46 -0700 | [diff] [blame] | 147 | virtual void draw(const sp<const DisplayDevice>& hw, const Region& clip) const; |
| 148 | virtual void draw(const sp<const DisplayDevice>& hw); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 149 | |
| 150 | /** |
| 151 | * onDraw - draws the surface. |
| 152 | */ |
Mathias Agopian | 4297734 | 2012-08-05 00:40:46 -0700 | [diff] [blame] | 153 | virtual void onDraw(const sp<const DisplayDevice>& hw, const Region& clip) const = 0; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 154 | |
| 155 | /** |
| 156 | * initStates - called just after construction |
| 157 | */ |
| 158 | virtual void initStates(uint32_t w, uint32_t h, uint32_t flags); |
| 159 | |
| 160 | /** |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 161 | * doTransaction - process the transaction. This is a good place to figure |
| 162 | * out which attributes of the surface have changed. |
| 163 | */ |
| 164 | virtual uint32_t doTransaction(uint32_t transactionFlags); |
| 165 | |
| 166 | /** |
| 167 | * setVisibleRegion - called to set the new visible region. This gives |
| 168 | * a chance to update the new visible region or record the fact it changed. |
| 169 | */ |
| 170 | virtual void setVisibleRegion(const Region& visibleRegion); |
| 171 | |
| 172 | /** |
| 173 | * setCoveredRegion - called when the covered region changes. The covered |
Mathias Agopian | ab02873 | 2010-03-16 16:41:46 -0700 | [diff] [blame] | 174 | * region corresponds to any area of the surface that is covered |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 175 | * (transparently or not) by another surface. |
| 176 | */ |
| 177 | virtual void setCoveredRegion(const Region& coveredRegion); |
Mathias Agopian | ab02873 | 2010-03-16 16:41:46 -0700 | [diff] [blame] | 178 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 179 | /** |
Mathias Agopian | 4fec873 | 2012-06-29 14:12:52 -0700 | [diff] [blame] | 180 | * latchBuffer - called each time the screen is redrawn and returns whether |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 181 | * the visible regions need to be recomputed (this is a fairly heavy |
| 182 | * operation, so this should be set only if needed). Typically this is used |
| 183 | * to figure out if the content or size of a surface has changed. |
| 184 | */ |
Mathias Agopian | 4fec873 | 2012-06-29 14:12:52 -0700 | [diff] [blame] | 185 | virtual Region latchBuffer(bool& recomputeVisibleRegions); |
| 186 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 187 | /** |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 188 | * isOpaque - true if this surface is opaque |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 189 | */ |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 190 | virtual bool isOpaque() const { return true; } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 191 | |
| 192 | /** |
Mathias Agopian | 401c257 | 2009-09-23 19:16:27 -0700 | [diff] [blame] | 193 | * needsDithering - true if this surface needs dithering |
| 194 | */ |
| 195 | virtual bool needsDithering() const { return false; } |
| 196 | |
| 197 | /** |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 198 | * needsLinearFiltering - true if this surface's state requires filtering |
Mathias Agopian | a7f6692 | 2010-05-26 22:08:52 -0700 | [diff] [blame] | 199 | */ |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 200 | virtual bool needsFiltering() const { return mNeedsFiltering; } |
Mathias Agopian | a7f6692 | 2010-05-26 22:08:52 -0700 | [diff] [blame] | 201 | |
| 202 | /** |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 203 | * isSecure - true if this surface is secure, that is if it prevents |
Mathias Agopian | 9a11206 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 204 | * screenshots or VNC servers. |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 205 | */ |
| 206 | virtual bool isSecure() const { return false; } |
| 207 | |
Glenn Kasten | 16f0453 | 2011-01-19 15:27:27 -0800 | [diff] [blame] | 208 | /** |
Jamie Gennis | 7a4d0df | 2011-03-09 17:05:02 -0800 | [diff] [blame] | 209 | * isProtected - true if the layer may contain protected content in the |
| 210 | * GRALLOC_USAGE_PROTECTED sense. |
Glenn Kasten | 16f0453 | 2011-01-19 15:27:27 -0800 | [diff] [blame] | 211 | */ |
Jamie Gennis | 7a4d0df | 2011-03-09 17:05:02 -0800 | [diff] [blame] | 212 | virtual bool isProtected() const { return false; } |
Glenn Kasten | 16f0453 | 2011-01-19 15:27:27 -0800 | [diff] [blame] | 213 | |
Mathias Agopian | 0b3ad46 | 2009-10-02 18:12:30 -0700 | [diff] [blame] | 214 | /** called with the state lock when the surface is removed from the |
| 215 | * current list */ |
Mathias Agopian | 99ce5cd | 2012-01-31 18:24:27 -0800 | [diff] [blame] | 216 | virtual void onRemoved() { } |
Jamie Gennis | e8696a4 | 2012-01-15 18:54:57 -0800 | [diff] [blame] | 217 | |
Mathias Agopian | 99ce5cd | 2012-01-31 18:24:27 -0800 | [diff] [blame] | 218 | /** called after page-flip |
| 219 | */ |
Mathias Agopian | 4297734 | 2012-08-05 00:40:46 -0700 | [diff] [blame] | 220 | virtual void onLayerDisplayed(const sp<const DisplayDevice>& hw, |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 221 | HWComposer::HWCLayerInterface* layer) { } |
Mathias Agopian | 99ce5cd | 2012-01-31 18:24:27 -0800 | [diff] [blame] | 222 | |
| 223 | /** called before composition. |
| 224 | * returns true if the layer has pending updates. |
| 225 | */ |
| 226 | virtual bool onPreComposition() { return false; } |
Jamie Gennis | e8696a4 | 2012-01-15 18:54:57 -0800 | [diff] [blame] | 227 | |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 228 | /** called before composition. |
| 229 | */ |
| 230 | virtual void onPostComposition() { } |
| 231 | |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 232 | /** always call base class first */ |
| 233 | virtual void dump(String8& result, char* scratch, size_t size) const; |
Mathias Agopian | 48b888a | 2011-01-19 16:15:53 -0800 | [diff] [blame] | 234 | virtual void shortDump(String8& result, char* scratch, size_t size) const; |
Mathias Agopian | 82d7ab6 | 2012-01-19 18:34:40 -0800 | [diff] [blame] | 235 | virtual void dumpStats(String8& result, char* buffer, size_t SIZE) const; |
Mathias Agopian | 25e66fc | 2012-01-28 22:31:55 -0800 | [diff] [blame] | 236 | virtual void clearStats(); |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 237 | |
| 238 | |
Mathias Agopian | 9a11206 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 239 | enum { // flags for doTransaction() |
Mathias Agopian | 05cec9d | 2012-05-23 14:35:49 -0700 | [diff] [blame] | 240 | eDontUpdateGeometryState = 0x00000001, |
| 241 | eVisibleRegion = 0x00000002, |
Mathias Agopian | 9a11206 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 242 | }; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 243 | |
| 244 | |
| 245 | inline const State& drawingState() const { return mDrawingState; } |
| 246 | inline const State& currentState() const { return mCurrentState; } |
| 247 | inline State& currentState() { return mCurrentState; } |
| 248 | |
Mathias Agopian | 4297734 | 2012-08-05 00:40:46 -0700 | [diff] [blame] | 249 | void clearWithOpenGL(const sp<const DisplayDevice>& hw, const Region& clip) const; |
Mathias Agopian | a2f4e56 | 2012-04-15 23:34:59 -0700 | [diff] [blame] | 250 | |
Mathias Agopian | fcb239d | 2012-08-02 16:01:34 -0700 | [diff] [blame] | 251 | void setFiltering(bool filtering); |
| 252 | bool getFiltering() const; |
| 253 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 254 | protected: |
Mathias Agopian | 4297734 | 2012-08-05 00:40:46 -0700 | [diff] [blame] | 255 | void clearWithOpenGL(const sp<const DisplayDevice>& hw, const Region& clip, |
Mathias Agopian | 1b03149 | 2012-06-20 17:51:20 -0700 | [diff] [blame] | 256 | GLclampf r, GLclampf g, GLclampf b, GLclampf alpha) const; |
Mathias Agopian | 4297734 | 2012-08-05 00:40:46 -0700 | [diff] [blame] | 257 | void drawWithOpenGL(const sp<const DisplayDevice>& hw, const Region& clip) const; |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 258 | |
Mathias Agopian | 9a11206 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 259 | sp<SurfaceFlinger> mFlinger; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 260 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 261 | private: |
| 262 | // accessed only in the main thread |
| 263 | // Whether filtering is forced on or not |
| 264 | bool mFiltering; |
Mathias Agopian | b661d66 | 2010-08-19 17:01:19 -0700 | [diff] [blame] | 265 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 266 | // Whether filtering is needed b/c of the drawingstate |
Mathias Agopian | a7f6692 | 2010-05-26 22:08:52 -0700 | [diff] [blame] | 267 | bool mNeedsFiltering; |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 268 | |
| 269 | protected: |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 270 | // these are protected by an external lock |
| 271 | State mCurrentState; |
| 272 | State mDrawingState; |
| 273 | volatile int32_t mTransactionFlags; |
| 274 | |
| 275 | // don't change, don't need a lock |
| 276 | bool mPremultipliedAlpha; |
Mathias Agopian | d129659 | 2010-03-09 19:17:47 -0800 | [diff] [blame] | 277 | String8 mName; |
| 278 | mutable bool mDebug; |
| 279 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 280 | |
Mathias Agopian | ca4d360 | 2011-05-19 15:38:14 -0700 | [diff] [blame] | 281 | public: |
| 282 | // called from class SurfaceFlinger |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 283 | virtual ~LayerBase(); |
| 284 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 285 | private: |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 286 | LayerBase(const LayerBase& rhs); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 287 | }; |
| 288 | |
| 289 | |
| 290 | // --------------------------------------------------------------------------- |
| 291 | |
| 292 | class LayerBaseClient : public LayerBase |
| 293 | { |
| 294 | public: |
Mathias Agopian | 3ee454a | 2012-08-27 16:28:24 -0700 | [diff] [blame^] | 295 | LayerBaseClient(SurfaceFlinger* flinger, const sp<Client>& client); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 296 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 297 | virtual ~LayerBaseClient(); |
| 298 | |
| 299 | sp<ISurface> getSurface(); |
Mathias Agopian | 0d15612 | 2011-01-25 20:17:45 -0800 | [diff] [blame] | 300 | wp<IBinder> getSurfaceBinder() const; |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 301 | virtual wp<IBinder> getSurfaceTextureBinder() const; |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 302 | |
Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 303 | virtual sp<LayerBaseClient> getLayerBaseClient() const { |
| 304 | return const_cast<LayerBaseClient*>(this); } |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 305 | |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 306 | virtual const char* getTypeId() const { return "LayerBaseClient"; } |
Mathias Agopian | 285dbde | 2010-03-01 16:09:43 -0800 | [diff] [blame] | 307 | |
Mathias Agopian | 96f0819 | 2010-06-02 23:28:45 -0700 | [diff] [blame] | 308 | uint32_t getIdentity() const { return mIdentity; } |
| 309 | |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 310 | protected: |
| 311 | virtual void dump(String8& result, char* scratch, size_t size) const; |
Mathias Agopian | 48b888a | 2011-01-19 16:15:53 -0800 | [diff] [blame] | 312 | virtual void shortDump(String8& result, char* scratch, size_t size) const; |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 313 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 314 | class LayerCleaner { |
| 315 | sp<SurfaceFlinger> mFlinger; |
| 316 | wp<LayerBaseClient> mLayer; |
| 317 | protected: |
| 318 | ~LayerCleaner(); |
| 319 | public: |
| 320 | LayerCleaner(const sp<SurfaceFlinger>& flinger, |
| 321 | const sp<LayerBaseClient>& layer); |
| 322 | }; |
| 323 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 324 | private: |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 325 | virtual sp<ISurface> createSurface(); |
| 326 | |
Mathias Agopian | 96f0819 | 2010-06-02 23:28:45 -0700 | [diff] [blame] | 327 | mutable Mutex mLock; |
Mathias Agopian | a1f47b9 | 2011-02-15 19:01:06 -0800 | [diff] [blame] | 328 | mutable bool mHasSurface; |
Mathias Agopian | 0d15612 | 2011-01-25 20:17:45 -0800 | [diff] [blame] | 329 | wp<IBinder> mClientSurfaceBinder; |
Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 330 | const wp<Client> mClientRef; |
Mathias Agopian | 2e12324 | 2009-06-23 20:06:46 -0700 | [diff] [blame] | 331 | // only read |
Mathias Agopian | 96f0819 | 2010-06-02 23:28:45 -0700 | [diff] [blame] | 332 | const uint32_t mIdentity; |
| 333 | static int32_t sIdentity; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 334 | }; |
| 335 | |
| 336 | // --------------------------------------------------------------------------- |
| 337 | |
| 338 | }; // namespace android |
| 339 | |
| 340 | #endif // ANDROID_LAYER_BASE_H |