| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 if (primary_result > 0) | 136 if (primary_result > 0) |
| 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 if (*this == gfx::ColorSpace::CreateSRGB()) |
| 147 return SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); |
| 146 | 148 |
| 147 // TODO(crbug.com/634102): Support more than just ICC profile based color | 149 // 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 | 150 // spaces. The DCHECK here is to ensure that callers that expect a valid |
| 149 // result are notified of this incomplete functionality. | 151 // result are notified of this incomplete functionality. |
| 150 std::vector<char> icc_data = gfx::ICCProfile::FromColorSpace(*this).GetData(); | 152 std::vector<char> icc_data = gfx::ICCProfile::FromColorSpace(*this).GetData(); |
| 151 sk_sp<SkColorSpace> result = | 153 sk_sp<SkColorSpace> result = |
| 152 SkColorSpace::MakeICC(icc_data.data(), icc_data.size()); | 154 SkColorSpace::MakeICC(icc_data.data(), icc_data.size()); |
| 153 DCHECK(result); | 155 DCHECK(result); |
| 154 return result; | 156 return result; |
| 155 } | 157 } |
| 156 | 158 |
| 157 ColorSpace ColorSpace::FromSkColorSpace( | 159 ColorSpace ColorSpace::FromSkColorSpace( |
| 158 const sk_sp<SkColorSpace>& sk_color_space) { | 160 const sk_sp<SkColorSpace>& sk_color_space) { |
| 159 if (!sk_color_space) | 161 if (!sk_color_space) |
| 160 return gfx::ColorSpace(); | 162 return gfx::ColorSpace(); |
| 163 if (SkColorSpace::Equals( |
| 164 sk_color_space.get(), |
| 165 SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named).get())) |
| 166 return gfx::ColorSpace::CreateSRGB(); |
| 161 | 167 |
| 162 // TODO(crbug.com/634102): Add conversion to gfx::ColorSpace. | 168 // TODO(crbug.com/634102): Add conversion to gfx::ColorSpace. |
| 163 return gfx::ColorSpace(); | 169 return gfx::ColorSpace(); |
| 164 } | 170 } |
| 165 | 171 |
| 166 } // namespace gfx | 172 } // namespace gfx |
| OLD | NEW |