Commit 2257f0c8 authored by Daniele Castagna's avatar Daniele Castagna Committed by Commit Bot

ash: Expand ambient EQ temperature range

Originally we remapped temperatures to a range [5700, 7500) and then
computed RGB scale factors using linear functions.

The table that remaps temperatures has been updated with
crrev.com/c/2001254 but we didn't update the code to accept the new range
[4500, 7500).

This CL updates the accepted range and also recomputes GB coefficients
used for the linear regression in the interval [4500, 6500].

Bug: 1045647
Test: ash_unittests --gtest_filter=AmbientTemperature.AmbientTemperatureToRGBScaleFactors
Change-Id: Ifa19820cd8d6b076dbf6c85841f126bca7ea4585
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2022246Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: Daniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736498}
parent d7bcb407
...@@ -99,7 +99,7 @@ constexpr int kNightLightAnimationFrameRate = 30; ...@@ -99,7 +99,7 @@ constexpr int kNightLightAnimationFrameRate = 30;
// The following are color temperatues in Kelvin. // The following are color temperatues in Kelvin.
// The min/max are a reasonable range we can clamp the values to. // The min/max are a reasonable range we can clamp the values to.
constexpr float kMinColorTemperatureInKelvin = 5700; constexpr float kMinColorTemperatureInKelvin = 4500;
constexpr float kNeutralColorTemperatureInKelvin = 6500; constexpr float kNeutralColorTemperatureInKelvin = 6500;
constexpr float kMaxColorTemperatureInKelvin = 7500; constexpr float kMaxColorTemperatureInKelvin = 7500;
...@@ -455,8 +455,8 @@ float NightLightControllerImpl::GetNonLinearTemperature(float temperature) { ...@@ -455,8 +455,8 @@ float NightLightControllerImpl::GetNonLinearTemperature(float temperature) {
float NightLightControllerImpl::RemapAmbientColorTemperature( float NightLightControllerImpl::RemapAmbientColorTemperature(
float temperature_in_kelvin) { float temperature_in_kelvin) {
// This function maps sensor input temperatures to other values since we want // This function maps sensor input temperatures to other values since we want
// to avoid extreme color temperatures (e.g: temperatures below 5700 and // to avoid extreme color temperatures (e.g: temperatures below 4500 and
// above 7450 are too extreme.) // above 7500 are too extreme.)
// The following table was created with internal user studies. // The following table was created with internal user studies.
constexpr struct { constexpr struct {
int32_t input_temperature; int32_t input_temperature;
...@@ -516,8 +516,8 @@ NightLightControllerImpl::ColorScalesFromRemappedTemperatureInKevin( ...@@ -516,8 +516,8 @@ NightLightControllerImpl::ColorScalesFromRemappedTemperatureInKevin(
float temperature_decrement = float temperature_decrement =
(kNeutralColorTemperatureInKelvin - temperature_in_kelvin) / (kNeutralColorTemperatureInKelvin - temperature_in_kelvin) /
(kNeutralColorTemperatureInKelvin - kMinColorTemperatureInKelvin); (kNeutralColorTemperatureInKelvin - kMinColorTemperatureInKelvin);
green = 1.f - temperature_decrement * 0.0368f; green = 1.f - temperature_decrement * 0.1211f;
blue = 1.f - temperature_decrement * 0.0882f; blue = 1.f - temperature_decrement * 0.2749f;
} }
return {red, green, blue}; return {red, green, blue};
} }
......
...@@ -1487,8 +1487,8 @@ TEST(AmbientTemperature, AmbientTemperatureToRGBScaleFactors) { ...@@ -1487,8 +1487,8 @@ TEST(AmbientTemperature, AmbientTemperatureToRGBScaleFactors) {
allowed_difference); allowed_difference);
// Warm // Warm
vec = vec =
NightLightControllerImpl::ColorScalesFromRemappedTemperatureInKevin(5800); NightLightControllerImpl::ColorScalesFromRemappedTemperatureInKevin(4500);
EXPECT_LT((vec - gfx::Vector3dF(1.0f, 0.968f, 0.924f)).Length(), EXPECT_LT((vec - gfx::Vector3dF(1.0f, 0.8816f, 0.7313f)).Length(),
allowed_difference); allowed_difference);
// Daylight // Daylight
vec = vec =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment