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