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_SURFACE_FLINGER_H |
| 18 | #define ANDROID_SURFACE_FLINGER_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
| 23 | #include <utils/SortedVector.h> |
| 24 | #include <utils/KeyedVector.h> |
| 25 | #include <utils/threads.h> |
| 26 | #include <utils/Atomic.h> |
| 27 | #include <utils/Errors.h> |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 28 | #include <utils/RefBase.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | |
Mathias Agopian | d763b5d | 2009-07-02 18:11:53 -0700 | [diff] [blame] | 30 | #include <binder/IMemory.h> |
Mathias Agopian | 151e859 | 2009-06-15 18:24:59 -0700 | [diff] [blame] | 31 | #include <binder/Permission.h> |
| 32 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | #include <ui/PixelFormat.h> |
Mathias Agopian | 000479f | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 34 | #include <surfaceflinger/ISurfaceComposer.h> |
| 35 | #include <surfaceflinger/ISurfaceFlingerClient.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | |
| 37 | #include "Barrier.h" |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | #include "Layer.h" |
| 39 | #include "Tokenizer.h" |
| 40 | |
Mathias Agopian | 6ead5d9 | 2009-04-20 19:39:12 -0700 | [diff] [blame] | 41 | #include "MessageQueue.h" |
| 42 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | struct copybit_device_t; |
| 44 | struct overlay_device_t; |
| 45 | |
| 46 | namespace android { |
| 47 | |
| 48 | // --------------------------------------------------------------------------- |
| 49 | |
| 50 | class Client; |
| 51 | class BClient; |
| 52 | class DisplayHardware; |
| 53 | class FreezeLock; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | class Layer; |
| 55 | class LayerBuffer; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 56 | |
| 57 | typedef int32_t ClientID; |
| 58 | |
| 59 | #define LIKELY( exp ) (__builtin_expect( (exp) != 0, true )) |
| 60 | #define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false )) |
| 61 | |
| 62 | // --------------------------------------------------------------------------- |
| 63 | |
Mathias Agopian | 6edf5af | 2009-06-19 17:00:27 -0700 | [diff] [blame] | 64 | class Client : public RefBase |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 65 | { |
| 66 | public: |
| 67 | Client(ClientID cid, const sp<SurfaceFlinger>& flinger); |
| 68 | ~Client(); |
| 69 | |
| 70 | int32_t generateId(int pid); |
| 71 | void free(int32_t id); |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 72 | status_t bindLayer(const sp<LayerBaseClient>& layer, int32_t id); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 73 | |
| 74 | inline bool isValid(int32_t i) const; |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 75 | sp<LayerBaseClient> getLayerUser(int32_t i) const; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 76 | void dump(const char* what); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 77 | |
Mathias Agopian | d763b5d | 2009-07-02 18:11:53 -0700 | [diff] [blame] | 78 | const Vector< wp<LayerBaseClient> >& getLayers() const { |
| 79 | return mLayers; |
| 80 | } |
| 81 | |
| 82 | const sp<IMemoryHeap>& getControlBlockMemory() const { |
| 83 | return mCblkHeap; |
| 84 | } |
| 85 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | // pointer to this client's control block |
Mathias Agopian | 9779b22 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 87 | SharedClient* ctrlblk; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 88 | ClientID cid; |
| 89 | |
| 90 | |
| 91 | private: |
Mathias Agopian | d763b5d | 2009-07-02 18:11:53 -0700 | [diff] [blame] | 92 | int getClientPid() const { return mPid; } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 93 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 94 | int mPid; |
| 95 | uint32_t mBitmap; |
| 96 | SortedVector<uint8_t> mInUse; |
| 97 | Vector< wp<LayerBaseClient> > mLayers; |
Mathias Agopian | d763b5d | 2009-07-02 18:11:53 -0700 | [diff] [blame] | 98 | sp<IMemoryHeap> mCblkHeap; |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 99 | sp<SurfaceFlinger> mFlinger; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | // --------------------------------------------------------------------------- |
| 103 | |
| 104 | class GraphicPlane |
| 105 | { |
| 106 | public: |
| 107 | static status_t orientationToTransfrom(int orientation, int w, int h, |
| 108 | Transform* tr); |
| 109 | |
| 110 | GraphicPlane(); |
| 111 | ~GraphicPlane(); |
| 112 | |
| 113 | bool initialized() const; |
| 114 | |
| 115 | void setDisplayHardware(DisplayHardware *); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 116 | status_t setOrientation(int orientation); |
Mathias Agopian | 3552f53 | 2009-03-27 17:58:20 -0700 | [diff] [blame] | 117 | int getOrientation() const { return mOrientation; } |
Mathias Agopian | 66c77a5 | 2010-02-08 15:49:35 -0800 | [diff] [blame] | 118 | int getWidth() const; |
| 119 | int getHeight() const; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 120 | |
| 121 | const DisplayHardware& displayHardware() const; |
| 122 | const Transform& transform() const; |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 123 | EGLDisplay getEGLDisplay() const; |
| 124 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 125 | private: |
| 126 | GraphicPlane(const GraphicPlane&); |
| 127 | GraphicPlane operator = (const GraphicPlane&); |
| 128 | |
| 129 | DisplayHardware* mHw; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 130 | Transform mGlobalTransform; |
Mathias Agopian | 66c77a5 | 2010-02-08 15:49:35 -0800 | [diff] [blame] | 131 | Transform mDisplayTransform; |
Mathias Agopian | 3552f53 | 2009-03-27 17:58:20 -0700 | [diff] [blame] | 132 | int mOrientation; |
Mathias Agopian | 66c77a5 | 2010-02-08 15:49:35 -0800 | [diff] [blame] | 133 | float mDisplayWidth; |
| 134 | float mDisplayHeight; |
| 135 | int mWidth; |
| 136 | int mHeight; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 137 | }; |
| 138 | |
| 139 | // --------------------------------------------------------------------------- |
| 140 | |
| 141 | enum { |
| 142 | eTransactionNeeded = 0x01, |
| 143 | eTraversalNeeded = 0x02 |
| 144 | }; |
| 145 | |
| 146 | class SurfaceFlinger : public BnSurfaceComposer, protected Thread |
| 147 | { |
| 148 | public: |
| 149 | static void instantiate(); |
| 150 | static void shutdown(); |
| 151 | |
| 152 | SurfaceFlinger(); |
| 153 | virtual ~SurfaceFlinger(); |
| 154 | void init(); |
| 155 | |
| 156 | virtual status_t onTransact( |
| 157 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags); |
| 158 | |
| 159 | virtual status_t dump(int fd, const Vector<String16>& args); |
| 160 | |
| 161 | // ISurfaceComposer interface |
| 162 | virtual sp<ISurfaceFlingerClient> createConnection(); |
Mathias Agopian | d763b5d | 2009-07-02 18:11:53 -0700 | [diff] [blame] | 163 | virtual sp<IMemoryHeap> getCblk() const; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 164 | virtual void bootFinished(); |
| 165 | virtual void openGlobalTransaction(); |
| 166 | virtual void closeGlobalTransaction(); |
| 167 | virtual status_t freezeDisplay(DisplayID dpy, uint32_t flags); |
| 168 | virtual status_t unfreezeDisplay(DisplayID dpy, uint32_t flags); |
Mathias Agopian | eb0c86e | 2009-03-27 18:11:38 -0700 | [diff] [blame] | 169 | virtual int setOrientation(DisplayID dpy, int orientation, uint32_t flags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 170 | virtual void signal() const; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 171 | |
| 172 | void screenReleased(DisplayID dpy); |
| 173 | void screenAcquired(DisplayID dpy); |
| 174 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 175 | overlay_control_device_t* getOverlayEngine() const; |
| 176 | |
| 177 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 178 | status_t removeLayer(const sp<LayerBase>& layer); |
| 179 | status_t addLayer(const sp<LayerBase>& layer); |
| 180 | status_t invalidateLayerVisibility(const sp<LayerBase>& layer); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 181 | |
| 182 | private: |
| 183 | friend class BClient; |
| 184 | friend class LayerBase; |
| 185 | friend class LayerBuffer; |
| 186 | friend class LayerBaseClient; |
Mathias Agopian | 94aadce | 2009-07-06 19:04:03 -0700 | [diff] [blame] | 187 | friend class LayerBaseClient::Surface; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 188 | friend class Layer; |
| 189 | friend class LayerBlur; |
Mathias Agopian | 9cc8852 | 2009-06-18 18:48:39 -0700 | [diff] [blame] | 190 | friend class LayerDim; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 191 | |
Mathias Agopian | 5d26c1e | 2010-03-01 16:09:43 -0800 | [diff] [blame] | 192 | sp<ISurface> createSurface(ClientID client, int pid, const String8& name, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 193 | ISurfaceFlingerClient::surface_data_t* params, |
| 194 | DisplayID display, uint32_t w, uint32_t h, PixelFormat format, |
| 195 | uint32_t flags); |
| 196 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 197 | sp<LayerBaseClient> createNormalSurfaceLocked( |
Mathias Agopian | 6edf5af | 2009-06-19 17:00:27 -0700 | [diff] [blame] | 198 | const sp<Client>& client, DisplayID display, |
Mathias Agopian | 18b6b49 | 2009-08-19 17:46:26 -0700 | [diff] [blame] | 199 | int32_t id, uint32_t w, uint32_t h, uint32_t flags, |
| 200 | PixelFormat& format); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 201 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 202 | sp<LayerBaseClient> createBlurSurfaceLocked( |
Mathias Agopian | 6edf5af | 2009-06-19 17:00:27 -0700 | [diff] [blame] | 203 | const sp<Client>& client, DisplayID display, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 204 | int32_t id, uint32_t w, uint32_t h, uint32_t flags); |
| 205 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 206 | sp<LayerBaseClient> createDimSurfaceLocked( |
Mathias Agopian | 6edf5af | 2009-06-19 17:00:27 -0700 | [diff] [blame] | 207 | const sp<Client>& client, DisplayID display, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 208 | int32_t id, uint32_t w, uint32_t h, uint32_t flags); |
| 209 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 210 | sp<LayerBaseClient> createPushBuffersSurfaceLocked( |
Mathias Agopian | 6edf5af | 2009-06-19 17:00:27 -0700 | [diff] [blame] | 211 | const sp<Client>& client, DisplayID display, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 212 | int32_t id, uint32_t w, uint32_t h, uint32_t flags); |
| 213 | |
Mathias Agopian | 6cf0db2 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 214 | status_t removeSurface(SurfaceID surface_id); |
| 215 | status_t destroySurface(const sp<LayerBaseClient>& layer); |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 216 | status_t setClientState(ClientID cid, int32_t count, const layer_state_t* states); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 217 | |
| 218 | |
| 219 | class LayerVector { |
| 220 | public: |
| 221 | inline LayerVector() { } |
| 222 | LayerVector(const LayerVector&); |
| 223 | inline size_t size() const { return layers.size(); } |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 224 | inline sp<LayerBase> const* array() const { return layers.array(); } |
| 225 | ssize_t add(const sp<LayerBase>&, Vector< sp<LayerBase> >::compar_t); |
| 226 | ssize_t remove(const sp<LayerBase>&); |
| 227 | ssize_t reorder(const sp<LayerBase>&, Vector< sp<LayerBase> >::compar_t); |
| 228 | ssize_t indexOf(const sp<LayerBase>& key, size_t guess=0) const; |
| 229 | inline sp<LayerBase> operator [] (size_t i) const { return layers[i]; } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 230 | private: |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 231 | KeyedVector< sp<LayerBase> , size_t> lookup; |
| 232 | Vector< sp<LayerBase> > layers; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 233 | }; |
| 234 | |
| 235 | struct State { |
| 236 | State() { |
| 237 | orientation = ISurfaceComposer::eOrientationDefault; |
| 238 | freezeDisplay = 0; |
| 239 | } |
| 240 | LayerVector layersSortedByZ; |
| 241 | uint8_t orientation; |
Mathias Agopian | eb0c86e | 2009-03-27 18:11:38 -0700 | [diff] [blame] | 242 | uint8_t orientationType; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 243 | uint8_t freezeDisplay; |
| 244 | }; |
| 245 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 246 | virtual bool threadLoop(); |
| 247 | virtual status_t readyToRun(); |
| 248 | virtual void onFirstRef(); |
| 249 | |
Andy McFadden | 08c19be | 2009-10-29 10:19:34 -0700 | [diff] [blame] | 250 | public: // hack to work around gcc 4.0.3 bug |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 251 | const GraphicPlane& graphicPlane(int dpy) const; |
| 252 | GraphicPlane& graphicPlane(int dpy); |
Andy McFadden | 08c19be | 2009-10-29 10:19:34 -0700 | [diff] [blame] | 253 | private: |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 254 | |
| 255 | void waitForEvent(); |
Andy McFadden | fa0a4bd | 2009-09-21 14:33:20 -0700 | [diff] [blame] | 256 | public: // hack to work around gcc 4.0.3 bug |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 257 | void signalEvent(); |
Andy McFadden | fa0a4bd | 2009-09-21 14:33:20 -0700 | [diff] [blame] | 258 | private: |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 259 | void signalDelayedEvent(nsecs_t delay); |
| 260 | |
| 261 | void handleConsoleEvents(); |
| 262 | void handleTransaction(uint32_t transactionFlags); |
Mathias Agopian | 2d5ee25 | 2009-06-04 18:46:21 -0700 | [diff] [blame] | 263 | void handleTransactionLocked( |
| 264 | uint32_t transactionFlags, |
| 265 | Vector< sp<LayerBase> >& ditchedLayers); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 266 | |
| 267 | void computeVisibleRegions( |
| 268 | LayerVector& currentLayers, |
| 269 | Region& dirtyRegion, |
| 270 | Region& wormholeRegion); |
| 271 | |
| 272 | void handlePageFlip(); |
| 273 | bool lockPageFlip(const LayerVector& currentLayers); |
| 274 | void unlockPageFlip(const LayerVector& currentLayers); |
| 275 | void handleRepaint(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 276 | void postFramebuffer(); |
| 277 | void composeSurfaces(const Region& dirty); |
| 278 | void unlockClients(); |
| 279 | |
| 280 | |
| 281 | void destroyConnection(ClientID cid); |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 282 | sp<LayerBaseClient> getLayerUser_l(SurfaceID index) const; |
| 283 | status_t addLayer_l(const sp<LayerBase>& layer); |
| 284 | status_t removeLayer_l(const sp<LayerBase>& layer); |
Mathias Agopian | 6cf0db2 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 285 | status_t purgatorizeLayer_l(const sp<LayerBase>& layer); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 286 | void free_resources_l(); |
| 287 | |
| 288 | uint32_t getTransactionFlags(uint32_t flags); |
| 289 | uint32_t setTransactionFlags(uint32_t flags, nsecs_t delay = 0); |
| 290 | void commitTransaction(); |
| 291 | |
| 292 | |
| 293 | friend class FreezeLock; |
| 294 | sp<FreezeLock> getFreezeLock() const; |
Mathias Agopian | 0e44976 | 2009-12-01 17:23:28 -0800 | [diff] [blame] | 295 | inline void incFreezeCount() { |
| 296 | if (mFreezeCount == 0) |
| 297 | mFreezeDisplayTime = 0; |
| 298 | mFreezeCount++; |
| 299 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 300 | inline void decFreezeCount() { if (mFreezeCount > 0) mFreezeCount--; } |
| 301 | inline bool hasFreezeRequest() const { return mFreezeDisplay; } |
| 302 | inline bool isFrozen() const { |
Mathias Agopian | 6950e42 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 303 | return (mFreezeDisplay || mFreezeCount>0) && mBootFinished; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | |
| 307 | void debugFlashRegions(); |
| 308 | void debugShowFPS() const; |
| 309 | void drawWormhole() const; |
| 310 | |
Mathias Agopian | 6ead5d9 | 2009-04-20 19:39:12 -0700 | [diff] [blame] | 311 | |
| 312 | mutable MessageQueue mEventQueue; |
| 313 | |
| 314 | |
| 315 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 316 | // access must be protected by mStateLock |
| 317 | mutable Mutex mStateLock; |
| 318 | State mCurrentState; |
| 319 | State mDrawingState; |
| 320 | volatile int32_t mTransactionFlags; |
| 321 | volatile int32_t mTransactionCount; |
| 322 | Condition mTransactionCV; |
Mathias Agopian | 9779b22 | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 323 | bool mResizeTransationPending; |
Mathias Agopian | 6cf0db2 | 2009-04-17 19:36:26 -0700 | [diff] [blame] | 324 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 325 | // protected by mStateLock (but we could use another lock) |
| 326 | Tokenizer mTokens; |
Mathias Agopian | 6edf5af | 2009-06-19 17:00:27 -0700 | [diff] [blame] | 327 | DefaultKeyedVector<ClientID, sp<Client> > mClientsMap; |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 328 | DefaultKeyedVector<SurfaceID, sp<LayerBaseClient> > mLayerMap; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 329 | GraphicPlane mGraphicPlanes[1]; |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 330 | bool mLayersRemoved; |
Mathias Agopian | 6edf5af | 2009-06-19 17:00:27 -0700 | [diff] [blame] | 331 | Vector< sp<Client> > mDisconnectedClients; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 332 | |
| 333 | // constant members (no synchronization needed for access) |
Mathias Agopian | d763b5d | 2009-07-02 18:11:53 -0700 | [diff] [blame] | 334 | sp<IMemoryHeap> mServerHeap; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 335 | surface_flinger_cblk_t* mServerCblk; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 336 | GLuint mWormholeTexName; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 337 | nsecs_t mBootTime; |
Mathias Agopian | 151e859 | 2009-06-15 18:24:59 -0700 | [diff] [blame] | 338 | Permission mHardwareTest; |
| 339 | Permission mAccessSurfaceFlinger; |
| 340 | Permission mDump; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 341 | |
| 342 | // Can only accessed from the main thread, these members |
| 343 | // don't need synchronization |
| 344 | Region mDirtyRegion; |
Mathias Agopian | 12cedff | 2009-07-28 10:57:27 -0700 | [diff] [blame] | 345 | Region mDirtyRegionRemovedLayer; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 346 | Region mInvalidRegion; |
| 347 | Region mWormholeRegion; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 348 | bool mVisibleRegionsDirty; |
| 349 | bool mDeferReleaseConsole; |
| 350 | bool mFreezeDisplay; |
| 351 | int32_t mFreezeCount; |
| 352 | nsecs_t mFreezeDisplayTime; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 353 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 354 | // don't use a lock for these, we don't care |
| 355 | int mDebugRegion; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 356 | int mDebugBackground; |
Mathias Agopian | a8d4917 | 2009-08-26 16:36:26 -0700 | [diff] [blame] | 357 | volatile nsecs_t mDebugInSwapBuffers; |
| 358 | nsecs_t mLastSwapBufferTime; |
| 359 | volatile nsecs_t mDebugInTransaction; |
| 360 | nsecs_t mLastTransactionTime; |
Mathias Agopian | 6950e42 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 361 | bool mBootFinished; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 362 | |
| 363 | // these are thread safe |
| 364 | mutable Barrier mReadyToRunBarrier; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 365 | |
| 366 | // atomic variables |
| 367 | enum { |
| 368 | eConsoleReleased = 1, |
| 369 | eConsoleAcquired = 2 |
| 370 | }; |
| 371 | volatile int32_t mConsoleSignals; |
| 372 | |
| 373 | // only written in the main thread, only read in other threads |
| 374 | volatile int32_t mSecureFrameBuffer; |
| 375 | }; |
| 376 | |
| 377 | // --------------------------------------------------------------------------- |
| 378 | |
| 379 | class FreezeLock : public LightRefBase<FreezeLock> { |
| 380 | SurfaceFlinger* mFlinger; |
| 381 | public: |
| 382 | FreezeLock(SurfaceFlinger* flinger) |
| 383 | : mFlinger(flinger) { |
| 384 | mFlinger->incFreezeCount(); |
| 385 | } |
| 386 | ~FreezeLock() { |
| 387 | mFlinger->decFreezeCount(); |
| 388 | } |
| 389 | }; |
| 390 | |
| 391 | // --------------------------------------------------------------------------- |
| 392 | |
| 393 | class BClient : public BnSurfaceFlingerClient |
| 394 | { |
| 395 | public: |
| 396 | BClient(SurfaceFlinger *flinger, ClientID cid, |
Mathias Agopian | d763b5d | 2009-07-02 18:11:53 -0700 | [diff] [blame] | 397 | const sp<IMemoryHeap>& cblk); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 398 | ~BClient(); |
| 399 | |
| 400 | // ISurfaceFlingerClient interface |
Mathias Agopian | d763b5d | 2009-07-02 18:11:53 -0700 | [diff] [blame] | 401 | virtual sp<IMemoryHeap> getControlBlock() const; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 402 | |
| 403 | virtual sp<ISurface> createSurface( |
Mathias Agopian | 5d26c1e | 2010-03-01 16:09:43 -0800 | [diff] [blame] | 404 | surface_data_t* params, int pid, const String8& name, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 405 | DisplayID display, uint32_t w, uint32_t h,PixelFormat format, |
| 406 | uint32_t flags); |
| 407 | |
| 408 | virtual status_t destroySurface(SurfaceID surfaceId); |
| 409 | virtual status_t setState(int32_t count, const layer_state_t* states); |
| 410 | |
| 411 | private: |
| 412 | ClientID mId; |
| 413 | SurfaceFlinger* mFlinger; |
Mathias Agopian | d763b5d | 2009-07-02 18:11:53 -0700 | [diff] [blame] | 414 | sp<IMemoryHeap> mCblk; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 415 | }; |
| 416 | |
| 417 | // --------------------------------------------------------------------------- |
| 418 | }; // namespace android |
| 419 | |
| 420 | #endif // ANDROID_SURFACE_FLINGER_H |