| OLD | NEW |
| 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 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| 11 #include "ui/gfx/icc_profile.h" | 11 #include "ui/gfx/icc_profile.h" |
| 12 | 12 |
| 13 namespace gfx { | 13 namespace gfx { |
| 14 | 14 |
| 15 ColorSpace::ColorSpace() = default; | 15 ColorSpace::ColorSpace() |
| 16 : primaries_(PrimaryID::UNSPECIFIED), |
| 17 transfer_(TransferID::UNSPECIFIED), |
| 18 matrix_(MatrixID::UNSPECIFIED), |
| 19 range_(RangeID::LIMITED) {} |
| 20 |
| 21 ColorSpace::ColorSpace(PrimaryID primaries, |
| 22 TransferID transfer, |
| 23 MatrixID matrix, |
| 24 RangeID range) |
| 25 : primaries_(primaries), |
| 26 transfer_(transfer), |
| 27 matrix_(matrix), |
| 28 range_(range) { |
| 29 // TODO: Set profile_id_ |
| 30 } |
| 16 | 31 |
| 17 // static | 32 // static |
| 18 ColorSpace ColorSpace::CreateSRGB() { | 33 ColorSpace ColorSpace::CreateSRGB() { |
| 19 ColorSpace color_space; | 34 return ColorSpace(PrimaryID::BT709, TransferID::IEC61966_2_1, MatrixID::RGB, |
| 20 color_space.valid_ = true; | 35 RangeID::FULL); |
| 21 color_space.icc_profile_id_ = ICCProfile::kSRGBId; | |
| 22 return color_space; | |
| 23 } | 36 } |
| 24 | 37 |
| 25 // static | 38 // static |
| 26 ColorSpace ColorSpace::CreateJpeg() { | 39 ColorSpace ColorSpace::CreateJpeg() { |
| 27 ColorSpace color_space; | 40 return ColorSpace(PrimaryID::BT709, TransferID::IEC61966_2_1, MatrixID::BT709, |
| 28 color_space.valid_ = true; | 41 RangeID::FULL); |
| 29 color_space.icc_profile_id_ = ICCProfile::kJpegId; | |
| 30 return color_space; | |
| 31 } | 42 } |
| 32 | 43 |
| 33 // static | 44 // static |
| 34 ColorSpace ColorSpace::CreateREC601() { | 45 ColorSpace ColorSpace::CreateREC601() { |
| 35 ColorSpace color_space; | 46 return ColorSpace(PrimaryID::SMPTE170M, TransferID::SMPTE170M, |
| 36 color_space.valid_ = true; | 47 MatrixID::SMPTE170M, RangeID::LIMITED); |
| 37 color_space.icc_profile_id_ = ICCProfile::kRec601Id; | |
| 38 return color_space; | |
| 39 } | 48 } |
| 40 | 49 |
| 41 // static | 50 // static |
| 42 ColorSpace ColorSpace::CreateREC709() { | 51 ColorSpace ColorSpace::CreateREC709() { |
| 43 ColorSpace color_space; | 52 return ColorSpace(PrimaryID::BT709, TransferID::BT709, MatrixID::BT709, |
| 44 color_space.valid_ = true; | 53 RangeID::LIMITED); |
| 45 color_space.icc_profile_id_ = ICCProfile::kRec709Id; | |
| 46 return color_space; | |
| 47 } | 54 } |
| 48 | 55 |
| 49 bool ColorSpace::operator==(const ColorSpace& other) const { | 56 bool ColorSpace::operator==(const ColorSpace& other) const { |
| 50 // TODO(ccameron): The |icc_profile_id_| should eventually not factor in | 57 return primaries_ == other.primaries_ && transfer_ == other.transfer_ && |
| 51 // to equality comparison at all, because it's just an optimization, but | 58 matrix_ == other.matrix_ && range_ == other.range_; |
| 52 // for now there is no other data in this structure. | |
| 53 return valid_ == other.valid_ && icc_profile_id_ == other.icc_profile_id_; | |
| 54 } | 59 } |
| 55 | 60 |
| 56 } // namespace gfx | 61 } // namespace gfx |
| OLD | NEW |