blob: 95668190f456c075dbb6b10baf9866067dea4d55 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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 Agopian1473f462009-04-10 14:24:30 -070028#include <utils/RefBase.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029
Mathias Agopiand763b5d2009-07-02 18:11:53 -070030#include <binder/IMemory.h>
Mathias Agopian151e8592009-06-15 18:24:59 -070031#include <binder/Permission.h>
Mathias Agopian24651682010-07-14 18:41:18 -070032#include <binder/BinderService.h>
Mathias Agopian151e8592009-06-15 18:24:59 -070033
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034#include <ui/PixelFormat.h>
Mathias Agopian000479f2010-02-09 17:46:37 -080035#include <surfaceflinger/ISurfaceComposer.h>
Mathias Agopian770492c2010-05-28 14:22:23 -070036#include <surfaceflinger/ISurfaceComposerClient.h>
Jamie Gennisf7acf162011-01-12 18:30:40 -080037#include <surfaceflinger/IGraphicBufferAlloc.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038
39#include "Barrier.h"
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080040#include "Layer.h"
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041
Mathias Agopian6ead5d92009-04-20 19:39:12 -070042#include "MessageQueue.h"
43
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080044namespace android {
45
46// ---------------------------------------------------------------------------
47
48class Client;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080049class DisplayHardware;
50class FreezeLock;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080051class Layer;
Mathias Agopian7623da42010-06-01 15:12:58 -070052class LayerDim;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080053
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080054#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
55#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
56
57// ---------------------------------------------------------------------------
58
Mathias Agopian593c05c2010-06-02 23:28:45 -070059class Client : public BnSurfaceComposerClient
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080060{
61public:
Mathias Agopian593c05c2010-06-02 23:28:45 -070062 Client(const sp<SurfaceFlinger>& flinger);
63 ~Client();
64
65 status_t initCheck() const;
66
67 // protected by SurfaceFlinger::mStateLock
68 ssize_t attachLayer(const sp<LayerBaseClient>& layer);
Mathias Agopian7623da42010-06-01 15:12:58 -070069 void detachLayer(const LayerBaseClient* layer);
Mathias Agopian593c05c2010-06-02 23:28:45 -070070 sp<LayerBaseClient> getLayerUser(int32_t i) const;
Mathias Agopian593c05c2010-06-02 23:28:45 -070071
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080072private:
Mathias Agopian593c05c2010-06-02 23:28:45 -070073
74 // ISurfaceComposerClient interface
75 virtual sp<IMemoryHeap> getControlBlock() const;
Mathias Agopian7623da42010-06-01 15:12:58 -070076 virtual ssize_t getTokenForSurface(const sp<ISurface>& sur) const;
Mathias Agopian593c05c2010-06-02 23:28:45 -070077 virtual sp<ISurface> createSurface(
78 surface_data_t* params, int pid, const String8& name,
79 DisplayID display, uint32_t w, uint32_t h,PixelFormat format,
80 uint32_t flags);
81 virtual status_t destroySurface(SurfaceID surfaceId);
82 virtual status_t setState(int32_t count, const layer_state_t* states);
83
Mathias Agopian593c05c2010-06-02 23:28:45 -070084 DefaultKeyedVector< size_t, wp<LayerBaseClient> > mLayers;
Mathias Agopian7623da42010-06-01 15:12:58 -070085 sp<SurfaceFlinger> mFlinger;
86 int32_t mNameGenerator;
87};
88
89class UserClient : public BnSurfaceComposerClient
90{
91public:
92 // pointer to this client's control block
93 SharedClient* ctrlblk;
94
95public:
96 UserClient(const sp<SurfaceFlinger>& flinger);
97 ~UserClient();
98
99 status_t initCheck() const;
100
101 // protected by SurfaceFlinger::mStateLock
102 void detachLayer(const Layer* layer);
103
104private:
105
106 // ISurfaceComposerClient interface
107 virtual sp<IMemoryHeap> getControlBlock() const;
108 virtual ssize_t getTokenForSurface(const sp<ISurface>& sur) const;
109 virtual sp<ISurface> createSurface(
110 surface_data_t* params, int pid, const String8& name,
111 DisplayID display, uint32_t w, uint32_t h,PixelFormat format,
112 uint32_t flags);
113 virtual status_t destroySurface(SurfaceID surfaceId);
114 virtual status_t setState(int32_t count, const layer_state_t* states);
115
116 // atomic-ops
117 mutable volatile int32_t mBitmap;
118
Mathias Agopian593c05c2010-06-02 23:28:45 -0700119 sp<IMemoryHeap> mCblkHeap;
120 sp<SurfaceFlinger> mFlinger;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800121};
122
Jamie Gennisf7acf162011-01-12 18:30:40 -0800123class GraphicBufferAlloc : public BnGraphicBufferAlloc
124{
125public:
126 GraphicBufferAlloc();
127 virtual ~GraphicBufferAlloc();
128
129 virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
130 PixelFormat format, uint32_t usage);
131 virtual void freeAllGraphicBuffersExcept(int bufIdx);
132
133private:
134 Vector<sp<GraphicBuffer> > mBuffers;
135 Mutex mLock;
136};
137
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800138// ---------------------------------------------------------------------------
139
140class GraphicPlane
141{
142public:
143 static status_t orientationToTransfrom(int orientation, int w, int h,
144 Transform* tr);
145
146 GraphicPlane();
147 ~GraphicPlane();
148
149 bool initialized() const;
150
151 void setDisplayHardware(DisplayHardware *);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800152 status_t setOrientation(int orientation);
Mathias Agopian3552f532009-03-27 17:58:20 -0700153 int getOrientation() const { return mOrientation; }
Mathias Agopian66c77a52010-02-08 15:49:35 -0800154 int getWidth() const;
155 int getHeight() const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800156
157 const DisplayHardware& displayHardware() const;
Mathias Agopianaab758e2010-10-11 12:37:43 -0700158 DisplayHardware& editDisplayHardware();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800159 const Transform& transform() const;
Mathias Agopian1473f462009-04-10 14:24:30 -0700160 EGLDisplay getEGLDisplay() const;
161
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800162private:
163 GraphicPlane(const GraphicPlane&);
164 GraphicPlane operator = (const GraphicPlane&);
165
166 DisplayHardware* mHw;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800167 Transform mGlobalTransform;
Mathias Agopian66c77a52010-02-08 15:49:35 -0800168 Transform mDisplayTransform;
Mathias Agopian3552f532009-03-27 17:58:20 -0700169 int mOrientation;
Mathias Agopian66c77a52010-02-08 15:49:35 -0800170 float mDisplayWidth;
171 float mDisplayHeight;
172 int mWidth;
173 int mHeight;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800174};
175
176// ---------------------------------------------------------------------------
177
178enum {
179 eTransactionNeeded = 0x01,
180 eTraversalNeeded = 0x02
181};
182
Mathias Agopian24651682010-07-14 18:41:18 -0700183class SurfaceFlinger :
184 public BinderService<SurfaceFlinger>,
185 public BnSurfaceComposer,
186 protected Thread
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800187{
188public:
Mathias Agopian24651682010-07-14 18:41:18 -0700189 static char const* getServiceName() { return "SurfaceFlinger"; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800190
191 SurfaceFlinger();
192 virtual ~SurfaceFlinger();
193 void init();
194
195 virtual status_t onTransact(
196 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags);
197
198 virtual status_t dump(int fd, const Vector<String16>& args);
199
200 // ISurfaceComposer interface
Mathias Agopian770492c2010-05-28 14:22:23 -0700201 virtual sp<ISurfaceComposerClient> createConnection();
Mathias Agopian7623da42010-06-01 15:12:58 -0700202 virtual sp<ISurfaceComposerClient> createClientConnection();
Jamie Gennisf7acf162011-01-12 18:30:40 -0800203 virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc();
Mathias Agopiand763b5d2009-07-02 18:11:53 -0700204 virtual sp<IMemoryHeap> getCblk() const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800205 virtual void bootFinished();
206 virtual void openGlobalTransaction();
207 virtual void closeGlobalTransaction();
208 virtual status_t freezeDisplay(DisplayID dpy, uint32_t flags);
209 virtual status_t unfreezeDisplay(DisplayID dpy, uint32_t flags);
Mathias Agopianeb0c86e2009-03-27 18:11:38 -0700210 virtual int setOrientation(DisplayID dpy, int orientation, uint32_t flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800211 virtual void signal() const;
Jamie Gennisd2acedf2011-03-08 12:18:54 -0800212 virtual bool authenticateSurface(const sp<ISurface>& surface) const;
Mathias Agopian3dd25a62010-12-10 16:22:31 -0800213
214 virtual status_t captureScreen(DisplayID dpy,
215 sp<IMemoryHeap>* heap,
216 uint32_t* width, uint32_t* height,
217 PixelFormat* format, uint32_t reqWidth, uint32_t reqHeight,
218 uint32_t minLayerZ, uint32_t maxLayerZ);
219
Mathias Agopianaab758e2010-10-11 12:37:43 -0700220 virtual status_t turnElectronBeamOff(int32_t mode);
Mathias Agopian2d2b8032010-10-12 16:05:48 -0700221 virtual status_t turnElectronBeamOn(int32_t mode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800222
223 void screenReleased(DisplayID dpy);
224 void screenAcquired(DisplayID dpy);
225
Mathias Agopian1473f462009-04-10 14:24:30 -0700226 status_t removeLayer(const sp<LayerBase>& layer);
227 status_t addLayer(const sp<LayerBase>& layer);
228 status_t invalidateLayerVisibility(const sp<LayerBase>& layer);
Mathias Agopianfb4dcb12011-01-13 17:53:01 -0800229 void invalidateHwcGeometry();
Mathias Agopian7623da42010-06-01 15:12:58 -0700230
231 sp<Layer> getLayer(const sp<ISurface>& sur) const;
232
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800233private:
Mathias Agopian593c05c2010-06-02 23:28:45 -0700234 friend class Client;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800235 friend class LayerBase;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800236 friend class LayerBaseClient;
Mathias Agopian94aadce2009-07-06 19:04:03 -0700237 friend class LayerBaseClient::Surface;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800238 friend class Layer;
Mathias Agopian9cc88522009-06-18 18:48:39 -0700239 friend class LayerDim;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800240
Mathias Agopian593c05c2010-06-02 23:28:45 -0700241 sp<ISurface> createSurface(const sp<Client>& client,
242 int pid, const String8& name,
Mathias Agopian770492c2010-05-28 14:22:23 -0700243 ISurfaceComposerClient::surface_data_t* params,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800244 DisplayID display, uint32_t w, uint32_t h, PixelFormat format,
245 uint32_t flags);
246
Mathias Agopian7623da42010-06-01 15:12:58 -0700247 sp<Layer> createNormalSurface(
Mathias Agopian6edf5af2009-06-19 17:00:27 -0700248 const sp<Client>& client, DisplayID display,
Mathias Agopian593c05c2010-06-02 23:28:45 -0700249 uint32_t w, uint32_t h, uint32_t flags,
Mathias Agopian18b6b492009-08-19 17:46:26 -0700250 PixelFormat& format);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800251
Mathias Agopian7623da42010-06-01 15:12:58 -0700252 sp<LayerDim> createDimSurface(
Mathias Agopian6edf5af2009-06-19 17:00:27 -0700253 const sp<Client>& client, DisplayID display,
Mathias Agopian593c05c2010-06-02 23:28:45 -0700254 uint32_t w, uint32_t h, uint32_t flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800255
Mathias Agopian593c05c2010-06-02 23:28:45 -0700256 status_t removeSurface(const sp<Client>& client, SurfaceID sid);
Mathias Agopian6cf0db22009-04-17 19:36:26 -0700257 status_t destroySurface(const sp<LayerBaseClient>& layer);
Mathias Agopian593c05c2010-06-02 23:28:45 -0700258 status_t setClientState(const sp<Client>& client,
259 int32_t count, const layer_state_t* states);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800260
Mathias Agopian1efba9a2010-08-10 18:09:09 -0700261 class LayerVector : public SortedVector< sp<LayerBase> > {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800262 public:
Mathias Agopian1efba9a2010-08-10 18:09:09 -0700263 LayerVector() { }
264 LayerVector(const LayerVector& rhs) : SortedVector< sp<LayerBase> >(rhs) { }
265 virtual int do_compare(const void* lhs, const void* rhs) const {
266 const sp<LayerBase>& l(*reinterpret_cast<const sp<LayerBase>*>(lhs));
267 const sp<LayerBase>& r(*reinterpret_cast<const sp<LayerBase>*>(rhs));
268 // sort layers by Z order
269 uint32_t lz = l->currentState().z;
270 uint32_t rz = r->currentState().z;
271 // then by sequence, so we get a stable ordering
272 return (lz != rz) ? (lz - rz) : (l->sequence - r->sequence);
273 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800274 };
275
276 struct State {
277 State() {
278 orientation = ISurfaceComposer::eOrientationDefault;
279 freezeDisplay = 0;
280 }
281 LayerVector layersSortedByZ;
282 uint8_t orientation;
Mathias Agopianeb0c86e2009-03-27 18:11:38 -0700283 uint8_t orientationType;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800284 uint8_t freezeDisplay;
285 };
286
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800287 virtual bool threadLoop();
288 virtual status_t readyToRun();
289 virtual void onFirstRef();
290
Andy McFadden08c19be2009-10-29 10:19:34 -0700291public: // hack to work around gcc 4.0.3 bug
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800292 const GraphicPlane& graphicPlane(int dpy) const;
293 GraphicPlane& graphicPlane(int dpy);
Andy McFadden08c19be2009-10-29 10:19:34 -0700294private:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800295
296 void waitForEvent();
Andy McFaddenfa0a4bd2009-09-21 14:33:20 -0700297public: // hack to work around gcc 4.0.3 bug
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800298 void signalEvent();
Andy McFaddenfa0a4bd2009-09-21 14:33:20 -0700299private:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800300 void handleConsoleEvents();
301 void handleTransaction(uint32_t transactionFlags);
Mathias Agopian2d5ee252009-06-04 18:46:21 -0700302 void handleTransactionLocked(
303 uint32_t transactionFlags,
304 Vector< sp<LayerBase> >& ditchedLayers);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800305
306 void computeVisibleRegions(
307 LayerVector& currentLayers,
308 Region& dirtyRegion,
309 Region& wormholeRegion);
310
311 void handlePageFlip();
312 bool lockPageFlip(const LayerVector& currentLayers);
313 void unlockPageFlip(const LayerVector& currentLayers);
Mathias Agopiane0d5f5b2010-08-10 17:14:02 -0700314 void handleWorkList();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800315 void handleRepaint();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800316 void postFramebuffer();
317 void composeSurfaces(const Region& dirty);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800318
319
Mathias Agopian593c05c2010-06-02 23:28:45 -0700320 ssize_t addClientLayer(const sp<Client>& client,
321 const sp<LayerBaseClient>& lbc);
Mathias Agopian1473f462009-04-10 14:24:30 -0700322 status_t addLayer_l(const sp<LayerBase>& layer);
323 status_t removeLayer_l(const sp<LayerBase>& layer);
Mathias Agopian6cf0db22009-04-17 19:36:26 -0700324 status_t purgatorizeLayer_l(const sp<LayerBase>& layer);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800325
326 uint32_t getTransactionFlags(uint32_t flags);
Mathias Agopian898c4c92010-05-18 17:06:55 -0700327 uint32_t setTransactionFlags(uint32_t flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800328 void commitTransaction();
329
330
Mathias Agopian38ed2e32010-09-29 13:02:36 -0700331 status_t captureScreenImplLocked(DisplayID dpy,
332 sp<IMemoryHeap>* heap,
333 uint32_t* width, uint32_t* height, PixelFormat* format,
Mathias Agopian3dd25a62010-12-10 16:22:31 -0800334 uint32_t reqWidth, uint32_t reqHeight,
335 uint32_t minLayerZ, uint32_t maxLayerZ);
Mathias Agopian38ed2e32010-09-29 13:02:36 -0700336
Mathias Agopiand4e03f32010-10-14 14:54:06 -0700337 status_t turnElectronBeamOffImplLocked(int32_t mode);
338 status_t turnElectronBeamOnImplLocked(int32_t mode);
Mathias Agopian2d2b8032010-10-12 16:05:48 -0700339 status_t electronBeamOffAnimationImplLocked();
340 status_t electronBeamOnAnimationImplLocked();
341 status_t renderScreenToTextureLocked(DisplayID dpy,
342 GLuint* textureName, GLfloat* uOut, GLfloat* vOut);
Mathias Agopianaab758e2010-10-11 12:37:43 -0700343
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800344 friend class FreezeLock;
345 sp<FreezeLock> getFreezeLock() const;
Mathias Agopian0e449762009-12-01 17:23:28 -0800346 inline void incFreezeCount() {
347 if (mFreezeCount == 0)
348 mFreezeDisplayTime = 0;
349 mFreezeCount++;
350 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800351 inline void decFreezeCount() { if (mFreezeCount > 0) mFreezeCount--; }
352 inline bool hasFreezeRequest() const { return mFreezeDisplay; }
353 inline bool isFrozen() const {
Mathias Agopian6950e422009-10-05 17:07:12 -0700354 return (mFreezeDisplay || mFreezeCount>0) && mBootFinished;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800355 }
356
357
358 void debugFlashRegions();
359 void debugShowFPS() const;
360 void drawWormhole() const;
361
Mathias Agopian6ead5d92009-04-20 19:39:12 -0700362
363 mutable MessageQueue mEventQueue;
Mathias Agopian898c4c92010-05-18 17:06:55 -0700364
365 status_t postMessageAsync(const sp<MessageBase>& msg,
366 nsecs_t reltime=0, uint32_t flags = 0);
367
368 status_t postMessageSync(const sp<MessageBase>& msg,
369 nsecs_t reltime=0, uint32_t flags = 0);
Mathias Agopian7623da42010-06-01 15:12:58 -0700370
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800371 // access must be protected by mStateLock
372 mutable Mutex mStateLock;
373 State mCurrentState;
374 State mDrawingState;
375 volatile int32_t mTransactionFlags;
376 volatile int32_t mTransactionCount;
377 Condition mTransactionCV;
Mathias Agopianf4dfe1b2011-01-14 17:37:42 -0800378 SortedVector< sp<LayerBase> > mLayerPurgatory;
Mathias Agopian9779b222009-09-07 16:32:45 -0700379 bool mResizeTransationPending;
Mathias Agopian593c05c2010-06-02 23:28:45 -0700380
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800381 // protected by mStateLock (but we could use another lock)
Mathias Agopian593c05c2010-06-02 23:28:45 -0700382 GraphicPlane mGraphicPlanes[1];
383 bool mLayersRemoved;
Mathias Agopian7623da42010-06-01 15:12:58 -0700384 DefaultKeyedVector< wp<IBinder>, wp<Layer> > mLayerMap;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800385
386 // constant members (no synchronization needed for access)
Mathias Agopiand763b5d2009-07-02 18:11:53 -0700387 sp<IMemoryHeap> mServerHeap;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800388 surface_flinger_cblk_t* mServerCblk;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800389 GLuint mWormholeTexName;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800390 nsecs_t mBootTime;
Mathias Agopian151e8592009-06-15 18:24:59 -0700391 Permission mHardwareTest;
392 Permission mAccessSurfaceFlinger;
Mathias Agopianca5edbe2010-09-24 11:26:58 -0700393 Permission mReadFramebuffer;
Mathias Agopian151e8592009-06-15 18:24:59 -0700394 Permission mDump;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800395
396 // Can only accessed from the main thread, these members
397 // don't need synchronization
398 Region mDirtyRegion;
Mathias Agopian12cedff2009-07-28 10:57:27 -0700399 Region mDirtyRegionRemovedLayer;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800400 Region mInvalidRegion;
401 Region mWormholeRegion;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800402 bool mVisibleRegionsDirty;
Mathias Agopiane0d5f5b2010-08-10 17:14:02 -0700403 bool mHwWorkListDirty;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800404 bool mDeferReleaseConsole;
405 bool mFreezeDisplay;
Mathias Agopiand4e03f32010-10-14 14:54:06 -0700406 int32_t mElectronBeamAnimationMode;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800407 int32_t mFreezeCount;
408 nsecs_t mFreezeDisplayTime;
Mathias Agopianff1d4102010-08-10 17:19:56 -0700409 Vector< sp<LayerBase> > mVisibleLayersSortedByZ;
410
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800411
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800412 // don't use a lock for these, we don't care
413 int mDebugRegion;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800414 int mDebugBackground;
Mathias Agopian6a969242010-09-22 18:58:01 -0700415 int mDebugDisableHWC;
Mathias Agopiana8d49172009-08-26 16:36:26 -0700416 volatile nsecs_t mDebugInSwapBuffers;
417 nsecs_t mLastSwapBufferTime;
418 volatile nsecs_t mDebugInTransaction;
419 nsecs_t mLastTransactionTime;
Mathias Agopian6950e422009-10-05 17:07:12 -0700420 bool mBootFinished;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800421
422 // these are thread safe
423 mutable Barrier mReadyToRunBarrier;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800424
425 // atomic variables
426 enum {
427 eConsoleReleased = 1,
428 eConsoleAcquired = 2
429 };
430 volatile int32_t mConsoleSignals;
431
432 // only written in the main thread, only read in other threads
433 volatile int32_t mSecureFrameBuffer;
434};
435
436// ---------------------------------------------------------------------------
437
438class FreezeLock : public LightRefBase<FreezeLock> {
439 SurfaceFlinger* mFlinger;
440public:
441 FreezeLock(SurfaceFlinger* flinger)
442 : mFlinger(flinger) {
443 mFlinger->incFreezeCount();
444 }
445 ~FreezeLock() {
446 mFlinger->decFreezeCount();
447 }
448};
449
450// ---------------------------------------------------------------------------
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800451}; // namespace android
452
453#endif // ANDROID_SURFACE_FLINGER_H