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

Unified Diff: cc/resources/resource.h

Issue 2496913003: Display linear-srgb color managed canvas (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | cc/resources/resource_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/resource.h
diff --git a/cc/resources/resource.h b/cc/resources/resource.h
index 7fd361f503dd0624690dea14d638d16721e6a292..993cbc071e38160d53bc6688ca988b326023454a 100644
--- a/cc/resources/resource.h
+++ b/cc/resources/resource.h
@@ -5,9 +5,11 @@
#ifndef CC_RESOURCES_RESOURCE_H_
#define CC_RESOURCES_RESOURCE_H_
+#include "base/command_line.h"
#include "base/logging.h"
#include "base/macros.h"
#include "cc/base/cc_export.h"
+#include "cc/base/switches.h"
#include "cc/resources/resource_provider.h"
#include "cc/resources/resource_util.h"
#include "ui/gfx/geometry/size.h"
@@ -16,12 +18,26 @@ namespace cc {
class CC_EXPORT Resource {
public:
- Resource() : id_(0), format_(RGBA_8888) {}
+ Resource() : id_(0), format_(RGBA_8888) {
+ // If color correct rendering is enabled, set the default color space to
+ // SRGB instead of unspecified.
+ base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
+ if (cmd->HasSwitch(switches::kEnableColorCorrectRendering))
Justin Novosad 2016/11/11 19:10:30 Calling HasSwitch is an expensive check. You shoul
zakerinasab 2016/11/16 20:13:59 Done.
+ color_space_ = gfx::ColorSpace::CreateSRGB();
+ }
Resource(unsigned id,
const gfx::Size& size,
ResourceFormat format,
const gfx::ColorSpace& color_space)
- : id_(id), size_(size), format_(format), color_space_(color_space) {}
+ : id_(id), size_(size), format_(format), color_space_(color_space) {
+ if (color_space_ == gfx::ColorSpace()) {
+ // If color correct rendering is enabled, replace the unspecified color
+ // space with SRGB.
+ base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
+ if (cmd->HasSwitch(switches::kEnableColorCorrectRendering))
+ color_space_ = gfx::ColorSpace::CreateSRGB();
+ }
+ }
ResourceId id() const { return id_; }
const gfx::Size& size() const { return size_; }
@@ -34,8 +50,17 @@ class CC_EXPORT Resource {
size_ = size;
format_ = format;
}
+
void set_color_space(const gfx::ColorSpace& color_space) {
- color_space_ = color_space;
+ if (color_space_ == gfx::ColorSpace()) {
+ // If color correct rendering is enabled, replace the unspecified color
+ // space with SRGB.
+ base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
+ if (cmd->HasSwitch(switches::kEnableColorCorrectRendering))
+ color_space_ = gfx::ColorSpace::CreateSRGB();
+ } else {
+ color_space_ = color_space;
+ }
}
private:
« no previous file with comments | « no previous file | cc/resources/resource_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698