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

Commit 7bb70faa authored by Ady Abraham's avatar Ady Abraham
Browse files

Remove render ahead from hwui

As HWUI uses vsync id to send buffers to SF, SF applies the right
amount of render ahead by latching the buffers at the configured time.

Test: launch an app and observe systrace
Bug: 178148035
Change-Id: Ifd3e1a2971aad0a085cb35d33e950194046aa634
parent dba0fb55
Loading
Loading
Loading
Loading
+3 −15
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@ import java.io.File;
import java.io.FileDescriptor;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
import java.util.Optional;
import java.util.concurrent.Executor;
import java.util.stream.Stream;
@@ -1148,24 +1147,14 @@ public class HardwareRenderer {
                            // Default to SRGB if the display doesn't support wide color
                            .orElse(Dataspace.SRGB);

            float maxRefreshRate =
                    (float) Arrays.stream(display.getSupportedModes())
                            .mapToDouble(Mode::getRefreshRate)
                            .max()
                            .orElseGet(() -> {
                                Log.i(LOG_TAG, "Failed to find the maximum display refresh rate");
                                // Assume that the max refresh rate is 60hz if we can't find one.
                                return 60.0;
                            });
            // Grab the physical screen dimensions from the active display mode
            // Strictly speaking the screen resolution may not always be constant - it is for
            // sizing the font cache for the underlying rendering thread. Since it's a
            // heuristic we don't need to be always 100% correct.
            Mode activeMode = display.getMode();
            nInitDisplayInfo(activeMode.getPhysicalWidth(), activeMode.getPhysicalHeight(),
                    display.getRefreshRate(), maxRefreshRate,
                    wideColorDataspace.mNativeDataspace, display.getAppVsyncOffsetNanos(),
                    display.getPresentationDeadlineNanos());
                    display.getRefreshRate(), wideColorDataspace.mNativeDataspace,
                    display.getAppVsyncOffsetNanos(), display.getPresentationDeadlineNanos());

            // Defensively clear out the context
            mContext = null;
@@ -1324,6 +1313,5 @@ public class HardwareRenderer {
    private static native void nSetDisplayDensityDpi(int densityDpi);

    private static native void nInitDisplayInfo(int width, int height, float refreshRate,
            float maxRefreshRate, int wideColorDataspace, long appVsyncOffsetNanos,
            long presentationDeadlineNanos);
            int wideColorDataspace, long appVsyncOffsetNanos, long presentationDeadlineNanos);
}
+0 −3
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ class DeviceInfo {

public:
    static DeviceInfo* get();
    static float getMaxRefreshRate() { return get()->mMaxRefreshRate; }
    static int32_t getWidth() { return get()->mWidth; }
    static int32_t getHeight() { return get()->mHeight; }
    // Gets the density in density-independent pixels
@@ -45,7 +44,6 @@ public:
    static int64_t getAppOffset() { return get()->mAppVsyncOffsetNanos; }
    // Sets the density in density-independent pixels
    static void setDensity(float density) { sDensity.store(density); }
    static void setMaxRefreshRate(float refreshRate) { get()->mMaxRefreshRate = refreshRate; }
    static void setWidth(int32_t width) { get()->mWidth = width; }
    static void setHeight(int32_t height) { get()->mHeight = height; }
    static void setRefreshRate(float refreshRate) {
@@ -91,7 +89,6 @@ private:
    SkColorType mWideColorType = SkColorType::kN32_SkColorType;
    int mDisplaysSize = 0;
    int mPhysicalDisplayIndex = -1;
    float mMaxRefreshRate = 60.0;
    int32_t mWidth = 1080;
    int32_t mHeight = 1920;
    int64_t mVsyncPeriod = 16666666;
+0 −5
Original line number Diff line number Diff line
@@ -79,7 +79,6 @@ bool Properties::debuggingEnabled = false;
bool Properties::isolatedProcess = false;

int Properties::contextPriority = 0;
int Properties::defaultRenderAhead = -1;
float Properties::defaultSdrWhitePoint = 200.f;

bool Properties::load() {
@@ -129,10 +128,6 @@ bool Properties::load() {

    runningInEmulator = base::GetBoolProperty(PROPERTY_QEMU_KERNEL, false);

    defaultRenderAhead = std::max(
            -1,
            std::min(2, base::GetIntProperty(PROPERTY_RENDERAHEAD, render_ahead().value_or(-1))));

    return (prevDebugLayersUpdates != debugLayersUpdates) || (prevDebugOverdraw != debugOverdraw);
}

+0 −4
Original line number Diff line number Diff line
@@ -162,8 +162,6 @@ enum DebugLevel {
 */
#define PROPERTY_QEMU_KERNEL "ro.kernel.qemu"

#define PROPERTY_RENDERAHEAD "debug.hwui.render_ahead"

///////////////////////////////////////////////////////////////////////////////
// Misc
///////////////////////////////////////////////////////////////////////////////
@@ -247,8 +245,6 @@ public:

    static int contextPriority;

    static int defaultRenderAhead;

    static float defaultSdrWhitePoint;

private:
+1 −3
Original line number Diff line number Diff line
@@ -603,14 +603,12 @@ static void android_view_ThreadedRenderer_setDisplayDensityDpi(JNIEnv*, jclass,

static void android_view_ThreadedRenderer_initDisplayInfo(JNIEnv*, jclass, jint physicalWidth,
                                                          jint physicalHeight, jfloat refreshRate,
                                                          jfloat maxRefreshRate,
                                                          jint wideColorDataspace,
                                                          jlong appVsyncOffsetNanos,
                                                          jlong presentationDeadlineNanos) {
    DeviceInfo::setWidth(physicalWidth);
    DeviceInfo::setHeight(physicalHeight);
    DeviceInfo::setRefreshRate(refreshRate);
    DeviceInfo::setMaxRefreshRate(maxRefreshRate);
    DeviceInfo::setWideColorDataspace(static_cast<ADataSpace>(wideColorDataspace));
    DeviceInfo::setAppVsyncOffsetNanos(appVsyncOffsetNanos);
    DeviceInfo::setPresentationDeadlineNanos(presentationDeadlineNanos);
@@ -735,7 +733,7 @@ static const JNINativeMethod gMethods[] = {
        {"nSetForceDark", "(JZ)V", (void*)android_view_ThreadedRenderer_setForceDark},
        {"nSetDisplayDensityDpi", "(I)V",
         (void*)android_view_ThreadedRenderer_setDisplayDensityDpi},
        {"nInitDisplayInfo", "(IIFFIJJ)V", (void*)android_view_ThreadedRenderer_initDisplayInfo},
        {"nInitDisplayInfo", "(IIFIJJ)V", (void*)android_view_ThreadedRenderer_initDisplayInfo},
        {"preload", "()V", (void*)android_view_ThreadedRenderer_preload},
};

Loading