#include <sys/types.h>
#include <EGL/egl.h>
-#include <GLES/gl.h> // needed for GLuint
+
+/*
+ * NOTE: Make sure this file doesn't include anything from <gl/ > or <gl2/ >
+ */
#include <cutils/compiler.h>
#include <utils/SortedVector.h>
#include <utils/threads.h>
-#include <binder/BinderService.h>
#include <binder/IMemory.h>
#include <ui/PixelFormat.h>
#include "Barrier.h"
#include "DisplayDevice.h"
+#include "DispSync.h"
#include "FrameTracker.h"
#include "MessageQueue.h"
#include "DisplayHardware/HWComposer.h"
+#include "Effects/Daltonizer.h"
namespace android {
class LayerDim;
class Surface;
class RenderEngine;
+class EventControlThread;
// ---------------------------------------------------------------------------
eTransactionMask = 0x07
};
-class SurfaceFlinger : public BinderService<SurfaceFlinger>,
- public BnSurfaceComposer,
+class SurfaceFlinger : public BnSurfaceComposer,
private IBinder::DeathRecipient,
- private Thread,
private HWComposer::EventHandler
{
public:
SurfaceFlinger() ANDROID_API;
+ // must be called before clients can connect
+ void init() ANDROID_API;
+
+ // starts SurfaceFlinger main loop in the current thread
+ void run() ANDROID_API;
+
enum {
EVENT_VSYNC = HWC_EVENT_VSYNC
};
// post an asynchronous message to the main thread
- status_t postMessageAsync(const sp<MessageBase>& msg, nsecs_t reltime = 0,
- uint32_t flags = 0);
+ status_t postMessageAsync(const sp<MessageBase>& msg, nsecs_t reltime = 0, uint32_t flags = 0);
// post a synchronous message to the main thread
- status_t postMessageSync(const sp<MessageBase>& msg, nsecs_t reltime = 0,
- uint32_t flags = 0);
+ status_t postMessageSync(const sp<MessageBase>& msg, nsecs_t reltime = 0, uint32_t flags = 0);
// force full composition on all displays
void repaintEverything();
}
// utility function to delete a texture on the main thread
- void deleteTextureAsync(GLuint texture);
+ void deleteTextureAsync(uint32_t texture);
// enable/disable h/w composer event
// TODO: this should be made accessible only to EventThread
virtual sp<ISurfaceComposerClient> createConnection();
virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc();
virtual sp<IBinder> createDisplay(const String8& displayName, bool secure);
+ virtual void destroyDisplay(const sp<IBinder>& display);
virtual sp<IBinder> getBuiltInDisplay(int32_t id);
virtual void setTransactionState(const Vector<ComposerState>& state,
const Vector<DisplayState>& displays, uint32_t flags);
virtual void binderDied(const wp<IBinder>& who);
/* ------------------------------------------------------------------------
- * Thread interface
+ * RefBase interface
*/
- virtual bool threadLoop();
- virtual status_t readyToRun();
virtual void onFirstRef();
/* ------------------------------------------------------------------------
uint32_t peekTransactionFlags(uint32_t flags);
uint32_t setTransactionFlags(uint32_t flags);
void commitTransaction();
- uint32_t setClientStateLocked(const sp<Client>& client,
- const layer_state_t& s);
+ uint32_t setClientStateLocked(const sp<Client>& client, const layer_state_t& s);
uint32_t setDisplayStateLocked(const DisplayState& s);
/* ------------------------------------------------------------------------
*/
static status_t selectConfigForAttribute(EGLDisplay dpy,
EGLint const* attrs, EGLint attribute, EGLint value, EGLConfig* outConfig);
- static EGLConfig selectEGLConfig(EGLDisplay disp, EGLint visualId);
+ static status_t selectEGLConfig(EGLDisplay disp, EGLint visualId,
+ EGLint renderableType, EGLConfig* config);
size_t getMaxTextureSize() const;
size_t getMaxViewportDims() const;
void setUpHWComposer();
void doComposition();
void doDebugFlashRegions();
- void doDisplayComposition(const sp<const DisplayDevice>& hw,
- const Region& dirtyRegion);
- void doComposeSurfaces(const sp<const DisplayDevice>& hw,
- const Region& dirty);
+ void doDisplayComposition(const sp<const DisplayDevice>& hw, const Region& dirtyRegion);
+ void doComposeSurfaces(const sp<const DisplayDevice>& hw, const Region& dirty);
void postFramebuffer();
- void drawWormhole(const sp<const DisplayDevice>& hw,
- const Region& region) const;
+ void drawWormhole(const sp<const DisplayDevice>& hw, const Region& region) const;
/* ------------------------------------------------------------------------
* Display management
*/
+ /* ------------------------------------------------------------------------
+ * VSync
+ */
+ void enableHardwareVsync();
+ void disableHardwareVsync(bool makeUnavailable);
+ void resyncToHardwareVsync(bool makeAvailable);
/* ------------------------------------------------------------------------
* Debugging & dumpsys
*/
- void listLayersLocked(const Vector<String16>& args, size_t& index,
- String8& result) const;
- void dumpStatsLocked(const Vector<String16>& args, size_t& index,
- String8& result) const;
- void clearStatsLocked(const Vector<String16>& args, size_t& index,
- String8& result);
- void dumpAllLocked(const Vector<String16>& args, size_t& index,
- String8& result) const;
+ void listLayersLocked(const Vector<String16>& args, size_t& index, String8& result) const;
+ void dumpStatsLocked(const Vector<String16>& args, size_t& index, String8& result) const;
+ void clearStatsLocked(const Vector<String16>& args, size_t& index, String8& result);
+ void dumpAllLocked(const Vector<String16>& args, size_t& index, String8& result) const;
bool startDdmConnection();
static void appendSfConfigString(String8& result);
- void checkScreenshot(const sp<GraphicBuffer>& buf, void const* vaddr,
+ void checkScreenshot(size_t w, size_t s, size_t h, void const* vaddr,
const sp<const DisplayDevice>& hw,
uint32_t minLayerZ, uint32_t maxLayerZ);
nsecs_t mBootTime;
bool mGpuToCpuSupported;
sp<EventThread> mEventThread;
+ sp<EventThread> mSFEventThread;
+ sp<EventControlThread> mEventControlThread;
EGLContext mEGLContext;
EGLConfig mEGLConfig;
EGLDisplay mEGLDisplay;
EGLint mEGLNativeVisualId;
- sp<IBinder> mBuiltinDisplays[DisplayDevice::NUM_DISPLAY_TYPES];
+ sp<IBinder> mBuiltinDisplays[DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES];
// Can only accessed from the main thread, these members
// don't need synchronization
// these are thread safe
mutable MessageQueue mEventQueue;
- mutable Barrier mReadyToRunBarrier;
FrameTracker mAnimFrameTracker;
+ DispSync mPrimaryDispSync;
// protected by mDestroyedLayerLock;
mutable Mutex mDestroyedLayerLock;
Vector<Layer const *> mDestroyedLayers;
+ // protected by mHWVsyncLock
+ Mutex mHWVsyncLock;
+ bool mPrimaryHWVsyncEnabled;
+ bool mHWVsyncAvailable;
+
/* ------------------------------------------------------------------------
* Feature prototyping
*/
- sp<IBinder> mExtDisplayToken;
+ Daltonizer mDaltonizer;
+ bool mDaltonize;
};
-// ---------------------------------------------------------------------------
}; // namespace android
#endif // ANDROID_SURFACE_FLINGER_H