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

Commit 93d6e248 authored by Nader Jawad's avatar Nader Jawad
Browse files

Add support to toggle different shader

behaviors

Updated HWUI to toggle overscroll stretch
implementation based on whether the
device supports high end graphics
or not

Bug: 187718492
Test: manual
Change-Id: I13a91a8861c07bec8af43268ba22d0f5b7060b4f
parent 72ac81f5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1195,6 +1195,7 @@ public class HardwareRenderer {
            // so not checking for isolated process here.
            initHintSession();

            nSetIsHighEndGfx(ActivityManager.isHighEndGfx());
            // Defensively clear out the context in case we were passed a context that can leak
            // if we live longer than it, e.g. an activity context.
            mContext = null;
@@ -1315,6 +1316,8 @@ public class HardwareRenderer {

    private static native void nSetSdrWhitePoint(long nativeProxy, float whitePoint);

    private static native void nSetIsHighEndGfx(boolean isHighEndGfx);

    private static native int nSyncAndDrawFrame(long nativeProxy, long[] frameInfo, int size);

    private static native void nDestroy(long nativeProxy, long rootRenderNode);
+1 −1
Original line number Diff line number Diff line
@@ -157,7 +157,7 @@ static inline void applyMatrix(const SkMatrix& transform, SkRect* rect) {
static inline void mapRect(const RenderProperties& props, const SkRect& in, SkRect* out) {
    if (in.isEmpty()) return;
    SkRect temp(in);
    if (Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
    if (Properties::getStretchEffectBehavior() == StretchEffectBehavior::UniformScale) {
        const StretchEffect& stretch = props.layerProperties().getStretchEffect();
        if (!stretch.isEmpty()) {
            applyMatrix(stretch.makeLinearStretch(props.getWidth(), props.getHeight()), &temp);
+0 −4
Original line number Diff line number Diff line
@@ -137,10 +137,6 @@ bool Properties::load() {
    targetCpuTimePercentage = base::GetIntProperty(PROPERTY_TARGET_CPU_TIME_PERCENTAGE, 70);
    if (targetCpuTimePercentage <= 0 || targetCpuTimePercentage > 100) targetCpuTimePercentage = 70;

    int stretchType = base::GetIntProperty(PROPERTY_STRETCH_EFFECT_TYPE, 0);
    stretchType = std::clamp(stretchType, 0, static_cast<int>(StretchEffectBehavior::UniformScale));
    stretchEffectBehavior = static_cast<StretchEffectBehavior>(stretchType);

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

+18 −3
Original line number Diff line number Diff line
@@ -171,8 +171,6 @@ enum DebugLevel {
 */
#define PROPERTY_TARGET_CPU_TIME_PERCENTAGE "debug.hwui.target_cpu_time_percent"

#define PROPERTY_STRETCH_EFFECT_TYPE "debug.hwui.stretch_mode"

/**
 * Property for whether this is running in the emulator.
 */
@@ -278,9 +276,26 @@ public:
    static bool useHintManager;
    static int targetCpuTimePercentage;

    static StretchEffectBehavior stretchEffectBehavior;
    static StretchEffectBehavior getStretchEffectBehavior() {
        return stretchEffectBehavior;
    }

    static void setIsHighEndGfx(bool isHighEndGfx) {
        stretchEffectBehavior = isHighEndGfx ?
            StretchEffectBehavior::ShaderHWUI :
            StretchEffectBehavior::UniformScale;
    }

    /**
     * Used for testing. Typical configuration of stretch behavior is done
     * through setIsHighEndGfx
     */
    static void setStretchEffectBehavior(StretchEffectBehavior behavior) {
        stretchEffectBehavior = behavior;
    }

private:
    static StretchEffectBehavior stretchEffectBehavior;
    static ProfileType sProfileType;
    static bool sDisableProfileBars;
    static RenderPipelineType sRenderPipelineType;
+1 −1
Original line number Diff line number Diff line
@@ -478,7 +478,7 @@ void RenderNode::applyViewPropertyTransforms(mat4& matrix, bool true3dTransform)
        }
    }

    if (Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
    if (Properties::getStretchEffectBehavior() == StretchEffectBehavior::UniformScale) {
        const StretchEffect& stretch = properties().layerProperties().getStretchEffect();
        if (!stretch.isEmpty()) {
            matrix.multiply(
Loading