Chromium Code Reviews| 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" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 return false; | 137 return false; |
| 138 } | 138 } |
| 139 return false; | 139 return false; |
| 140 } | 140 } |
| 141 | 141 |
| 142 sk_sp<SkColorSpace> ColorSpace::ToSkColorSpace() const { | 142 sk_sp<SkColorSpace> ColorSpace::ToSkColorSpace() const { |
| 143 // Unspecified color spaces are represented as nullptr SkColorSpaces. | 143 // Unspecified color spaces are represented as nullptr SkColorSpaces. |
| 144 if (*this == gfx::ColorSpace()) | 144 if (*this == gfx::ColorSpace()) |
| 145 return nullptr; | 145 return nullptr; |
| 146 | 146 |
| 147 // Check for srgb and linear-srgb | |
|
ccameron
2016/11/11 20:00:44
Thanks, sorry for leaving this part unimplemented.
| |
| 148 if (primaries_ == PrimaryID::BT709 && matrix_ == MatrixID::RGB | |
| 149 && range_ == RangeID::FULL) { | |
| 150 if (transfer_ == TransferID::IEC61966_2_1) | |
| 151 return SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); | |
| 152 else if (transfer_ == TransferID::BT709) | |
| 153 return SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named); | |
| 154 } | |
| 155 | |
| 147 // TODO(crbug.com/634102): Support more than just ICC profile based color | 156 // TODO(crbug.com/634102): Support more than just ICC profile based color |
| 148 // spaces. The DCHECK here is to ensure that callers that expect a valid | 157 // spaces. The DCHECK here is to ensure that callers that expect a valid |
| 149 // result are notified of this incomplete functionality. | 158 // result are notified of this incomplete functionality. |
| 150 std::vector<char> icc_data = gfx::ICCProfile::FromColorSpace(*this).GetData(); | 159 std::vector<char> icc_data = gfx::ICCProfile::FromColorSpace(*this).GetData(); |
| 151 sk_sp<SkColorSpace> result = | 160 sk_sp<SkColorSpace> result = |
| 152 SkColorSpace::MakeICC(icc_data.data(), icc_data.size()); | 161 SkColorSpace::MakeICC(icc_data.data(), icc_data.size()); |
| 153 DCHECK(result); | 162 DCHECK(result); |
| 154 return result; | 163 return result; |
| 155 } | 164 } |
| 156 | 165 |
| 157 ColorSpace ColorSpace::FromSkColorSpace( | 166 ColorSpace ColorSpace::FromSkColorSpace( |
| 158 const sk_sp<SkColorSpace>& sk_color_space) { | 167 const sk_sp<SkColorSpace>& sk_color_space) { |
| 159 if (!sk_color_space) | 168 if (!sk_color_space) |
| 160 return gfx::ColorSpace(); | 169 return gfx::ColorSpace(); |
| 161 | 170 |
| 162 // TODO(crbug.com/634102): Add conversion to gfx::ColorSpace. | 171 // TODO(crbug.com/634102): Add conversion to gfx::ColorSpace. |
| 163 return gfx::ColorSpace(); | 172 return gfx::ColorSpace(); |
| 164 } | 173 } |
| 165 | 174 |
| 166 } // namespace gfx | 175 } // namespace gfx |
| OLD | NEW |