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

Unified Diff: ash/display/display_color_manager_chromeos.cc

Issue 1528963002: Quirks Client for downloading and providing display profiles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fourth round of review fixes Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
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 1241978958018acff967d30fbfd9dcb2d0c961dd..9db523f18c58e10ff5a81510cffb1b5be895a160 100644
--- a/ash/display/display_color_manager_chromeos.cc
+++ b/ash/display/display_color_manager_chromeos.cc
@@ -6,40 +6,44 @@
#include <utility>
-#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"
-#include "base/logging.h"
#include "base/message_loop/message_loop.h"
-#include "base/path_service.h"
-#include "base/stl_util.h"
-#include "base/strings/stringprintf.h"
#include "base/task_runner_util.h"
-#include "base/threading/sequenced_worker_pool.h"
-#include "chromeos/chromeos_paths.h"
+#include "components/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"
-#include "ui/display/types/native_display_delegate.h"
-#include "ui/gfx/display.h"
-#include "ui/gfx/screen.h"
namespace ash {
namespace {
-bool ParseFile(const base::FilePath& path,
- DisplayColorManager::ColorCalibrationData* data) {
- if (!base::PathExists(path)) // No icc file for this display; not an error.
- return false;
+void DoNothing(base::FilePath) {}
Bernhard Bauer 2016/02/12 14:51:21 Take a const reference, so the path doesn't have t
Greg Levin 2016/02/15 21:53:52 Done.
+
+scoped_ptr<DisplayColorManager::ColorCalibrationData> ParseDisplayProfile(
+ const int64_t display_id,
+ const int64_t product_id) {
+ // TODO(glevin): At some point, we may want to add a callback, and apply the
+ // icc file as soon as it's downloaded. For now, we'll only apply it if it
+ // exists at startup, and try to download it for next time if it doesn't.
+ base::FilePath path =
+ quirks_client::RequestIccProfilePath(product_id, base::Bind(DoNothing));
+ std::string product_string = quirks_client::IdToHexString(product_id);
+ if (path.empty()) {
+ VLOG(1) << "No icc file found with product id: " << product_string
+ << " for display id: " << display_id;
+ return nullptr;
+ }
+
+ VLOG(1) << "Loading ICC file " << path.value()
+ << " for display id: " << display_id
+ << " with product id: " << product_string;
+
+ DCHECK(base::PathExists(path)); // Quirks Client should ensure this.
qcms_profile* display_profile = qcms_profile_from_path(path.value().c_str());
if (!display_profile) {
LOG(WARNING) << "Unable to load ICC file: " << path.value();
- return false;
+ return nullptr;
}
size_t vcgt_channel_length =
@@ -47,7 +51,7 @@ bool ParseFile(const base::FilePath& path,
if (!vcgt_channel_length) {
LOG(WARNING) << "No vcgt table in ICC file: " << path.value();
qcms_profile_release(display_profile);
- return false;
+ return nullptr;
}
std::vector<uint16_t> vcgt_data;
@@ -55,9 +59,11 @@ bool ParseFile(const base::FilePath& path,
if (!qcms_profile_get_vcgt_rgb_channels(display_profile, &vcgt_data[0])) {
LOG(WARNING) << "Unable to get vcgt data";
qcms_profile_release(display_profile);
- return false;
+ return nullptr;
}
+ scoped_ptr<DisplayColorManager::ColorCalibrationData> data(
+ new DisplayColorManager::ColorCalibrationData());
data->lut.resize(vcgt_channel_length);
for (size_t i = 0; i < vcgt_channel_length; ++i) {
data->lut[i].r = vcgt_data[i];
@@ -65,16 +71,8 @@ bool ParseFile(const base::FilePath& path,
data->lut[i].b = vcgt_data[(vcgt_channel_length * 2) + i];
}
qcms_profile_release(display_profile);
- 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;
+ VLOG(1) << "Gamma data successfully read from icc file";
+ return data;
}
} // namespace
@@ -119,28 +117,20 @@ 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::PostTaskAndReplyWithResult(
- blocking_pool_, FROM_HERE, request,
+ blocking_pool_, FROM_HERE,
+ base::Bind(&ParseDisplayProfile, display->display_id(),
+ display->product_id()),
base::Bind(&DisplayColorManager::UpdateCalibrationData, AsWeakPtr(),
- display->display_id(), display->product_id(),
- base::Passed(std::move(data))));
+ display->display_id(), display->product_id()));
}
void DisplayColorManager::UpdateCalibrationData(
int64_t display_id,
int64_t product_id,
- scoped_ptr<ColorCalibrationData> data,
- bool success) {
+ scoped_ptr<ColorCalibrationData> data) {
DCHECK_EQ(base::MessageLoop::current()->type(), base::MessageLoop::TYPE_UI);
- if (success) {
+ if (data) {
// The map takes over ownership of the underlying memory.
calibration_map_[product_id] = data.release();
ApplyDisplayColorCalibration(display_id, product_id);

Powered by Google App Engine
This is Rietveld 408576698