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 "SkImageInfoPriv.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 static bool alpha_type_is_valid(SkAlphaType alphaType) { | 25 static bool alpha_type_is_valid(SkAlphaType alphaType) { |
26 return (alphaType >= 0) && (alphaType <= kLastEnum_SkAlphaType); | 26 return (alphaType >= 0) && (alphaType <= kLastEnum_SkAlphaType); |
27 } | 27 } |
28 | 28 |
29 static bool color_type_is_valid(SkColorType colorType) { | 29 static bool color_type_is_valid(SkColorType colorType) { |
30 return (colorType >= 0) && (colorType <= kLastEnum_SkColorType); | 30 return (colorType >= 0) && (colorType <= kLastEnum_SkColorType); |
31 } | 31 } |
32 | 32 |
33 SkImageInfo SkImageInfo::Make(int width, int height, SkColorType ct, SkAlphaType
at, | 33 SkImageInfo SkImageInfo::Make(int width, int height, SkColorType ct, SkAlphaType
at, |
34 sk_sp<SkColorSpace> cs) { | 34 sk_sp<SkColorSpace> cs) { |
35 return SkImageInfo(width, height, ct, at, SkDefaultColorProfile(), std::move
(cs)); | 35 SkColorProfileType pt = SkDefaultColorProfile(); |
| 36 // try to keep the enum and the colorspace in sync. |
| 37 // TODO: eliminate the enum entirely, now that we have colorspace objects |
| 38 if (cs && (SkColorSpace::kLinear_GammaNamed != cs->gammaNamed())) { |
| 39 pt = kSRGB_SkColorProfileType; |
| 40 } |
| 41 return SkImageInfo(width, height, ct, at, pt, std::move(cs)); |
36 } | 42 } |
37 | 43 |
38 SkImageInfo SkImageInfo::MakeS32(int width, int height, SkAlphaType at) { | 44 SkImageInfo SkImageInfo::MakeS32(int width, int height, SkAlphaType at) { |
39 return SkImageInfo(width, height, kN32_SkColorType, at, kSRGB_SkColorProfile
Type, | 45 return SkImageInfo(width, height, kN32_SkColorType, at, kSRGB_SkColorProfile
Type, |
40 SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)); | 46 SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)); |
41 } | 47 } |
42 | 48 |
43 void SkImageInfo::unflatten(SkReadBuffer& buffer) { | 49 void SkImageInfo::unflatten(SkReadBuffer& buffer) { |
44 fWidth = buffer.read32(); | 50 fWidth = buffer.read32(); |
45 fHeight = buffer.read32(); | 51 fHeight = buffer.read32(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 } | 139 } |
134 // here x,y are either 0 or negative | 140 // here x,y are either 0 or negative |
135 fPixels = ((char*)fPixels - y * fRowBytes - x * fInfo.bytesPerPixel()); | 141 fPixels = ((char*)fPixels - y * fRowBytes - x * fInfo.bytesPerPixel()); |
136 // the intersect may have shrunk info's logical size | 142 // the intersect may have shrunk info's logical size |
137 fInfo = fInfo.makeWH(srcR.width(), srcR.height()); | 143 fInfo = fInfo.makeWH(srcR.width(), srcR.height()); |
138 fX = srcR.x(); | 144 fX = srcR.x(); |
139 fY = srcR.y(); | 145 fY = srcR.y(); |
140 | 146 |
141 return true; | 147 return true; |
142 } | 148 } |
OLD | NEW |