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

Side by Side Diff: ui/gfx/color_space.cc

Issue 2841813002: Converting video color space enums to their corresponding gfx:color space eqvivalent. (Closed)
Patch Set: Fixed ==> "warning C4701: potentially uninitialized local variable 'primary_id' used" Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « ui/gfx/color_space.h ('k') | ui/gfx/color_transform_unittest.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "ui/gfx/color_space.h" 5 #include "ui/gfx/color_space.h"
6 6
7 #include <map> 7 #include <map>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 #include "third_party/skia/include/core/SkColorSpace.h" 12 #include "third_party/skia/include/core/SkColorSpace.h"
13 #include "third_party/skia/include/core/SkData.h" 13 #include "third_party/skia/include/core/SkData.h"
14 #include "third_party/skia/include/core/SkICC.h" 14 #include "third_party/skia/include/core/SkICC.h"
15 #include "ui/gfx/icc_profile.h" 15 #include "ui/gfx/icc_profile.h"
16 #include "ui/gfx/skia_color_space_util.h" 16 #include "ui/gfx/skia_color_space_util.h"
17 17
18 namespace gfx { 18 namespace gfx {
19 19
20 // static
21 ColorSpace ColorSpace::CreateVideo(int video_primary,
22 int video_transfer,
23 int video_matrix,
24 RangeID range_id) {
25 // TODO(hubbe): Use more context to decide how to handle UNSPECIFIED values.
26 ColorSpace result;
27 switch (video_primary) {
28 default:
29 case 0: // RESERVED0
30 case 1: // BT709
31 case 2: // UNSPECIFIED
32 case 3: // RESERVED
33 result.primaries_ = PrimaryID::BT709;
34 break;
35 case 4: // BT470M
36 result.primaries_ = PrimaryID::BT470M;
37 break;
38 case 5: // BT470BG
39 result.primaries_ = PrimaryID::BT470BG;
40 break;
41 case 6: // SMPTE170M
42 result.primaries_ = PrimaryID::SMPTE170M;
43 break;
44 case 7: // SMPTE240M
45 result.primaries_ = PrimaryID::SMPTE240M;
46 break;
47 case 8: // FILM
48 result.primaries_ = PrimaryID::FILM;
49 break;
50 case 9: // BT2020
51 result.primaries_ = PrimaryID::BT2020;
52 break;
53 case 10: // SMPTEST428_1
54 result.primaries_ = PrimaryID::SMPTEST428_1;
55 break;
56 case 11: // SMPTEST431_2
57 result.primaries_ = PrimaryID::SMPTEST431_2;
58 break;
59 case 12: // SMPTEST432_1
60 result.primaries_ = PrimaryID::SMPTEST432_1;
61 break;
62 }
63 switch (video_transfer) {
64 default:
65 case 0: // RESERVED0
66 case 1: // BT709
67 case 2: // UNSPECIFIED
68 case 3: // RESERVED
69 result.transfer_ = TransferID::BT709;
70 break;
71 case 4: // GAMMA22
72 result.transfer_ = TransferID::GAMMA22;
73 break;
74 case 5: // GAMMA28
75 result.transfer_ = TransferID::GAMMA28;
76 break;
77 case 6: // SMPTE170M
78 result.transfer_ = TransferID::SMPTE170M;
79 break;
80 case 7: // SMPTE240M
81 result.transfer_ = TransferID::SMPTE240M;
82 break;
83 case 8: // LINEAR
84 result.transfer_ = TransferID::LINEAR;
85 break;
86 case 9: // LOG
87 result.transfer_ = TransferID::LOG;
88 break;
89 case 10: // LOG_SQRT
90 result.transfer_ = TransferID::LOG_SQRT;
91 break;
92 case 11: // IEC61966_2_4
93 result.transfer_ = TransferID::IEC61966_2_4;
94 break;
95 case 12: // BT1361_ECG
96 result.transfer_ = TransferID::BT1361_ECG;
97 break;
98 case 13: // IEC61966_2_1
99 result.transfer_ = TransferID::IEC61966_2_1;
100 break;
101 case 14: // BT2020_10
102 result.transfer_ = TransferID::BT2020_10;
103 break;
104 case 15: // BT2020_12
105 result.transfer_ = TransferID::BT2020_12;
106 break;
107 case 16: // SMPTEST2084
108 result.transfer_ = TransferID::SMPTEST2084;
109 break;
110 case 17: // SMPTEST428_1
111 result.transfer_ = TransferID::SMPTEST428_1;
112 break;
113 case 18: // ARIB_STD_B67
114 result.transfer_ = TransferID::ARIB_STD_B67;
115 break;
116 }
117 switch (video_matrix) {
118 case 0: // RGB
119 result.matrix_ = MatrixID::RGB;
120 break;
121 default:
122 case 1: // BT709
123 case 2: // UNSPECIFIED
124 case 3: // RESERVED
125 result.matrix_ = MatrixID::BT709;
126 break;
127 case 4: // FCC
128 result.matrix_ = MatrixID::FCC;
129 break;
130 case 5: // BT470BG
131 result.matrix_ = MatrixID::BT470BG;
132 break;
133 case 6: // SMPTE170M
134 result.matrix_ = MatrixID::SMPTE170M;
135 break;
136 case 7: // SMPTE240M
137 result.matrix_ = MatrixID::SMPTE240M;
138 break;
139 case 8: // YCOCG
140 result.matrix_ = MatrixID::YCOCG;
141 break;
142 case 9: // BT2020_NCL
143 result.matrix_ = MatrixID::BT2020_NCL;
144 break;
145 case 10: // BT2020_CL
146 result.matrix_ = MatrixID::BT2020_CL;
147 break;
148 case 11: // YDZDX
149 result.matrix_ = MatrixID::YDZDX;
150 break;
151 }
152 result.range_ = range_id;
153 return result;
154 }
155
156 ColorSpace::ColorSpace() {} 20 ColorSpace::ColorSpace() {}
157 21
158 ColorSpace::ColorSpace(PrimaryID primaries, 22 ColorSpace::ColorSpace(PrimaryID primaries,
159 TransferID transfer) 23 TransferID transfer)
160 : primaries_(primaries), 24 : primaries_(primaries),
161 transfer_(transfer), 25 transfer_(transfer),
162 matrix_(MatrixID::RGB), 26 matrix_(MatrixID::RGB),
163 range_(RangeID::FULL) {} 27 range_(RangeID::FULL) {}
164 28
165 ColorSpace::ColorSpace(PrimaryID primaries, 29 ColorSpace::ColorSpace(PrimaryID primaries,
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 matrix->postTranslate(-16.0f/219.0f, -15.5f/224.0f, -15.5f/224.0f); 733 matrix->postTranslate(-16.0f/219.0f, -15.5f/224.0f, -15.5f/224.0f);
870 break; 734 break;
871 } 735 }
872 } 736 }
873 737
874 std::ostream& operator<<(std::ostream& out, const ColorSpace& color_space) { 738 std::ostream& operator<<(std::ostream& out, const ColorSpace& color_space) {
875 return out << color_space.ToString(); 739 return out << color_space.ToString();
876 } 740 }
877 741
878 } // namespace gfx 742 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/color_space.h ('k') | ui/gfx/color_transform_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698