From 303d538bb012e82c6b9a98c4930a03455000f761 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Sun, 5 Feb 2012 01:49:16 -0800 Subject: [PATCH] ui freeze workaround: reenable triple buffering mode we're seeing UI freezes when window updates and composition are separated. for now we workaround this by always doing a composition after window updates on vsync. triple buffering is reenabled for performance. Change-Id: I693d705000b7452489bb0b4918fbeadb9879315c --- services/surfaceflinger/Android.mk | 1 + services/surfaceflinger/Layer.cpp | 5 +++++ services/surfaceflinger/MessageQueue.cpp | 3 ++- services/surfaceflinger/SurfaceFlinger.cpp | 21 ++++++++++++++------- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk index 8b4c0744b..42e280fa9 100644 --- a/services/surfaceflinger/Android.mk +++ b/services/surfaceflinger/Android.mk @@ -32,6 +32,7 @@ ifeq ($(TARGET_BOARD_PLATFORM), omap3) endif ifeq ($(TARGET_BOARD_PLATFORM), omap4) LOCAL_CFLAGS += -DHAS_CONTEXT_PRIORITY + LOCAL_CFLAGS += -DUSE_TRIPLE_BUFFERING endif ifeq ($(TARGET_BOARD_PLATFORM), s5pc110) LOCAL_CFLAGS += -DHAS_CONTEXT_PRIORITY -DNEVER_DEFAULT_TO_ASYNC_MODE diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 64f72d5c8..3e6b87252 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -98,7 +98,12 @@ void Layer::onFirstRef() mSurfaceTexture = new SurfaceTextureLayer(mTextureName, this); mSurfaceTexture->setFrameAvailableListener(new FrameQueuedListener(this)); mSurfaceTexture->setSynchronousMode(true); +#ifdef USE_TRIPLE_BUFFERING +#warning "using triple buffering" + mSurfaceTexture->setBufferCountServer(3); +#else mSurfaceTexture->setBufferCountServer(2); +#endif } Layer::~Layer() diff --git a/services/surfaceflinger/MessageQueue.cpp b/services/surfaceflinger/MessageQueue.cpp index 1ff3567f4..290fff469 100644 --- a/services/surfaceflinger/MessageQueue.cpp +++ b/services/surfaceflinger/MessageQueue.cpp @@ -133,7 +133,8 @@ status_t MessageQueue::postMessage( } void MessageQueue::invalidate() { - mHandler->signalInvalidate(); +// mHandler->signalInvalidate(); + mEvents->requestNextVsync(); } void MessageQueue::refresh() { diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index b30adafb1..88666ea04 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -403,7 +403,8 @@ bool SurfaceFlinger::threadLoop() void SurfaceFlinger::onMessageReceived(int32_t what) { switch (what) { - case MessageQueue::INVALIDATE: { + case MessageQueue::REFRESH: { +// case MessageQueue::INVALIDATE: { // check for transactions if (CC_UNLIKELY(mConsoleSignals)) { handleConsoleEvents(); @@ -419,19 +420,25 @@ void SurfaceFlinger::onMessageReceived(int32_t what) // post surfaces (if needed) handlePageFlip(); - signalRefresh(); - } break; +// signalRefresh(); +// +// } break; +// +// case MessageQueue::REFRESH: { - case MessageQueue::REFRESH: { - // NOTE: it is mandatory to call hw.compositionComplete() - // after handleRefresh() - const DisplayHardware& hw(graphicPlane(0).displayHardware()); handleRefresh(); + const DisplayHardware& hw(graphicPlane(0).displayHardware()); + +// if (mDirtyRegion.isEmpty()) { +// return; +// } + if (CC_UNLIKELY(mHwWorkListDirty)) { // build the h/w work list handleWorkList(); } + if (CC_LIKELY(hw.canDraw())) { // repaint the framebuffer (if needed) handleRepaint();