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

Commit 63005e6e authored by John Reck's avatar John Reck
Browse files

Reduce wasted buffer allocations

Bug: 20170924

Don't pre-allocate buffers if there is a SurfaceView or other
View that has requested transparent regions. This doesn't fully
address the problem of allocating buffers when there's a full
screen SurfaceView but it at least gets back to KitKat levels
of only having 1 wasted buffer instead of 3 (the 1 being
a result of the fact that it will still draw one frame of emptiness
forcing a buffer dequeue).

Change-Id: Ied9553186bc7b111d180b63f87b92bd317cb4b97
parent 95ba62f8
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -148,7 +148,6 @@ public class ThreadedRenderer extends HardwareRenderer {
        mInitialized = true;
        updateEnabledState(surface);
        boolean status = nInitialize(mNativeProxy, surface);
        surface.allocateBuffers();
        return status;
    }

+9 −0
Original line number Diff line number Diff line
@@ -1708,10 +1708,19 @@ public final class ViewRootImpl implements ViewParent,
                        mFullRedrawNeeded = true;
                        mPreviousTransparentRegion.setEmpty();

                        // Only initialize up-front if transparent regions are not
                        // requested, otherwise defer to see if the entire window
                        // will be transparent
                        if (mAttachInfo.mHardwareRenderer != null) {
                            try {
                                hwInitialized = mAttachInfo.mHardwareRenderer.initialize(
                                        mSurface);
                                if (hwInitialized && (host.mPrivateFlags
                                        & View.PFLAG_REQUEST_TRANSPARENT_REGIONS) == 0) {
                                    // Don't pre-allocate if transparent regions
                                    // are requested as they may not be needed
                                    mSurface.allocateBuffers();
                                }
                            } catch (OutOfResourcesException e) {
                                handleOutOfResourcesException(e);
                                return;