Chromium Code Reviews| Index: ash/display/display_color_manager_chromeos.cc |
| diff --git a/ash/display/display_color_manager_chromeos.cc b/ash/display/display_color_manager_chromeos.cc |
| index 1ae844ffa72ee2620bac5d8b90f6054010b2f461..21c354049559c370699f3c04368e1b3a62caf821 100644 |
| --- a/ash/display/display_color_manager_chromeos.cc |
| +++ b/ash/display/display_color_manager_chromeos.cc |
| @@ -6,7 +6,6 @@ |
| #include "base/bind.h" |
| #include "base/bind_helpers.h" |
| -#include "base/command_line.h" |
| #include "base/files/file_path.h" |
| #include "base/files/file_util.h" |
| #include "base/format_macros.h" |
| @@ -18,6 +17,7 @@ |
| #include "base/task_runner_util.h" |
| #include "base/threading/sequenced_worker_pool.h" |
| #include "chromeos/chromeos_paths.h" |
| +#include "chromeos/quirks_client/quirks_client.h" |
| #include "third_party/qcms/src/qcms.h" |
| #include "ui/display/types/display_snapshot.h" |
| #include "ui/display/types/gamma_ramp_rgb_entry.h" |
| @@ -29,8 +29,41 @@ namespace ash { |
| namespace { |
|
Greg Levin
2015/12/15 23:09:13
I'll move or remove this before submitting. It's
|
| -bool ParseFile(const base::FilePath& path, |
| - DisplayColorManager::ColorCalibrationData* data) { |
| +class FakeDisplaySnapshot : public ui::DisplaySnapshot { |
| + public: |
| + FakeDisplaySnapshot(int64_t product_id) |
| + : ui::DisplaySnapshot(0, gfx::Point(0, 0), gfx::Size(0, 0), |
| + ui::DISPLAY_CONNECTION_TYPE_NONE, false, false, |
| + "test", std::vector<const ui::DisplayMode*>(), |
| + nullptr, nullptr) { |
| + product_id_ = product_id; |
| + } |
| + ~FakeDisplaySnapshot() override{}; |
| + |
| + // DisplaySnapshot override: |
| + std::string ToString() const override { return display_name_; } |
| + |
| + DISALLOW_COPY_AND_ASSIGN(FakeDisplaySnapshot); |
| +}; |
| + |
| +bool ParseDisplayProfile(const int64_t display_id, |
| + const int64_t product_id, |
| + DisplayColorManager::ColorCalibrationData* data) { |
| + chromeos::QuirksClient::DownloadFinishedCallback* callback = nullptr; |
| + // TODO(glevin): Do we want to add a callback so that we can apply the icc |
| + // profile as soon as it's downloaded? |
| + base::FilePath path = |
| + chromeos::QuirksClient::RequestIccProfilePath(product_id, callback); |
| + std::string product_string = base::StringPrintf("0x%08" PRIx64, product_id); |
| + if (path.empty()) { |
| + VLOG(1) << "No icc file found with product id: " << product_string |
| + << " for display id: " << display_id; |
| + } else { |
| + VLOG(1) << "Loading ICC file " << path.value() |
| + << " for display id: " << display_id |
| + << " with product id: " << product_string; |
| + } |
| + |
| if (!base::PathExists(path)) // No icc file for this display; not an error. |
| return false; |
| qcms_profile* display_profile = qcms_profile_from_path(path.value().c_str()); |
| @@ -63,18 +96,10 @@ bool ParseFile(const base::FilePath& path, |
| data->lut[i].b = vcgt_data[(vcgt_channel_length * 2) + i]; |
| } |
| qcms_profile_release(display_profile); |
| + VLOG(1) << "Gamma data successfully read from icc file"; |
| return true; |
| } |
| -base::FilePath PathForDisplaySnapshot(const ui::DisplaySnapshot* snapshot) { |
| - base::FilePath path; |
| - CHECK( |
| - PathService::Get(chromeos::DIR_DEVICE_COLOR_CALIBRATION_PROFILES, &path)); |
| - path = path.Append( |
| - base::StringPrintf("%08" PRIx64 ".icc", snapshot->product_id())); |
| - return path; |
| -} |
| - |
| } // namespace |
| DisplayColorManager::DisplayColorManager( |
| @@ -117,14 +142,10 @@ void DisplayColorManager::LoadCalibrationForDisplay( |
| return; |
| } |
| - base::FilePath path = PathForDisplaySnapshot(display); |
| - VLOG(1) << "Loading ICC file " << path.value() |
| - << " for display id: " << display->display_id() |
| - << " with product id: " << display->product_id(); |
| - |
| scoped_ptr<ColorCalibrationData> data(new ColorCalibrationData()); |
| base::Callback<bool(void)> request( |
| - base::Bind(&ParseFile, path, base::Unretained(data.get()))); |
| + base::Bind(&ParseDisplayProfile, display->display_id(), |
| + display->product_id(), base::Unretained(data.get()))); |
| base::PostTaskAndReplyWithResult( |
| blocking_pool_, FROM_HERE, request, |
| base::Bind(&DisplayColorManager::UpdateCalibrationData, AsWeakPtr(), |
| @@ -132,6 +153,15 @@ void DisplayColorManager::LoadCalibrationForDisplay( |
| base::Passed(data.Pass()))); |
| } |
| +// TODO!!! Remove! |
| +// Temporary debugging function for ChromeOS on Linux. Provides an entry point |
| +// into ParseDisplayProfile() from the same thread / earlier up the stack from |
| +// it's actual calling location (which isn't hit due to lack of display device) |
| +void DisplayColorManager::LoadCalibrationForDisplayQuirksTest() { |
| + FakeDisplaySnapshot fake_snapshot(0x06af5c10); |
| + LoadCalibrationForDisplay(&fake_snapshot); |
| +} |
| + |
| void DisplayColorManager::UpdateCalibrationData( |
| int64_t display_id, |
| int64_t product_id, |