Chromium Code Reviews| Index: src/core/SkImageInfo.cpp |
| diff --git a/src/core/SkImageInfo.cpp b/src/core/SkImageInfo.cpp |
| index e61cd7d45f398c115f36d4332744f65d95e2fdad..655fea3577d37574fc796448fdf295efa89eb03e 100644 |
| --- a/src/core/SkImageInfo.cpp |
| +++ b/src/core/SkImageInfo.cpp |
| @@ -9,6 +9,10 @@ |
| #include "SkReadBuffer.h" |
| #include "SkWriteBuffer.h" |
| +static bool profile_type_is_valid(SkColorProfileType profileType) { |
| + return (profileType >= 0) && (profileType <= kLastEnum_SkColorProfileType); |
| +} |
| + |
| static bool alpha_type_is_valid(SkAlphaType alphaType) { |
| return (alphaType >= 0) && (alphaType <= kLastEnum_SkAlphaType); |
| } |
| @@ -23,9 +27,11 @@ void SkImageInfo::unflatten(SkReadBuffer& buffer) { |
| uint32_t packed = buffer.read32(); |
|
robertphillips
2014/11/07 18:38:56
Seems like this assert could give us trouble in th
reed1
2014/11/07 19:48:10
When we knowingly add more bits, we will change th
reed1
2014/11/07 19:50:39
I'm an idiot. Will now write a test (and then fix
|
| SkASSERT(0 == (packed >> 16)); |
| + fProfileType = (SkColorProfileType)((packed >> 16) & 0xFF); |
| fAlphaType = (SkAlphaType)((packed >> 8) & 0xFF); |
| fColorType = (SkColorType)((packed >> 0) & 0xFF); |
| - buffer.validate(alpha_type_is_valid(fAlphaType) && |
| + buffer.validate(profile_type_is_valid(fProfileType) && |
| + alpha_type_is_valid(fAlphaType) && |
| color_type_is_valid(fColorType)); |
| } |
| @@ -33,9 +39,10 @@ void SkImageInfo::flatten(SkWriteBuffer& buffer) const { |
| buffer.write32(fWidth); |
| buffer.write32(fHeight); |
| + SkASSERT(0 == (fProfileType & ~0xFF)); |
| SkASSERT(0 == (fAlphaType & ~0xFF)); |
| SkASSERT(0 == (fColorType & ~0xFF)); |
| - uint32_t packed = (fAlphaType << 8) | fColorType; |
| + uint32_t packed = (fProfileType << 16) | (fAlphaType << 8) | fColorType; |
| buffer.write32(packed); |
| } |