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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | cc/resources/resource_provider.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #ifndef CC_RESOURCES_RESOURCE_H_ 5 #ifndef CC_RESOURCES_RESOURCE_H_
6 #define CC_RESOURCES_RESOURCE_H_ 6 #define CC_RESOURCES_RESOURCE_H_
7 7
8 #include "base/command_line.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "base/macros.h" 10 #include "base/macros.h"
10 #include "cc/base/cc_export.h" 11 #include "cc/base/cc_export.h"
12 #include "cc/base/switches.h"
11 #include "cc/resources/resource_provider.h" 13 #include "cc/resources/resource_provider.h"
12 #include "cc/resources/resource_util.h" 14 #include "cc/resources/resource_util.h"
13 #include "ui/gfx/geometry/size.h" 15 #include "ui/gfx/geometry/size.h"
14 16
15 namespace cc { 17 namespace cc {
16 18
17 class CC_EXPORT Resource { 19 class CC_EXPORT Resource {
18 public: 20 public:
19 Resource() : id_(0), format_(RGBA_8888) {} 21 Resource() : id_(0), format_(RGBA_8888) {
22 // If color correct rendering is enabled, set the default color space to
23 // SRGB instead of unspecified.
24 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
25 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.
26 color_space_ = gfx::ColorSpace::CreateSRGB();
27 }
20 Resource(unsigned id, 28 Resource(unsigned id,
21 const gfx::Size& size, 29 const gfx::Size& size,
22 ResourceFormat format, 30 ResourceFormat format,
23 const gfx::ColorSpace& color_space) 31 const gfx::ColorSpace& color_space)
24 : id_(id), size_(size), format_(format), color_space_(color_space) {} 32 : id_(id), size_(size), format_(format), color_space_(color_space) {
33 if (color_space_ == gfx::ColorSpace()) {
34 // If color correct rendering is enabled, replace the unspecified color
35 // space with SRGB.
36 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
37 if (cmd->HasSwitch(switches::kEnableColorCorrectRendering))
38 color_space_ = gfx::ColorSpace::CreateSRGB();
39 }
40 }
25 41
26 ResourceId id() const { return id_; } 42 ResourceId id() const { return id_; }
27 const gfx::Size& size() const { return size_; } 43 const gfx::Size& size() const { return size_; }
28 ResourceFormat format() const { return format_; } 44 ResourceFormat format() const { return format_; }
29 const gfx::ColorSpace& color_space() const { return color_space_; } 45 const gfx::ColorSpace& color_space() const { return color_space_; }
30 46
31 protected: 47 protected:
32 void set_id(ResourceId id) { id_ = id; } 48 void set_id(ResourceId id) { id_ = id; }
33 void set_dimensions(const gfx::Size& size, ResourceFormat format) { 49 void set_dimensions(const gfx::Size& size, ResourceFormat format) {
34 size_ = size; 50 size_ = size;
35 format_ = format; 51 format_ = format;
36 } 52 }
53
37 void set_color_space(const gfx::ColorSpace& color_space) { 54 void set_color_space(const gfx::ColorSpace& color_space) {
38 color_space_ = color_space; 55 if (color_space_ == gfx::ColorSpace()) {
56 // If color correct rendering is enabled, replace the unspecified color
57 // space with SRGB.
58 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
59 if (cmd->HasSwitch(switches::kEnableColorCorrectRendering))
60 color_space_ = gfx::ColorSpace::CreateSRGB();
61 } else {
62 color_space_ = color_space;
63 }
39 } 64 }
40 65
41 private: 66 private:
42 ResourceId id_; 67 ResourceId id_;
43 gfx::Size size_; 68 gfx::Size size_;
44 ResourceFormat format_; 69 ResourceFormat format_;
45 gfx::ColorSpace color_space_; 70 gfx::ColorSpace color_space_;
46 71
47 DISALLOW_COPY_AND_ASSIGN(Resource); 72 DISALLOW_COPY_AND_ASSIGN(Resource);
48 }; 73 };
49 74
50 } // namespace cc 75 } // namespace cc
51 76
52 #endif // CC_RESOURCES_RESOURCE_H_ 77 #endif // CC_RESOURCES_RESOURCE_H_
OLDNEW
« 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