SurfaceFlinger.h revision 8dfa92fef9759a881e96ee58d59875d35023aab9
1edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project/*
2edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * Copyright (C) 2007 The Android Open Source Project
3edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *
4edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
5edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * you may not use this file except in compliance with the License.
6edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * You may obtain a copy of the License at
7edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *
8edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
9edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *
10edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * Unless required by applicable law or agreed to in writing, software
11edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
12edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * See the License for the specific language governing permissions and
14edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * limitations under the License.
15edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project */
16edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
17edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#ifndef ANDROID_SURFACE_FLINGER_H
18edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#define ANDROID_SURFACE_FLINGER_H
19edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
20edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#include <stdint.h>
21edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#include <sys/types.h>
22edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
23921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian#include <EGL/egl.h>
24921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian#include <GLES/gl.h>
25921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
2699ed22412db547c59d3da08114d9d5a586442b30Glenn Kasten#include <cutils/compiler.h>
2799ed22412db547c59d3da08114d9d5a586442b30Glenn Kasten
28edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#include <utils/Atomic.h>
29edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#include <utils/Errors.h>
3099b49840d309727678b77403d6cc9f920111623fMathias Agopian#include <utils/KeyedVector.h>
31076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian#include <utils/RefBase.h>
3299b49840d309727678b77403d6cc9f920111623fMathias Agopian#include <utils/SortedVector.h>
3399b49840d309727678b77403d6cc9f920111623fMathias Agopian#include <utils/threads.h>
34edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
35a1e6bc864fb821c1b470b7aad9b75c441f54eeb4Mathias Agopian#include <binder/BinderService.h>
3699b49840d309727678b77403d6cc9f920111623fMathias Agopian#include <binder/IMemory.h>
37375f56363a8737119ce2222dcfaacbe1cf733fc0Mathias Agopian
38edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#include <ui/PixelFormat.h>
39921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
4090ac799241f077a7b7e6c1875fd933864c8dd2a7Mathias Agopian#include <gui/IGraphicBufferAlloc.h>
4190ac799241f077a7b7e6c1875fd933864c8dd2a7Mathias Agopian#include <gui/ISurfaceComposer.h>
4290ac799241f077a7b7e6c1875fd933864c8dd2a7Mathias Agopian#include <gui/ISurfaceComposerClient.h>
43edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
448630320433bd15aca239522e54e711ef6372ab07Mathias Agopian#include <hardware/hwcomposer_defs.h>
458630320433bd15aca239522e54e711ef6372ab07Mathias Agopian
46921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian#include <private/gui/LayerState.h>
47edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
48921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian#include "Barrier.h"
49f1d8e87b09abf963cd5b6a026194c1940fadb7b4Mathias Agopian#include "MessageQueue.h"
5092a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian#include "DisplayDevice.h"
51f1d8e87b09abf963cd5b6a026194c1940fadb7b4Mathias Agopian
528630320433bd15aca239522e54e711ef6372ab07Mathias Agopian#include "DisplayHardware/HWComposer.h"
538630320433bd15aca239522e54e711ef6372ab07Mathias Agopian
54edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectnamespace android {
55edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
56edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project// ---------------------------------------------------------------------------
57edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
58edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectclass Client;
59d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopianclass DisplayEventConnection;
60d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopianclass EventThread;
61edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectclass Layer;
62921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopianclass LayerBase;
63921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopianclass LayerBaseClient;
64b7e930db175c192464cebdeb49eb56cf6dd60114Mathias Agopianclass LayerDim;
65118d0245ee0a3b107055782aa8b555404b6f0280Mathias Agopianclass LayerScreenshot;
66921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopianclass SurfaceTextureClient;
67edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
68edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project// ---------------------------------------------------------------------------
69edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
70921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopianclass GraphicBufferAlloc : public BnGraphicBufferAlloc {
719a78c90cd46b2a3bd637b056873149d3b94384b4Jamie Gennispublic:
729a78c90cd46b2a3bd637b056873149d3b94384b4Jamie Gennis    GraphicBufferAlloc();
739a78c90cd46b2a3bd637b056873149d3b94384b4Jamie Gennis    virtual ~GraphicBufferAlloc();
749a78c90cd46b2a3bd637b056873149d3b94384b4Jamie Gennis    virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t w, uint32_t h,
75d9e8c64c3dce1612eb948a5c16ba4ff62202b423Mathias Agopian        PixelFormat format, uint32_t usage, status_t* error);
769a78c90cd46b2a3bd637b056873149d3b94384b4Jamie Gennis};
779a78c90cd46b2a3bd637b056873149d3b94384b4Jamie Gennis
78edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project// ---------------------------------------------------------------------------
79edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
80edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectenum {
81e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    eTransactionNeeded        = 0x01,
82e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    eTraversalNeeded          = 0x02,
83e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    eDisplayTransactionNeeded = 0x04,
84e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    eTransactionMask          = 0x07
85edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project};
86edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
87921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopianclass SurfaceFlinger : public BinderService<SurfaceFlinger>,
88921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian                       public BnSurfaceComposer,
89921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian                       private IBinder::DeathRecipient,
908630320433bd15aca239522e54e711ef6372ab07Mathias Agopian                       private Thread,
918630320433bd15aca239522e54e711ef6372ab07Mathias Agopian                       private HWComposer::EventHandler
92edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project{
93edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectpublic:
94921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    static char const* getServiceName() {
95921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        return "SurfaceFlinger";
96921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    }
97118d0245ee0a3b107055782aa8b555404b6f0280Mathias Agopian
98921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    SurfaceFlinger();
9999ce5cdeb383216dee95af4d90e47406b0948ea1Mathias Agopian
1008630320433bd15aca239522e54e711ef6372ab07Mathias Agopian    enum {
1018630320433bd15aca239522e54e711ef6372ab07Mathias Agopian        EVENT_VSYNC = HWC_EVENT_VSYNC
1028630320433bd15aca239522e54e711ef6372ab07Mathias Agopian    };
1038630320433bd15aca239522e54e711ef6372ab07Mathias Agopian
104921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // post an asynchronous message to the main thread
105921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    status_t postMessageAsync(const sp<MessageBase>& msg, nsecs_t reltime = 0,
106921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        uint32_t flags = 0);
107118d0245ee0a3b107055782aa8b555404b6f0280Mathias Agopian
108921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // post a synchronous message to the main thread
109921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    status_t postMessageSync(const sp<MessageBase>& msg, nsecs_t reltime = 0,
110921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        uint32_t flags = 0);
111118d0245ee0a3b107055782aa8b555404b6f0280Mathias Agopian
112921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // force full composition on all displays
113921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void repaintEverything();
114b7e930db175c192464cebdeb49eb56cf6dd60114Mathias Agopian
115921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // renders content on given display to a texture. thread-safe version.
1163ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian    status_t renderScreenToTexture(uint32_t layerStack, GLuint* textureName,
117921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        GLfloat* uOut, GLfloat* vOut);
1189575f60722f7a4f54384fe0be6938a8de48dc23aJamie Gennis
119921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // renders content on given display to a texture, w/o acquiring main lock
1203ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian    status_t renderScreenToTextureLocked(uint32_t layerStack, GLuint* textureName,
121921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        GLfloat* uOut, GLfloat* vOut);
122a49126087b4494f4ef50873f3a3f6727265f6621Mathias Agopian
123921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // returns the default Display
1244297734c1156fd8ede7e9c61b1e439f9e1c18cd9Mathias Agopian    sp<const DisplayDevice> getDefaultDisplayDevice() const {
1253ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian        return getDisplayDevice(mDefaultDisplays[DisplayDevice::DISPLAY_PRIMARY]);
126921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    }
127118d0245ee0a3b107055782aa8b555404b6f0280Mathias Agopian
1288630320433bd15aca239522e54e711ef6372ab07Mathias Agopian    // utility function to delete a texture on the main thread
1298630320433bd15aca239522e54e711ef6372ab07Mathias Agopian    void deleteTextureAsync(GLuint texture);
1308630320433bd15aca239522e54e711ef6372ab07Mathias Agopian
1313ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian    // allocate a h/w composer display id
1323ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian    int32_t allocateHwcDisplayId(DisplayDevice::DisplayType type);
1338630320433bd15aca239522e54e711ef6372ab07Mathias Agopian
1348630320433bd15aca239522e54e711ef6372ab07Mathias Agopian    // enable/disable h/w composer event
1358630320433bd15aca239522e54e711ef6372ab07Mathias Agopian    // TODO: this should be made accessible only to EventThread
1368630320433bd15aca239522e54e711ef6372ab07Mathias Agopian    void eventControl(int event, int enabled);
1378630320433bd15aca239522e54e711ef6372ab07Mathias Agopian
138921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // called on the main thread by MessageQueue when an internal message
139921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // is received
140921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // TODO: this should be made accessible only to MessageQueue
141921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void onMessageReceived(int32_t what);
142118d0245ee0a3b107055782aa8b555404b6f0280Mathias Agopian
1431f339ff3875afad128a8e16ee6395c5fad295826Mathias Agopianprivate:
14496f0819f81293076e652792794a961543e6750d7Mathias Agopian    friend class Client;
145d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian    friend class DisplayEventConnection;
146edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    friend class LayerBase;
147edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    friend class LayerBaseClient;
148edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    friend class Layer;
149edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
150921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // We're reference counted, never destroy SurfaceFlinger directly
151921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual ~SurfaceFlinger();
152edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
153921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
154921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Internal data structures
155921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
156118d0245ee0a3b107055782aa8b555404b6f0280Mathias Agopian
157921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    class LayerVector : public SortedVector<sp<LayerBase> > {
158edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    public:
159921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        LayerVector();
160921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        LayerVector(const LayerVector& rhs);
161921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        virtual int do_compare(const void* lhs, const void* rhs) const;
162edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    };
163edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
16492a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian    struct DisplayDeviceState {
16592a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian        DisplayDeviceState();
1663ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian        DisplayDeviceState(DisplayDevice::DisplayType type);
1673ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian        bool isValid() const { return type >= 0; }
1683ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian        bool isMainDisplay() const { return type == DisplayDevice::DISPLAY_PRIMARY; }
169cde87a3b9d3f8dc15232d927b56ee9e5e520f58dMathias Agopian        bool isVirtualDisplay() const { return type >= DisplayDevice::DISPLAY_VIRTUAL; }
1703ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian        DisplayDevice::DisplayType type;
171e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian        sp<ISurfaceTexture> surface;
17292a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian        uint32_t layerStack;
17392a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian        Rect viewport;
17492a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian        Rect frame;
17592a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian        uint8_t orientation;
1768dfa92fef9759a881e96ee58d59875d35023aab9Andy McFadden        String8 displayName;
17792a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian    };
17892a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian
179edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    struct State {
180921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        LayerVector layersSortedByZ;
181e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian        DefaultKeyedVector< wp<IBinder>, DisplayDeviceState> displays;
182edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    };
183edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
184921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
185921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * IBinder interface
186921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
187921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual status_t onTransact(uint32_t code, const Parcel& data,
188921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        Parcel* reply, uint32_t flags);
189921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual status_t dump(int fd, const Vector<String16>& args);
190edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
191921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
192921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * ISurfaceComposer interface
193921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
194921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual sp<ISurfaceComposerClient> createConnection();
195921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc();
1968dfa92fef9759a881e96ee58d59875d35023aab9Andy McFadden    virtual sp<IBinder> createDisplay(const String8& displayName);
197e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    virtual sp<IBinder> getBuiltInDisplay(int32_t id);
198921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual void setTransactionState(const Vector<ComposerState>& state,
1998b33f032327f8de0dcc0e6d0d43ed80f834b51f6Mathias Agopian            const Vector<DisplayState>& displays, uint32_t flags);
20092a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian    virtual void bootFinished();
201921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual bool authenticateSurfaceTexture(
202921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        const sp<ISurfaceTexture>& surface) const;
203921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual sp<IDisplayEventConnection> createDisplayEventConnection();
2049d4e3d2f42e93e2d12bacabe97d307d30c3c20ddJeff Brown    virtual status_t captureScreen(const sp<IBinder>& display, sp<IMemoryHeap>* heap,
205921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        uint32_t* width, uint32_t* height, PixelFormat* format,
206921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ,
207921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        uint32_t maxLayerZ);
208921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // called when screen needs to turn off
209921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual void blank();
210921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // called when screen is turning back on
211921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual void unblank();
2129d4e3d2f42e93e2d12bacabe97d307d30c3c20ddJeff Brown    virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info);
2139d4e3d2f42e93e2d12bacabe97d307d30c3c20ddJeff Brown    virtual void connectDisplay(const sp<ISurfaceTexture>& display);
2141b03149f3533db04e72e088d3fdd09d0087ca594Mathias Agopian
215921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
216921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * DeathRecipient interface
217921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
218921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual void binderDied(const wp<IBinder>& who);
21999ce5cdeb383216dee95af4d90e47406b0948ea1Mathias Agopian
220921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
221921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Thread interface
222921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
223921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual bool threadLoop();
224921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual status_t readyToRun();
225921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual void onFirstRef();
226921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
227921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
2288630320433bd15aca239522e54e711ef6372ab07Mathias Agopian     * HWComposer::EventHandler interface
2298630320433bd15aca239522e54e711ef6372ab07Mathias Agopian     */
2303ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian    virtual void onVSyncReceived(int type, nsecs_t timestamp);
2318630320433bd15aca239522e54e711ef6372ab07Mathias Agopian
2328630320433bd15aca239522e54e711ef6372ab07Mathias Agopian    /* ------------------------------------------------------------------------
233921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Message handling
234921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
235921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void waitForEvent();
236921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void signalTransaction();
237921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void signalLayerUpdate();
238921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void signalRefresh();
239921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
24013a082e160c2d1d8006b93a555a57035213d568bAndy McFadden    // called on the main thread in response to initializeDisplays()
24113a082e160c2d1d8006b93a555a57035213d568bAndy McFadden    void onInitializeDisplays();
24213a082e160c2d1d8006b93a555a57035213d568bAndy McFadden    // called on the main thread in response to blank()
243cde87a3b9d3f8dc15232d927b56ee9e5e520f58dMathias Agopian    void onScreenReleased(const sp<const DisplayDevice>& hw);
24413a082e160c2d1d8006b93a555a57035213d568bAndy McFadden    // called on the main thread in response to unblank()
245cde87a3b9d3f8dc15232d927b56ee9e5e520f58dMathias Agopian    void onScreenAcquired(const sp<const DisplayDevice>& hw);
246921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
247921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void handleMessageTransaction();
248921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void handleMessageInvalidate();
249921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void handleMessageRefresh();
250921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
25187baae104a3e4c2059990b01c393476065c558b0Mathias Agopian    void handleTransaction(uint32_t transactionFlags);
25287baae104a3e4c2059990b01c393476065c558b0Mathias Agopian    void handleTransactionLocked(uint32_t transactionFlags);
253921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
254921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* handlePageFilp: this is were we latch a new buffer
255921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * if available and compute the dirty region.
256921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
25787baae104a3e4c2059990b01c393476065c558b0Mathias Agopian    void handlePageFlip();
258921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
259921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
260921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Transactions
261921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
262921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    uint32_t getTransactionFlags(uint32_t flags);
263921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    uint32_t peekTransactionFlags(uint32_t flags);
264921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    uint32_t setTransactionFlags(uint32_t flags);
265921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void commitTransaction();
266921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    uint32_t setClientStateLocked(const sp<Client>& client,
267921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        const layer_state_t& s);
268e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    uint32_t setDisplayStateLocked(const DisplayState& s);
269921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
270921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
271921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Layer management
272921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
273921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    sp<ISurface> createLayer(ISurfaceComposerClient::surface_data_t* params,
2743ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian            const String8& name, const sp<Client>& client,
2753ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian            uint32_t w, uint32_t h, PixelFormat format, uint32_t flags);
276921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
2773ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian    sp<Layer> createNormalLayer(const sp<Client>& client,
2783ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian            uint32_t w, uint32_t h, uint32_t flags, PixelFormat& format);
279921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
2803ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian    sp<LayerDim> createDimLayer(const sp<Client>& client,
2813ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian            uint32_t w, uint32_t h, uint32_t flags);
282921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
283921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    sp<LayerScreenshot> createScreenshotLayer(const sp<Client>& client,
2843ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian            uint32_t w, uint32_t h, uint32_t flags);
285921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
286921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // called in response to the window-manager calling
287921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // ISurfaceComposerClient::destroySurface()
288921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // The specified layer is first placed in a purgatory list
289921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // until all references from the client are released.
290921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    status_t onLayerRemoved(const sp<Client>& client, SurfaceID sid);
291921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
292921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // called when all clients have released all their references to
293921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // this layer meaning it is entirely safe to destroy all
294921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // resources associated to this layer.
295921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    status_t onLayerDestroyed(const wp<LayerBaseClient>& layer);
296921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
297921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // remove a layer from SurfaceFlinger immediately
298921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    status_t removeLayer(const sp<LayerBase>& layer);
299edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
300921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // add a layer to SurfaceFlinger
301921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    ssize_t addClientLayer(const sp<Client>& client,
302921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        const sp<LayerBaseClient>& lbc);
303921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
304921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    status_t removeLayer_l(const sp<LayerBase>& layer);
305921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    status_t purgatorizeLayer_l(const sp<LayerBase>& layer);
306921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
307921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
308921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Boot animation, on/off animations and screen capture
309921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
310921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
311921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void startBootAnim();
312921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
3139d4e3d2f42e93e2d12bacabe97d307d30c3c20ddJeff Brown    status_t captureScreenImplLocked(const sp<IBinder>& display, sp<IMemoryHeap>* heap,
314921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        uint32_t* width, uint32_t* height, PixelFormat* format,
315921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ,
316921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        uint32_t maxLayerZ);
317921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
318921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
319921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * EGL
320921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
321921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    static status_t selectConfigForPixelFormat(EGLDisplay dpy,
322921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        EGLint const* attrs, PixelFormat format, EGLConfig* outConfig);
323921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    static EGLConfig selectEGLConfig(EGLDisplay disp, EGLint visualId);
324921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    static EGLContext createGLContext(EGLDisplay disp, EGLConfig config);
325cde87a3b9d3f8dc15232d927b56ee9e5e520f58dMathias Agopian    void initializeGL(EGLDisplay display);
326921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    uint32_t getMaxTextureSize() const;
327921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    uint32_t getMaxViewportDims() const;
328921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
329921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
33087baae104a3e4c2059990b01c393476065c558b0Mathias Agopian     * Display and layer stack management
331921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
33213a082e160c2d1d8006b93a555a57035213d568bAndy McFadden    // called when starting, or restarting after system_server death
33313a082e160c2d1d8006b93a555a57035213d568bAndy McFadden    void initializeDisplays();
33413a082e160c2d1d8006b93a555a57035213d568bAndy McFadden
3353ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian    sp<const DisplayDevice> getDisplayDevice(const wp<IBinder>& dpy) const {
33692a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian        return mDisplays.valueFor(dpy);
33792a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian    }
3383ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian    const sp<DisplayDevice>& getDisplayDevice(const wp<IBinder>& dpy) {
3394297734c1156fd8ede7e9c61b1e439f9e1c18cd9Mathias Agopian        return mDisplays.valueFor(dpy);
340921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    }
341921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
34287baae104a3e4c2059990b01c393476065c558b0Mathias Agopian    // mark a region of a layer stack dirty. this updates the dirty
34387baae104a3e4c2059990b01c393476065c558b0Mathias Agopian    // region of all screens presenting this layer stack.
34487baae104a3e4c2059990b01c393476065c558b0Mathias Agopian    void invalidateLayerStack(uint32_t layerStack, const Region& dirty);
34587baae104a3e4c2059990b01c393476065c558b0Mathias Agopian
346921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
3478630320433bd15aca239522e54e711ef6372ab07Mathias Agopian     * H/W composer
3488630320433bd15aca239522e54e711ef6372ab07Mathias Agopian     */
3498630320433bd15aca239522e54e711ef6372ab07Mathias Agopian
3508630320433bd15aca239522e54e711ef6372ab07Mathias Agopian    HWComposer& getHwComposer() const { return *mHwc; }
3518630320433bd15aca239522e54e711ef6372ab07Mathias Agopian
352888c822c4cb6976aab9256c58bae9e17e3e55c5cMathias Agopian    /* ------------------------------------------------------------------------
353921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Compositing
354921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
355921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void invalidateHwcGeometry();
356ce3a0a541c3dde1330551bd7a048cd9d92335c00Mathias Agopian    static void computeVisibleRegions(
357ce3a0a541c3dde1330551bd7a048cd9d92335c00Mathias Agopian            const LayerVector& currentLayers, uint32_t layerStack,
35887baae104a3e4c2059990b01c393476065c558b0Mathias Agopian            Region& dirtyRegion, Region& opaqueRegion);
359cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian
360cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian    void preComposition();
361cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian    void postComposition();
362cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian    void rebuildLayerStacks();
363cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian    void setUpHWComposer();
364cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian    void doComposition();
365cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian    void doDebugFlashRegions();
366cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian    void doDisplayComposition(const sp<const DisplayDevice>& hw,
367cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian            const Region& dirtyRegion);
368cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian    void doComposeSurfaces(const sp<const DisplayDevice>& hw,
369cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian            const Region& dirty);
370cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian
371921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void postFramebuffer();
37255801e41e6d7306d75d8134dd69d7d8cbbfbc63cMathias Agopian    void drawWormhole(const sp<const DisplayDevice>& hw,
37355801e41e6d7306d75d8134dd69d7d8cbbfbc63cMathias Agopian            const Region& region) const;
374921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    GLuint getProtectedTexName() const {
375921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        return mProtectedTexName;
376921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    }
377921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
378921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
3790bceb84773882b796d9dacbaf96167cb15928d78Jamie Gennis     * Display management
3800bceb84773882b796d9dacbaf96167cb15928d78Jamie Gennis     */
3813ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian
3820bceb84773882b796d9dacbaf96167cb15928d78Jamie Gennis
3830bceb84773882b796d9dacbaf96167cb15928d78Jamie Gennis    /* ------------------------------------------------------------------------
384921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Debugging & dumpsys
385921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
386921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void listLayersLocked(const Vector<String16>& args, size_t& index,
387921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        String8& result, char* buffer, size_t SIZE) const;
388921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void dumpStatsLocked(const Vector<String16>& args, size_t& index,
389921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        String8& result, char* buffer, size_t SIZE) const;
390921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void clearStatsLocked(const Vector<String16>& args, size_t& index,
391921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        String8& result, char* buffer, size_t SIZE) const;
392921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void dumpAllLocked(String8& result, char* buffer, size_t SIZE) const;
39363f165fd6b86d04be94d4023e845e98560504a96Keun young Park    bool startDdmConnection();
394921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
395921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
396921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Attributes
397921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
398921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
399921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // access must be protected by mStateLock
400921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    mutable Mutex mStateLock;
401921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    State mCurrentState;
402921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    volatile int32_t mTransactionFlags;
403921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    Condition mTransactionCV;
404921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    SortedVector<sp<LayerBase> > mLayerPurgatory;
405921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    bool mTransationPending;
406921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    Vector<sp<LayerBase> > mLayersPendingRemoval;
407921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
408921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // protected by mStateLock (but we could use another lock)
409921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    bool mLayersRemoved;
410921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
411921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // access must be protected by mInvalidateLock
41287baae104a3e4c2059990b01c393476065c558b0Mathias Agopian    volatile int32_t mRepaintEverything;
413921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
414921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // constant members (no synchronization needed for access)
4158630320433bd15aca239522e54e711ef6372ab07Mathias Agopian    HWComposer* mHwc;
416921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    GLuint mProtectedTexName;
417921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    nsecs_t mBootTime;
418921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    sp<EventThread> mEventThread;
419921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    GLint mMaxViewportDims[2];
420921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    GLint mMaxTextureSize;
421921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    EGLContext mEGLContext;
422921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    EGLConfig mEGLConfig;
42334a09ba1efd706323a15633da5044b352988eb5fJesse Hall    EGLDisplay mEGLDisplay;
4243ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian    sp<IBinder> mDefaultDisplays[DisplayDevice::NUM_DISPLAY_TYPES];
425921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
426921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // Can only accessed from the main thread, these members
427921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // don't need synchronization
428921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    State mDrawingState;
429921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    bool mVisibleRegionsDirty;
430921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    bool mHwWorkListDirty;
4313ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian    DefaultKeyedVector< wp<IBinder>, sp<DisplayDevice> > mDisplays;
432921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
433921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // don't use a lock for these, we don't care
434921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    int mDebugRegion;
435921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    int mDebugDDMS;
436921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    int mDebugDisableHWC;
437921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    int mDebugDisableTransformHint;
438921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    volatile nsecs_t mDebugInSwapBuffers;
439921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    nsecs_t mLastSwapBufferTime;
440921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    volatile nsecs_t mDebugInTransaction;
441921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    nsecs_t mLastTransactionTime;
442921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    bool mBootFinished;
443921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
444921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // these are thread safe
445921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    mutable MessageQueue mEventQueue;
446921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    mutable Barrier mReadyToRunBarrier;
447921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
448921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // protected by mDestroyedLayerLock;
449921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    mutable Mutex mDestroyedLayerLock;
450921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    Vector<LayerBase const *> mDestroyedLayers;
451921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
452921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
453921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Feature prototyping
454921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
455921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
4565f20e2d4462da3471f59152b32cd8640fa4a21daMathias Agopian    sp<IBinder> mExtDisplayToken;
457edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project};
458edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
459edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project// ---------------------------------------------------------------------------
460edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project}; // namespace android
461edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
462edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#endif // ANDROID_SURFACE_FLINGER_H
463