Commit 3394d6ec authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

color: Use ColorProfileReader on Windows

This was already present, now use it to populate the information read
by the compositor and renderers.

Bug: 735613
Change-Id: Id5c85b2bc3a0891e35760dd27b65d85c898d9176
Reviewed-on: https://chromium-review.googlesource.com/564392Reviewed-by: default avatarFredrik Hubinette <hubbe@chromium.org>
Commit-Queue: ccameron chromium <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485841}
parent 13f9833e
...@@ -80,7 +80,8 @@ std::vector<DisplayInfo> FindAndRemoveTouchingDisplayInfos( ...@@ -80,7 +80,8 @@ std::vector<DisplayInfo> FindAndRemoveTouchingDisplayInfos(
return touching_display_infos; return touching_display_infos;
} }
Display CreateDisplayFromDisplayInfo(const DisplayInfo& display_info) { Display CreateDisplayFromDisplayInfo(const DisplayInfo& display_info,
ColorProfileReader* color_profile_reader) {
Display display(display_info.id()); Display display(display_info.id());
float scale_factor = display_info.device_scale_factor(); float scale_factor = display_info.device_scale_factor();
display.set_device_scale_factor(scale_factor); display.set_device_scale_factor(scale_factor);
...@@ -90,11 +91,10 @@ Display CreateDisplayFromDisplayInfo(const DisplayInfo& display_info) { ...@@ -90,11 +91,10 @@ Display CreateDisplayFromDisplayInfo(const DisplayInfo& display_info) {
display.set_bounds(gfx::ScaleToEnclosingRect(display_info.screen_rect(), display.set_bounds(gfx::ScaleToEnclosingRect(display_info.screen_rect(),
1.0f / scale_factor)); 1.0f / scale_factor));
display.set_rotation(display_info.rotation()); display.set_rotation(display_info.rotation());
if (!gfx::ICCProfile::HasForcedProfile()) {
// TODO(ccameron): Populate this based on this specific display. display.set_color_space(
// http://crbug.com/735613 color_profile_reader->GetDisplayColorSpace(display_info.id()));
display.set_color_space(gfx::ICCProfile::FromBestMonitor().GetColorSpace()); }
return display; return display;
} }
...@@ -116,7 +116,8 @@ Display CreateDisplayFromDisplayInfo(const DisplayInfo& display_info) { ...@@ -116,7 +116,8 @@ Display CreateDisplayFromDisplayInfo(const DisplayInfo& display_info) {
// map to multiple screen points due to overlap. The first discovered screen // map to multiple screen points due to overlap. The first discovered screen
// will take precedence. // will take precedence.
std::vector<ScreenWinDisplay> DisplayInfosToScreenWinDisplays( std::vector<ScreenWinDisplay> DisplayInfosToScreenWinDisplays(
const std::vector<DisplayInfo>& display_infos) { const std::vector<DisplayInfo>& display_infos,
ColorProfileReader* color_profile_reader) {
// Find and extract the primary display. // Find and extract the primary display.
std::vector<DisplayInfo> display_infos_remaining = display_infos; std::vector<DisplayInfo> display_infos_remaining = display_infos;
auto primary_display_iter = std::find_if( auto primary_display_iter = std::find_if(
...@@ -145,7 +146,8 @@ std::vector<ScreenWinDisplay> DisplayInfosToScreenWinDisplays( ...@@ -145,7 +146,8 @@ std::vector<ScreenWinDisplay> DisplayInfosToScreenWinDisplays(
// Layout and create the ScreenWinDisplays. // Layout and create the ScreenWinDisplays.
std::vector<Display> displays; std::vector<Display> displays;
for (const auto& display_info : display_infos) for (const auto& display_info : display_infos)
displays.push_back(CreateDisplayFromDisplayInfo(display_info)); displays.push_back(
CreateDisplayFromDisplayInfo(display_info, color_profile_reader));
std::unique_ptr<DisplayLayout> layout(builder.Build()); std::unique_ptr<DisplayLayout> layout(builder.Build());
layout->ApplyToDisplayList(&displays, nullptr, 0); layout->ApplyToDisplayList(&displays, nullptr, 0);
...@@ -163,7 +165,6 @@ std::vector<Display> ScreenWinDisplaysToDisplays( ...@@ -163,7 +165,6 @@ std::vector<Display> ScreenWinDisplaysToDisplays(
std::vector<Display> displays; std::vector<Display> displays;
for (const auto& screen_win_display : screen_win_displays) for (const auto& screen_win_display : screen_win_displays)
displays.push_back(screen_win_display.display()); displays.push_back(screen_win_display.display());
return displays; return displays;
} }
...@@ -456,7 +457,8 @@ gfx::Rect ScreenWin::DIPToScreenRectInWindow(gfx::NativeView view, ...@@ -456,7 +457,8 @@ gfx::Rect ScreenWin::DIPToScreenRectInWindow(gfx::NativeView view,
void ScreenWin::UpdateFromDisplayInfos( void ScreenWin::UpdateFromDisplayInfos(
const std::vector<DisplayInfo>& display_infos) { const std::vector<DisplayInfo>& display_infos) {
screen_win_displays_ = DisplayInfosToScreenWinDisplays(display_infos); screen_win_displays_ = DisplayInfosToScreenWinDisplays(
display_infos, color_profile_reader_.get());
displays_ = ScreenWinDisplaysToDisplays(screen_win_displays_); displays_ = ScreenWinDisplaysToDisplays(screen_win_displays_);
} }
...@@ -511,7 +513,23 @@ void ScreenWin::OnWndProc(HWND hwnd, ...@@ -511,7 +513,23 @@ void ScreenWin::OnWndProc(HWND hwnd,
} }
void ScreenWin::OnColorProfilesChanged() { void ScreenWin::OnColorProfilesChanged() {
// TODO(ccameron): Re-build the display list here. // The color profile reader will often just confirm that our guess that the
// color profile was sRGB was indeed correct. Avoid doing an update in these
// cases.
bool changed = false;
for (const auto& display : displays_) {
if (display.color_space() !=
color_profile_reader_->GetDisplayColorSpace(display.id())) {
changed = true;
break;
}
}
if (!changed)
return;
std::vector<Display> old_displays = std::move(displays_);
UpdateFromDisplayInfos(GetDisplayInfosFromSystem());
change_notifier_.NotifyDisplaysChanged(old_displays, displays_);
} }
ScreenWinDisplay ScreenWin::GetScreenWinDisplayNearestHWND(HWND hwnd) ScreenWinDisplay ScreenWin::GetScreenWinDisplayNearestHWND(HWND hwnd)
......
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