The Android Open Source Project | 9066cfe | 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 | 999543b | 2009-06-23 18:08:22 -0700 | [diff] [blame] | 23 | #include <EGL/egl.h> |
| 24 | #include <EGL/eglext.h> |
Mathias Agopian | 8c20ca3 | 2010-02-22 03:15:57 -0800 | [diff] [blame] | 25 | #include <GLES/gl.h> |
Mathias Agopian | 999543b | 2009-06-23 18:08:22 -0700 | [diff] [blame] | 26 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 27 | #include <utils/RefBase.h> |
| 28 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | #include <ui/Region.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | |
Mathias Agopian | 770492c | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 31 | #include <surfaceflinger/ISurfaceComposerClient.h> |
Mathias Agopian | 000479f | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 32 | #include <private/surfaceflinger/LayerState.h> |
| 33 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | #include <pixelflinger/pixelflinger.h> |
| 35 | |
Mathias Agopian | e0d5f5b | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 36 | #include <hardware/hwcomposer.h> |
| 37 | |
Mathias Agopian | 0b38aa0 | 2010-12-07 23:41:55 -0800 | [diff] [blame] | 38 | #include "DisplayHardware/DisplayHardware.h" |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | #include "Transform.h" |
| 40 | |
| 41 | namespace android { |
| 42 | |
| 43 | // --------------------------------------------------------------------------- |
| 44 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 | class Client; |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 46 | class DisplayHardware; |
Mathias Agopian | 6950e42 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 47 | class GraphicBuffer; |
| 48 | class GraphicPlane; |
Mathias Agopian | 951c12e | 2011-09-20 15:13:14 -0700 | [diff] [blame] | 49 | class Layer; |
Mathias Agopian | 7623da4 | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 50 | class LayerBaseClient; |
Mathias Agopian | 6950e42 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 51 | class SurfaceFlinger; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | |
| 53 | // --------------------------------------------------------------------------- |
| 54 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 55 | class LayerBase : public RefBase |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 56 | { |
Mathias Agopian | 1efba9a | 2010-08-10 18:09:09 -0700 | [diff] [blame] | 57 | static int32_t sSequence; |
| 58 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | public: |
Mathias Agopian | 9bce873 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 60 | LayerBase(SurfaceFlinger* flinger, DisplayID display); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 62 | DisplayID dpy; |
| 63 | mutable bool contentDirty; |
| 64 | Region visibleRegionScreen; |
| 65 | Region transparentRegionScreen; |
| 66 | Region coveredRegionScreen; |
Mathias Agopian | 1efba9a | 2010-08-10 18:09:09 -0700 | [diff] [blame] | 67 | int32_t sequence; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 68 | |
| 69 | struct State { |
| 70 | uint32_t w; |
| 71 | uint32_t h; |
Mathias Agopian | e1b6f24 | 2009-09-29 22:39:22 -0700 | [diff] [blame] | 72 | uint32_t requested_w; |
| 73 | uint32_t requested_h; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | uint32_t z; |
| 75 | uint8_t alpha; |
| 76 | uint8_t flags; |
| 77 | uint8_t reserved[2]; |
| 78 | int32_t sequence; // changes when visible regions can change |
| 79 | uint32_t tint; |
| 80 | Transform transform; |
| 81 | Region transparentRegion; |
| 82 | }; |
| 83 | |
Jamie Gennis | 5b315da | 2011-09-16 17:31:54 -0700 | [diff] [blame] | 84 | virtual void setName(const String8& name); |
Mathias Agopian | 015b597 | 2010-03-09 19:17:47 -0800 | [diff] [blame] | 85 | String8 getName() const; |
| 86 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 87 | // modify current state |
Mathias Agopian | 34cb9f2a | 2011-08-30 18:51:54 -0700 | [diff] [blame] | 88 | bool setPosition(float x, float y); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 89 | bool setLayer(uint32_t z); |
| 90 | bool setSize(uint32_t w, uint32_t h); |
| 91 | bool setAlpha(uint8_t alpha); |
| 92 | bool setMatrix(const layer_state_t::matrix22_t& matrix); |
| 93 | bool setTransparentRegionHint(const Region& opaque); |
| 94 | bool setFlags(uint8_t flags, uint8_t mask); |
| 95 | |
Mathias Agopian | 8851617 | 2009-09-29 22:32:36 -0700 | [diff] [blame] | 96 | void commitTransaction(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 97 | bool requestTransaction(); |
| 98 | void forceVisibilityTransaction(); |
| 99 | |
| 100 | uint32_t getTransactionFlags(uint32_t flags); |
| 101 | uint32_t setTransactionFlags(uint32_t flags); |
| 102 | |
| 103 | Rect visibleBounds() const; |
| 104 | void drawRegion(const Region& reg) const; |
| 105 | |
| 106 | void invalidate(); |
Mathias Agopian | 015b597 | 2010-03-09 19:17:47 -0800 | [diff] [blame] | 107 | |
Mathias Agopian | 7623da4 | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 108 | virtual sp<LayerBaseClient> getLayerBaseClient() const { return 0; } |
Mathias Agopian | 951c12e | 2011-09-20 15:13:14 -0700 | [diff] [blame] | 109 | virtual sp<Layer> getLayer() const { return 0; } |
Mathias Agopian | 7623da4 | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 110 | |
Mathias Agopian | 9bce873 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 111 | virtual const char* getTypeId() const { return "LayerBase"; } |
Mathias Agopian | 9bce873 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 112 | |
Mathias Agopian | e0d5f5b | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 113 | virtual void setGeometry(hwc_layer_t* hwcl); |
Mathias Agopian | e0d5f5b | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 114 | virtual void setPerFrameData(hwc_layer_t* hwcl); |
Mathias Agopian | 4bacc9d | 2011-09-08 18:31:55 -0700 | [diff] [blame] | 115 | void setOverlay(bool inOverlay); |
| 116 | bool isOverlay() const; |
| 117 | |
Mathias Agopian | e0d5f5b | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 118 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 119 | /** |
| 120 | * draw - performs some global clipping optimizations |
| 121 | * and calls onDraw(). |
| 122 | * Typically this method is not overridden, instead implement onDraw() |
| 123 | * to perform the actual drawing. |
| 124 | */ |
| 125 | virtual void draw(const Region& clip) const; |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 126 | virtual void drawForSreenShot(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 127 | |
| 128 | /** |
| 129 | * onDraw - draws the surface. |
| 130 | */ |
| 131 | virtual void onDraw(const Region& clip) const = 0; |
| 132 | |
| 133 | /** |
| 134 | * initStates - called just after construction |
| 135 | */ |
| 136 | virtual void initStates(uint32_t w, uint32_t h, uint32_t flags); |
| 137 | |
| 138 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 139 | * doTransaction - process the transaction. This is a good place to figure |
| 140 | * out which attributes of the surface have changed. |
| 141 | */ |
| 142 | virtual uint32_t doTransaction(uint32_t transactionFlags); |
| 143 | |
| 144 | /** |
| 145 | * setVisibleRegion - called to set the new visible region. This gives |
| 146 | * a chance to update the new visible region or record the fact it changed. |
| 147 | */ |
| 148 | virtual void setVisibleRegion(const Region& visibleRegion); |
| 149 | |
| 150 | /** |
| 151 | * setCoveredRegion - called when the covered region changes. The covered |
Mathias Agopian | 9c041bb | 2010-03-16 16:41:46 -0700 | [diff] [blame] | 152 | * region corresponds to any area of the surface that is covered |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 153 | * (transparently or not) by another surface. |
| 154 | */ |
| 155 | virtual void setCoveredRegion(const Region& coveredRegion); |
Mathias Agopian | 9c041bb | 2010-03-16 16:41:46 -0700 | [diff] [blame] | 156 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 157 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 158 | * validateVisibility - cache a bunch of things |
| 159 | */ |
| 160 | virtual void validateVisibility(const Transform& globalTransform); |
| 161 | |
| 162 | /** |
| 163 | * lockPageFlip - called each time the screen is redrawn and returns whether |
| 164 | * the visible regions need to be recomputed (this is a fairly heavy |
| 165 | * operation, so this should be set only if needed). Typically this is used |
| 166 | * to figure out if the content or size of a surface has changed. |
| 167 | */ |
| 168 | virtual void lockPageFlip(bool& recomputeVisibleRegions); |
| 169 | |
| 170 | /** |
| 171 | * unlockPageFlip - called each time the screen is redrawn. updates the |
| 172 | * final dirty region wrt the planeTransform. |
| 173 | * At this point, all visible regions, surface position and size, etc... are |
| 174 | * correct. |
| 175 | */ |
| 176 | virtual void unlockPageFlip(const Transform& planeTransform, Region& outDirtyRegion); |
| 177 | |
| 178 | /** |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 179 | * isOpaque - true if this surface is opaque |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 180 | */ |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 181 | virtual bool isOpaque() const { return true; } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 182 | |
| 183 | /** |
Mathias Agopian | cc93476 | 2009-09-23 19:16:27 -0700 | [diff] [blame] | 184 | * needsDithering - true if this surface needs dithering |
| 185 | */ |
| 186 | virtual bool needsDithering() const { return false; } |
| 187 | |
| 188 | /** |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 189 | * needsLinearFiltering - true if this surface's state requires filtering |
Mathias Agopian | 9237703 | 2010-05-26 22:08:52 -0700 | [diff] [blame] | 190 | */ |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 191 | virtual bool needsFiltering() const { return mNeedsFiltering; } |
Mathias Agopian | 9237703 | 2010-05-26 22:08:52 -0700 | [diff] [blame] | 192 | |
| 193 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 194 | * isSecure - true if this surface is secure, that is if it prevents |
Mathias Agopian | 6cf0db2 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 195 | * screenshots or VNC servers. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 196 | */ |
| 197 | virtual bool isSecure() const { return false; } |
| 198 | |
Glenn Kasten | d6f5bde | 2011-01-19 15:27:27 -0800 | [diff] [blame] | 199 | /** |
Jamie Gennis | f72606c | 2011-03-09 17:05:02 -0800 | [diff] [blame] | 200 | * isProtected - true if the layer may contain protected content in the |
| 201 | * GRALLOC_USAGE_PROTECTED sense. |
Glenn Kasten | d6f5bde | 2011-01-19 15:27:27 -0800 | [diff] [blame] | 202 | */ |
Jamie Gennis | f72606c | 2011-03-09 17:05:02 -0800 | [diff] [blame] | 203 | virtual bool isProtected() const { return false; } |
Glenn Kasten | d6f5bde | 2011-01-19 15:27:27 -0800 | [diff] [blame] | 204 | |
Mathias Agopian | 0c4cec7 | 2009-10-02 18:12:30 -0700 | [diff] [blame] | 205 | /** called with the state lock when the surface is removed from the |
| 206 | * current list */ |
| 207 | virtual void onRemoved() { }; |
Mathias Agopian | 6cf0db2 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 208 | |
Mathias Agopian | 9bce873 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 209 | /** always call base class first */ |
| 210 | virtual void dump(String8& result, char* scratch, size_t size) const; |
Mathias Agopian | 06a61e2 | 2011-01-19 16:15:53 -0800 | [diff] [blame] | 211 | virtual void shortDump(String8& result, char* scratch, size_t size) const; |
Mathias Agopian | 9bce873 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 212 | |
| 213 | |
Mathias Agopian | 6cf0db2 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 214 | enum { // flags for doTransaction() |
| 215 | eVisibleRegion = 0x00000002, |
Mathias Agopian | 6cf0db2 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 216 | }; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 217 | |
| 218 | |
| 219 | inline const State& drawingState() const { return mDrawingState; } |
| 220 | inline const State& currentState() const { return mCurrentState; } |
| 221 | inline State& currentState() { return mCurrentState; } |
| 222 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 223 | int32_t getOrientation() const { return mOrientation; } |
Jamie Gennis | fd2429d | 2011-09-23 15:54:34 -0700 | [diff] [blame] | 224 | int32_t getPlaneOrientation() const { return mPlaneOrientation; } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 225 | |
| 226 | protected: |
| 227 | const GraphicPlane& graphicPlane(int dpy) const; |
| 228 | GraphicPlane& graphicPlane(int dpy); |
| 229 | |
Mathias Agopian | 0d3c006 | 2010-05-26 22:26:12 -0700 | [diff] [blame] | 230 | void clearWithOpenGL(const Region& clip, GLclampf r, GLclampf g, |
| 231 | GLclampf b, GLclampf alpha) const; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 232 | void clearWithOpenGL(const Region& clip) const; |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 233 | void drawWithOpenGL(const Region& clip) const; |
| 234 | |
| 235 | void setFiltering(bool filtering); |
| 236 | bool getFiltering() const; |
Mathias Agopian | e96aa3e | 2010-08-19 17:01:19 -0700 | [diff] [blame] | 237 | |
Mathias Agopian | 6cf0db2 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 238 | sp<SurfaceFlinger> mFlinger; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 239 | uint32_t mFlags; |
| 240 | |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 241 | private: |
| 242 | // accessed only in the main thread |
| 243 | // Whether filtering is forced on or not |
| 244 | bool mFiltering; |
Mathias Agopian | e96aa3e | 2010-08-19 17:01:19 -0700 | [diff] [blame] | 245 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 246 | // cached during validateVisibility() |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 247 | // Whether filtering is needed b/c of the drawingstate |
Mathias Agopian | 9237703 | 2010-05-26 22:08:52 -0700 | [diff] [blame] | 248 | bool mNeedsFiltering; |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 249 | |
Mathias Agopian | 4bacc9d | 2011-09-08 18:31:55 -0700 | [diff] [blame] | 250 | // this layer is currently handled by the hwc. this is |
| 251 | // updated at composition time, always frmo the composition |
| 252 | // thread. |
| 253 | bool mInOverlay; |
| 254 | |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 255 | protected: |
| 256 | // cached during validateVisibility() |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 257 | int32_t mOrientation; |
Jamie Gennis | fd2429d | 2011-09-23 15:54:34 -0700 | [diff] [blame] | 258 | int32_t mPlaneOrientation; |
Mathias Agopian | 3f88327 | 2011-08-18 18:31:00 -0700 | [diff] [blame] | 259 | Transform mTransform; |
Mathias Agopian | e5c0a7b | 2010-04-20 14:51:04 -0700 | [diff] [blame] | 260 | GLfloat mVertices[4][2]; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 261 | Rect mTransformedBounds; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 262 | |
| 263 | // these are protected by an external lock |
| 264 | State mCurrentState; |
| 265 | State mDrawingState; |
| 266 | volatile int32_t mTransactionFlags; |
| 267 | |
| 268 | // don't change, don't need a lock |
| 269 | bool mPremultipliedAlpha; |
Mathias Agopian | 015b597 | 2010-03-09 19:17:47 -0800 | [diff] [blame] | 270 | String8 mName; |
| 271 | mutable bool mDebug; |
| 272 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 273 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 274 | // atomic |
| 275 | volatile int32_t mInvalidate; |
| 276 | |
| 277 | |
Mathias Agopian | 6960811 | 2011-05-19 15:38:14 -0700 | [diff] [blame] | 278 | public: |
| 279 | // called from class SurfaceFlinger |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 280 | virtual ~LayerBase(); |
| 281 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 282 | private: |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 283 | LayerBase(const LayerBase& rhs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 284 | }; |
| 285 | |
| 286 | |
| 287 | // --------------------------------------------------------------------------- |
| 288 | |
| 289 | class LayerBaseClient : public LayerBase |
| 290 | { |
| 291 | public: |
Mathias Agopian | 593c05c | 2010-06-02 23:28:45 -0700 | [diff] [blame] | 292 | LayerBaseClient(SurfaceFlinger* flinger, DisplayID display, |
| 293 | const sp<Client>& client); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 294 | |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 295 | virtual ~LayerBaseClient(); |
| 296 | |
| 297 | sp<ISurface> getSurface(); |
Mathias Agopian | d35c666 | 2011-01-25 20:17:45 -0800 | [diff] [blame] | 298 | wp<IBinder> getSurfaceBinder() const; |
Jamie Gennis | 9b8fc65 | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 299 | virtual wp<IBinder> getSurfaceTextureBinder() const; |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 300 | |
Mathias Agopian | 7623da4 | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 301 | virtual sp<LayerBaseClient> getLayerBaseClient() const { |
| 302 | return const_cast<LayerBaseClient*>(this); } |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 303 | |
Mathias Agopian | 9bce873 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 304 | virtual const char* getTypeId() const { return "LayerBaseClient"; } |
Mathias Agopian | 5d26c1e | 2010-03-01 16:09:43 -0800 | [diff] [blame] | 305 | |
Mathias Agopian | 593c05c | 2010-06-02 23:28:45 -0700 | [diff] [blame] | 306 | uint32_t getIdentity() const { return mIdentity; } |
| 307 | |
Mathias Agopian | 9bce873 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 308 | protected: |
| 309 | virtual void dump(String8& result, char* scratch, size_t size) const; |
Mathias Agopian | 06a61e2 | 2011-01-19 16:15:53 -0800 | [diff] [blame] | 310 | virtual void shortDump(String8& result, char* scratch, size_t size) const; |
Mathias Agopian | 9bce873 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 311 | |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 312 | class LayerCleaner { |
| 313 | sp<SurfaceFlinger> mFlinger; |
| 314 | wp<LayerBaseClient> mLayer; |
| 315 | protected: |
| 316 | ~LayerCleaner(); |
| 317 | public: |
| 318 | LayerCleaner(const sp<SurfaceFlinger>& flinger, |
| 319 | const sp<LayerBaseClient>& layer); |
| 320 | }; |
| 321 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 322 | private: |
Mathias Agopian | 7bb843c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 323 | virtual sp<ISurface> createSurface(); |
| 324 | |
Mathias Agopian | 593c05c | 2010-06-02 23:28:45 -0700 | [diff] [blame] | 325 | mutable Mutex mLock; |
Mathias Agopian | 1b0114f | 2011-02-15 19:01:06 -0800 | [diff] [blame] | 326 | mutable bool mHasSurface; |
Mathias Agopian | d35c666 | 2011-01-25 20:17:45 -0800 | [diff] [blame] | 327 | wp<IBinder> mClientSurfaceBinder; |
Mathias Agopian | 7623da4 | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 328 | const wp<Client> mClientRef; |
Mathias Agopian | c660395 | 2009-06-23 20:06:46 -0700 | [diff] [blame] | 329 | // only read |
Mathias Agopian | 593c05c | 2010-06-02 23:28:45 -0700 | [diff] [blame] | 330 | const uint32_t mIdentity; |
| 331 | static int32_t sIdentity; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 332 | }; |
| 333 | |
| 334 | // --------------------------------------------------------------------------- |
| 335 | |
| 336 | }; // namespace android |
| 337 | |
| 338 | #endif // ANDROID_LAYER_BASE_H |