Commit 0635a5ef authored by Daniel Nicoara's avatar Daniel Nicoara Committed by Commit Bot

Don't try to configure display color correction if not supported

Check that the display supports color correction before trying to apply
it to the hardware.

BUG=850182
TEST=Ran on device and verified NOTREACHED in
HardwareDisplayPlaneManagerLegacy isn't triggered.

Change-Id: I086e718e7ebfa8bbaf0286dac411ffee45a743ef
Reviewed-on: https://chromium-review.googlesource.com/1089858Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Commit-Queue: Daniel Nicoara <dnicoara@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565389}
parent 31b51b0d
......@@ -209,6 +209,18 @@ std::vector<display::GammaRampRGBEntry> GetDefaultDeGammaLut() {
return table;
}
bool HasColorCorrectionMatrix(display::DisplayConfigurator* configurator,
int64_t display_id) {
for (const auto* display_snapshot : configurator->cached_displays()) {
if (display_snapshot->display_id() != display_id)
continue;
return display_snapshot->has_color_correction_matrix();
}
return false;
}
} // namespace
DisplayColorManager::DisplayColorManager(
......@@ -305,17 +317,20 @@ void DisplayColorManager::OnDisplayRemoved(
void DisplayColorManager::ApplyDisplayColorCalibration(
int64_t display_id,
const ColorCalibrationData& calibration_data) {
const auto color_matrix_iter = displays_color_matrix_map_.find(display_id);
const std::vector<float>* final_matrix = &calibration_data.correction_matrix;
if (color_matrix_iter != displays_color_matrix_map_.end()) {
SkMatrix44 combined_matrix = color_matrix_iter->second;
combined_matrix.preConcat(SkMatrix44FromColorMatrixVector(*final_matrix));
ColorMatrixVectorFromSkMatrix44(combined_matrix, &matrix_buffer_);
final_matrix = &matrix_buffer_;
}
if (HasColorCorrectionMatrix(configurator_, display_id)) {
const auto color_matrix_iter = displays_color_matrix_map_.find(display_id);
const std::vector<float>* final_matrix =
&calibration_data.correction_matrix;
if (color_matrix_iter != displays_color_matrix_map_.end()) {
SkMatrix44 combined_matrix = color_matrix_iter->second;
combined_matrix.preConcat(SkMatrix44FromColorMatrixVector(*final_matrix));
ColorMatrixVectorFromSkMatrix44(combined_matrix, &matrix_buffer_);
final_matrix = &matrix_buffer_;
}
if (!configurator_->SetColorMatrix(display_id, *final_matrix))
LOG(WARNING) << "Error applying the color matrix.";
if (!configurator_->SetColorMatrix(display_id, *final_matrix))
LOG(WARNING) << "Error applying the color matrix.";
}
// When applying gamma correction, we either use the gamma/degamma tables from
// the calibration data if available, or we apply default ones. This makes
......
......@@ -249,8 +249,8 @@ TEST_F(DisplayColorManagerTest, SetDisplayColorMatrixNoCTMSupport) {
// this display has no CTM support.
const std::string& actions = log_->GetActionsAndClear();
EXPECT_TRUE(base::MatchPattern(actions, kResetGammaAction));
EXPECT_TRUE(base::MatchPattern(
actions, "*set_color_matrix(id=123,ctm[0]=1*ctm[4]=1*ctm[8]=1*)*"));
// Hardware doesn't support CTM, so CTM shouldn't be configured.
EXPECT_FALSE(base::MatchPattern(actions, "*set_color_matrix*"));
// Attempt to set a color matrix.
SkMatrix44 matrix(SkMatrix44::kIdentity_Constructor);
......
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