blob: 3284fdba999a031efc8e22760f768b2bcab8030d [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
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080023#include <utils/Atomic.h>
24#include <utils/Errors.h>
Mathias Agopian0dd593f2011-06-27 16:05:52 -070025#include <utils/KeyedVector.h>
Mathias Agopian1473f462009-04-10 14:24:30 -070026#include <utils/RefBase.h>
Mathias Agopian0dd593f2011-06-27 16:05:52 -070027#include <utils/SortedVector.h>
28#include <utils/threads.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029
Mathias Agopian24651682010-07-14 18:41:18 -070030#include <binder/BinderService.h>
Mathias Agopian0dd593f2011-06-27 16:05:52 -070031#include <binder/IMemory.h>
Mathias Agopian151e8592009-06-15 18:24:59 -070032
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033#include <ui/PixelFormat.h>
Mathias Agopian0dd593f2011-06-27 16:05:52 -070034#include <surfaceflinger/IGraphicBufferAlloc.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>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080037
38#include "Barrier.h"
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039#include "Layer.h"
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080040
Mathias Agopian6ead5d92009-04-20 19:39:12 -070041#include "MessageQueue.h"
42
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043namespace android {
44
45// ---------------------------------------------------------------------------
46
47class Client;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080048class DisplayHardware;
49class FreezeLock;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080050class Layer;
Mathias Agopian7623da42010-06-01 15:12:58 -070051class LayerDim;
Mathias Agopian0ab84ef2011-10-13 16:02:48 -070052class LayerScreenshot;
Mathias Agopian7bb843c2011-04-20 14:20:59 -070053struct surface_flinger_cblk_t;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080054
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080055#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
56#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
57
58// ---------------------------------------------------------------------------
59
Mathias Agopian593c05c2010-06-02 23:28:45 -070060class Client : public BnSurfaceComposerClient
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080061{
62public:
Mathias Agopian593c05c2010-06-02 23:28:45 -070063 Client(const sp<SurfaceFlinger>& flinger);
64 ~Client();
65
66 status_t initCheck() const;
67
68 // protected by SurfaceFlinger::mStateLock
Mathias Agopian5fa7ad62011-05-03 16:21:41 -070069 size_t attachLayer(const sp<LayerBaseClient>& layer);
Mathias Agopian7623da42010-06-01 15:12:58 -070070 void detachLayer(const LayerBaseClient* layer);
Mathias Agopian593c05c2010-06-02 23:28:45 -070071 sp<LayerBaseClient> getLayerUser(int32_t i) const;
Mathias Agopian593c05c2010-06-02 23:28:45 -070072
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080073private:
Mathias Agopian593c05c2010-06-02 23:28:45 -070074 // ISurfaceComposerClient interface
Mathias Agopian593c05c2010-06-02 23:28:45 -070075 virtual sp<ISurface> createSurface(
Mathias Agopian9638e5c2011-04-20 14:19:32 -070076 surface_data_t* params, const String8& name,
Mathias Agopian593c05c2010-06-02 23:28:45 -070077 DisplayID display, uint32_t w, uint32_t h,PixelFormat format,
78 uint32_t flags);
79 virtual status_t destroySurface(SurfaceID surfaceId);
Mathias Agopian7bb843c2011-04-20 14:20:59 -070080 virtual status_t onTransact(
81 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags);
Mathias Agopian593c05c2010-06-02 23:28:45 -070082
Mathias Agopian5fa7ad62011-05-03 16:21:41 -070083 // constant
Mathias Agopian7623da42010-06-01 15:12:58 -070084 sp<SurfaceFlinger> mFlinger;
Mathias Agopian5fa7ad62011-05-03 16:21:41 -070085
86 // protected by mLock
87 DefaultKeyedVector< size_t, wp<LayerBaseClient> > mLayers;
88 size_t mNameGenerator;
89
90 // thread-safe
91 mutable Mutex mLock;
Mathias Agopian7623da42010-06-01 15:12:58 -070092};
93
Jamie Gennisf7acf162011-01-12 18:30:40 -080094class GraphicBufferAlloc : public BnGraphicBufferAlloc
95{
96public:
97 GraphicBufferAlloc();
98 virtual ~GraphicBufferAlloc();
Jamie Gennisf7acf162011-01-12 18:30:40 -080099 virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
Mathias Agopianeec0f7e2011-07-01 14:53:49 -0700100 PixelFormat format, uint32_t usage, status_t* error);
Jamie Gennisf7acf162011-01-12 18:30:40 -0800101};
102
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800103// ---------------------------------------------------------------------------
104
105class GraphicPlane
106{
107public:
108 static status_t orientationToTransfrom(int orientation, int w, int h,
109 Transform* tr);
110
111 GraphicPlane();
112 ~GraphicPlane();
113
114 bool initialized() const;
115
116 void setDisplayHardware(DisplayHardware *);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800117 status_t setOrientation(int orientation);
Mathias Agopian3552f532009-03-27 17:58:20 -0700118 int getOrientation() const { return mOrientation; }
Mathias Agopian66c77a52010-02-08 15:49:35 -0800119 int getWidth() const;
120 int getHeight() const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800121
122 const DisplayHardware& displayHardware() const;
Mathias Agopianaab758e2010-10-11 12:37:43 -0700123 DisplayHardware& editDisplayHardware();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800124 const Transform& transform() const;
Mathias Agopian1473f462009-04-10 14:24:30 -0700125 EGLDisplay getEGLDisplay() const;
126
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800127private:
128 GraphicPlane(const GraphicPlane&);
129 GraphicPlane operator = (const GraphicPlane&);
130
131 DisplayHardware* mHw;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800132 Transform mGlobalTransform;
Mathias Agopian66c77a52010-02-08 15:49:35 -0800133 Transform mDisplayTransform;
Mathias Agopian3552f532009-03-27 17:58:20 -0700134 int mOrientation;
Mathias Agopian66c77a52010-02-08 15:49:35 -0800135 float mDisplayWidth;
136 float mDisplayHeight;
137 int mWidth;
138 int mHeight;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800139};
140
141// ---------------------------------------------------------------------------
142
143enum {
144 eTransactionNeeded = 0x01,
145 eTraversalNeeded = 0x02
146};
147
Mathias Agopian24651682010-07-14 18:41:18 -0700148class SurfaceFlinger :
149 public BinderService<SurfaceFlinger>,
150 public BnSurfaceComposer,
Mathias Agopian0c63ef52011-07-01 17:08:43 -0700151 public IBinder::DeathRecipient,
Mathias Agopian24651682010-07-14 18:41:18 -0700152 protected Thread
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800153{
154public:
Mathias Agopian24651682010-07-14 18:41:18 -0700155 static char const* getServiceName() { return "SurfaceFlinger"; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800156
157 SurfaceFlinger();
158 virtual ~SurfaceFlinger();
159 void init();
160
161 virtual status_t onTransact(
162 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags);
163
164 virtual status_t dump(int fd, const Vector<String16>& args);
165
166 // ISurfaceComposer interface
Mathias Agopian770492c2010-05-28 14:22:23 -0700167 virtual sp<ISurfaceComposerClient> createConnection();
Jamie Gennisf7acf162011-01-12 18:30:40 -0800168 virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc();
Mathias Agopiand763b5d2009-07-02 18:11:53 -0700169 virtual sp<IMemoryHeap> getCblk() const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800170 virtual void bootFinished();
Jamie Gennise2909e12011-10-10 15:48:06 -0700171 virtual void setTransactionState(const Vector<ComposerState>& state,
172 int orientation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800173 virtual status_t freezeDisplay(DisplayID dpy, uint32_t flags);
174 virtual status_t unfreezeDisplay(DisplayID dpy, uint32_t flags);
Mathias Agopianeb0c86e2009-03-27 18:11:38 -0700175 virtual int setOrientation(DisplayID dpy, int orientation, uint32_t flags);
Jamie Gennis9b8fc652011-08-17 18:19:00 -0700176 virtual bool authenticateSurfaceTexture(const sp<ISurfaceTexture>& surface) const;
Mathias Agopian3dd25a62010-12-10 16:22:31 -0800177
178 virtual status_t captureScreen(DisplayID dpy,
179 sp<IMemoryHeap>* heap,
180 uint32_t* width, uint32_t* height,
181 PixelFormat* format, uint32_t reqWidth, uint32_t reqHeight,
182 uint32_t minLayerZ, uint32_t maxLayerZ);
183
Mathias Agopianaab758e2010-10-11 12:37:43 -0700184 virtual status_t turnElectronBeamOff(int32_t mode);
Mathias Agopian2d2b8032010-10-12 16:05:48 -0700185 virtual status_t turnElectronBeamOn(int32_t mode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800186
187 void screenReleased(DisplayID dpy);
188 void screenAcquired(DisplayID dpy);
189
Mathias Agopian0ab84ef2011-10-13 16:02:48 -0700190 status_t renderScreenToTexture(DisplayID dpy,
191 GLuint* textureName, GLfloat* uOut, GLfloat* vOut);
192
193 status_t postMessageAsync(const sp<MessageBase>& msg,
194 nsecs_t reltime=0, uint32_t flags = 0);
195
196 status_t postMessageSync(const sp<MessageBase>& msg,
197 nsecs_t reltime=0, uint32_t flags = 0);
198
Mathias Agopian1473f462009-04-10 14:24:30 -0700199 status_t removeLayer(const sp<LayerBase>& layer);
200 status_t addLayer(const sp<LayerBase>& layer);
201 status_t invalidateLayerVisibility(const sp<LayerBase>& layer);
Mathias Agopianfb4dcb12011-01-13 17:53:01 -0800202 void invalidateHwcGeometry();
Mathias Agopian7623da42010-06-01 15:12:58 -0700203
204 sp<Layer> getLayer(const sp<ISurface>& sur) const;
205
Jamie Gennis830d0832011-10-07 14:51:16 -0700206 GLuint getProtectedTexName() const { return mProtectedTexName; }
207
Mathias Agopian0ab84ef2011-10-13 16:02:48 -0700208
209 class MessageDestroyGLTexture : public MessageBase {
210 GLuint texture;
211 public:
212 MessageDestroyGLTexture(GLuint texture) : texture(texture) { }
213 virtual bool handler() {
214 glDeleteTextures(1, &texture);
215 return true;
216 }
217 };
218
219
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800220private:
Mathias Agopian0c63ef52011-07-01 17:08:43 -0700221 // DeathRecipient interface
222 virtual void binderDied(const wp<IBinder>& who);
223
224private:
Mathias Agopian593c05c2010-06-02 23:28:45 -0700225 friend class Client;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800226 friend class LayerBase;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800227 friend class LayerBaseClient;
228 friend class Layer;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800229
Mathias Agopian9638e5c2011-04-20 14:19:32 -0700230 sp<ISurface> createSurface(
Mathias Agopian770492c2010-05-28 14:22:23 -0700231 ISurfaceComposerClient::surface_data_t* params,
Mathias Agopian9638e5c2011-04-20 14:19:32 -0700232 const String8& name,
233 const sp<Client>& client,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800234 DisplayID display, uint32_t w, uint32_t h, PixelFormat format,
235 uint32_t flags);
236
Mathias Agopian7623da42010-06-01 15:12:58 -0700237 sp<Layer> createNormalSurface(
Mathias Agopian6edf5af2009-06-19 17:00:27 -0700238 const sp<Client>& client, DisplayID display,
Mathias Agopian593c05c2010-06-02 23:28:45 -0700239 uint32_t w, uint32_t h, uint32_t flags,
Mathias Agopian18b6b492009-08-19 17:46:26 -0700240 PixelFormat& format);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800241
Mathias Agopian7623da42010-06-01 15:12:58 -0700242 sp<LayerDim> createDimSurface(
Mathias Agopian6edf5af2009-06-19 17:00:27 -0700243 const sp<Client>& client, DisplayID display,
Mathias Agopian593c05c2010-06-02 23:28:45 -0700244 uint32_t w, uint32_t h, uint32_t flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800245
Mathias Agopian0ab84ef2011-10-13 16:02:48 -0700246 sp<LayerScreenshot> createScreenshotSurface(
247 const sp<Client>& client, DisplayID display,
248 uint32_t w, uint32_t h, uint32_t flags);
249
Mathias Agopian593c05c2010-06-02 23:28:45 -0700250 status_t removeSurface(const sp<Client>& client, SurfaceID sid);
Mathias Agopian69608112011-05-19 15:38:14 -0700251 status_t destroySurface(const wp<LayerBaseClient>& layer);
Mathias Agopian439863f2011-06-28 19:09:31 -0700252 uint32_t setClientStateLocked(const sp<Client>& client, const layer_state_t& s);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800253
Mathias Agopian1efba9a2010-08-10 18:09:09 -0700254 class LayerVector : public SortedVector< sp<LayerBase> > {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800255 public:
Mathias Agopian1efba9a2010-08-10 18:09:09 -0700256 LayerVector() { }
257 LayerVector(const LayerVector& rhs) : SortedVector< sp<LayerBase> >(rhs) { }
258 virtual int do_compare(const void* lhs, const void* rhs) const {
259 const sp<LayerBase>& l(*reinterpret_cast<const sp<LayerBase>*>(lhs));
260 const sp<LayerBase>& r(*reinterpret_cast<const sp<LayerBase>*>(rhs));
261 // sort layers by Z order
262 uint32_t lz = l->currentState().z;
263 uint32_t rz = r->currentState().z;
264 // then by sequence, so we get a stable ordering
265 return (lz != rz) ? (lz - rz) : (l->sequence - r->sequence);
266 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800267 };
268
269 struct State {
270 State() {
271 orientation = ISurfaceComposer::eOrientationDefault;
272 freezeDisplay = 0;
273 }
274 LayerVector layersSortedByZ;
275 uint8_t orientation;
Jeff Brown01a98dd2011-09-20 15:08:29 -0700276 uint8_t orientationFlags;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800277 uint8_t freezeDisplay;
278 };
279
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800280 virtual bool threadLoop();
281 virtual status_t readyToRun();
282 virtual void onFirstRef();
283
Andy McFadden08c19be2009-10-29 10:19:34 -0700284public: // hack to work around gcc 4.0.3 bug
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800285 const GraphicPlane& graphicPlane(int dpy) const;
286 GraphicPlane& graphicPlane(int dpy);
Mathias Agopianedaab942011-10-05 15:00:22 -0700287 void signalEvent();
288 void repaintEverything();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800289
Andy McFaddenfa0a4bd2009-09-21 14:33:20 -0700290private:
Mathias Agopianedaab942011-10-05 15:00:22 -0700291 void waitForEvent();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800292 void handleConsoleEvents();
293 void handleTransaction(uint32_t transactionFlags);
Mathias Agopian69608112011-05-19 15:38:14 -0700294 void handleTransactionLocked(uint32_t transactionFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800295
296 void computeVisibleRegions(
Mathias Agopianf0ff9062011-03-11 16:54:47 -0800297 const LayerVector& currentLayers,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800298 Region& dirtyRegion,
299 Region& wormholeRegion);
300
301 void handlePageFlip();
302 bool lockPageFlip(const LayerVector& currentLayers);
303 void unlockPageFlip(const LayerVector& currentLayers);
Mathias Agopiane0d5f5b2010-08-10 17:14:02 -0700304 void handleWorkList();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800305 void handleRepaint();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800306 void postFramebuffer();
Mathias Agopian88cde072011-09-20 17:21:56 -0700307 void setupHardwareComposer(Region& dirtyInOut);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800308 void composeSurfaces(const Region& dirty);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800309
310
Mathias Agopian6497eab2011-10-21 15:18:28 -0700311 void setInvalidateRegion(const Region& reg);
312 Region getAndClearInvalidateRegion();
313
Mathias Agopian593c05c2010-06-02 23:28:45 -0700314 ssize_t addClientLayer(const sp<Client>& client,
315 const sp<LayerBaseClient>& lbc);
Mathias Agopian1473f462009-04-10 14:24:30 -0700316 status_t addLayer_l(const sp<LayerBase>& layer);
317 status_t removeLayer_l(const sp<LayerBase>& layer);
Mathias Agopian6cf0db22009-04-17 19:36:26 -0700318 status_t purgatorizeLayer_l(const sp<LayerBase>& layer);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800319
320 uint32_t getTransactionFlags(uint32_t flags);
Mathias Agopian6dcb1552011-05-03 17:04:02 -0700321 uint32_t peekTransactionFlags(uint32_t flags);
Mathias Agopian898c4c92010-05-18 17:06:55 -0700322 uint32_t setTransactionFlags(uint32_t flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800323 void commitTransaction();
324
325
Mathias Agopian38ed2e32010-09-29 13:02:36 -0700326 status_t captureScreenImplLocked(DisplayID dpy,
327 sp<IMemoryHeap>* heap,
328 uint32_t* width, uint32_t* height, PixelFormat* format,
Mathias Agopian3dd25a62010-12-10 16:22:31 -0800329 uint32_t reqWidth, uint32_t reqHeight,
330 uint32_t minLayerZ, uint32_t maxLayerZ);
Mathias Agopian38ed2e32010-09-29 13:02:36 -0700331
Mathias Agopiand4e03f32010-10-14 14:54:06 -0700332 status_t turnElectronBeamOffImplLocked(int32_t mode);
333 status_t turnElectronBeamOnImplLocked(int32_t mode);
Mathias Agopian2d2b8032010-10-12 16:05:48 -0700334 status_t electronBeamOffAnimationImplLocked();
335 status_t electronBeamOnAnimationImplLocked();
336 status_t renderScreenToTextureLocked(DisplayID dpy,
337 GLuint* textureName, GLfloat* uOut, GLfloat* vOut);
Mathias Agopianaab758e2010-10-11 12:37:43 -0700338
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800339 friend class FreezeLock;
340 sp<FreezeLock> getFreezeLock() const;
Mathias Agopian0e449762009-12-01 17:23:28 -0800341 inline void incFreezeCount() {
342 if (mFreezeCount == 0)
343 mFreezeDisplayTime = 0;
344 mFreezeCount++;
345 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800346 inline void decFreezeCount() { if (mFreezeCount > 0) mFreezeCount--; }
347 inline bool hasFreezeRequest() const { return mFreezeDisplay; }
348 inline bool isFrozen() const {
Mathias Agopian6950e422009-10-05 17:07:12 -0700349 return (mFreezeDisplay || mFreezeCount>0) && mBootFinished;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800350 }
351
352
353 void debugFlashRegions();
354 void debugShowFPS() const;
355 void drawWormhole() const;
356
Mathias Agopian6ead5d92009-04-20 19:39:12 -0700357
358 mutable MessageQueue mEventQueue;
Mathias Agopian898c4c92010-05-18 17:06:55 -0700359
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800360 // access must be protected by mStateLock
361 mutable Mutex mStateLock;
362 State mCurrentState;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800363 volatile int32_t mTransactionFlags;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800364 Condition mTransactionCV;
Mathias Agopianf4dfe1b2011-01-14 17:37:42 -0800365 SortedVector< sp<LayerBase> > mLayerPurgatory;
Mathias Agopian9779b222009-09-07 16:32:45 -0700366 bool mResizeTransationPending;
Mathias Agopian593c05c2010-06-02 23:28:45 -0700367
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800368 // protected by mStateLock (but we could use another lock)
Mathias Agopian593c05c2010-06-02 23:28:45 -0700369 GraphicPlane mGraphicPlanes[1];
370 bool mLayersRemoved;
Mathias Agopian7623da42010-06-01 15:12:58 -0700371 DefaultKeyedVector< wp<IBinder>, wp<Layer> > mLayerMap;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800372
Mathias Agopian6497eab2011-10-21 15:18:28 -0700373 // access must be protected by mInvalidateLock
374 mutable Mutex mInvalidateLock;
375 Region mInvalidateRegion;
376
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800377 // constant members (no synchronization needed for access)
Mathias Agopiand763b5d2009-07-02 18:11:53 -0700378 sp<IMemoryHeap> mServerHeap;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800379 surface_flinger_cblk_t* mServerCblk;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800380 GLuint mWormholeTexName;
Jamie Gennis830d0832011-10-07 14:51:16 -0700381 GLuint mProtectedTexName;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800382 nsecs_t mBootTime;
Mathias Agopian0dd593f2011-06-27 16:05:52 -0700383
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800384 // Can only accessed from the main thread, these members
385 // don't need synchronization
Mathias Agopianf0ff9062011-03-11 16:54:47 -0800386 State mDrawingState;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800387 Region mDirtyRegion;
Mathias Agopian12cedff2009-07-28 10:57:27 -0700388 Region mDirtyRegionRemovedLayer;
Mathias Agopiand0f2f0d2011-09-20 17:22:44 -0700389 Region mSwapRegion;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800390 Region mWormholeRegion;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800391 bool mVisibleRegionsDirty;
Mathias Agopiane0d5f5b2010-08-10 17:14:02 -0700392 bool mHwWorkListDirty;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800393 bool mFreezeDisplay;
Mathias Agopiand4e03f32010-10-14 14:54:06 -0700394 int32_t mElectronBeamAnimationMode;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800395 int32_t mFreezeCount;
396 nsecs_t mFreezeDisplayTime;
Mathias Agopianff1d4102010-08-10 17:19:56 -0700397 Vector< sp<LayerBase> > mVisibleLayersSortedByZ;
398
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800399
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800400 // don't use a lock for these, we don't care
401 int mDebugRegion;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800402 int mDebugBackground;
Mathias Agopian93d75ec2011-08-15 20:44:40 -0700403 int mDebugDDMS;
Mathias Agopian6a969242010-09-22 18:58:01 -0700404 int mDebugDisableHWC;
Mathias Agopian2143fe02011-08-23 18:03:18 -0700405 int mDebugDisableTransformHint;
Mathias Agopiana8d49172009-08-26 16:36:26 -0700406 volatile nsecs_t mDebugInSwapBuffers;
407 nsecs_t mLastSwapBufferTime;
408 volatile nsecs_t mDebugInTransaction;
409 nsecs_t mLastTransactionTime;
Mathias Agopian6950e422009-10-05 17:07:12 -0700410 bool mBootFinished;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800411
412 // these are thread safe
413 mutable Barrier mReadyToRunBarrier;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800414
Mathias Agopian69608112011-05-19 15:38:14 -0700415
416 // protected by mDestroyedLayerLock;
417 mutable Mutex mDestroyedLayerLock;
418 Vector<LayerBase const *> mDestroyedLayers;
419
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800420 // atomic variables
421 enum {
422 eConsoleReleased = 1,
423 eConsoleAcquired = 2
424 };
425 volatile int32_t mConsoleSignals;
426
427 // only written in the main thread, only read in other threads
428 volatile int32_t mSecureFrameBuffer;
429};
430
431// ---------------------------------------------------------------------------
432
433class FreezeLock : public LightRefBase<FreezeLock> {
434 SurfaceFlinger* mFlinger;
435public:
436 FreezeLock(SurfaceFlinger* flinger)
437 : mFlinger(flinger) {
438 mFlinger->incFreezeCount();
439 }
440 ~FreezeLock() {
441 mFlinger->decFreezeCount();
442 }
443};
444
445// ---------------------------------------------------------------------------
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800446}; // namespace android
447
448#endif // ANDROID_SURFACE_FLINGER_H