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