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

Commit 13ae3e72 authored by Candice Lo's avatar Candice Lo Committed by Candice
Browse files

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

Revert submission 33149009-revert-30679429-forcedark-colorarea-detection-KGFLTNVUGM

Reason for revert: Relanding the ColorArea mechanisms

Reverted changes: /q/submissionid:33149009-revert-30679429-forcedark-colorarea-detection-KGFLTNVUGM
Relanding changes: /q/submissionid:30679429-forcedark-colorarea-detection

Bug: 372558459
Test: None - relanding without changes
Flag: android.view.accessibility.force_invert_color
Change-Id: I3714afafe24ca0cc754ce76bef8555f8f99b07e5
parent 874f339b
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
#ifdef __ANDROID__
#include "include/gpu/ganesh/SkImageGanesh.h"
#endif
#include "FeatureFlags.h"
#include "utils/ForceDark.h"
#include "utils/MathUtils.h"
#include "utils/StringUtils.h"
@@ -409,8 +410,10 @@ 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(info.forceDarkType ==
                       android::uirenderer::ForceDarkType::FORCE_INVERT_COLOR_DARK);
    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 true if the tree should use the force dark feature that selectively
@@ -435,12 +438,15 @@ void RenderNode::gatherColorAreasForSubtree(ColorArea& target, bool isModeFull)
    }
}

void RenderNode::handleForceDark(TreeInfo *info) {
    if (CC_UNLIKELY(view_accessibility_flags::force_invert_color() && info &&
                    isForceInvertDark(*info))) {
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!
        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::NONE ? 1 : 0)
        , disableForceDark(canvasContext.getForceDarkType() == ForceDarkType::FORCE_DARK ? 0 : 1)
        , forceDarkType(canvasContext.getForceDarkType())
        , screenSize(canvasContext.getNextFrameSize()) {}