OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 1548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1559 buffer.writeInt(SERIALIZE_PIXELTYPE_NONE); | 1559 buffer.writeInt(SERIALIZE_PIXELTYPE_NONE); |
1560 } | 1560 } |
1561 } | 1561 } |
1562 | 1562 |
1563 void SkBitmap::unflatten(SkReadBuffer& buffer) { | 1563 void SkBitmap::unflatten(SkReadBuffer& buffer) { |
1564 this->reset(); | 1564 this->reset(); |
1565 | 1565 |
1566 SkImageInfo info; | 1566 SkImageInfo info; |
1567 info.unflatten(buffer); | 1567 info.unflatten(buffer); |
1568 size_t rowBytes = buffer.readInt(); | 1568 size_t rowBytes = buffer.readInt(); |
1569 buffer.validate((info.width() >= 0) && (info.height() >= 0) && | 1569 if (!buffer.validate((info.width() >= 0) && (info.height() >= 0) && |
1570 SkColorTypeIsValid(info.fColorType) && | 1570 SkColorTypeIsValid(info.fColorType) && |
1571 SkAlphaTypeIsValid(info.fAlphaType) && | 1571 SkAlphaTypeIsValid(info.fAlphaType) && |
1572 validate_alphaType(info.fColorType, info.fAlphaType) && | 1572 validate_alphaType(info.fColorType, info.fAlphaType) && |
1573 info.validRowBytes(rowBytes)); | 1573 info.validRowBytes(rowBytes))) { |
1574 // Clear info if it's invalid | |
1575 sk_bzero(&info, sizeof(SkImageInfo)); | |
reed2
2014/02/13 16:55:48
Why not just
if (invalid) {
return;
}
We've a
sugoi1
2014/02/13 18:05:53
Done.
| |
1576 } | |
1574 | 1577 |
1575 bool configIsValid = this->setConfig(info, rowBytes); | 1578 bool configIsValid = this->setConfig(info, rowBytes); |
1576 buffer.validate(configIsValid); | 1579 buffer.validate(configIsValid); |
1577 | 1580 |
1578 int reftype = buffer.readInt(); | 1581 int reftype = buffer.readInt(); |
1579 if (buffer.validate((SERIALIZE_PIXELTYPE_REF_DATA == reftype) || | 1582 if (buffer.validate((SERIALIZE_PIXELTYPE_REF_DATA == reftype) || |
1580 (SERIALIZE_PIXELTYPE_NONE == reftype))) { | 1583 (SERIALIZE_PIXELTYPE_NONE == reftype))) { |
1581 switch (reftype) { | 1584 switch (reftype) { |
1582 case SERIALIZE_PIXELTYPE_REF_DATA: { | 1585 case SERIALIZE_PIXELTYPE_REF_DATA: { |
1583 SkIPoint origin; | 1586 SkIPoint origin; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1684 /////////////////////////////////////////////////////////////////////////////// | 1687 /////////////////////////////////////////////////////////////////////////////// |
1685 | 1688 |
1686 #ifdef SK_DEBUG | 1689 #ifdef SK_DEBUG |
1687 void SkImageInfo::validate() const { | 1690 void SkImageInfo::validate() const { |
1688 SkASSERT(fWidth >= 0); | 1691 SkASSERT(fWidth >= 0); |
1689 SkASSERT(fHeight >= 0); | 1692 SkASSERT(fHeight >= 0); |
1690 SkASSERT(SkColorTypeIsValid(fColorType)); | 1693 SkASSERT(SkColorTypeIsValid(fColorType)); |
1691 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); | 1694 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); |
1692 } | 1695 } |
1693 #endif | 1696 #endif |
OLD | NEW |