Commit 09edd90d authored by Nick Czajka's avatar Nick Czajka Committed by Commit Bot

Makes ambient eq only affect internal display

This change modifieds the behavior of night_light_controller.cc to
selectively apply ambient color to only internal displays.

It also restructures night_light_controller_unittest.cc to allow for
multiple displays in AmbientEQTest.

The two tests affected by this change are also moved from
NightLightTest into AmbientEQTest.

Bug: 1078901
Change-Id: Ie967698d99713026591b44ddeaee294f80e2df60
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2453904
Commit-Queue: Nick Czajka <czajka@google.com>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816310}
parent c4f4fc04
......@@ -170,12 +170,13 @@ int GetTemperatureRange(float temperature) {
// Returns the color matrix that corresponds to the given |temperature|.
// The matrix will be affected by the current |ambient_temperature_| if
// GetAmbientColorEnabled() returns true.
// |apply_ambient_temperature| is true.
// If |in_linear_gamma_space| is true, the generated matrix is the one that
// should be applied after gamma correction, and it corresponds to the
// non-linear temperature value for the given |temperature|.
SkMatrix44 MatrixFromTemperature(float temperature,
bool in_linear_gamma_space) {
bool in_linear_gamma_space,
bool apply_ambient_temperature) {
if (in_linear_gamma_space)
temperature =
NightLightControllerImpl::GetNonLinearTemperature(temperature);
......@@ -194,7 +195,7 @@ SkMatrix44 MatrixFromTemperature(float temperature,
auto* night_light_controller = Shell::Get()->night_light_controller();
DCHECK(night_light_controller);
if (night_light_controller->GetAmbientColorEnabled()) {
if (apply_ambient_temperature) {
const gfx::Vector3dF& ambient_rgb_scaling_factors =
night_light_controller->ambient_rgb_scaling_factors();
......@@ -265,10 +266,18 @@ void ApplyTemperatureToHost(aura::WindowTreeHost* host, float temperature) {
return;
}
auto* night_light_controller = Shell::Get()->night_light_controller();
DCHECK(night_light_controller);
// Only apply ambient EQ to internal displays.
const bool apply_ambient_temperature =
night_light_controller->GetAmbientColorEnabled() &&
display::Display::IsInternalDisplayId(display_id);
const SkMatrix44 linear_gamma_space_matrix =
MatrixFromTemperature(temperature, true);
MatrixFromTemperature(temperature, true, apply_ambient_temperature);
const SkMatrix44 gamma_compressed_matrix =
MatrixFromTemperature(temperature, false);
MatrixFromTemperature(temperature, false, apply_ambient_temperature);
const bool crtc_result = AttemptSettingHardwareCtm(
display_id, linear_gamma_space_matrix, gamma_compressed_matrix);
UpdateCompositorMatrix(host, gamma_compressed_matrix, crtc_result);
......@@ -280,10 +289,6 @@ void ApplyTemperatureToHost(aura::WindowTreeHost* host, float temperature) {
// by the current |ambient_temperature_| if GetAmbientColorEnabled() returns
// true.
void ApplyTemperatureToAllDisplays(float temperature) {
const SkMatrix44 linear_gamma_space_matrix =
MatrixFromTemperature(temperature, true);
const SkMatrix44 gamma_compressed_matrix =
MatrixFromTemperature(temperature, false);
Shell* shell = Shell::Get();
WindowTreeHostManager* wth_manager = shell->window_tree_host_manager();
......@@ -291,9 +296,6 @@ void ApplyTemperatureToAllDisplays(float temperature) {
shell->display_manager()->GetCurrentDisplayIdList()) {
DCHECK_NE(display_id, display::kUnifiedDisplayId);
const bool crtc_result = AttemptSettingHardwareCtm(
display_id, linear_gamma_space_matrix, gamma_compressed_matrix);
aura::Window* root_window =
wth_manager->GetRootWindowForDisplayId(display_id);
if (!root_window) {
......@@ -305,7 +307,7 @@ void ApplyTemperatureToAllDisplays(float temperature) {
auto* host = root_window->GetHost();
DCHECK(host);
UpdateCompositorMatrix(host, gamma_compressed_matrix, crtc_result);
ApplyTemperatureToHost(host, temperature);
}
}
......
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