| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 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 "SkPaint.h" | 8 #include "SkPaint.h" |
| 9 #include "SkAnnotation.h" | 9 #include "SkAnnotation.h" |
| 10 #include "SkAutoKern.h" | 10 #include "SkAutoKern.h" |
| (...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1698 SkASSERT(descSize == desc1->getLength()); | 1698 SkASSERT(descSize == desc1->getLength()); |
| 1699 SkASSERT(descSize == desc2->getLength()); | 1699 SkASSERT(descSize == desc2->getLength()); |
| 1700 desc1->computeChecksum(); | 1700 desc1->computeChecksum(); |
| 1701 desc2->computeChecksum(); | 1701 desc2->computeChecksum(); |
| 1702 SkASSERT(!memcmp(desc, desc1, descSize)); | 1702 SkASSERT(!memcmp(desc, desc1, descSize)); |
| 1703 SkASSERT(!memcmp(desc, desc2, descSize)); | 1703 SkASSERT(!memcmp(desc, desc2, descSize)); |
| 1704 } | 1704 } |
| 1705 #endif | 1705 #endif |
| 1706 | 1706 |
| 1707 /* see the note on ignoreGamma on descriptorProc */ | 1707 /* see the note on ignoreGamma on descriptorProc */ |
| 1708 const SkData* SkPaint::getScalerContextDescriptor(const SkDeviceProperties* devi
ceProperties, | 1708 void SkPaint::getScalerContextDescriptor(SkAutoDescriptor* ad, |
| 1709 const SkMatrix* deviceMatrix, | 1709 const SkDeviceProperties* devicePropert
ies, |
| 1710 bool ignoreGamma) const { | 1710 const SkMatrix* deviceMatrix, bool igno
reGamma) const { |
| 1711 SkScalerContext::Rec rec; | 1711 SkScalerContext::Rec rec; |
| 1712 | 1712 |
| 1713 SkPathEffect* pe = this->getPathEffect(); | 1713 SkPathEffect* pe = this->getPathEffect(); |
| 1714 SkMaskFilter* mf = this->getMaskFilter(); | 1714 SkMaskFilter* mf = this->getMaskFilter(); |
| 1715 SkRasterizer* ra = this->getRasterizer(); | 1715 SkRasterizer* ra = this->getRasterizer(); |
| 1716 | 1716 |
| 1717 SkWriteBuffer peBuffer, mfBuffer, raBuffer; | 1717 SkWriteBuffer peBuffer, mfBuffer, raBuffer; |
| 1718 size_t descSize = fill_out_rec(*this, &rec, deviceProperties, deviceMatrix,
ignoreGamma, | 1718 size_t descSize = fill_out_rec(*this, &rec, deviceProperties, deviceMatrix,
ignoreGamma, |
| 1719 pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer); | 1719 pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer); |
| 1720 | 1720 |
| 1721 SkASSERT(SkAlign4(descSize) == descSize); | 1721 ad->reset(descSize); |
| 1722 SkData* data = SkData::NewUninitialized(descSize); | 1722 SkDescriptor* desc = ad->getDesc(); |
| 1723 SkDescriptor* desc = reinterpret_cast<SkDescriptor*>(data->writable_da
ta()); | |
| 1724 | 1723 |
| 1725 write_out_descriptor(desc, rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer,
descSize); | 1724 write_out_descriptor(desc, rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer,
descSize); |
| 1726 | 1725 |
| 1727 SkASSERT(descSize == desc->getLength()); | 1726 SkASSERT(descSize == desc->getLength()); |
| 1728 | 1727 |
| 1729 #ifdef TEST_DESC | 1728 #ifdef TEST_DESC |
| 1730 test_desc(rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer, desc, descSize); | 1729 test_desc(rec, pe, &peBuffer, mf, &mfBuffer, ra, &raBuffer, desc, descSize); |
| 1731 #endif | 1730 #endif |
| 1732 | |
| 1733 return data; | |
| 1734 } | 1731 } |
| 1735 | 1732 |
| 1736 /* | 1733 /* |
| 1737 * ignoreGamma tells us that the caller just wants metrics that are unaffected | 1734 * ignoreGamma tells us that the caller just wants metrics that are unaffected |
| 1738 * by gamma correction, so we set the rec to ignore preblend: i.e. gamma = 1, | 1735 * by gamma correction, so we set the rec to ignore preblend: i.e. gamma = 1, |
| 1739 * contrast = 0, luminanceColor = transparent black. | 1736 * contrast = 0, luminanceColor = transparent black. |
| 1740 */ | 1737 */ |
| 1741 void SkPaint::descriptorProc(const SkDeviceProperties* deviceProperties, | 1738 void SkPaint::descriptorProc(const SkDeviceProperties* deviceProperties, |
| 1742 const SkMatrix* deviceMatrix, | 1739 const SkMatrix* deviceMatrix, |
| 1743 void (*proc)(SkTypeface*, const SkDescriptor*, void
*), | 1740 void (*proc)(SkTypeface*, const SkDescriptor*, void
*), |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2433 } | 2430 } |
| 2434 | 2431 |
| 2435 uint32_t SkPaint::getHash() const { | 2432 uint32_t SkPaint::getHash() const { |
| 2436 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, | 2433 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, |
| 2437 // so fBitfields should be 10 pointers and 6 32-bit values from the start. | 2434 // so fBitfields should be 10 pointers and 6 32-bit values from the start. |
| 2438 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 *
sizeof(uint32_t), | 2435 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 *
sizeof(uint32_t), |
| 2439 SkPaint_notPackedTightly); | 2436 SkPaint_notPackedTightly); |
| 2440 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), | 2437 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), |
| 2441 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); | 2438 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); |
| 2442 } | 2439 } |
| OLD | NEW |