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

Commit 323060e9 authored by James O'Leary's avatar James O'Leary
Browse files

[CP] Adjust chroma/lstar filters for seed colors

There is a set of wallpapers, namely some Landscape wallpapers, that
don’t have any colors extracted from them. The wallpaper visually has
some color to it, but, the chroma of those colors is low enough that
they get filtered out by the low chroma filter.

Lower the chroma filter from 15 to 5, and eliminate the tone filter
(previously, L >= 10). Scoring compensates for this by prioritizing
chromatic colors, thus ensuring these low-chroma options are only used
if there’s no better options.

Bug: b/200675148
Test: Push landscape wallpapers #912, #914, and #924 from Monet
Studio to device. Verify color choices reflect wallpaper and aren't just
fallback colors.

Change-Id: I080e6cb51978638462a8b0ab41340aa11d495c93
parent 5ebb0fdc
Loading
Loading
Loading
Loading
+11 −7
Original line number Original line Diff line number Diff line
@@ -37,8 +37,7 @@ const val NEUTRAL2_CHROMA = 8.0f


const val GOOGLE_BLUE = 0xFF1b6ef3.toInt()
const val GOOGLE_BLUE = 0xFF1b6ef3.toInt()


const val MIN_CHROMA = 15
const val MIN_CHROMA = 5
const val MIN_LSTAR = 10


public class ColorScheme(@ColorInt seed: Int, val darkTheme: Boolean) {
public class ColorScheme(@ColorInt seed: Int, val darkTheme: Boolean) {


@@ -75,7 +74,14 @@ public class ColorScheme(@ColorInt seed: Int, val darkTheme: Boolean) {
        get() = ColorUtils.setAlphaComponent(if (darkTheme) accent1[2] else accent1[6], 0xFF)
        get() = ColorUtils.setAlphaComponent(if (darkTheme) accent1[2] else accent1[6], 0xFF)


    init {
    init {
        val seedArgb = if (seed == Color.TRANSPARENT) GOOGLE_BLUE else seed
        val proposedSeedCam = Cam.fromInt(seed)
        val seedArgb = if (seed == Color.TRANSPARENT) {
            GOOGLE_BLUE
        } else if (proposedSeedCam.chroma < 5) {
            GOOGLE_BLUE
        } else {
            seed
        }
        val camSeed = Cam.fromInt(seedArgb)
        val camSeed = Cam.fromInt(seedArgb)
        val hue = camSeed.hue
        val hue = camSeed.hue
        val chroma = camSeed.chroma.coerceAtLeast(ACCENT1_CHROMA)
        val chroma = camSeed.chroma.coerceAtLeast(ACCENT1_CHROMA)
@@ -129,9 +135,7 @@ public class ColorScheme(@ColorInt seed: Int, val darkTheme: Boolean) {
                val distinctColors = wallpaperColors.mainColors.map {
                val distinctColors = wallpaperColors.mainColors.map {
                    it.toArgb()
                    it.toArgb()
                }.distinct().filter {
                }.distinct().filter {
                    val cam = Cam.fromInt(it)
                    Cam.fromInt(it).chroma >= MIN_CHROMA
                    val lstar = lstarFromInt(it)
                    cam.chroma >= MIN_CHROMA && lstar >= MIN_LSTAR
                }.toList()
                }.toList()


                if (distinctColors.isEmpty()) {
                if (distinctColors.isEmpty()) {
@@ -164,7 +168,7 @@ public class ColorScheme(@ColorInt seed: Int, val darkTheme: Boolean) {
                val cam = it.value
                val cam = it.value
                val lstar = lstarFromInt(it.key)
                val lstar = lstarFromInt(it.key)
                val proportion = intToHueProportion[it.key]!!
                val proportion = intToHueProportion[it.key]!!
                cam.chroma >= MIN_CHROMA && lstar >= MIN_LSTAR &&
                cam.chroma >= MIN_CHROMA &&
                        (totalPopulationMeaningless || proportion > 0.01)
                        (totalPopulationMeaningless || proportion > 0.01)
            }
            }
            // Sort the colors by score, from high to low.
            // Sort the colors by score, from high to low.