| 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 "SkReadBuffer.h" | 9 #include "SkReadBuffer.h" |
| 10 #include "SkWriteBuffer.h" | 10 #include "SkWriteBuffer.h" |
| 11 | 11 |
| 12 const uint8_t gPrivate_SkColorTypeBytesPerPixel[] = { | |
| 13 0, // Unknown | |
| 14 1, // Alpha_8 | |
| 15 2, // RGB_565 | |
| 16 2, // ARGB_4444 | |
| 17 4, // RGBA_8888 | |
| 18 4, // BGRA_8888 | |
| 19 1, // kIndex_8 | |
| 20 1, // kGray_8 | |
| 21 8, // kRGBA_F16 | |
| 22 }; | |
| 23 static_assert(SK_ARRAY_COUNT(gPrivate_SkColorTypeBytesPerPixel) == (size_t)(kLas
tEnum_SkColorType + 1), | |
| 24 "size_mismatch_with_SkColorType_enum"); | |
| 25 | |
| 26 const uint8_t gPrivate_SkColorTypeShiftPerPixel[] = { | |
| 27 0, // Unknown | |
| 28 0, // Alpha_8 | |
| 29 1, // RGB_565 | |
| 30 1, // ARGB_4444 | |
| 31 2, // RGBA_8888 | |
| 32 2, // BGRA_8888 | |
| 33 0, // kIndex_8 | |
| 34 0, // kGray_8 | |
| 35 3, // kRGBA_F16 | |
| 36 }; | |
| 37 static_assert(SK_ARRAY_COUNT(gPrivate_SkColorTypeShiftPerPixel) == (size_t)(kLas
tEnum_SkColorType + 1), | |
| 38 "size_mismatch_with_SkColorType_enum"); | |
| 39 | |
| 40 static bool profile_type_is_valid(SkColorProfileType profileType) { | 12 static bool profile_type_is_valid(SkColorProfileType profileType) { |
| 41 return (profileType >= 0) && (profileType <= kLastEnum_SkColorProfileType); | 13 return (profileType >= 0) && (profileType <= kLastEnum_SkColorProfileType); |
| 42 } | 14 } |
| 43 | 15 |
| 44 static bool alpha_type_is_valid(SkAlphaType alphaType) { | 16 static bool alpha_type_is_valid(SkAlphaType alphaType) { |
| 45 return (alphaType >= 0) && (alphaType <= kLastEnum_SkAlphaType); | 17 return (alphaType >= 0) && (alphaType <= kLastEnum_SkAlphaType); |
| 46 } | 18 } |
| 47 | 19 |
| 48 static bool color_type_is_valid(SkColorType colorType) { | 20 static bool color_type_is_valid(SkColorType colorType) { |
| 49 return (colorType >= 0) && (colorType <= kLastEnum_SkColorType); | 21 return (colorType >= 0) && (colorType <= kLastEnum_SkColorType); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 114 } |
| 143 // here x,y are either 0 or negative | 115 // here x,y are either 0 or negative |
| 144 fPixels = ((char*)fPixels - y * fRowBytes - x * fInfo.bytesPerPixel()); | 116 fPixels = ((char*)fPixels - y * fRowBytes - x * fInfo.bytesPerPixel()); |
| 145 // the intersect may have shrunk info's logical size | 117 // the intersect may have shrunk info's logical size |
| 146 fInfo = fInfo.makeWH(srcR.width(), srcR.height()); | 118 fInfo = fInfo.makeWH(srcR.width(), srcR.height()); |
| 147 fX = srcR.x(); | 119 fX = srcR.x(); |
| 148 fY = srcR.y(); | 120 fY = srcR.y(); |
| 149 | 121 |
| 150 return true; | 122 return true; |
| 151 } | 123 } |
| OLD | NEW |