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

Commit 7a40195b authored by Candice's avatar Candice
Browse files

Apply color area calculation when ForceInvert is enabled only

Bug: 410295655
Bug: 368725782
Test: manually check the benchmark - see screenshots
Test: atest hwui_unit_tests
Flag: android.view.accessibility.force_invert_color
Change-Id: I298252278cc264ea30831fa55fe21b8afd923930
parent f46f9cc3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ bool Properties::enableWebViewOverlays = true;
bool Properties::isHighEndGfx = true;
bool Properties::isLowRam = false;
bool Properties::isSystemOrPersistent = false;
bool Properties::isForceInvertEnabled = false;

float Properties::maxHdrHeadroomOn8bit = 5.f;  // TODO: Refine this number

+5 −0
Original line number Diff line number Diff line
@@ -341,6 +341,7 @@ public:
    static bool isHighEndGfx;
    static bool isLowRam;
    static bool isSystemOrPersistent;
    static bool isForceInvertEnabled;

    static float maxHdrHeadroomOn8bit;

@@ -375,6 +376,10 @@ public:
        stretchEffectBehavior = behavior;
    }

    static void setIsForceInvertEnabled(bool forceInvertEnabled) {
        Properties::isForceInvertEnabled = forceInvertEnabled;
    }

    // Represents if drawing is enabled. Should only be Off in headless testing environments
    static DrawingEnabled drawingEnabled;
    static bool isDrawingEnabled();
+2 −2
Original line number Diff line number Diff line
@@ -850,7 +850,7 @@ template <class T>
constexpr bool has_palette = std::experimental::is_detected_v<has_palette_helper, T>;

inline bool DisplayListData::shouldCountColorAreas() const {
    return view_accessibility_flags::force_invert_color();
    return view_accessibility_flags::force_invert_color() && Properties::isForceInvertEnabled;
}

typedef void (*color_area_fn)(const void*, ColorArea*);
@@ -969,7 +969,7 @@ void* DisplayListData::push(size_t pod, Args&&... args) {
        }
    }

    if (shouldCountColorAreas()) {
    if (CC_UNLIKELY(shouldCountColorAreas())) {
        if (auto fn = color_area_fns[op->type]) {
            fn(op, &mColorArea);
        }
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include "CanvasTransform.h"
#include "ColorArea.h"
#include "Gainmap.h"
#include "Properties.h"
#include "hwui/Bitmap.h"
#include "pipeline/skia/AnimatedDrawables.h"
#include "utils/AutoMalloc.h"
+2 −0
Original line number Diff line number Diff line
@@ -848,6 +848,8 @@ static void android_view_ThreadedRenderer_allocateBuffers(JNIEnv* env, jobject c

static void android_view_ThreadedRenderer_setForceDark(JNIEnv* env, jobject clazz, jlong proxyPtr,
                                                       jint type) {
    Properties::setIsForceInvertEnabled(static_cast<ForceDarkType>(type) ==
                                        ForceDarkType::FORCE_INVERT_COLOR_DARK);
    RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
    proxy->setForceDark(static_cast<ForceDarkType>(type));
}
Loading