blob: 2f2977a368e8a6b68ee6abec1de81992ebbb5b7b [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;
Mathias Agopian3dd25a62010-12-10 16:22:31 -0800212
213 virtual status_t captureScreen(DisplayID dpy,
214 sp<IMemoryHeap>* heap,
215 uint32_t* width, uint32_t* height,
216 PixelFormat* format, uint32_t reqWidth, uint32_t reqHeight,
217 uint32_t minLayerZ, uint32_t maxLayerZ);
218
Mathias Agopianaab758e2010-10-11 12:37:43 -0700219 virtual status_t turnElectronBeamOff(int32_t mode);
Mathias Agopian2d2b8032010-10-12 16:05:48 -0700220 virtual status_t turnElectronBeamOn(int32_t mode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800221
222 void screenReleased(DisplayID dpy);
223 void screenAcquired(DisplayID dpy);
224
Mathias Agopian1473f462009-04-10 14:24:30 -0700225 status_t removeLayer(const sp<LayerBase>& layer);
226 status_t addLayer(const sp<LayerBase>& layer);
227 status_t invalidateLayerVisibility(const sp<LayerBase>& layer);
Mathias Agopian7623da42010-06-01 15:12:58 -0700228
229 sp<Layer> getLayer(const sp<ISurface>& sur) const;
230
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800231private:
Mathias Agopian593c05c2010-06-02 23:28:45 -0700232 friend class Client;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800233 friend class LayerBase;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800234 friend class LayerBaseClient;
Mathias Agopian94aadce2009-07-06 19:04:03 -0700235 friend class LayerBaseClient::Surface;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800236 friend class Layer;
Mathias Agopian9cc88522009-06-18 18:48:39 -0700237 friend class LayerDim;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800238
Mathias Agopian593c05c2010-06-02 23:28:45 -0700239 sp<ISurface> createSurface(const sp<Client>& client,
240 int pid, const String8& name,
Mathias Agopian770492c2010-05-28 14:22:23 -0700241 ISurfaceComposerClient::surface_data_t* params,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800242 DisplayID display, uint32_t w, uint32_t h, PixelFormat format,
243 uint32_t flags);
244
Mathias Agopian7623da42010-06-01 15:12:58 -0700245 sp<Layer> createNormalSurface(
Mathias Agopian6edf5af2009-06-19 17:00:27 -0700246 const sp<Client>& client, DisplayID display,
Mathias Agopian593c05c2010-06-02 23:28:45 -0700247 uint32_t w, uint32_t h, uint32_t flags,
Mathias Agopian18b6b492009-08-19 17:46:26 -0700248 PixelFormat& format);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800249
Mathias Agopian7623da42010-06-01 15:12:58 -0700250 sp<LayerDim> createDimSurface(
Mathias Agopian6edf5af2009-06-19 17:00:27 -0700251 const sp<Client>& client, DisplayID display,
Mathias Agopian593c05c2010-06-02 23:28:45 -0700252 uint32_t w, uint32_t h, uint32_t flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800253
Mathias Agopian593c05c2010-06-02 23:28:45 -0700254 status_t removeSurface(const sp<Client>& client, SurfaceID sid);
Mathias Agopian6cf0db22009-04-17 19:36:26 -0700255 status_t destroySurface(const sp<LayerBaseClient>& layer);
Mathias Agopian593c05c2010-06-02 23:28:45 -0700256 status_t setClientState(const sp<Client>& client,
257 int32_t count, const layer_state_t* states);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800258
Mathias Agopian1efba9a2010-08-10 18:09:09 -0700259 class LayerVector : public SortedVector< sp<LayerBase> > {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800260 public:
Mathias Agopian1efba9a2010-08-10 18:09:09 -0700261 LayerVector() { }
262 LayerVector(const LayerVector& rhs) : SortedVector< sp<LayerBase> >(rhs) { }
263 virtual int do_compare(const void* lhs, const void* rhs) const {
264 const sp<LayerBase>& l(*reinterpret_cast<const sp<LayerBase>*>(lhs));
265 const sp<LayerBase>& r(*reinterpret_cast<const sp<LayerBase>*>(rhs));
266 // sort layers by Z order
267 uint32_t lz = l->currentState().z;
268 uint32_t rz = r->currentState().z;
269 // then by sequence, so we get a stable ordering
270 return (lz != rz) ? (lz - rz) : (l->sequence - r->sequence);
271 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800272 };
273
274 struct State {
275 State() {
276 orientation = ISurfaceComposer::eOrientationDefault;
277 freezeDisplay = 0;
278 }
279 LayerVector layersSortedByZ;
280 uint8_t orientation;
Mathias Agopianeb0c86e2009-03-27 18:11:38 -0700281 uint8_t orientationType;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800282 uint8_t freezeDisplay;
283 };
284
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800285 virtual bool threadLoop();
286 virtual status_t readyToRun();
287 virtual void onFirstRef();
288
Andy McFadden08c19be2009-10-29 10:19:34 -0700289public: // hack to work around gcc 4.0.3 bug
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800290 const GraphicPlane& graphicPlane(int dpy) const;
291 GraphicPlane& graphicPlane(int dpy);
Andy McFadden08c19be2009-10-29 10:19:34 -0700292private:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800293
294 void waitForEvent();
Andy McFaddenfa0a4bd2009-09-21 14:33:20 -0700295public: // hack to work around gcc 4.0.3 bug
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800296 void signalEvent();
Andy McFaddenfa0a4bd2009-09-21 14:33:20 -0700297private:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800298 void handleConsoleEvents();
299 void handleTransaction(uint32_t transactionFlags);
Mathias Agopian2d5ee252009-06-04 18:46:21 -0700300 void handleTransactionLocked(
301 uint32_t transactionFlags,
302 Vector< sp<LayerBase> >& ditchedLayers);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800303
304 void computeVisibleRegions(
305 LayerVector& currentLayers,
306 Region& dirtyRegion,
307 Region& wormholeRegion);
308
309 void handlePageFlip();
310 bool lockPageFlip(const LayerVector& currentLayers);
311 void unlockPageFlip(const LayerVector& currentLayers);
Mathias Agopiane0d5f5b2010-08-10 17:14:02 -0700312 void handleWorkList();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800313 void handleRepaint();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800314 void postFramebuffer();
315 void composeSurfaces(const Region& dirty);
316 void unlockClients();
317
318
Mathias Agopian593c05c2010-06-02 23:28:45 -0700319 ssize_t addClientLayer(const sp<Client>& client,
320 const sp<LayerBaseClient>& lbc);
Mathias Agopian1473f462009-04-10 14:24:30 -0700321 status_t addLayer_l(const sp<LayerBase>& layer);
322 status_t removeLayer_l(const sp<LayerBase>& layer);
Mathias Agopian6cf0db22009-04-17 19:36:26 -0700323 status_t purgatorizeLayer_l(const sp<LayerBase>& layer);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800324
325 uint32_t getTransactionFlags(uint32_t flags);
Mathias Agopian898c4c92010-05-18 17:06:55 -0700326 uint32_t setTransactionFlags(uint32_t flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800327 void commitTransaction();
328
329
Mathias Agopian38ed2e32010-09-29 13:02:36 -0700330 status_t captureScreenImplLocked(DisplayID dpy,
331 sp<IMemoryHeap>* heap,
332 uint32_t* width, uint32_t* height, PixelFormat* format,
Mathias Agopian3dd25a62010-12-10 16:22:31 -0800333 uint32_t reqWidth, uint32_t reqHeight,
334 uint32_t minLayerZ, uint32_t maxLayerZ);
Mathias Agopian38ed2e32010-09-29 13:02:36 -0700335
Mathias Agopiand4e03f32010-10-14 14:54:06 -0700336 status_t turnElectronBeamOffImplLocked(int32_t mode);
337 status_t turnElectronBeamOnImplLocked(int32_t mode);
Mathias Agopian2d2b8032010-10-12 16:05:48 -0700338 status_t electronBeamOffAnimationImplLocked();
339 status_t electronBeamOnAnimationImplLocked();
340 status_t renderScreenToTextureLocked(DisplayID dpy,
341 GLuint* textureName, GLfloat* uOut, GLfloat* vOut);
Mathias Agopianaab758e2010-10-11 12:37:43 -0700342
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800343 friend class FreezeLock;
344 sp<FreezeLock> getFreezeLock() const;
Mathias Agopian0e449762009-12-01 17:23:28 -0800345 inline void incFreezeCount() {
346 if (mFreezeCount == 0)
347 mFreezeDisplayTime = 0;
348 mFreezeCount++;
349 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800350 inline void decFreezeCount() { if (mFreezeCount > 0) mFreezeCount--; }
351 inline bool hasFreezeRequest() const { return mFreezeDisplay; }
352 inline bool isFrozen() const {
Mathias Agopian6950e422009-10-05 17:07:12 -0700353 return (mFreezeDisplay || mFreezeCount>0) && mBootFinished;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800354 }
355
356
357 void debugFlashRegions();
358 void debugShowFPS() const;
359 void drawWormhole() const;
360
Mathias Agopian6ead5d92009-04-20 19:39:12 -0700361
362 mutable MessageQueue mEventQueue;
Mathias Agopian898c4c92010-05-18 17:06:55 -0700363
364 status_t postMessageAsync(const sp<MessageBase>& msg,
365 nsecs_t reltime=0, uint32_t flags = 0);
366
367 status_t postMessageSync(const sp<MessageBase>& msg,
368 nsecs_t reltime=0, uint32_t flags = 0);
Mathias Agopian7623da42010-06-01 15:12:58 -0700369
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800370 // access must be protected by mStateLock
371 mutable Mutex mStateLock;
372 State mCurrentState;
373 State mDrawingState;
374 volatile int32_t mTransactionFlags;
375 volatile int32_t mTransactionCount;
376 Condition mTransactionCV;
Mathias Agopian9779b2212009-09-07 16:32:45 -0700377 bool mResizeTransationPending;
Mathias Agopian593c05c2010-06-02 23:28:45 -0700378
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800379 // protected by mStateLock (but we could use another lock)
Mathias Agopian593c05c2010-06-02 23:28:45 -0700380 GraphicPlane mGraphicPlanes[1];
381 bool mLayersRemoved;
Mathias Agopian7623da42010-06-01 15:12:58 -0700382 DefaultKeyedVector< wp<IBinder>, wp<Layer> > mLayerMap;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800383
384 // constant members (no synchronization needed for access)
Mathias Agopiand763b5d2009-07-02 18:11:53 -0700385 sp<IMemoryHeap> mServerHeap;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800386 surface_flinger_cblk_t* mServerCblk;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800387 GLuint mWormholeTexName;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800388 nsecs_t mBootTime;
Mathias Agopian151e8592009-06-15 18:24:59 -0700389 Permission mHardwareTest;
390 Permission mAccessSurfaceFlinger;
Mathias Agopianca5edbe2010-09-24 11:26:58 -0700391 Permission mReadFramebuffer;
Mathias Agopian151e8592009-06-15 18:24:59 -0700392 Permission mDump;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800393
394 // Can only accessed from the main thread, these members
395 // don't need synchronization
396 Region mDirtyRegion;
Mathias Agopian12cedff2009-07-28 10:57:27 -0700397 Region mDirtyRegionRemovedLayer;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800398 Region mInvalidRegion;
399 Region mWormholeRegion;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800400 bool mVisibleRegionsDirty;
Mathias Agopiane0d5f5b2010-08-10 17:14:02 -0700401 bool mHwWorkListDirty;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800402 bool mDeferReleaseConsole;
403 bool mFreezeDisplay;
Mathias Agopiand4e03f32010-10-14 14:54:06 -0700404 int32_t mElectronBeamAnimationMode;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800405 int32_t mFreezeCount;
406 nsecs_t mFreezeDisplayTime;
Mathias Agopianff1d4102010-08-10 17:19:56 -0700407 Vector< sp<LayerBase> > mVisibleLayersSortedByZ;
408
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800409
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800410 // don't use a lock for these, we don't care
411 int mDebugRegion;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800412 int mDebugBackground;
Mathias Agopian6a969242010-09-22 18:58:01 -0700413 int mDebugDisableHWC;
Mathias Agopiana8d49172009-08-26 16:36:26 -0700414 volatile nsecs_t mDebugInSwapBuffers;
415 nsecs_t mLastSwapBufferTime;
416 volatile nsecs_t mDebugInTransaction;
417 nsecs_t mLastTransactionTime;
Mathias Agopian6950e422009-10-05 17:07:12 -0700418 bool mBootFinished;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800419
420 // these are thread safe
421 mutable Barrier mReadyToRunBarrier;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800422
423 // atomic variables
424 enum {
425 eConsoleReleased = 1,
426 eConsoleAcquired = 2
427 };
428 volatile int32_t mConsoleSignals;
429
430 // only written in the main thread, only read in other threads
431 volatile int32_t mSecureFrameBuffer;
432};
433
434// ---------------------------------------------------------------------------
435
436class FreezeLock : public LightRefBase<FreezeLock> {
437 SurfaceFlinger* mFlinger;
438public:
439 FreezeLock(SurfaceFlinger* flinger)
440 : mFlinger(flinger) {
441 mFlinger->incFreezeCount();
442 }
443 ~FreezeLock() {
444 mFlinger->decFreezeCount();
445 }
446};
447
448// ---------------------------------------------------------------------------
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800449}; // namespace android
450
451#endif // ANDROID_SURFACE_FLINGER_H