OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 #include "SkImageInfo.h" | 8 #include "SkImageInfo.h" |
| 9 #include "SkImageInfoPriv.h" |
9 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
10 #include "SkWriteBuffer.h" | 11 #include "SkWriteBuffer.h" |
11 | 12 |
12 /* | 13 /* |
13 * We store this as a byte in the ImageInfo flatten buffer. | 14 * We store this as a byte in the ImageInfo flatten buffer. |
14 */ | 15 */ |
15 enum class SkFlattenColorSpaceEnum { | 16 enum class SkFlattenColorSpaceEnum { |
16 kUnspecified, | 17 kUnspecified, |
17 kSRGB, | 18 kSRGB, |
18 kAdobe1998, | 19 kAdobe1998, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 54 |
54 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 55 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
55 | 56 |
56 #ifdef SK_SUPPORT_LEGACY_COLORPROFILETYPE | 57 #ifdef SK_SUPPORT_LEGACY_COLORPROFILETYPE |
57 SkColorProfileType SkImageInfo::profileType() const { | 58 SkColorProfileType SkImageInfo::profileType() const { |
58 return fColorSpace && fColorSpace->gammaCloseToSRGB() | 59 return fColorSpace && fColorSpace->gammaCloseToSRGB() |
59 ? kSRGB_SkColorProfileType : kLinear_SkColorProfileType; | 60 ? kSRGB_SkColorProfileType : kLinear_SkColorProfileType; |
60 } | 61 } |
61 #endif | 62 #endif |
62 | 63 |
| 64 // Indicate how images and gradients should interpret colors by default. |
| 65 bool gDefaultProfileIsSRGB; |
| 66 |
| 67 SkColorProfileType SkDefaultColorProfile() { |
| 68 return gDefaultProfileIsSRGB ? kSRGB_SkColorProfileType |
| 69 : kLinear_SkColorProfileType; |
| 70 } |
| 71 |
63 static bool alpha_type_is_valid(SkAlphaType alphaType) { | 72 static bool alpha_type_is_valid(SkAlphaType alphaType) { |
64 return (alphaType >= 0) && (alphaType <= kLastEnum_SkAlphaType); | 73 return (alphaType >= 0) && (alphaType <= kLastEnum_SkAlphaType); |
65 } | 74 } |
66 | 75 |
67 static bool color_type_is_valid(SkColorType colorType) { | 76 static bool color_type_is_valid(SkColorType colorType) { |
68 return (colorType >= 0) && (colorType <= kLastEnum_SkColorType); | 77 return (colorType >= 0) && (colorType <= kLastEnum_SkColorType); |
69 } | 78 } |
70 | 79 |
71 SkImageInfo SkImageInfo::MakeS32(int width, int height, SkAlphaType at) { | 80 SkImageInfo SkImageInfo::MakeS32(int width, int height, SkAlphaType at) { |
72 return SkImageInfo(width, height, kN32_SkColorType, at, | 81 return SkImageInfo(width, height, kN32_SkColorType, at, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 195 } |
187 // here x,y are either 0 or negative | 196 // here x,y are either 0 or negative |
188 fPixels = ((char*)fPixels - y * fRowBytes - x * fInfo.bytesPerPixel()); | 197 fPixels = ((char*)fPixels - y * fRowBytes - x * fInfo.bytesPerPixel()); |
189 // the intersect may have shrunk info's logical size | 198 // the intersect may have shrunk info's logical size |
190 fInfo = fInfo.makeWH(srcR.width(), srcR.height()); | 199 fInfo = fInfo.makeWH(srcR.width(), srcR.height()); |
191 fX = srcR.x(); | 200 fX = srcR.x(); |
192 fY = srcR.y(); | 201 fY = srcR.y(); |
193 | 202 |
194 return true; | 203 return true; |
195 } | 204 } |
OLD | NEW |