blob: 64181222c55c6a289b5f5771e572b6a75b150cc1 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-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
Mathias Agopian921e6ac2012-07-23 23:11:29 -070023#include <EGL/egl.h>
24#include <GLES/gl.h>
25
Glenn Kasten99ed2242011-12-15 09:51:17 -080026#include <cutils/compiler.h>
27
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080028#include <utils/Atomic.h>
29#include <utils/Errors.h>
Mathias Agopian99b49842011-06-27 16:05:52 -070030#include <utils/KeyedVector.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070031#include <utils/RefBase.h>
Mathias Agopian99b49842011-06-27 16:05:52 -070032#include <utils/SortedVector.h>
33#include <utils/threads.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080034
Mathias Agopiana1e6bc82010-07-14 18:41:18 -070035#include <binder/BinderService.h>
Mathias Agopian99b49842011-06-27 16:05:52 -070036#include <binder/IMemory.h>
Mathias Agopian375f5632009-06-15 18:24:59 -070037
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080038#include <ui/PixelFormat.h>
Mathias Agopian921e6ac2012-07-23 23:11:29 -070039
Mathias Agopian90ac7992012-02-25 18:48:35 -080040#include <gui/IGraphicBufferAlloc.h>
41#include <gui/ISurfaceComposer.h>
42#include <gui/ISurfaceComposerClient.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080043
Mathias Agopian86303202012-07-24 22:46:10 -070044#include <hardware/hwcomposer_defs.h>
45
Mathias Agopian921e6ac2012-07-23 23:11:29 -070046#include <private/gui/LayerState.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080047
Mathias Agopian921e6ac2012-07-23 23:11:29 -070048#include "Barrier.h"
Mathias Agopianf1d8e872009-04-20 19:39:12 -070049#include "MessageQueue.h"
50
Mathias Agopian86303202012-07-24 22:46:10 -070051#include "DisplayHardware/HWComposer.h"
52
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080053namespace android {
54
55// ---------------------------------------------------------------------------
56
57class Client;
Mathias Agopiand0566bc2011-11-17 17:49:17 -080058class DisplayEventConnection;
Mathias Agopian921e6ac2012-07-23 23:11:29 -070059class DisplayHardware;
Mathias Agopiand0566bc2011-11-17 17:49:17 -080060class EventThread;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080061class Layer;
Mathias Agopian921e6ac2012-07-23 23:11:29 -070062class LayerBase;
63class LayerBaseClient;
Mathias Agopianb7e930d2010-06-01 15:12:58 -070064class LayerDim;
Mathias Agopian118d0242011-10-13 16:02:48 -070065class LayerScreenshot;
Mathias Agopian921e6ac2012-07-23 23:11:29 -070066class SurfaceTextureClient;
Mathias Agopiana67932f2011-04-20 14:20:59 -070067struct surface_flinger_cblk_t;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080068
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080069// ---------------------------------------------------------------------------
70
Mathias Agopian921e6ac2012-07-23 23:11:29 -070071class GraphicBufferAlloc : public BnGraphicBufferAlloc {
Jamie Gennis9a78c902011-01-12 18:30:40 -080072public:
73 GraphicBufferAlloc();
74 virtual ~GraphicBufferAlloc();
Jamie Gennis9a78c902011-01-12 18:30:40 -080075 virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
Mathias Agopiand9e8c642011-07-01 14:53:49 -070076 PixelFormat format, uint32_t usage, status_t* error);
Jamie Gennis9a78c902011-01-12 18:30:40 -080077};
78
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080079// ---------------------------------------------------------------------------
80
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080081enum {
Mathias Agopian921e6ac2012-07-23 23:11:29 -070082 eTransactionNeeded = 0x01, eTraversalNeeded = 0x02
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080083};
84
Mathias Agopian921e6ac2012-07-23 23:11:29 -070085class SurfaceFlinger : public BinderService<SurfaceFlinger>,
86 public BnSurfaceComposer,
87 private IBinder::DeathRecipient,
Mathias Agopian86303202012-07-24 22:46:10 -070088 private Thread,
89 private HWComposer::EventHandler
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080090{
91public:
Mathias Agopian921e6ac2012-07-23 23:11:29 -070092 static char const* getServiceName() {
93 return "SurfaceFlinger";
94 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080095
Mathias Agopian921e6ac2012-07-23 23:11:29 -070096 SurfaceFlinger();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080097
Mathias Agopian86303202012-07-24 22:46:10 -070098 enum {
99 EVENT_VSYNC = HWC_EVENT_VSYNC
100 };
101
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700102 // post an asynchronous message to the main thread
103 status_t postMessageAsync(const sp<MessageBase>& msg, nsecs_t reltime = 0,
104 uint32_t flags = 0);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800105
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700106 // post a synchronous message to the main thread
107 status_t postMessageSync(const sp<MessageBase>& msg, nsecs_t reltime = 0,
108 uint32_t flags = 0);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800109
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700110 // force full composition on all displays
111 void repaintEverything();
Mathias Agopianbf2c6a62010-12-10 16:22:31 -0800112
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700113 // renders content on given display to a texture. thread-safe version.
114 status_t renderScreenToTexture(DisplayID dpy, GLuint* textureName,
115 GLfloat* uOut, GLfloat* vOut);
Mathias Agopianbf2c6a62010-12-10 16:22:31 -0800116
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700117 // renders content on given display to a texture, w/o acquiring main lock
118 status_t renderScreenToTextureLocked(DisplayID dpy, GLuint* textureName,
119 GLfloat* uOut, GLfloat* vOut);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800120
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700121 // returns the default Display
122 const DisplayHardware& getDefaultDisplayHardware() const {
123 return getDisplayHardware(0);
124 }
Mathias Agopianb60314a2012-04-10 22:09:54 -0700125
Mathias Agopian86303202012-07-24 22:46:10 -0700126 // utility function to delete a texture on the main thread
127 void deleteTextureAsync(GLuint texture);
128
129
130 // enable/disable h/w composer event
131 // TODO: this should be made accessible only to EventThread
132 void eventControl(int event, int enabled);
133
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700134 // called on the main thread by MessageQueue when an internal message
135 // is received
136 // TODO: this should be made accessible only to MessageQueue
137 void onMessageReceived(int32_t what);
Mathias Agopian3094df32012-06-18 18:06:45 -0700138
Mathias Agopian1f339ff2011-07-01 17:08:43 -0700139private:
Mathias Agopian96f08192010-06-02 23:28:45 -0700140 friend class Client;
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800141 friend class DisplayEventConnection;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800142 friend class LayerBase;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800143 friend class LayerBaseClient;
144 friend class Layer;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800145
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700146 // We're reference counted, never destroy SurfaceFlinger directly
147 virtual ~SurfaceFlinger();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800148
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700149 /* ------------------------------------------------------------------------
150 * Internal data structures
151 */
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800152
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700153 class LayerVector : public SortedVector<sp<LayerBase> > {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800154 public:
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700155 LayerVector();
156 LayerVector(const LayerVector& rhs);
157 virtual int do_compare(const void* lhs, const void* rhs) const;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800158 };
159
160 struct State {
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700161 State();
162 LayerVector layersSortedByZ;
163 uint8_t orientation;
164 uint8_t orientationFlags;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800165 };
166
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700167 /* ------------------------------------------------------------------------
168 * IBinder interface
169 */
170 virtual status_t onTransact(uint32_t code, const Parcel& data,
171 Parcel* reply, uint32_t flags);
172 virtual status_t dump(int fd, const Vector<String16>& args);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800173
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700174 /* ------------------------------------------------------------------------
175 * ISurfaceComposer interface
176 */
177 virtual sp<ISurfaceComposerClient> createConnection();
178 virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc();
179 virtual sp<IMemoryHeap> getCblk() const;
180 virtual void bootFinished();
181 virtual void setTransactionState(const Vector<ComposerState>& state,
Mathias Agopian8b33f032012-07-24 20:43:54 -0700182 const Vector<DisplayState>& displays, uint32_t flags);
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700183 virtual bool authenticateSurfaceTexture(
184 const sp<ISurfaceTexture>& surface) const;
185 virtual sp<IDisplayEventConnection> createDisplayEventConnection();
186 virtual status_t captureScreen(DisplayID dpy, sp<IMemoryHeap>* heap,
187 uint32_t* width, uint32_t* height, PixelFormat* format,
188 uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ,
189 uint32_t maxLayerZ);
190 virtual status_t turnElectronBeamOff(int32_t mode);
191 virtual status_t turnElectronBeamOn(int32_t mode);
192 // called when screen needs to turn off
193 virtual void blank();
194 // called when screen is turning back on
195 virtual void unblank();
196 virtual void connectDisplay(const sp<ISurfaceTexture> display);
Mathias Agopian1b031492012-06-20 17:51:20 -0700197
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700198 /* ------------------------------------------------------------------------
199 * DeathRecipient interface
200 */
201 virtual void binderDied(const wp<IBinder>& who);
Mathias Agopian99ce5cd2012-01-31 18:24:27 -0800202
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700203 /* ------------------------------------------------------------------------
204 * Thread interface
205 */
206 virtual bool threadLoop();
207 virtual status_t readyToRun();
208 virtual void onFirstRef();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800209
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700210 /* ------------------------------------------------------------------------
Mathias Agopian86303202012-07-24 22:46:10 -0700211 * HWComposer::EventHandler interface
212 */
213 virtual void onVSyncReceived(int dpy, nsecs_t timestamp);
214
215 /* ------------------------------------------------------------------------
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700216 * Message handling
217 */
218 void waitForEvent();
219 void signalTransaction();
220 void signalLayerUpdate();
221 void signalRefresh();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800222
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700223 // called on the main thread in response to screenReleased()
224 void onScreenReleased();
225 // called on the main thread in response to screenAcquired()
226 void onScreenAcquired();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800227
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700228 void handleMessageTransaction();
229 void handleMessageInvalidate();
230 void handleMessageRefresh();
Mathias Agopian4fec8732012-06-29 14:12:52 -0700231
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700232 Region handleTransaction(uint32_t transactionFlags);
233 Region handleTransactionLocked(uint32_t transactionFlags);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800234
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700235 /* handlePageFilp: this is were we latch a new buffer
236 * if available and compute the dirty region.
237 * The return value is the dirty region expressed in the
238 * window manager's coordinate space (or the layer's state
239 * space, which is the same thing), in particular the dirty
240 * region is independent from a specific display's orientation.
241 */
242 Region handlePageFlip();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800243
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700244 void handleRefresh();
245 void handleWorkList(const DisplayHardware& hw);
246 void handleRepaint(const DisplayHardware& hw);
Mathias Agopian0dfb7b72011-10-21 15:18:28 -0700247
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700248 /* ------------------------------------------------------------------------
249 * Transactions
250 */
251 uint32_t getTransactionFlags(uint32_t flags);
252 uint32_t peekTransactionFlags(uint32_t flags);
253 uint32_t setTransactionFlags(uint32_t flags);
254 void commitTransaction();
255 uint32_t setClientStateLocked(const sp<Client>& client,
256 const layer_state_t& s);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800257
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700258 /* ------------------------------------------------------------------------
259 * Layer management
260 */
261 sp<ISurface> createLayer(ISurfaceComposerClient::surface_data_t* params,
262 const String8& name, const sp<Client>& client, DisplayID display,
263 uint32_t w, uint32_t h, PixelFormat format, uint32_t flags);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800264
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700265 sp<Layer> createNormalLayer(const sp<Client>& client, DisplayID display,
266 uint32_t w, uint32_t h, uint32_t flags, PixelFormat& format);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800267
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700268 sp<LayerDim> createDimLayer(const sp<Client>& client, DisplayID display,
269 uint32_t w, uint32_t h, uint32_t flags);
Mathias Agopian74c40c02010-09-29 13:02:36 -0700270
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700271 sp<LayerScreenshot> createScreenshotLayer(const sp<Client>& client,
272 DisplayID display, uint32_t w, uint32_t h, uint32_t flags);
Mathias Agopian59119e62010-10-11 12:37:43 -0700273
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700274 // called in response to the window-manager calling
275 // ISurfaceComposerClient::destroySurface()
276 // The specified layer is first placed in a purgatory list
277 // until all references from the client are released.
278 status_t onLayerRemoved(const sp<Client>& client, SurfaceID sid);
Mathias Agopianb9494d52012-04-18 02:28:45 -0700279
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700280 // called when all clients have released all their references to
281 // this layer meaning it is entirely safe to destroy all
282 // resources associated to this layer.
283 status_t onLayerDestroyed(const wp<LayerBaseClient>& layer);
Mathias Agopiana4912602012-07-12 14:25:33 -0700284
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700285 // remove a layer from SurfaceFlinger immediately
286 status_t removeLayer(const sp<LayerBase>& layer);
Mathias Agopiana4912602012-07-12 14:25:33 -0700287
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700288 // add a layer to SurfaceFlinger
289 ssize_t addClientLayer(const sp<Client>& client,
290 const sp<LayerBaseClient>& lbc);
Mathias Agopiana67e4182012-06-19 17:26:12 -0700291
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700292 status_t removeLayer_l(const sp<LayerBase>& layer);
293 status_t purgatorizeLayer_l(const sp<LayerBase>& layer);
Mathias Agopianf1d8e872009-04-20 19:39:12 -0700294
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700295 /* ------------------------------------------------------------------------
296 * Boot animation, on/off animations and screen capture
297 */
Mathias Agopianbb641242010-05-18 17:06:55 -0700298
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700299 void startBootAnim();
Mathias Agopian96f08192010-06-02 23:28:45 -0700300
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700301 status_t captureScreenImplLocked(DisplayID dpy, sp<IMemoryHeap>* heap,
302 uint32_t* width, uint32_t* height, PixelFormat* format,
303 uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ,
304 uint32_t maxLayerZ);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800305
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700306 status_t turnElectronBeamOffImplLocked(int32_t mode);
307 status_t turnElectronBeamOnImplLocked(int32_t mode);
308 status_t electronBeamOffAnimationImplLocked();
309 status_t electronBeamOnAnimationImplLocked();
Mathias Agopian0dfb7b72011-10-21 15:18:28 -0700310
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700311 /* ------------------------------------------------------------------------
312 * EGL
313 */
314 static status_t selectConfigForPixelFormat(EGLDisplay dpy,
315 EGLint const* attrs, PixelFormat format, EGLConfig* outConfig);
316 static EGLConfig selectEGLConfig(EGLDisplay disp, EGLint visualId);
317 static EGLContext createGLContext(EGLDisplay disp, EGLConfig config);
318 void initializeGL(EGLDisplay display, EGLSurface surface);
319 uint32_t getMaxTextureSize() const;
320 uint32_t getMaxViewportDims() const;
Mathias Agopiana4912602012-07-12 14:25:33 -0700321
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700322 /* ------------------------------------------------------------------------
323 * Display management
324 */
325 const DisplayHardware& getDisplayHardware(DisplayID dpy) const {
326 return *mDisplayHardwares[dpy];
327 }
Mathias Agopian99b49842011-06-27 16:05:52 -0700328
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700329 /* ------------------------------------------------------------------------
Mathias Agopian86303202012-07-24 22:46:10 -0700330 * H/W composer
331 */
332
333 HWComposer& getHwComposer() const { return *mHwc; }
334
335 /* ------------------------------------------------------------------------
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700336 * Compositing
337 */
338 void invalidateHwcGeometry();
339 void computeVisibleRegions(const LayerVector& currentLayers,
340 Region& dirtyRegion, Region& wormholeRegion);
341 void postFramebuffer();
342 void setupHardwareComposer(const DisplayHardware& hw);
343 void composeSurfaces(const DisplayHardware& hw, const Region& dirty);
344 void setInvalidateRegion(const Region& reg);
345 Region getAndClearInvalidateRegion();
346 void drawWormhole() const;
347 GLuint getProtectedTexName() const {
348 return mProtectedTexName;
349 }
Mathias Agopian4da75192010-08-10 17:19:56 -0700350
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700351 /* ------------------------------------------------------------------------
352 * Debugging & dumpsys
353 */
354 void debugFlashRegions(const DisplayHardware& hw);
355 void listLayersLocked(const Vector<String16>& args, size_t& index,
356 String8& result, char* buffer, size_t SIZE) const;
357 void dumpStatsLocked(const Vector<String16>& args, size_t& index,
358 String8& result, char* buffer, size_t SIZE) const;
359 void clearStatsLocked(const Vector<String16>& args, size_t& index,
360 String8& result, char* buffer, size_t SIZE) const;
361 void dumpAllLocked(String8& result, char* buffer, size_t SIZE) const;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800362
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700363 /* ------------------------------------------------------------------------
364 * Attributes
365 */
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800366
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700367 // access must be protected by mStateLock
368 mutable Mutex mStateLock;
369 State mCurrentState;
370 volatile int32_t mTransactionFlags;
371 Condition mTransactionCV;
372 SortedVector<sp<LayerBase> > mLayerPurgatory;
373 bool mTransationPending;
374 Vector<sp<LayerBase> > mLayersPendingRemoval;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800375
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700376 // protected by mStateLock (but we could use another lock)
377 DisplayHardware* mDisplayHardwares[1];
378 bool mLayersRemoved;
Mathias Agopianca4d3602011-05-19 15:38:14 -0700379
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700380 // access must be protected by mInvalidateLock
381 mutable Mutex mInvalidateLock;
382 Region mInvalidateRegion;
Mathias Agopianca4d3602011-05-19 15:38:14 -0700383
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700384 // constant members (no synchronization needed for access)
385 sp<IMemoryHeap> mServerHeap;
386 surface_flinger_cblk_t* mServerCblk;
Mathias Agopian86303202012-07-24 22:46:10 -0700387 HWComposer* mHwc;
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700388 GLuint mWormholeTexName;
389 GLuint mProtectedTexName;
390 nsecs_t mBootTime;
391 sp<EventThread> mEventThread;
392 GLint mMaxViewportDims[2];
393 GLint mMaxTextureSize;
394 EGLContext mEGLContext;
395 EGLConfig mEGLConfig;
Mathias Agopian3094df32012-06-18 18:06:45 -0700396
Mathias Agopian921e6ac2012-07-23 23:11:29 -0700397 // Can only accessed from the main thread, these members
398 // don't need synchronization
399 State mDrawingState;
400 Region mDirtyRegion;
401 Region mDirtyRegionRemovedLayer;
402 Region mSwapRegion;
403 Region mWormholeRegion;
404 bool mVisibleRegionsDirty;
405 bool mHwWorkListDirty;
406 int32_t mElectronBeamAnimationMode;
407
408 // don't use a lock for these, we don't care
409 int mDebugRegion;
410 int mDebugDDMS;
411 int mDebugDisableHWC;
412 int mDebugDisableTransformHint;
413 volatile nsecs_t mDebugInSwapBuffers;
414 nsecs_t mLastSwapBufferTime;
415 volatile nsecs_t mDebugInTransaction;
416 nsecs_t mLastTransactionTime;
417 bool mBootFinished;
418
419 // these are thread safe
420 mutable MessageQueue mEventQueue;
421 mutable Barrier mReadyToRunBarrier;
422
423 // protected by mDestroyedLayerLock;
424 mutable Mutex mDestroyedLayerLock;
425 Vector<LayerBase const *> mDestroyedLayers;
426
427 /* ------------------------------------------------------------------------
428 * Feature prototyping
429 */
430
431 EGLSurface getExternalDisplaySurface() const;
432 sp<SurfaceTextureClient> mExternalDisplayNativeWindow;
433 EGLSurface mExternalDisplaySurface;
434public:
435 surface_flinger_cblk_t* getControlBlock() const;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800436};
437
438// ---------------------------------------------------------------------------
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800439}; // namespace android
440
441#endif // ANDROID_SURFACE_FLINGER_H