OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkColorSpace_DEFINED | 8 #ifndef SkColorSpace_DEFINED |
9 #define SkColorSpace_DEFINED | 9 #define SkColorSpace_DEFINED |
10 | 10 |
11 #include "SkMatrix44.h" | 11 #include "SkMatrix44.h" |
12 #include "SkRefCnt.h" | 12 #include "SkRefCnt.h" |
13 | 13 |
| 14 class SkData; |
| 15 |
14 class SK_API SkColorSpace : public SkRefCnt { | 16 class SK_API SkColorSpace : public SkRefCnt { |
15 public: | 17 public: |
16 | 18 |
17 /** | 19 /** |
18 * Common, named profiles that we can recognize. | 20 * Common, named profiles that we can recognize. |
19 */ | 21 */ |
20 enum Named { | 22 enum Named { |
21 kUnknown_Named, | 23 kUnknown_Named, |
22 kSRGB_Named, | 24 kSRGB_Named, |
23 kAdobeRGB_Named, | 25 kAdobeRGB_Named, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 */ | 70 */ |
69 const SkMatrix44& xyz() const { return fToXYZD50; } | 71 const SkMatrix44& xyz() const { return fToXYZD50; } |
70 | 72 |
71 /** | 73 /** |
72 * Returns true if the color space gamma is near enough to be approximated
as sRGB. | 74 * Returns true if the color space gamma is near enough to be approximated
as sRGB. |
73 */ | 75 */ |
74 bool gammaCloseToSRGB() const { | 76 bool gammaCloseToSRGB() const { |
75 return kSRGB_GammaNamed == fGammaNamed || k2Dot2Curve_GammaNamed == fGam
maNamed; | 77 return kSRGB_GammaNamed == fGammaNamed || k2Dot2Curve_GammaNamed == fGam
maNamed; |
76 } | 78 } |
77 | 79 |
| 80 /** |
| 81 * Returns nullptr on failure. Fails when we fallback to serializing ICC d
ata and |
| 82 * the data is too large to serialize. |
| 83 */ |
| 84 sk_sp<SkData> serialize() const; |
| 85 |
| 86 static sk_sp<SkColorSpace> Deserialize(const void* data, size_t length); |
| 87 |
78 protected: | 88 protected: |
79 SkColorSpace(GammaNamed gammaNamed, const SkMatrix44& toXYZD50, Named named)
; | 89 SkColorSpace(GammaNamed gammaNamed, const SkMatrix44& toXYZD50, Named named)
; |
80 | 90 |
81 friend Named sk_deduce_named_from_colorspace(SkColorSpace*); | |
82 | |
83 const GammaNamed fGammaNamed; | 91 const GammaNamed fGammaNamed; |
84 const SkMatrix44 fToXYZD50; | 92 const SkMatrix44 fToXYZD50; |
85 const Named fNamed; | 93 const Named fNamed; |
86 }; | 94 }; |
87 | 95 |
88 #endif | 96 #endif |
OLD | NEW |