| 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" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 SkASSERT(0 == (packed >> 24)); | 31 SkASSERT(0 == (packed >> 24)); |
| 32 fProfileType = (SkColorProfileType)((packed >> 16) & 0xFF); | 32 fProfileType = (SkColorProfileType)((packed >> 16) & 0xFF); |
| 33 fAlphaType = (SkAlphaType)((packed >> 8) & 0xFF); | 33 fAlphaType = (SkAlphaType)((packed >> 8) & 0xFF); |
| 34 fColorType = (SkColorType)((packed >> 0) & 0xFF); | 34 fColorType = (SkColorType)((packed >> 0) & 0xFF); |
| 35 buffer.validate(profile_type_is_valid(fProfileType) && | 35 buffer.validate(profile_type_is_valid(fProfileType) && |
| 36 alpha_type_is_valid(fAlphaType) && | 36 alpha_type_is_valid(fAlphaType) && |
| 37 color_type_is_valid(fColorType)); | 37 color_type_is_valid(fColorType)); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void SkImageInfo::flatten(SkWriteBuffer& buffer) const { | 40 void SkImageInfo::flatten(SkWriteBuffer& buffer) const { |
| 41 buffer.write32(fWidth); | 41 buffer.write32("fWidth", fWidth); |
| 42 buffer.write32(fHeight); | 42 buffer.write32("fHeight", fHeight); |
| 43 | 43 |
| 44 SkASSERT(0 == (fProfileType & ~0xFF)); | 44 SkASSERT(0 == (fProfileType & ~0xFF)); |
| 45 SkASSERT(0 == (fAlphaType & ~0xFF)); | 45 SkASSERT(0 == (fAlphaType & ~0xFF)); |
| 46 SkASSERT(0 == (fColorType & ~0xFF)); | 46 SkASSERT(0 == (fColorType & ~0xFF)); |
| 47 uint32_t packed = (fProfileType << 16) | (fAlphaType << 8) | fColorType; | 47 uint32_t packed = (fProfileType << 16) | (fAlphaType << 8) | fColorType; |
| 48 buffer.write32(packed); | 48 buffer.write32("packed", packed); |
| 49 } | 49 } |
| 50 | 50 |
| 51 bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType, | 51 bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType, |
| 52 SkAlphaType* canonical) { | 52 SkAlphaType* canonical) { |
| 53 switch (colorType) { | 53 switch (colorType) { |
| 54 case kUnknown_SkColorType: | 54 case kUnknown_SkColorType: |
| 55 alphaType = kUnknown_SkAlphaType; | 55 alphaType = kUnknown_SkAlphaType; |
| 56 break; | 56 break; |
| 57 case kAlpha_8_SkColorType: | 57 case kAlpha_8_SkColorType: |
| 58 if (kUnpremul_SkAlphaType == alphaType) { | 58 if (kUnpremul_SkAlphaType == alphaType) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 116 } |
| 117 // here x,y are either 0 or negative | 117 // here x,y are either 0 or negative |
| 118 fPixels = ((char*)fPixels - y * fRowBytes - x * fInfo.bytesPerPixel()); | 118 fPixels = ((char*)fPixels - y * fRowBytes - x * fInfo.bytesPerPixel()); |
| 119 // the intersect may have shrunk info's logical size | 119 // the intersect may have shrunk info's logical size |
| 120 fInfo = fInfo.makeWH(srcR.width(), srcR.height()); | 120 fInfo = fInfo.makeWH(srcR.width(), srcR.height()); |
| 121 fX = srcR.x(); | 121 fX = srcR.x(); |
| 122 fY = srcR.y(); | 122 fY = srcR.y(); |
| 123 | 123 |
| 124 return true; | 124 return true; |
| 125 } | 125 } |
| OLD | NEW |