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> |
| 28 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | #include <ui/Region.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | |
Mathias Agopian | 7e27f05 | 2010-05-28 14:22:23 -0700 | [diff] [blame] | 31 | #include <surfaceflinger/ISurfaceComposerClient.h> |
Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 32 | #include <private/surfaceflinger/LayerState.h> |
| 33 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | #include <pixelflinger/pixelflinger.h> |
| 35 | |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 36 | #include <hardware/hwcomposer.h> |
| 37 | |
Mathias Agopian | 5ec99b5 | 2010-12-07 23:41:55 -0800 | [diff] [blame] | 38 | #include "DisplayHardware/DisplayHardware.h" |
The Android Open Source Project | edbf3b6 | 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 | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 | class Client; |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 46 | class DisplayHardware; |
Mathias Agopian | 3330b20 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 47 | class GraphicBuffer; |
| 48 | class GraphicPlane; |
Mathias Agopian | 670a899 | 2011-09-20 15:13:14 -0700 | [diff] [blame] | 49 | class Layer; |
Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 50 | class LayerBaseClient; |
Mathias Agopian | 3330b20 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 51 | class SurfaceFlinger; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | |
| 53 | // --------------------------------------------------------------------------- |
| 54 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 55 | class LayerBase : public RefBase |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 56 | { |
Mathias Agopian | f6679fc | 2010-08-10 18:09:09 -0700 | [diff] [blame] | 57 | static int32_t sSequence; |
| 58 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | public: |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 60 | LayerBase(SurfaceFlinger* flinger, DisplayID display); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | |
The Android Open Source Project | edbf3b6 | 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 | f6679fc | 2010-08-10 18:09:09 -0700 | [diff] [blame] | 67 | int32_t sequence; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 68 | |
| 69 | struct State { |
| 70 | uint32_t w; |
| 71 | uint32_t h; |
Mathias Agopian | 7e4a587 | 2009-09-29 22:39:22 -0700 | [diff] [blame] | 72 | uint32_t requested_w; |
| 73 | uint32_t requested_h; |
The Android Open Source Project | edbf3b6 | 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 | a249f2d | 2011-09-16 17:31:54 -0700 | [diff] [blame] | 84 | virtual void setName(const String8& name); |
Mathias Agopian | d129659 | 2010-03-09 19:17:47 -0800 | [diff] [blame] | 85 | String8 getName() const; |
| 86 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 87 | // modify current state |
Mathias Agopian | 41b6aab | 2011-08-30 18:51:54 -0700 | [diff] [blame] | 88 | bool setPosition(float x, float y); |
The Android Open Source Project | edbf3b6 | 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 | ba6be54 | 2009-09-29 22:32:36 -0700 | [diff] [blame] | 96 | void commitTransaction(); |
The Android Open Source Project | edbf3b6 | 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 | d129659 | 2010-03-09 19:17:47 -0800 | [diff] [blame] | 107 | |
Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 108 | virtual sp<LayerBaseClient> getLayerBaseClient() const { return 0; } |
Mathias Agopian | 670a899 | 2011-09-20 15:13:14 -0700 | [diff] [blame] | 109 | virtual sp<Layer> getLayer() const { return 0; } |
Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 110 | |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 111 | virtual const char* getTypeId() const { return "LayerBase"; } |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 112 | |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 113 | virtual void setGeometry(hwc_layer_t* hwcl); |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 114 | virtual void setPerFrameData(hwc_layer_t* hwcl); |
Mathias Agopian | f384cc3 | 2011-09-08 18:31:55 -0700 | [diff] [blame] | 115 | void setOverlay(bool inOverlay); |
| 116 | bool isOverlay() const; |
| 117 | |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 118 | |
The Android Open Source Project | edbf3b6 | 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 | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 126 | virtual void drawForSreenShot(); |
The Android Open Source Project | edbf3b6 | 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 | edbf3b6 | 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 | ab02873 | 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 | edbf3b6 | 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 | ab02873 | 2010-03-16 16:41:46 -0700 | [diff] [blame] | 156 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 157 | /** |
The Android Open Source Project | edbf3b6 | 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 | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 179 | * isOpaque - true if this surface is opaque |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 180 | */ |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 181 | virtual bool isOpaque() const { return true; } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 182 | |
| 183 | /** |
Mathias Agopian | 401c257 | 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 | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 189 | * needsLinearFiltering - true if this surface's state requires filtering |
Mathias Agopian | a7f6692 | 2010-05-26 22:08:52 -0700 | [diff] [blame] | 190 | */ |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 191 | virtual bool needsFiltering() const { return mNeedsFiltering; } |
Mathias Agopian | a7f6692 | 2010-05-26 22:08:52 -0700 | [diff] [blame] | 192 | |
| 193 | /** |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 194 | * isSecure - true if this surface is secure, that is if it prevents |
Mathias Agopian | 9a11206 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 195 | * screenshots or VNC servers. |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 196 | */ |
| 197 | virtual bool isSecure() const { return false; } |
| 198 | |
Glenn Kasten | 16f0453 | 2011-01-19 15:27:27 -0800 | [diff] [blame] | 199 | /** |
Jamie Gennis | 7a4d0df | 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 | 16f0453 | 2011-01-19 15:27:27 -0800 | [diff] [blame] | 202 | */ |
Jamie Gennis | 7a4d0df | 2011-03-09 17:05:02 -0800 | [diff] [blame] | 203 | virtual bool isProtected() const { return false; } |
Glenn Kasten | 16f0453 | 2011-01-19 15:27:27 -0800 | [diff] [blame] | 204 | |
Mathias Agopian | 0b3ad46 | 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() { }; |
Jamie Gennis | e8696a4 | 2012-01-15 18:54:57 -0800 | [diff] [blame] | 208 | |
| 209 | virtual void onLayerDisplayed() { }; |
| 210 | |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 211 | /** always call base class first */ |
| 212 | virtual void dump(String8& result, char* scratch, size_t size) const; |
Mathias Agopian | 48b888a | 2011-01-19 16:15:53 -0800 | [diff] [blame] | 213 | virtual void shortDump(String8& result, char* scratch, size_t size) const; |
Mathias Agopian | 82d7ab6 | 2012-01-19 18:34:40 -0800 | [diff] [blame] | 214 | virtual void dumpStats(String8& result, char* buffer, size_t SIZE) const; |
Mathias Agopian | 25e66fc | 2012-01-28 22:31:55 -0800 | [diff] [blame] | 215 | virtual void clearStats(); |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 216 | |
| 217 | |
Mathias Agopian | 9a11206 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 218 | enum { // flags for doTransaction() |
| 219 | eVisibleRegion = 0x00000002, |
Mathias Agopian | 9a11206 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 220 | }; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 221 | |
| 222 | |
| 223 | inline const State& drawingState() const { return mDrawingState; } |
| 224 | inline const State& currentState() const { return mCurrentState; } |
| 225 | inline State& currentState() { return mCurrentState; } |
| 226 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 227 | int32_t getOrientation() const { return mOrientation; } |
Jamie Gennis | 8d91b42 | 2011-09-23 15:54:34 -0700 | [diff] [blame] | 228 | int32_t getPlaneOrientation() const { return mPlaneOrientation; } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 229 | |
| 230 | protected: |
| 231 | const GraphicPlane& graphicPlane(int dpy) const; |
| 232 | GraphicPlane& graphicPlane(int dpy); |
| 233 | |
Mathias Agopian | 010fccb | 2010-05-26 22:26:12 -0700 | [diff] [blame] | 234 | void clearWithOpenGL(const Region& clip, GLclampf r, GLclampf g, |
| 235 | GLclampf b, GLclampf alpha) const; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 236 | void clearWithOpenGL(const Region& clip) const; |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 237 | void drawWithOpenGL(const Region& clip) const; |
| 238 | |
| 239 | void setFiltering(bool filtering); |
| 240 | bool getFiltering() const; |
Mathias Agopian | b661d66 | 2010-08-19 17:01:19 -0700 | [diff] [blame] | 241 | |
Mathias Agopian | 9a11206 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 242 | sp<SurfaceFlinger> mFlinger; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 243 | uint32_t mFlags; |
| 244 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 245 | private: |
| 246 | // accessed only in the main thread |
| 247 | // Whether filtering is forced on or not |
| 248 | bool mFiltering; |
Mathias Agopian | b661d66 | 2010-08-19 17:01:19 -0700 | [diff] [blame] | 249 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 250 | // cached during validateVisibility() |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 251 | // Whether filtering is needed b/c of the drawingstate |
Mathias Agopian | a7f6692 | 2010-05-26 22:08:52 -0700 | [diff] [blame] | 252 | bool mNeedsFiltering; |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 253 | |
Mathias Agopian | f384cc3 | 2011-09-08 18:31:55 -0700 | [diff] [blame] | 254 | // this layer is currently handled by the hwc. this is |
| 255 | // updated at composition time, always frmo the composition |
| 256 | // thread. |
| 257 | bool mInOverlay; |
| 258 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 259 | protected: |
| 260 | // cached during validateVisibility() |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 261 | int32_t mOrientation; |
Jamie Gennis | 8d91b42 | 2011-09-23 15:54:34 -0700 | [diff] [blame] | 262 | int32_t mPlaneOrientation; |
Mathias Agopian | d992db3 | 2011-08-18 18:31:00 -0700 | [diff] [blame] | 263 | Transform mTransform; |
Mathias Agopian | 78fd501 | 2010-04-20 14:51:04 -0700 | [diff] [blame] | 264 | GLfloat mVertices[4][2]; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 265 | Rect mTransformedBounds; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 266 | |
| 267 | // these are protected by an external lock |
| 268 | State mCurrentState; |
| 269 | State mDrawingState; |
| 270 | volatile int32_t mTransactionFlags; |
| 271 | |
| 272 | // don't change, don't need a lock |
| 273 | bool mPremultipliedAlpha; |
Mathias Agopian | d129659 | 2010-03-09 19:17:47 -0800 | [diff] [blame] | 274 | String8 mName; |
| 275 | mutable bool mDebug; |
| 276 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 277 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 278 | // atomic |
| 279 | volatile int32_t mInvalidate; |
| 280 | |
| 281 | |
Mathias Agopian | ca4d360 | 2011-05-19 15:38:14 -0700 | [diff] [blame] | 282 | public: |
| 283 | // called from class SurfaceFlinger |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 284 | virtual ~LayerBase(); |
| 285 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 286 | private: |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 287 | LayerBase(const LayerBase& rhs); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 288 | }; |
| 289 | |
| 290 | |
| 291 | // --------------------------------------------------------------------------- |
| 292 | |
| 293 | class LayerBaseClient : public LayerBase |
| 294 | { |
| 295 | public: |
Mathias Agopian | 96f0819 | 2010-06-02 23:28:45 -0700 | [diff] [blame] | 296 | LayerBaseClient(SurfaceFlinger* flinger, DisplayID display, |
| 297 | const sp<Client>& client); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 298 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 299 | virtual ~LayerBaseClient(); |
| 300 | |
| 301 | sp<ISurface> getSurface(); |
Mathias Agopian | 0d15612 | 2011-01-25 20:17:45 -0800 | [diff] [blame] | 302 | wp<IBinder> getSurfaceBinder() const; |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 303 | virtual wp<IBinder> getSurfaceTextureBinder() const; |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 304 | |
Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 305 | virtual sp<LayerBaseClient> getLayerBaseClient() const { |
| 306 | return const_cast<LayerBaseClient*>(this); } |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 307 | |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 308 | virtual const char* getTypeId() const { return "LayerBaseClient"; } |
Mathias Agopian | 285dbde | 2010-03-01 16:09:43 -0800 | [diff] [blame] | 309 | |
Mathias Agopian | 96f0819 | 2010-06-02 23:28:45 -0700 | [diff] [blame] | 310 | uint32_t getIdentity() const { return mIdentity; } |
| 311 | |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 312 | protected: |
| 313 | virtual void dump(String8& result, char* scratch, size_t size) const; |
Mathias Agopian | 48b888a | 2011-01-19 16:15:53 -0800 | [diff] [blame] | 314 | virtual void shortDump(String8& result, char* scratch, size_t size) const; |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 315 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 316 | class LayerCleaner { |
| 317 | sp<SurfaceFlinger> mFlinger; |
| 318 | wp<LayerBaseClient> mLayer; |
| 319 | protected: |
| 320 | ~LayerCleaner(); |
| 321 | public: |
| 322 | LayerCleaner(const sp<SurfaceFlinger>& flinger, |
| 323 | const sp<LayerBaseClient>& layer); |
| 324 | }; |
| 325 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 326 | private: |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 327 | virtual sp<ISurface> createSurface(); |
| 328 | |
Mathias Agopian | 96f0819 | 2010-06-02 23:28:45 -0700 | [diff] [blame] | 329 | mutable Mutex mLock; |
Mathias Agopian | a1f47b9 | 2011-02-15 19:01:06 -0800 | [diff] [blame] | 330 | mutable bool mHasSurface; |
Mathias Agopian | 0d15612 | 2011-01-25 20:17:45 -0800 | [diff] [blame] | 331 | wp<IBinder> mClientSurfaceBinder; |
Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 332 | const wp<Client> mClientRef; |
Mathias Agopian | 2e12324 | 2009-06-23 20:06:46 -0700 | [diff] [blame] | 333 | // only read |
Mathias Agopian | 96f0819 | 2010-06-02 23:28:45 -0700 | [diff] [blame] | 334 | const uint32_t mIdentity; |
| 335 | static int32_t sIdentity; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 336 | }; |
| 337 | |
| 338 | // --------------------------------------------------------------------------- |
| 339 | |
| 340 | }; // namespace android |
| 341 | |
| 342 | #endif // ANDROID_LAYER_BASE_H |