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

Commit 6e4b7658 authored by John Reck's avatar John Reck
Browse files

Revert "feat(force invert): force invert the entire app if its p..."

Revert submission 30679429-forcedark-colorarea-detection

Reason for revert: Triggered a performance regression

Bug: 410295655

Reverted changes: /q/submissionid:30679429-forcedark-colorarea-detection

Change-Id: Id267933e1bd1e7ab73c6cf6c3e044c3fbfc80bf9
parent 5d882534
Loading
Loading
Loading
Loading
+5 −11
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@
#ifdef __ANDROID__
#include "include/gpu/ganesh/SkImageGanesh.h"
#endif
#include "FeatureFlags.h"
#include "utils/ForceDark.h"
#include "utils/MathUtils.h"
#include "utils/StringUtils.h"
@@ -410,10 +409,8 @@ void RenderNode::syncDisplayList(TreeObserver& observer, TreeInfo* info) {
// Return true if the tree should use the force invert feature that inverts
// the entire tree to darken it.
inline bool RenderNode::isForceInvertDark(TreeInfo& info) {
    return CC_UNLIKELY(view_accessibility_flags::force_invert_color() &&
                       info.forceDarkType ==
                               android::uirenderer::ForceDarkType::FORCE_INVERT_COLOR_DARK &&
                       info.colorArea && info.colorArea->getPolarity() == Polarity::Light);
    return CC_UNLIKELY(info.forceDarkType ==
                       android::uirenderer::ForceDarkType::FORCE_INVERT_COLOR_DARK);
}

// Return true if the tree should use the force dark feature that selectively
@@ -438,15 +435,12 @@ void RenderNode::gatherColorAreasForSubtree(ColorArea& target, bool isModeFull)
    }
}

void RenderNode::handleForceDark(android::uirenderer::TreeInfo* info) {
    if (CC_UNLIKELY(info && isForceInvertDark(*info))) {
        // TODO(b/391959649): what about apps who have opted in to force dark, but only partially?
        //  will this mess them up? e.g. if they set disableForceDark but only on a few nodes.
        // The app is too bright, captain! Reverse the polarity!
void RenderNode::handleForceDark(TreeInfo *info) {
    if (CC_UNLIKELY(view_accessibility_flags::force_invert_color() && info &&
                    isForceInvertDark(*info))) {
        mDisplayList.applyColorTransform(ColorTransform::Invert);
        return;
    }

    if (!shouldEnableForceDark(info)) {
        return;
    }
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ TreeInfo::TreeInfo(TraversalMode mode, renderthread::CanvasContext& canvasContex
        : mode(mode)
        , prepareTextures(mode == MODE_FULL)
        , canvasContext(canvasContext)
        , disableForceDark(canvasContext.getForceDarkType() == ForceDarkType::FORCE_DARK ? 0 : 1)
        , disableForceDark(canvasContext.getForceDarkType() == ForceDarkType::NONE ? 1 : 0)
        , forceDarkType(canvasContext.getForceDarkType())
        , screenSize(canvasContext.getNextFrameSize()) {}