Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5681005d authored by Jeykumar Sankaran's avatar Jeykumar Sankaran Committed by Giulio Cervera
Browse files

Support triple application buffers

This change modifies surfaceflinger to use 3 application buffers
by default for performance improvement.

Change-Id: Ia3b1354f1b5d23f8237d73d1761436dd05ab004a
parent a8c72e6c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -162,7 +162,11 @@ private:
    // must be used from the lock/unlock thread
    sp<GraphicBuffer>           mLockedBuffer;
    sp<GraphicBuffer>           mPostedBuffer;
#ifdef QCOM_HARDWARE
    mutable Region              mOldDirtyRegion[NUM_BUFFER_SLOTS];
#else
    mutable Region              mOldDirtyRegion;
#endif
    bool                        mConnectedToCpu;
};

+5 −0
Original line number Diff line number Diff line
@@ -1211,6 +1211,11 @@ int SurfaceTexture::query(int what, int* outValue)
        value = mSynchronousMode ?
                (MIN_UNDEQUEUED_BUFFERS-1) : MIN_UNDEQUEUED_BUFFERS;
        break;
#ifdef QCOM_HARDWARE
    case NATIVE_WINDOW_NUM_BUFFERS:
        value = mBufferCount;
        break;
#endif
    default:
        return BAD_VALUE;
    }
+26 −0
Original line number Diff line number Diff line
@@ -677,20 +677,46 @@ status_t SurfaceTextureClient::lock(
                    backBuffer->height == frontBuffer->height &&
                    backBuffer->format == frontBuffer->format);

#ifdef QCOM_HARDWARE
            int bufferCount;

            mSurfaceTexture->query(NATIVE_WINDOW_NUM_BUFFERS, &bufferCount);
            const int backBufferidx = getSlotFromBufferLocked(out);
#endif

            if (canCopyBack) {
                // copy the area that is invalid and not repainted this round
#ifdef QCOM_HARDWARE
                Region oldDirtyRegion;
                for(int i = 0 ; i < bufferCount; i++ ) {
                    if(i != backBufferidx  && !mOldDirtyRegion[i].isEmpty())
                        oldDirtyRegion.orSelf(mOldDirtyRegion[i]);
                }

                const Region copyback(oldDirtyRegion.subtract(newDirtyRegion));
#else
                const Region copyback(mOldDirtyRegion.subtract(newDirtyRegion));
#endif
                if (!copyback.isEmpty())
                    copyBlt(backBuffer, frontBuffer, copyback);
            } else {
                // if we can't copy-back anything, modify the user's dirty
                // region to make sure they redraw the whole buffer
                newDirtyRegion.set(bounds);
#ifdef QCOM_HARDWARE
                for(int i = 0 ; i < bufferCount; i++ ) {
                     mOldDirtyRegion[i].clear();
                }
#endif
            }

            // keep track of the are of the buffer that is "clean"
            // (ie: that will be redrawn)
#ifdef QCOM_HARDWARE
            mOldDirtyRegion[backBufferidx] = newDirtyRegion;
#else
            mOldDirtyRegion = newDirtyRegion;
#endif

            if (inOutDirtyBounds) {
                *inOutDirtyBounds = newDirtyRegion.getBounds();
+6 −0
Original line number Diff line number Diff line
@@ -59,6 +59,12 @@ LOCAL_C_INCLUDES := \
LOCAL_C_INCLUDES += hardware/libhardware/modules/gralloc

ifeq ($(BOARD_USES_QCOM_HARDWARE),true)
ifeq ($(TARGET_HAVE_BYPASS),true)
    LOCAL_CFLAGS += -DBUFFER_COUNT_SERVER=3
else
    LOCAL_CFLAGS += -DBUFFER_COUNT_SERVER=2
endif

LOCAL_SHARED_LIBRARIES += \
	libQcomUI
LOCAL_C_INCLUDES += hardware/qcom/display/libqcomui
+4 −0
Original line number Diff line number Diff line
@@ -93,7 +93,11 @@ void Layer::onFirstRef()
    mSurfaceTexture = new SurfaceTextureLayer(mTextureName, this);
    mSurfaceTexture->setFrameAvailableListener(new FrameQueuedListener(this));
    mSurfaceTexture->setSynchronousMode(true);
#ifdef QCOM_HARDWARE
    mSurfaceTexture->setBufferCountServer(BUFFER_COUNT_SERVER);
#else
    mSurfaceTexture->setBufferCountServer(2);
#endif
}

Layer::~Layer()