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 "SkFlattenable.h" |
13 | 13 |
14 class SK_API SkColorSpace : public SkRefCnt { | 14 class SK_API SkColorSpace : public SkFlattenable { |
msarett
2016/06/20 22:41:59
We can flatten/unflatten without making SkColorSpa
| |
15 public: | 15 public: |
16 | 16 |
17 /** | 17 /** |
18 * Common, named profiles that we can recognize. | 18 * Common, named profiles that we can recognize. |
19 */ | 19 */ |
20 enum Named { | 20 enum Named { |
21 kUnknown_Named, | 21 kUnknown_Named, |
22 kSRGB_Named, | 22 kSRGB_Named, |
23 kAdobeRGB_Named, | 23 kAdobeRGB_Named, |
24 }; | 24 }; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 */ | 68 */ |
69 const SkMatrix44& xyz() const { return fToXYZD50; } | 69 const SkMatrix44& xyz() const { return fToXYZD50; } |
70 | 70 |
71 /** | 71 /** |
72 * Returns true if the color space gamma is near enough to be approximated as sRGB. | 72 * Returns true if the color space gamma is near enough to be approximated as sRGB. |
73 */ | 73 */ |
74 bool gammaCloseToSRGB() const { | 74 bool gammaCloseToSRGB() const { |
75 return kSRGB_GammaNamed == fGammaNamed || k2Dot2Curve_GammaNamed == fGam maNamed; | 75 return kSRGB_GammaNamed == fGammaNamed || k2Dot2Curve_GammaNamed == fGam maNamed; |
76 } | 76 } |
77 | 77 |
78 SK_DEFINE_FLATTENABLE_TYPE(SkColorSpace) | |
79 static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&); | |
80 | |
78 protected: | 81 protected: |
79 | |
80 SkColorSpace(GammaNamed gammaNamed, const SkMatrix44& toXYZD50, Named named) ; | 82 SkColorSpace(GammaNamed gammaNamed, const SkMatrix44& toXYZD50, Named named) ; |
81 | 83 |
82 friend Named sk_deduce_named_from_colorspace(SkColorSpace*); | 84 void flatten(SkWriteBuffer&) const override; |
85 Factory getFactory() const override { return CreateProc; } | |
83 | 86 |
84 const GammaNamed fGammaNamed; | 87 const GammaNamed fGammaNamed; |
85 const SkMatrix44 fToXYZD50; | 88 const SkMatrix44 fToXYZD50; |
86 const Named fNamed; | 89 const Named fNamed; |
87 }; | 90 }; |
88 | 91 |
89 #endif | 92 #endif |
OLD | NEW |