OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef ASH_DISPLAY_DISPLAY_COLOR_MANAGER_CHROMEOS_H_ | 5 #ifndef ASH_DISPLAY_DISPLAY_COLOR_MANAGER_CHROMEOS_H_ |
6 #define ASH_DISPLAY_DISPLAY_COLOR_MANAGER_CHROMEOS_H_ | 6 #define ASH_DISPLAY_DISPLAY_COLOR_MANAGER_CHROMEOS_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "ash/ash_export.h" | 13 #include "ash/ash_export.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/threading/thread_checker.h" |
17 #include "ui/display/chromeos/display_configurator.h" | 18 #include "ui/display/chromeos/display_configurator.h" |
18 #include "ui/gfx/display.h" | 19 #include "ui/display/types/display_constants.h" |
19 #include "ui/gfx/display_observer.h" | |
20 | 20 |
21 namespace base { | 21 namespace base { |
22 class SequencedWorkerPool; | 22 class SequencedWorkerPool; |
23 } | 23 } |
24 | 24 |
25 namespace ui { | 25 namespace ui { |
| 26 class DisplaySnapshot; |
26 struct GammaRampRGBEntry; | 27 struct GammaRampRGBEntry; |
27 } // namespace ui | 28 } // namespace ui |
28 | 29 |
29 namespace ash { | 30 namespace ash { |
30 | 31 |
31 // An object that observes changes in display configuration applies any color | 32 // An object that observes changes in display configuration applies any color |
32 // calibration where needed. | 33 // calibration where needed. |
33 class ASH_EXPORT DisplayColorManager | 34 class ASH_EXPORT DisplayColorManager |
34 : public ui::DisplayConfigurator::Observer, | 35 : public ui::DisplayConfigurator::Observer { |
35 public base::SupportsWeakPtr<DisplayColorManager> { | |
36 public: | 36 public: |
37 DisplayColorManager(ui::DisplayConfigurator* configurator, | 37 DisplayColorManager(ui::DisplayConfigurator* configurator, |
38 base::SequencedWorkerPool* blocking_pool); | 38 base::SequencedWorkerPool* blocking_pool); |
39 ~DisplayColorManager() override; | 39 ~DisplayColorManager() override; |
40 | 40 |
41 // ui::DisplayConfigurator::Observer | 41 // ui::DisplayConfigurator::Observer |
42 void OnDisplayModeChanged( | 42 void OnDisplayModeChanged( |
43 const ui::DisplayConfigurator::DisplayStateList& outputs) override; | 43 const ui::DisplayConfigurator::DisplayStateList& outputs) override; |
44 void OnDisplayModeChangeFailed( | 44 void OnDisplayModeChangeFailed( |
45 const ui::DisplayConfigurator::DisplayStateList& displays, | 45 const ui::DisplayConfigurator::DisplayStateList& displays, |
46 ui::MultipleDisplayState failed_new_state) override {} | 46 ui::MultipleDisplayState failed_new_state) override {} |
47 | 47 |
48 struct ColorCalibrationData { | 48 struct ColorCalibrationData { |
49 ColorCalibrationData(); | 49 ColorCalibrationData(); |
50 ~ColorCalibrationData(); | 50 ~ColorCalibrationData(); |
51 | 51 |
52 std::vector<ui::GammaRampRGBEntry> lut; | 52 std::vector<ui::GammaRampRGBEntry> lut; |
53 }; | 53 }; |
54 | 54 |
| 55 protected: |
| 56 virtual void FinishLoadCalibrationForDisplay(int64_t display_id, |
| 57 int64_t product_id, |
| 58 ui::DisplayConnectionType type, |
| 59 const base::FilePath& path, |
| 60 bool file_downloaded); |
| 61 virtual void UpdateCalibrationData(int64_t display_id, |
| 62 int64_t product_id, |
| 63 scoped_ptr<ColorCalibrationData> data); |
| 64 |
55 private: | 65 private: |
56 void ApplyDisplayColorCalibration(int64_t display_id, int64_t product_id); | 66 void ApplyDisplayColorCalibration(int64_t display_id, int64_t product_id); |
57 void LoadCalibrationForDisplay(const ui::DisplaySnapshot* display); | 67 void LoadCalibrationForDisplay(const ui::DisplaySnapshot* display); |
58 void UpdateCalibrationData( | |
59 int64_t display_id, | |
60 int64_t product_id, | |
61 scoped_ptr<DisplayColorManager::ColorCalibrationData> data, | |
62 bool success); | |
63 | 68 |
64 ui::DisplayConfigurator* configurator_; | 69 ui::DisplayConfigurator* configurator_; |
65 std::map<int64_t, ColorCalibrationData*> calibration_map_; | 70 std::map<int64_t, ColorCalibrationData*> calibration_map_; |
| 71 base::ThreadChecker thread_checker_; |
66 base::SequencedWorkerPool* blocking_pool_; | 72 base::SequencedWorkerPool* blocking_pool_; |
67 | 73 |
| 74 // Factory for callbacks. |
| 75 base::WeakPtrFactory<DisplayColorManager> weak_ptr_factory_; |
| 76 |
68 DISALLOW_COPY_AND_ASSIGN(DisplayColorManager); | 77 DISALLOW_COPY_AND_ASSIGN(DisplayColorManager); |
69 }; | 78 }; |
70 | 79 |
71 } // namespace ash | 80 } // namespace ash |
72 | 81 |
73 #endif // ASH_DISPLAY_DISPLAY_COLOR_MANAGER_CHROMEOS_H_ | 82 #endif // ASH_DISPLAY_DISPLAY_COLOR_MANAGER_CHROMEOS_H_ |
OLD | NEW |