| 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 17 matching lines...) Expand all Loading... |
| 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 return SkImageInfo(width, height, ct, at, SkDefaultColorProfile(), std::move
(cs)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 SkImageInfo SkImageInfo::MakeS32(int width, int height, SkAlphaType at) { |
| 39 return SkImageInfo(width, height, kN32_SkColorType, at, kSRGB_SkColorProfile
Type, |
| 40 SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)); |
| 41 } |
| 42 |
| 38 void SkImageInfo::unflatten(SkReadBuffer& buffer) { | 43 void SkImageInfo::unflatten(SkReadBuffer& buffer) { |
| 39 fWidth = buffer.read32(); | 44 fWidth = buffer.read32(); |
| 40 fHeight = buffer.read32(); | 45 fHeight = buffer.read32(); |
| 41 | 46 |
| 42 uint32_t packed = buffer.read32(); | 47 uint32_t packed = buffer.read32(); |
| 43 SkASSERT(0 == (packed >> 24)); | 48 SkASSERT(0 == (packed >> 24)); |
| 44 fProfileType = (SkColorProfileType)((packed >> 16) & 0xFF); | 49 fProfileType = (SkColorProfileType)((packed >> 16) & 0xFF); |
| 45 fAlphaType = (SkAlphaType)((packed >> 8) & 0xFF); | 50 fAlphaType = (SkAlphaType)((packed >> 8) & 0xFF); |
| 46 fColorType = (SkColorType)((packed >> 0) & 0xFF); | 51 fColorType = (SkColorType)((packed >> 0) & 0xFF); |
| 47 buffer.validate(profile_type_is_valid(fProfileType) && | 52 buffer.validate(profile_type_is_valid(fProfileType) && |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 } | 133 } |
| 129 // here x,y are either 0 or negative | 134 // here x,y are either 0 or negative |
| 130 fPixels = ((char*)fPixels - y * fRowBytes - x * fInfo.bytesPerPixel()); | 135 fPixels = ((char*)fPixels - y * fRowBytes - x * fInfo.bytesPerPixel()); |
| 131 // the intersect may have shrunk info's logical size | 136 // the intersect may have shrunk info's logical size |
| 132 fInfo = fInfo.makeWH(srcR.width(), srcR.height()); | 137 fInfo = fInfo.makeWH(srcR.width(), srcR.height()); |
| 133 fX = srcR.x(); | 138 fX = srcR.x(); |
| 134 fY = srcR.y(); | 139 fY = srcR.y(); |
| 135 | 140 |
| 136 return true; | 141 return true; |
| 137 } | 142 } |
| OLD | NEW |