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