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

Commit cbe6850d authored by Balamurugan Thanikachalam's avatar Balamurugan Thanikachalam Committed by Gerrit - the friendly Code Review server
Browse files

Choreographer: Add disable VSync for CPU Rendered apps

Choreographer VSync has some performance impact for CPU rendered apps as the
app has to wait for VSync to start a new frame draw. When the frame draw time
exceeds one VSync, this has a direct impact on the FPS.

Add a feature to disable VSync for CPU rendered apps using system property.

"debug.cpurend.vsync" property controls the VSync for CPU rendered apps.
This is set to true by default to maintain upstream behavior. To disable VSync
for CPU rendered app, the property is set to false.

Change-Id: If302c003ddfa57b4b45d8ebbb9b241a049eb32c8
parent de550cea
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -139,6 +139,7 @@ public final class Choreographer {
    private boolean mCallbacksRunning;
    private long mLastFrameTimeNanos;
    private long mFrameIntervalNanos;
    private boolean mSoftwareRendered;

    /**
     * Callback type: Input callback.  Runs first.
@@ -173,6 +174,7 @@ public final class Choreographer {
        for (int i = 0; i <= CALLBACK_LAST; i++) {
            mCallbackQueues[i] = new CallbackQueue();
        }
        mSoftwareRendered = false;
    }

    private static float getRefreshRate() {
@@ -274,6 +276,10 @@ public final class Choreographer {
                writer.println(TimeUtils.formatUptime(mLastFrameTimeNanos / 1000000));
    }

    void setSoftwareRendering(boolean softRendered) {
        mSoftwareRendered = softRendered;
    }

    /**
     * Posts a callback to run on the next frame.
     * <p>
@@ -478,7 +484,7 @@ public final class Choreographer {
    private void scheduleFrameLocked(long now) {
        if (!mFrameScheduled) {
            mFrameScheduled = true;
            if (USE_VSYNC) {
            if (USE_VSYNC && !mSoftwareRendered) {
                if (DEBUG) {
                    Log.d(TAG, "Scheduling next frame on vsync.");
                }
+12 −0
Original line number Diff line number Diff line
@@ -195,6 +195,7 @@ public final class ViewRootImpl implements ViewParent,
    InputQueue mInputQueue;
    FallbackEventHandler mFallbackEventHandler;
    Choreographer mChoreographer;
    boolean mDebugCpuRendVsync;

    final Rect mTempRect; // used in the transaction to not thrash the heap.
    final Rect mVisRect; // used to retrieve visible rect of focused view.
@@ -388,6 +389,8 @@ public final class ViewRootImpl implements ViewParent,
        mNoncompatDensity = context.getResources().getDisplayMetrics().noncompatDensityDpi;
        mFallbackEventHandler = PolicyManager.makeNewFallbackEventHandler(context);
        mChoreographer = Choreographer.getInstance();
        mDebugCpuRendVsync = SystemProperties.getBoolean("debug.cpurend.vsync", true);
        Log.i(TAG, "CPU Rendering VSync enable = " + mDebugCpuRendVsync);
        mDisplayManager = (DisplayManager)context.getSystemService(Context.DISPLAY_SERVICE);
        loadSystemProperties();
        mWindowIsRound = context.getResources().getBoolean(
@@ -484,6 +487,15 @@ public final class ViewRootImpl implements ViewParent,
                    enableHardwareAcceleration(attrs);
                }

                if (!mDebugCpuRendVsync) {
                    if(!mAttachInfo.mHardwareAccelerated ||
                            mAttachInfo.mHardwareRenderer == null) {
                        mChoreographer.setSoftwareRendering(true);
                    } else {
                        mChoreographer.setSoftwareRendering(false);
                    }
                }

                boolean restore = false;
                if (mTranslator != null) {
                    mSurface.setCompatibilityTranslator(mTranslator);