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

Commit e8f1a8c5 authored by Mark Renouf's avatar Mark Renouf
Browse files

Restores a capture rate limit for long screenshots

A previous change accidentally lost this delay between
incremental screen captures. This rate limit is needed
to prevent pushing screen capture faster than it can
render correctly.

Bug: 173700533
Bug: 217046739
Test: manual; long screenshot, observe app systrace
Change-Id: Ibd7940299b502c40212957395d272b6e52cc28be
parent 2b7ad933
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ public class ScrollCaptureViewSupport<V extends View> implements ScrollCaptureCa
        ContentResolver contentResolver = context.getContentResolver();
        mPostScrollDelayMillis = Settings.Global.getLong(contentResolver,
                SETTING_CAPTURE_DELAY, SETTING_CAPTURE_DELAY_DEFAULT);
        Log.d(TAG, "screenshot.scroll_capture_delay = " + mPostScrollDelayMillis);
    }

    /** Based on ViewRootImpl#updateColorModeIfNeeded */
@@ -271,6 +272,13 @@ public class ScrollCaptureViewSupport<V extends View> implements ScrollCaptureCa
        Rect viewCaptureArea = new Rect(scrollResult.availableArea);
        viewCaptureArea.offset(0, -scrollResult.scrollDelta);

        view.postOnAnimationDelayed(
                () -> doCapture(scrollResult, view, viewCaptureArea, onComplete),
                mPostScrollDelayMillis);
    }

    private void doCapture(ScrollResult scrollResult, V view, Rect viewCaptureArea,
            Consumer<Rect> onComplete) {
        int result = mRenderer.renderView(view, viewCaptureArea);
        if (result == HardwareRenderer.SYNC_OK
                || result == HardwareRenderer.SYNC_REDRAW_REQUESTED) {