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" |
11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
12 #include "SkDither.h" | 12 #include "SkDither.h" |
13 #include "SkFlattenable.h" | 13 #include "SkFlattenable.h" |
14 #include "SkImagePriv.h" | 14 #include "SkImagePriv.h" |
15 #include "SkMallocPixelRef.h" | 15 #include "SkMallocPixelRef.h" |
16 #include "SkMask.h" | 16 #include "SkMask.h" |
17 #include "SkOrderedReadBuffer.h" | 17 #include "SkReadBuffer.h" |
18 #include "SkOrderedWriteBuffer.h" | 18 #include "SkWriteBuffer.h" |
19 #include "SkPixelRef.h" | 19 #include "SkPixelRef.h" |
20 #include "SkThread.h" | 20 #include "SkThread.h" |
21 #include "SkUnPreMultiply.h" | 21 #include "SkUnPreMultiply.h" |
22 #include "SkUtils.h" | 22 #include "SkUtils.h" |
23 #include "SkValidationUtils.h" | 23 #include "SkValidationUtils.h" |
24 #include "SkPackBits.h" | 24 #include "SkPackBits.h" |
25 #include <new> | 25 #include <new> |
26 | 26 |
27 struct MipLevel { | 27 struct MipLevel { |
28 void* fPixels; | 28 void* fPixels; |
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1576 return true; | 1576 return true; |
1577 } | 1577 } |
1578 | 1578 |
1579 /////////////////////////////////////////////////////////////////////////////// | 1579 /////////////////////////////////////////////////////////////////////////////// |
1580 | 1580 |
1581 enum { | 1581 enum { |
1582 SERIALIZE_PIXELTYPE_NONE, | 1582 SERIALIZE_PIXELTYPE_NONE, |
1583 SERIALIZE_PIXELTYPE_REF_DATA | 1583 SERIALIZE_PIXELTYPE_REF_DATA |
1584 }; | 1584 }; |
1585 | 1585 |
1586 void SkBitmap::flatten(SkFlattenableWriteBuffer& buffer) const { | 1586 void SkBitmap::flatten(SkWriteBuffer& buffer) const { |
1587 buffer.writeInt(fWidth); | 1587 buffer.writeInt(fWidth); |
1588 buffer.writeInt(fHeight); | 1588 buffer.writeInt(fHeight); |
1589 buffer.writeInt(fRowBytes); | 1589 buffer.writeInt(fRowBytes); |
1590 buffer.writeInt(fConfig); | 1590 buffer.writeInt(fConfig); |
1591 buffer.writeInt(fAlphaType); | 1591 buffer.writeInt(fAlphaType); |
1592 | 1592 |
1593 if (fPixelRef) { | 1593 if (fPixelRef) { |
1594 if (fPixelRef->getFactory()) { | 1594 if (fPixelRef->getFactory()) { |
1595 buffer.writeInt(SERIALIZE_PIXELTYPE_REF_DATA); | 1595 buffer.writeInt(SERIALIZE_PIXELTYPE_REF_DATA); |
1596 buffer.writeInt(fPixelRefOrigin.fX); | 1596 buffer.writeInt(fPixelRefOrigin.fX); |
1597 buffer.writeInt(fPixelRefOrigin.fY); | 1597 buffer.writeInt(fPixelRefOrigin.fY); |
1598 buffer.writeFlattenable(fPixelRef); | 1598 buffer.writeFlattenable(fPixelRef); |
1599 return; | 1599 return; |
1600 } | 1600 } |
1601 // if we get here, we can't record the pixels | 1601 // if we get here, we can't record the pixels |
1602 buffer.writeInt(SERIALIZE_PIXELTYPE_NONE); | 1602 buffer.writeInt(SERIALIZE_PIXELTYPE_NONE); |
1603 } else { | 1603 } else { |
1604 buffer.writeInt(SERIALIZE_PIXELTYPE_NONE); | 1604 buffer.writeInt(SERIALIZE_PIXELTYPE_NONE); |
1605 } | 1605 } |
1606 } | 1606 } |
1607 | 1607 |
1608 void SkBitmap::unflatten(SkFlattenableReadBuffer& buffer) { | 1608 void SkBitmap::unflatten(SkReadBuffer& buffer) { |
1609 this->reset(); | 1609 this->reset(); |
1610 | 1610 |
1611 int width = buffer.readInt(); | 1611 int width = buffer.readInt(); |
1612 int height = buffer.readInt(); | 1612 int height = buffer.readInt(); |
1613 int rowBytes = buffer.readInt(); | 1613 int rowBytes = buffer.readInt(); |
1614 Config config = (Config)buffer.readInt(); | 1614 Config config = (Config)buffer.readInt(); |
1615 SkAlphaType alphaType = (SkAlphaType)buffer.readInt(); | 1615 SkAlphaType alphaType = (SkAlphaType)buffer.readInt(); |
1616 buffer.validate((width >= 0) && (height >= 0) && (rowBytes >= 0) && | 1616 buffer.validate((width >= 0) && (height >= 0) && (rowBytes >= 0) && |
1617 SkIsValidConfig(config) && validate_alphaType(config, alphaT
ype)); | 1617 SkIsValidConfig(config) && validate_alphaType(config, alphaT
ype)); |
1618 | 1618 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1725 if (NULL != uri) { | 1725 if (NULL != uri) { |
1726 str->appendf(" uri:\"%s\"", uri); | 1726 str->appendf(" uri:\"%s\"", uri); |
1727 } else { | 1727 } else { |
1728 str->appendf(" pixelref:%p", pr); | 1728 str->appendf(" pixelref:%p", pr); |
1729 } | 1729 } |
1730 } | 1730 } |
1731 | 1731 |
1732 str->append(")"); | 1732 str->append(")"); |
1733 } | 1733 } |
1734 #endif | 1734 #endif |
OLD | NEW |