Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(609)

Side by Side Diff: ui/display/win/screen_win.cc

Issue 2959423003: color: Read all displays' color profiles on Windows (Closed)
Patch Set: Remove unused Initialize method Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/display/win/screen_win.h ('k') | ui/display/win/screen_win_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/display/win/screen_win.h" 5 #include "ui/display/win/screen_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shellscalingapi.h> 8 #include <shellscalingapi.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 const gfx::Point& point) { 204 const gfx::Point& point) {
205 gfx::Vector2d from_origin_vector(from_origin.x(), from_origin.y()); 205 gfx::Vector2d from_origin_vector(from_origin.x(), from_origin.y());
206 gfx::Vector2d to_origin_vector(to_origin.x(), to_origin.y()); 206 gfx::Vector2d to_origin_vector(to_origin.x(), to_origin.y());
207 gfx::Point scaled_relative_point( 207 gfx::Point scaled_relative_point(
208 gfx::ScaleToFlooredPoint(point - from_origin_vector, scale_factor)); 208 gfx::ScaleToFlooredPoint(point - from_origin_vector, scale_factor));
209 return scaled_relative_point + to_origin_vector; 209 return scaled_relative_point + to_origin_vector;
210 } 210 }
211 211
212 } // namespace 212 } // namespace
213 213
214 ScreenWin::ScreenWin() { 214 ScreenWin::ScreenWin() : ScreenWin(true) {}
215
216 ScreenWin::ScreenWin(bool initialize)
217 : color_profile_reader_(new ColorProfileReader(this)) {
215 DCHECK(!g_screen_win_instance); 218 DCHECK(!g_screen_win_instance);
216 g_screen_win_instance = this; 219 g_screen_win_instance = this;
217 Initialize(); 220 if (initialize)
221 Initialize();
218 } 222 }
219 223
220 ScreenWin::~ScreenWin() { 224 ScreenWin::~ScreenWin() {
221 DCHECK_EQ(g_screen_win_instance, this); 225 DCHECK_EQ(g_screen_win_instance, this);
222 g_screen_win_instance = nullptr; 226 g_screen_win_instance = nullptr;
223 } 227 }
224 228
225 // static 229 // static
226 gfx::Point ScreenWin::ScreenToDIPPoint(const gfx::Point& pixel_point) { 230 gfx::Point ScreenWin::ScreenToDIPPoint(const gfx::Point& pixel_point) {
227 const ScreenWinDisplay screen_win_display = 231 const ScreenWinDisplay screen_win_display =
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 return DIPToScreenRect(hwnd, dip_rect); 454 return DIPToScreenRect(hwnd, dip_rect);
451 } 455 }
452 456
453 void ScreenWin::UpdateFromDisplayInfos( 457 void ScreenWin::UpdateFromDisplayInfos(
454 const std::vector<DisplayInfo>& display_infos) { 458 const std::vector<DisplayInfo>& display_infos) {
455 screen_win_displays_ = DisplayInfosToScreenWinDisplays(display_infos); 459 screen_win_displays_ = DisplayInfosToScreenWinDisplays(display_infos);
456 displays_ = ScreenWinDisplaysToDisplays(screen_win_displays_); 460 displays_ = ScreenWinDisplaysToDisplays(screen_win_displays_);
457 } 461 }
458 462
459 void ScreenWin::Initialize() { 463 void ScreenWin::Initialize() {
464 color_profile_reader_->UpdateIfNeeded();
460 singleton_hwnd_observer_.reset( 465 singleton_hwnd_observer_.reset(
461 new gfx::SingletonHwndObserver( 466 new gfx::SingletonHwndObserver(
462 base::Bind(&ScreenWin::OnWndProc, base::Unretained(this)))); 467 base::Bind(&ScreenWin::OnWndProc, base::Unretained(this))));
463 UpdateFromDisplayInfos(GetDisplayInfosFromSystem()); 468 UpdateFromDisplayInfos(GetDisplayInfosFromSystem());
464 RecordDisplayScaleFactors(); 469 RecordDisplayScaleFactors();
465 } 470 }
466 471
467 MONITORINFOEX ScreenWin::MonitorInfoFromScreenPoint( 472 MONITORINFOEX ScreenWin::MonitorInfoFromScreenPoint(
468 const gfx::Point& screen_point) const { 473 const gfx::Point& screen_point) const {
469 POINT initial_loc = { screen_point.x(), screen_point.y() }; 474 POINT initial_loc = { screen_point.x(), screen_point.y() };
(...skipping 22 matching lines...) Expand all
492 } 497 }
493 498
494 void ScreenWin::OnWndProc(HWND hwnd, 499 void ScreenWin::OnWndProc(HWND hwnd,
495 UINT message, 500 UINT message,
496 WPARAM wparam, 501 WPARAM wparam,
497 LPARAM lparam) { 502 LPARAM lparam) {
498 if (message != WM_DISPLAYCHANGE && 503 if (message != WM_DISPLAYCHANGE &&
499 !(message == WM_SETTINGCHANGE && wparam == SPI_SETWORKAREA)) 504 !(message == WM_SETTINGCHANGE && wparam == SPI_SETWORKAREA))
500 return; 505 return;
501 506
507 color_profile_reader_->UpdateIfNeeded();
502 std::vector<Display> old_displays = std::move(displays_); 508 std::vector<Display> old_displays = std::move(displays_);
503 UpdateFromDisplayInfos(GetDisplayInfosFromSystem()); 509 UpdateFromDisplayInfos(GetDisplayInfosFromSystem());
504 change_notifier_.NotifyDisplaysChanged(old_displays, displays_); 510 change_notifier_.NotifyDisplaysChanged(old_displays, displays_);
505 } 511 }
506 512
513 void ScreenWin::OnColorProfilesChanged() {
514 // TODO(ccameron): Re-build the display list here.
515 }
516
507 ScreenWinDisplay ScreenWin::GetScreenWinDisplayNearestHWND(HWND hwnd) 517 ScreenWinDisplay ScreenWin::GetScreenWinDisplayNearestHWND(HWND hwnd)
508 const { 518 const {
509 return GetScreenWinDisplay(MonitorInfoFromWindow(hwnd, 519 return GetScreenWinDisplay(MonitorInfoFromWindow(hwnd,
510 MONITOR_DEFAULTTONEAREST)); 520 MONITOR_DEFAULTTONEAREST));
511 } 521 }
512 522
513 ScreenWinDisplay ScreenWin::GetScreenWinDisplayNearestScreenRect( 523 ScreenWinDisplay ScreenWin::GetScreenWinDisplayNearestScreenRect(
514 const gfx::Rect& screen_rect) const { 524 const gfx::Rect& screen_rect) const {
515 return GetScreenWinDisplay(MonitorInfoFromScreenRect(screen_rect)); 525 return GetScreenWinDisplay(MonitorInfoFromScreenRect(screen_rect));
516 } 526 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 std::max(base::checked_cast<int>(scale_factor * 100), 0), 1000); 609 std::max(base::checked_cast<int>(scale_factor * 100), 0), 1000);
600 if (!base::ContainsValue(unique_scale_factors, reported_scale)) { 610 if (!base::ContainsValue(unique_scale_factors, reported_scale)) {
601 unique_scale_factors.push_back(reported_scale); 611 unique_scale_factors.push_back(reported_scale);
602 UMA_HISTOGRAM_SPARSE_SLOWLY("UI.DeviceScale", reported_scale); 612 UMA_HISTOGRAM_SPARSE_SLOWLY("UI.DeviceScale", reported_scale);
603 } 613 }
604 } 614 }
605 } 615 }
606 616
607 } // namespace win 617 } // namespace win
608 } // namespace display 618 } // namespace display
OLDNEW
« no previous file with comments | « ui/display/win/screen_win.h ('k') | ui/display/win/screen_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698