| 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 12 matching lines...) Expand all Loading... |
| 23 } | 23 } |
| 24 | 24 |
| 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, |
| 34 sk_sp<SkColorSpace> cs) { |
| 35 return SkImageInfo(width, height, ct, at, SkDefaultColorProfile(), std::move
(cs)); |
| 36 } |
| 37 |
| 33 void SkImageInfo::unflatten(SkReadBuffer& buffer) { | 38 void SkImageInfo::unflatten(SkReadBuffer& buffer) { |
| 34 fWidth = buffer.read32(); | 39 fWidth = buffer.read32(); |
| 35 fHeight = buffer.read32(); | 40 fHeight = buffer.read32(); |
| 36 | 41 |
| 37 uint32_t packed = buffer.read32(); | 42 uint32_t packed = buffer.read32(); |
| 38 SkASSERT(0 == (packed >> 24)); | 43 SkASSERT(0 == (packed >> 24)); |
| 39 fProfileType = (SkColorProfileType)((packed >> 16) & 0xFF); | 44 fProfileType = (SkColorProfileType)((packed >> 16) & 0xFF); |
| 40 fAlphaType = (SkAlphaType)((packed >> 8) & 0xFF); | 45 fAlphaType = (SkAlphaType)((packed >> 8) & 0xFF); |
| 41 fColorType = (SkColorType)((packed >> 0) & 0xFF); | 46 fColorType = (SkColorType)((packed >> 0) & 0xFF); |
| 42 buffer.validate(profile_type_is_valid(fProfileType) && | 47 buffer.validate(profile_type_is_valid(fProfileType) && |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 } | 128 } |
| 124 // here x,y are either 0 or negative | 129 // here x,y are either 0 or negative |
| 125 fPixels = ((char*)fPixels - y * fRowBytes - x * fInfo.bytesPerPixel()); | 130 fPixels = ((char*)fPixels - y * fRowBytes - x * fInfo.bytesPerPixel()); |
| 126 // the intersect may have shrunk info's logical size | 131 // the intersect may have shrunk info's logical size |
| 127 fInfo = fInfo.makeWH(srcR.width(), srcR.height()); | 132 fInfo = fInfo.makeWH(srcR.width(), srcR.height()); |
| 128 fX = srcR.x(); | 133 fX = srcR.x(); |
| 129 fY = srcR.y(); | 134 fY = srcR.y(); |
| 130 | 135 |
| 131 return true; | 136 return true; |
| 132 } | 137 } |
| OLD | NEW |