SurfaceFlinger.h revision 29c3f352797d9d2ddf055d8f888e7694ef8b3947
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/ISurfaceComposer.h>
4190ac799241f077a7b7e6c1875fd933864c8dd2a7Mathias Agopian#include <gui/ISurfaceComposerClient.h>
42edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
438630320433bd15aca239522e54e711ef6372ab07Mathias Agopian#include <hardware/hwcomposer_defs.h>
448630320433bd15aca239522e54e711ef6372ab07Mathias Agopian
45921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian#include <private/gui/LayerState.h>
46edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
47921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian#include "Barrier.h"
4892a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian#include "DisplayDevice.h"
494b0eba949cc026ffb2c75313042d8a7bcb3fcf86Jamie Gennis#include "FrameTracker.h"
504b0eba949cc026ffb2c75313042d8a7bcb3fcf86Jamie Gennis#include "MessageQueue.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;
61f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopianclass IGraphicBufferAlloc;
62edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectclass Layer;
63b7e930db175c192464cebdeb49eb56cf6dd60114Mathias Agopianclass LayerDim;
64e3c697fb929c856b59fa56a8e05a2a7eba187c3dMathias Agopianclass Surface;
65edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
66edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project// ---------------------------------------------------------------------------
67edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
68edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectenum {
69e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    eTransactionNeeded        = 0x01,
70e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    eTraversalNeeded          = 0x02,
71e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    eDisplayTransactionNeeded = 0x04,
72e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    eTransactionMask          = 0x07
73edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project};
74edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
7529c3f352797d9d2ddf055d8f888e7694ef8b3947Jesse Hallenum GlesVersion {
7629c3f352797d9d2ddf055d8f888e7694ef8b3947Jesse Hall    GLES_VERSION_1_0    = 0x10000,
7729c3f352797d9d2ddf055d8f888e7694ef8b3947Jesse Hall    GLES_VERSION_1_1    = 0x10001,
7829c3f352797d9d2ddf055d8f888e7694ef8b3947Jesse Hall    GLES_VERSION_2_0    = 0x20000,
7929c3f352797d9d2ddf055d8f888e7694ef8b3947Jesse Hall    GLES_VERSION_3_0    = 0x30000,
8029c3f352797d9d2ddf055d8f888e7694ef8b3947Jesse Hall};
8129c3f352797d9d2ddf055d8f888e7694ef8b3947Jesse Hall
82921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopianclass SurfaceFlinger : public BinderService<SurfaceFlinger>,
83921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian                       public BnSurfaceComposer,
84921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian                       private IBinder::DeathRecipient,
858630320433bd15aca239522e54e711ef6372ab07Mathias Agopian                       private Thread,
868630320433bd15aca239522e54e711ef6372ab07Mathias Agopian                       private HWComposer::EventHandler
87edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project{
88edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectpublic:
89b6df7d0e4c2117ca476662bd52b6745b3d8a305fMathias Agopian    static char const* getServiceName() ANDROID_API {
90921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        return "SurfaceFlinger";
91921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    }
92118d0245ee0a3b107055782aa8b555404b6f0280Mathias Agopian
93b6df7d0e4c2117ca476662bd52b6745b3d8a305fMathias Agopian    SurfaceFlinger() ANDROID_API;
9499ce5cdeb383216dee95af4d90e47406b0948ea1Mathias Agopian
958630320433bd15aca239522e54e711ef6372ab07Mathias Agopian    enum {
968630320433bd15aca239522e54e711ef6372ab07Mathias Agopian        EVENT_VSYNC = HWC_EVENT_VSYNC
978630320433bd15aca239522e54e711ef6372ab07Mathias Agopian    };
988630320433bd15aca239522e54e711ef6372ab07Mathias Agopian
99921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // post an asynchronous message to the main thread
100921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    status_t postMessageAsync(const sp<MessageBase>& msg, nsecs_t reltime = 0,
101921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        uint32_t flags = 0);
102118d0245ee0a3b107055782aa8b555404b6f0280Mathias Agopian
103921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // post a synchronous message to the main thread
104921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    status_t postMessageSync(const sp<MessageBase>& msg, nsecs_t reltime = 0,
105921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        uint32_t flags = 0);
106118d0245ee0a3b107055782aa8b555404b6f0280Mathias Agopian
107921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // force full composition on all displays
108921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void repaintEverything();
109b7e930db175c192464cebdeb49eb56cf6dd60114Mathias Agopian
110921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // returns the default Display
1114297734c1156fd8ede7e9c61b1e439f9e1c18cd9Mathias Agopian    sp<const DisplayDevice> getDefaultDisplayDevice() const {
112692c723e84e6f2747447d871d468ff50e5c73f19Jesse Hall        return getDisplayDevice(mBuiltinDisplays[DisplayDevice::DISPLAY_PRIMARY]);
113921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    }
114118d0245ee0a3b107055782aa8b555404b6f0280Mathias Agopian
1158630320433bd15aca239522e54e711ef6372ab07Mathias Agopian    // utility function to delete a texture on the main thread
1168630320433bd15aca239522e54e711ef6372ab07Mathias Agopian    void deleteTextureAsync(GLuint texture);
1178630320433bd15aca239522e54e711ef6372ab07Mathias Agopian
1188630320433bd15aca239522e54e711ef6372ab07Mathias Agopian    // enable/disable h/w composer event
1198630320433bd15aca239522e54e711ef6372ab07Mathias Agopian    // TODO: this should be made accessible only to EventThread
12081cd5d3b94d21253a0be925f4ae58cc7f4afeef7Mathias Agopian    void eventControl(int disp, int event, int enabled);
1218630320433bd15aca239522e54e711ef6372ab07Mathias Agopian
122921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // called on the main thread by MessageQueue when an internal message
123921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // is received
124921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // TODO: this should be made accessible only to MessageQueue
125921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void onMessageReceived(int32_t what);
126118d0245ee0a3b107055782aa8b555404b6f0280Mathias Agopian
127cb55857bbde34a06c19dde3db5064d1717a0173eMathias Agopian    // for debugging only
128cb55857bbde34a06c19dde3db5064d1717a0173eMathias Agopian    // TODO: this should be made accessible only to HWComposer
12948bc05b56df9919fc39c5f2e3ea6535560eec98fJesse Hall    const Vector< sp<Layer> >& getLayerSortedByZForHwcDisplay(int id);
130cb55857bbde34a06c19dde3db5064d1717a0173eMathias Agopian
13129c3f352797d9d2ddf055d8f888e7694ef8b3947Jesse Hall    // return the version of the OpenGL ES composition context
13229c3f352797d9d2ddf055d8f888e7694ef8b3947Jesse Hall    GlesVersion getGlesVersion() const {
13329c3f352797d9d2ddf055d8f888e7694ef8b3947Jesse Hall        return mGlesVersion;
13429c3f352797d9d2ddf055d8f888e7694ef8b3947Jesse Hall    }
13529c3f352797d9d2ddf055d8f888e7694ef8b3947Jesse Hall
1361f339ff3875afad128a8e16ee6395c5fad295826Mathias Agopianprivate:
13796f0819f81293076e652792794a961543e6750d7Mathias Agopian    friend class Client;
138d0566bc26fcf6ca396118701fa11900b627f2c09Mathias Agopian    friend class DisplayEventConnection;
139edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    friend class Layer;
1406710604286401d4205c27235a252dd0e5008cc08Mathias Agopian    friend class SurfaceTextureLayer;
141edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
142921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // We're reference counted, never destroy SurfaceFlinger directly
143921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual ~SurfaceFlinger();
144edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
145921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
146921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Internal data structures
147921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
148118d0245ee0a3b107055782aa8b555404b6f0280Mathias Agopian
14913127d8921356dff794250e04208c3ed60b3a3dfMathias Agopian    class LayerVector : public SortedVector< sp<Layer> > {
150edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    public:
151921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        LayerVector();
152921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        LayerVector(const LayerVector& rhs);
153921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        virtual int do_compare(const void* lhs, const void* rhs) const;
154edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    };
155edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
15692a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian    struct DisplayDeviceState {
15792a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian        DisplayDeviceState();
1583ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian        DisplayDeviceState(DisplayDevice::DisplayType type);
1593ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian        bool isValid() const { return type >= 0; }
1603ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian        bool isMainDisplay() const { return type == DisplayDevice::DISPLAY_PRIMARY; }
161cde87a3b9d3f8dc15232d927b56ee9e5e520f58dMathias Agopian        bool isVirtualDisplay() const { return type >= DisplayDevice::DISPLAY_VIRTUAL; }
1623ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian        DisplayDevice::DisplayType type;
1632adaf04fab35cf47c824d74d901b54094e01ccd3Andy McFadden        sp<IGraphicBufferProducer> surface;
16492a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian        uint32_t layerStack;
16592a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian        Rect viewport;
16692a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian        Rect frame;
16792a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian        uint8_t orientation;
1688dfa92fef9759a881e96ee58d59875d35023aab9Andy McFadden        String8 displayName;
169dd3cb84cfbe8068790c6233b5829fae9c4a0ee93Jamie Gennis        bool isSecure;
17092a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian    };
17192a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian
172edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    struct State {
173921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        LayerVector layersSortedByZ;
174e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian        DefaultKeyedVector< wp<IBinder>, DisplayDeviceState> displays;
175edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    };
176edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
177921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
178921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * IBinder interface
179921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
180921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual status_t onTransact(uint32_t code, const Parcel& data,
181921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        Parcel* reply, uint32_t flags);
182921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual status_t dump(int fd, const Vector<String16>& args);
183edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
184921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
185921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * ISurfaceComposer interface
186921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
187921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual sp<ISurfaceComposerClient> createConnection();
188921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc();
189dd3cb84cfbe8068790c6233b5829fae9c4a0ee93Jamie Gennis    virtual sp<IBinder> createDisplay(const String8& displayName, bool secure);
190e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    virtual sp<IBinder> getBuiltInDisplay(int32_t id);
191921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual void setTransactionState(const Vector<ComposerState>& state,
1928b33f032327f8de0dcc0e6d0d43ed80f834b51f6Mathias Agopian            const Vector<DisplayState>& displays, uint32_t flags);
19392a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian    virtual void bootFinished();
194921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual bool authenticateSurfaceTexture(
1952adaf04fab35cf47c824d74d901b54094e01ccd3Andy McFadden        const sp<IGraphicBufferProducer>& bufferProducer) const;
196921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual sp<IDisplayEventConnection> createDisplayEventConnection();
1972a9fc493dfdba67108e4335bb1fe931bc1e2a025Mathias Agopian    virtual status_t captureScreen(const sp<IBinder>& display,
1982a9fc493dfdba67108e4335bb1fe931bc1e2a025Mathias Agopian            const sp<IGraphicBufferProducer>& producer,
1992a9fc493dfdba67108e4335bb1fe931bc1e2a025Mathias Agopian            uint32_t reqWidth, uint32_t reqHeight,
200abe815dd6978b718c04f6e22e1a893d2b51d11a1Mathias Agopian            uint32_t minLayerZ, uint32_t maxLayerZ, bool isCpuConsumer);
201921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // called when screen needs to turn off
202c01a79d77b829e7de86ef137694e8ad708470ca1Andy McFadden    virtual void blank(const sp<IBinder>& display);
203921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // called when screen is turning back on
204c01a79d77b829e7de86ef137694e8ad708470ca1Andy McFadden    virtual void unblank(const sp<IBinder>& display);
2059d4e3d2f42e93e2d12bacabe97d307d30c3c20ddJeff Brown    virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info);
2061b03149f3533db04e72e088d3fdd09d0087ca594Mathias Agopian
207921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
208921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * DeathRecipient interface
209921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
210921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual void binderDied(const wp<IBinder>& who);
21199ce5cdeb383216dee95af4d90e47406b0948ea1Mathias Agopian
212921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
213921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Thread interface
214921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
215921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual bool threadLoop();
216921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual status_t readyToRun();
217921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    virtual void onFirstRef();
218921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
219921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
2208630320433bd15aca239522e54e711ef6372ab07Mathias Agopian     * HWComposer::EventHandler interface
2218630320433bd15aca239522e54e711ef6372ab07Mathias Agopian     */
2223ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian    virtual void onVSyncReceived(int type, nsecs_t timestamp);
223148994e5f33ce240ff24ceb5bc0500b7f2001959Mathias Agopian    virtual void onHotplugReceived(int disp, bool connected);
2248630320433bd15aca239522e54e711ef6372ab07Mathias Agopian
2258630320433bd15aca239522e54e711ef6372ab07Mathias Agopian    /* ------------------------------------------------------------------------
226921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Message handling
227921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
228921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void waitForEvent();
229921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void signalTransaction();
230921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void signalLayerUpdate();
231921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void signalRefresh();
232921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
23313a082e160c2d1d8006b93a555a57035213d568bAndy McFadden    // called on the main thread in response to initializeDisplays()
23413a082e160c2d1d8006b93a555a57035213d568bAndy McFadden    void onInitializeDisplays();
23513a082e160c2d1d8006b93a555a57035213d568bAndy McFadden    // called on the main thread in response to blank()
236cde87a3b9d3f8dc15232d927b56ee9e5e520f58dMathias Agopian    void onScreenReleased(const sp<const DisplayDevice>& hw);
23713a082e160c2d1d8006b93a555a57035213d568bAndy McFadden    // called on the main thread in response to unblank()
238cde87a3b9d3f8dc15232d927b56ee9e5e520f58dMathias Agopian    void onScreenAcquired(const sp<const DisplayDevice>& hw);
239921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
240921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void handleMessageTransaction();
241921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void handleMessageInvalidate();
242921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void handleMessageRefresh();
243921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
24487baae104a3e4c2059990b01c393476065c558b0Mathias Agopian    void handleTransaction(uint32_t transactionFlags);
24587baae104a3e4c2059990b01c393476065c558b0Mathias Agopian    void handleTransactionLocked(uint32_t transactionFlags);
246921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
247921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* handlePageFilp: this is were we latch a new buffer
248921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * if available and compute the dirty region.
249921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
25087baae104a3e4c2059990b01c393476065c558b0Mathias Agopian    void handlePageFlip();
251921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
252921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
253921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Transactions
254921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
255921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    uint32_t getTransactionFlags(uint32_t flags);
256921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    uint32_t peekTransactionFlags(uint32_t flags);
257921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    uint32_t setTransactionFlags(uint32_t flags);
258921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void commitTransaction();
259921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    uint32_t setClientStateLocked(const sp<Client>& client,
260921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        const layer_state_t& s);
261e57f292595bec48f65c8088b00ff6beea01217e9Mathias Agopian    uint32_t setDisplayStateLocked(const DisplayState& s);
262921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
263921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
264921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Layer management
265921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
2664d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian    status_t createLayer(const String8& name, const sp<Client>& client,
2674d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian            uint32_t w, uint32_t h, PixelFormat format, uint32_t flags,
2684d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian            sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp);
2694d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian
2704d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian    status_t createNormalLayer(const sp<Client>& client, const String8& name,
2714d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian            uint32_t w, uint32_t h, uint32_t flags, PixelFormat& format,
2724d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian            sp<IBinder>* outHandle, sp<IGraphicBufferProducer>* outGbp,
2734d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian            sp<Layer>* outLayer);
2744d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian
2754d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian    status_t createDimLayer(const sp<Client>& client, const String8& name,
2764d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian            uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* outHandle,
2774d9b822e2c18142e55fe2611aa6cd7dc7d4a62c6Mathias Agopian            sp<IGraphicBufferProducer>* outGbp, sp<Layer>* outLayer);
278921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
279921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // called in response to the window-manager calling
280921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // ISurfaceComposerClient::destroySurface()
281ac9fa427d4a86745e60a5f7fd8e3ea340c4db907Mathias Agopian    status_t onLayerRemoved(const sp<Client>& client, const sp<IBinder>& handle);
282921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
283921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // called when all clients have released all their references to
284921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // this layer meaning it is entirely safe to destroy all
285921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // resources associated to this layer.
28613127d8921356dff794250e04208c3ed60b3a3dfMathias Agopian    status_t onLayerDestroyed(const wp<Layer>& layer);
287921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
288921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // remove a layer from SurfaceFlinger immediately
28913127d8921356dff794250e04208c3ed60b3a3dfMathias Agopian    status_t removeLayer(const sp<Layer>& layer);
290edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
291921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // add a layer to SurfaceFlinger
2926710604286401d4205c27235a252dd0e5008cc08Mathias Agopian    void addClientLayer(const sp<Client>& client,
2936710604286401d4205c27235a252dd0e5008cc08Mathias Agopian            const sp<IBinder>& handle,
2946710604286401d4205c27235a252dd0e5008cc08Mathias Agopian            const sp<IGraphicBufferProducer>& gbc,
2956710604286401d4205c27235a252dd0e5008cc08Mathias Agopian            const sp<Layer>& lbc);
296921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
297921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
298921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Boot animation, on/off animations and screen capture
299921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
300921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
301921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void startBootAnim();
302921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
303180f10de6f504d2ba56ff32ae8ed53c58bb458e9Mathias Agopian    void renderScreenImplLocked(
304180f10de6f504d2ba56ff32ae8ed53c58bb458e9Mathias Agopian            const sp<const DisplayDevice>& hw,
305180f10de6f504d2ba56ff32ae8ed53c58bb458e9Mathias Agopian            uint32_t reqWidth, uint32_t reqHeight,
306180f10de6f504d2ba56ff32ae8ed53c58bb458e9Mathias Agopian            uint32_t minLayerZ, uint32_t maxLayerZ,
307180f10de6f504d2ba56ff32ae8ed53c58bb458e9Mathias Agopian            bool yswap);
308180f10de6f504d2ba56ff32ae8ed53c58bb458e9Mathias Agopian
3092a9fc493dfdba67108e4335bb1fe931bc1e2a025Mathias Agopian    status_t captureScreenImplLocked(
3102a9fc493dfdba67108e4335bb1fe931bc1e2a025Mathias Agopian            const sp<const DisplayDevice>& hw,
311abe815dd6978b718c04f6e22e1a893d2b51d11a1Mathias Agopian            const sp<IGraphicBufferProducer>& producer,
312abe815dd6978b718c04f6e22e1a893d2b51d11a1Mathias Agopian            uint32_t reqWidth, uint32_t reqHeight,
3130aea53ff3f71f9f8df55d1cf58fd586442582643Mathias Agopian            uint32_t minLayerZ, uint32_t maxLayerZ,
3140aea53ff3f71f9f8df55d1cf58fd586442582643Mathias Agopian            bool useReadPixels);
315abe815dd6978b718c04f6e22e1a893d2b51d11a1Mathias Agopian
316921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
317921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * EGL
318921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
319722b98f9dfe8f04de8734630198b99a6cd024118Mathias Agopian    static status_t selectConfigForAttribute(EGLDisplay dpy,
320722b98f9dfe8f04de8734630198b99a6cd024118Mathias Agopian        EGLint const* attrs, EGLint attribute, EGLint value, EGLConfig* outConfig);
321921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    static EGLConfig selectEGLConfig(EGLDisplay disp, EGLint visualId);
322921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    static EGLContext createGLContext(EGLDisplay disp, EGLConfig config);
323cde87a3b9d3f8dc15232d927b56ee9e5e520f58dMathias Agopian    void initializeGL(EGLDisplay display);
324921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    uint32_t getMaxTextureSize() const;
325921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    uint32_t getMaxViewportDims() const;
326921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
327921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
32887baae104a3e4c2059990b01c393476065c558b0Mathias Agopian     * Display and layer stack management
329921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
33013a082e160c2d1d8006b93a555a57035213d568bAndy McFadden    // called when starting, or restarting after system_server death
33113a082e160c2d1d8006b93a555a57035213d568bAndy McFadden    void initializeDisplays();
33213a082e160c2d1d8006b93a555a57035213d568bAndy McFadden
333692c723e84e6f2747447d871d468ff50e5c73f19Jesse Hall    // Create an IBinder for a builtin display and add it to current state
334692c723e84e6f2747447d871d468ff50e5c73f19Jesse Hall    void createBuiltinDisplayLocked(DisplayDevice::DisplayType type);
335692c723e84e6f2747447d871d468ff50e5c73f19Jesse Hall
336db9b41fd157279d1b988a854e0d7c5b43c2fac38Mathias Agopian    // NOTE: can only be called from the main thread or with mStateLock held
3373ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian    sp<const DisplayDevice> getDisplayDevice(const wp<IBinder>& dpy) const {
33892a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian        return mDisplays.valueFor(dpy);
33992a979a92c34b7de609ce2b1662c73bb8a2728b9Mathias Agopian    }
340db9b41fd157279d1b988a854e0d7c5b43c2fac38Mathias Agopian
341db9b41fd157279d1b988a854e0d7c5b43c2fac38Mathias Agopian    // NOTE: can only be called from the main thread or with mStateLock held
342db9b41fd157279d1b988a854e0d7c5b43c2fac38Mathias Agopian    sp<DisplayDevice> getDisplayDevice(const wp<IBinder>& dpy) {
3434297734c1156fd8ede7e9c61b1e439f9e1c18cd9Mathias Agopian        return mDisplays.valueFor(dpy);
344921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    }
345921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
34687baae104a3e4c2059990b01c393476065c558b0Mathias Agopian    // mark a region of a layer stack dirty. this updates the dirty
34787baae104a3e4c2059990b01c393476065c558b0Mathias Agopian    // region of all screens presenting this layer stack.
34887baae104a3e4c2059990b01c393476065c558b0Mathias Agopian    void invalidateLayerStack(uint32_t layerStack, const Region& dirty);
34987baae104a3e4c2059990b01c393476065c558b0Mathias Agopian
35002d86567d95b99e1142941ed7ec23a4465822813Jesse Hall    // allocate a h/w composer display id
35102d86567d95b99e1142941ed7ec23a4465822813Jesse Hall    int32_t allocateHwcDisplayId(DisplayDevice::DisplayType type);
35202d86567d95b99e1142941ed7ec23a4465822813Jesse Hall
353921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
3548630320433bd15aca239522e54e711ef6372ab07Mathias Agopian     * H/W composer
3558630320433bd15aca239522e54e711ef6372ab07Mathias Agopian     */
3568630320433bd15aca239522e54e711ef6372ab07Mathias Agopian
3578630320433bd15aca239522e54e711ef6372ab07Mathias Agopian    HWComposer& getHwComposer() const { return *mHwc; }
3588630320433bd15aca239522e54e711ef6372ab07Mathias Agopian
359888c822c4cb6976aab9256c58bae9e17e3e55c5cMathias Agopian    /* ------------------------------------------------------------------------
360921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Compositing
361921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
362921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void invalidateHwcGeometry();
363ce3a0a541c3dde1330551bd7a048cd9d92335c00Mathias Agopian    static void computeVisibleRegions(
364ce3a0a541c3dde1330551bd7a048cd9d92335c00Mathias Agopian            const LayerVector& currentLayers, uint32_t layerStack,
36587baae104a3e4c2059990b01c393476065c558b0Mathias Agopian            Region& dirtyRegion, Region& opaqueRegion);
366cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian
367cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian    void preComposition();
368cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian    void postComposition();
369cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian    void rebuildLayerStacks();
370cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian    void setUpHWComposer();
371cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian    void doComposition();
372cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian    void doDebugFlashRegions();
373cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian    void doDisplayComposition(const sp<const DisplayDevice>& hw,
374cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian            const Region& dirtyRegion);
375cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian    void doComposeSurfaces(const sp<const DisplayDevice>& hw,
376cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian            const Region& dirty);
377cd60f99aba9e750700a967db30b74a29145739cfMathias Agopian
378921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void postFramebuffer();
37955801e41e6d7306d75d8134dd69d7d8cbbfbc63cMathias Agopian    void drawWormhole(const sp<const DisplayDevice>& hw,
38055801e41e6d7306d75d8134dd69d7d8cbbfbc63cMathias Agopian            const Region& region) const;
381921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    GLuint getProtectedTexName() const {
382921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian        return mProtectedTexName;
383921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    }
384921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
385921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
3860bceb84773882b796d9dacbaf96167cb15928d78Jamie Gennis     * Display management
3870bceb84773882b796d9dacbaf96167cb15928d78Jamie Gennis     */
3883ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian
3890bceb84773882b796d9dacbaf96167cb15928d78Jamie Gennis
3900bceb84773882b796d9dacbaf96167cb15928d78Jamie Gennis    /* ------------------------------------------------------------------------
391921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Debugging & dumpsys
392921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
393921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void listLayersLocked(const Vector<String16>& args, size_t& index,
39474d211ae26a0257c6075a823812e40b55aa1e653Mathias Agopian        String8& result) const;
395921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void dumpStatsLocked(const Vector<String16>& args, size_t& index,
39674d211ae26a0257c6075a823812e40b55aa1e653Mathias Agopian        String8& result) const;
397921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    void clearStatsLocked(const Vector<String16>& args, size_t& index,
39874d211ae26a0257c6075a823812e40b55aa1e653Mathias Agopian        String8& result);
39974d211ae26a0257c6075a823812e40b55aa1e653Mathias Agopian    void dumpAllLocked(const Vector<String16>& args, size_t& index,
40074d211ae26a0257c6075a823812e40b55aa1e653Mathias Agopian        String8& result) const;
40163f165fd6b86d04be94d4023e845e98560504a96Keun young Park    bool startDdmConnection();
4024803b74e2a12a508f7bbfde6f6a962fe3299c61cAndy McFadden    static void appendSfConfigString(String8& result);
403921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
404921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
405921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Attributes
406921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
407921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
408921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // access must be protected by mStateLock
409921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    mutable Mutex mStateLock;
410921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    State mCurrentState;
411921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    volatile int32_t mTransactionFlags;
412921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    Condition mTransactionCV;
4132d5e230292c27d59f4c096bc742a0a19abf811c1Jamie Gennis    bool mTransactionPending;
4142d5e230292c27d59f4c096bc742a0a19abf811c1Jamie Gennis    bool mAnimTransactionPending;
41513127d8921356dff794250e04208c3ed60b3a3dfMathias Agopian    Vector< sp<Layer> > mLayersPendingRemoval;
4166710604286401d4205c27235a252dd0e5008cc08Mathias Agopian    SortedVector< wp<IBinder> > mGraphicBufferProducerList;
417921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
418921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // protected by mStateLock (but we could use another lock)
419921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    bool mLayersRemoved;
420921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
421921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // access must be protected by mInvalidateLock
42287baae104a3e4c2059990b01c393476065c558b0Mathias Agopian    volatile int32_t mRepaintEverything;
423921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
424921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // constant members (no synchronization needed for access)
4258630320433bd15aca239522e54e711ef6372ab07Mathias Agopian    HWComposer* mHwc;
426921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    GLuint mProtectedTexName;
427921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    nsecs_t mBootTime;
428b4b1730abb7824dc084468c4942f010d94a7e039Mathias Agopian    bool mGpuToCpuSupported;
429921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    sp<EventThread> mEventThread;
430921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    GLint mMaxViewportDims[2];
431921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    GLint mMaxTextureSize;
432921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    EGLContext mEGLContext;
433921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    EGLConfig mEGLConfig;
43434a09ba1efd706323a15633da5044b352988eb5fJesse Hall    EGLDisplay mEGLDisplay;
435ed985574148a938bc3af24442eead313cc62521cMathias Agopian    EGLint mEGLNativeVisualId;
43629c3f352797d9d2ddf055d8f888e7694ef8b3947Jesse Hall    GlesVersion mGlesVersion;
437692c723e84e6f2747447d871d468ff50e5c73f19Jesse Hall    sp<IBinder> mBuiltinDisplays[DisplayDevice::NUM_DISPLAY_TYPES];
438921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
439921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // Can only accessed from the main thread, these members
440921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // don't need synchronization
441921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    State mDrawingState;
442921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    bool mVisibleRegionsDirty;
443921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    bool mHwWorkListDirty;
4444b0eba949cc026ffb2c75313042d8a7bcb3fcf86Jamie Gennis    bool mAnimCompositionPending;
445db9b41fd157279d1b988a854e0d7c5b43c2fac38Mathias Agopian
446db9b41fd157279d1b988a854e0d7c5b43c2fac38Mathias Agopian    // this may only be written from the main thread with mStateLock held
447db9b41fd157279d1b988a854e0d7c5b43c2fac38Mathias Agopian    // it may be read from other threads with mStateLock held
4483ee454a7bef8bd3d1c9cdd9d17108eb80ebadf2aMathias Agopian    DefaultKeyedVector< wp<IBinder>, sp<DisplayDevice> > mDisplays;
449921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
450921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // don't use a lock for these, we don't care
451921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    int mDebugRegion;
452921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    int mDebugDDMS;
453921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    int mDebugDisableHWC;
454921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    int mDebugDisableTransformHint;
455921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    volatile nsecs_t mDebugInSwapBuffers;
456921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    nsecs_t mLastSwapBufferTime;
457921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    volatile nsecs_t mDebugInTransaction;
458921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    nsecs_t mLastTransactionTime;
459921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    bool mBootFinished;
460921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
461921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // these are thread safe
462921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    mutable MessageQueue mEventQueue;
463921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    mutable Barrier mReadyToRunBarrier;
4644b0eba949cc026ffb2c75313042d8a7bcb3fcf86Jamie Gennis    FrameTracker mAnimFrameTracker;
465921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
466921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    // protected by mDestroyedLayerLock;
467921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    mutable Mutex mDestroyedLayerLock;
46813127d8921356dff794250e04208c3ed60b3a3dfMathias Agopian    Vector<Layer const *> mDestroyedLayers;
469921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
470921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian    /* ------------------------------------------------------------------------
471921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     * Feature prototyping
472921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian     */
473921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian
4745f20e2d4462da3471f59152b32cd8640fa4a21daMathias Agopian    sp<IBinder> mExtDisplayToken;
475edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project};
476edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
477edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project// ---------------------------------------------------------------------------
478edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project}; // namespace android
479edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
480edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#endif // ANDROID_SURFACE_FLINGER_H
481