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

Commit 33567749 authored by Tyler Freeman's avatar Tyler Freeman
Browse files

fix(force invert): don't let devs opt-out of force dark when force invert is on

Bug: 282821643
Test: manual??
Change-Id: I0a3907ede2ad5d0c895ae70d3d1ec47b0902e3b4
parent 417accdc
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@
#ifdef __ANDROID__
#include "include/gpu/ganesh/SkImageGanesh.h"
#endif
#include "utils/ForceDark.h"
#include "utils/MathUtils.h"
#include "utils/StringUtils.h"

@@ -403,16 +404,21 @@ void RenderNode::syncDisplayList(TreeObserver& observer, TreeInfo* info) {
    deleteDisplayList(observer, info);
    mDisplayList = std::move(mStagingDisplayList);
    if (mDisplayList) {
        WebViewSyncData syncData {
            .applyForceDark = info && !info->disableForceDark
        };
        WebViewSyncData syncData{.applyForceDark = shouldEnableForceDark(info)};
        mDisplayList.syncContents(syncData);
        handleForceDark(info);
    }
}

inline bool RenderNode::shouldEnableForceDark(TreeInfo* info) {
    return CC_UNLIKELY(
            info &&
            (!info->disableForceDark ||
             info->forceDarkType == android::uirenderer::ForceDarkType::FORCE_INVERT_COLOR_DARK));
}

void RenderNode::handleForceDark(android::uirenderer::TreeInfo *info) {
    if (CC_LIKELY(!info || info->disableForceDark)) {
    if (!shouldEnableForceDark(info)) {
        return;
    }
    auto usage = usageHint();
+1 −0
Original line number Diff line number Diff line
@@ -233,6 +233,7 @@ private:
    void syncProperties();
    void syncDisplayList(TreeObserver& observer, TreeInfo* info);
    void handleForceDark(TreeInfo* info);
    bool shouldEnableForceDark(TreeInfo* info);

    void prepareTreeImpl(TreeObserver& observer, TreeInfo& info, bool functorsNeedLayer);
    void pushStagingPropertiesChanges(TreeInfo& info);
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ TreeInfo::TreeInfo(TraversalMode mode, renderthread::CanvasContext& canvasContex
        , prepareTextures(mode == MODE_FULL)
        , canvasContext(canvasContext)
        , disableForceDark(canvasContext.getForceDarkType() == ForceDarkType::NONE ? 1 : 0)
        , forceDarkType(canvasContext.getForceDarkType())
        , screenSize(canvasContext.getNextFrameSize()) {}

}  // namespace android::uirenderer
+2 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include "Properties.h"
#include "SkSize.h"
#include "SkippedFrameInfo.h"
#include "utils/ForceDark.h"
#include "utils/Macros.h"

namespace android {
@@ -97,6 +98,7 @@ public:
    bool updateWindowPositions = false;

    int disableForceDark;
    ForceDarkType forceDarkType = ForceDarkType::NONE;

    const SkISize screenSize;