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 "SkAutoKern.h" | 9 #include "SkAutoKern.h" |
10 #include "SkChecksum.h" | 10 #include "SkChecksum.h" |
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 rec->ignoreGamma(); | 1560 rec->ignoreGamma(); |
1561 } | 1561 } |
1562 if (!boostContrast) { | 1562 if (!boostContrast) { |
1563 rec->setContrast(0); | 1563 rec->setContrast(0); |
1564 } | 1564 } |
1565 | 1565 |
1566 int entryCount = 1; | 1566 int entryCount = 1; |
1567 size_t descSize = sizeof(*rec); | 1567 size_t descSize = sizeof(*rec); |
1568 | 1568 |
1569 if (pe) { | 1569 if (pe) { |
1570 peBuffer->writeFlattenable(pe); | 1570 peBuffer->writeFlattenable("pathEffect", pe); |
1571 descSize += peBuffer->bytesWritten(); | 1571 descSize += peBuffer->bytesWritten(); |
1572 entryCount += 1; | 1572 entryCount += 1; |
1573 rec->fMaskFormat = SkMask::kA8_Format; // force antialiasing when we do
the scan conversion | 1573 rec->fMaskFormat = SkMask::kA8_Format; // force antialiasing when we do
the scan conversion |
1574 // seems like we could support kLCD as well at this point... | 1574 // seems like we could support kLCD as well at this point... |
1575 } | 1575 } |
1576 if (mf) { | 1576 if (mf) { |
1577 mfBuffer->writeFlattenable(mf); | 1577 mfBuffer->writeFlattenable("maskFilter", mf); |
1578 descSize += mfBuffer->bytesWritten(); | 1578 descSize += mfBuffer->bytesWritten(); |
1579 entryCount += 1; | 1579 entryCount += 1; |
1580 rec->fMaskFormat = SkMask::kA8_Format; // force antialiasing with mask
filters | 1580 rec->fMaskFormat = SkMask::kA8_Format; // force antialiasing with mask
filters |
1581 /* Pre-blend is not currently applied to filtered text. | 1581 /* Pre-blend is not currently applied to filtered text. |
1582 The primary filter is blur, for which contrast makes no sense, | 1582 The primary filter is blur, for which contrast makes no sense, |
1583 and for which the destination guess error is more visible. | 1583 and for which the destination guess error is more visible. |
1584 Also, all existing users of blur have calibrated for linear. */ | 1584 Also, all existing users of blur have calibrated for linear. */ |
1585 rec->ignorePreBlend(); | 1585 rec->ignorePreBlend(); |
1586 } | 1586 } |
1587 if (ra) { | 1587 if (ra) { |
1588 raBuffer->writeFlattenable(ra); | 1588 raBuffer->writeFlattenable("rasterizer", ra); |
1589 descSize += raBuffer->bytesWritten(); | 1589 descSize += raBuffer->bytesWritten(); |
1590 entryCount += 1; | 1590 entryCount += 1; |
1591 rec->fMaskFormat = SkMask::kA8_Format; // force antialiasing when we do
the scan conversion | 1591 rec->fMaskFormat = SkMask::kA8_Format; // force antialiasing when we do
the scan conversion |
1592 } | 1592 } |
1593 | 1593 |
1594 /////////////////////////////////////////////////////////////////////////// | 1594 /////////////////////////////////////////////////////////////////////////// |
1595 // Now that we're done tweaking the rec, call the PostMakeRec cleanup | 1595 // Now that we're done tweaking the rec, call the PostMakeRec cleanup |
1596 SkScalerContext::PostMakeRec(paint, rec); | 1596 SkScalerContext::PostMakeRec(paint, rec); |
1597 | 1597 |
1598 descSize += SkDescriptor::ComputeOverhead(entryCount); | 1598 descSize += SkDescriptor::ComputeOverhead(entryCount); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1887 *ptr++ = this->getColor(); | 1887 *ptr++ = this->getColor(); |
1888 | 1888 |
1889 *ptr++ = pack_paint_flags(this->getFlags(), this->getHinting(), this->getTex
tAlign(), | 1889 *ptr++ = pack_paint_flags(this->getFlags(), this->getHinting(), this->getTex
tAlign(), |
1890 this->getFilterQuality(), flatFlags); | 1890 this->getFilterQuality(), flatFlags); |
1891 *ptr++ = pack_4(this->getStrokeCap(), this->getStrokeJoin(), | 1891 *ptr++ = pack_4(this->getStrokeCap(), this->getStrokeJoin(), |
1892 this->getStyle(), this->getTextEncoding()); | 1892 this->getStyle(), this->getTextEncoding()); |
1893 | 1893 |
1894 // now we're done with ptr and the (pre)reserved space. If we need to write | 1894 // now we're done with ptr and the (pre)reserved space. If we need to write |
1895 // additional fields, use the buffer directly | 1895 // additional fields, use the buffer directly |
1896 if (flatFlags & kHasTypeface_FlatFlag) { | 1896 if (flatFlags & kHasTypeface_FlatFlag) { |
1897 buffer.writeTypeface(this->getTypeface()); | 1897 buffer.writeTypeface("typeface", this->getTypeface()); |
1898 } | 1898 } |
1899 if (flatFlags & kHasEffects_FlatFlag) { | 1899 if (flatFlags & kHasEffects_FlatFlag) { |
1900 buffer.writeFlattenable(this->getPathEffect()); | 1900 buffer.writeFlattenable("pathEffect", this->getPathEffect()); |
1901 buffer.writeFlattenable(this->getShader()); | 1901 buffer.writeFlattenable("shader", this->getShader()); |
1902 buffer.writeFlattenable(this->getXfermode()); | 1902 buffer.writeFlattenable("xferMode", this->getXfermode()); |
1903 buffer.writeFlattenable(this->getMaskFilter()); | 1903 buffer.writeFlattenable("maskFilter", this->getMaskFilter()); |
1904 buffer.writeFlattenable(this->getColorFilter()); | 1904 buffer.writeFlattenable("colorFilter", this->getColorFilter()); |
1905 buffer.writeFlattenable(this->getRasterizer()); | 1905 buffer.writeFlattenable("rasterizer", this->getRasterizer()); |
1906 buffer.writeFlattenable(this->getLooper()); | 1906 buffer.writeFlattenable("looper", this->getLooper()); |
1907 buffer.writeFlattenable(this->getImageFilter()); | 1907 buffer.writeFlattenable("imageFilter", this->getImageFilter()); |
1908 } | 1908 } |
1909 } | 1909 } |
1910 | 1910 |
1911 void SkPaint::unflatten(SkReadBuffer& buffer) { | 1911 void SkPaint::unflatten(SkReadBuffer& buffer) { |
1912 SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize); | 1912 SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize); |
1913 if (!buffer.validateAvailable(kPODPaintSize)) { | 1913 if (!buffer.validateAvailable(kPODPaintSize)) { |
1914 return; | 1914 return; |
1915 } | 1915 } |
1916 const void* podData = buffer.skip(kPODPaintSize); | 1916 const void* podData = buffer.skip(kPODPaintSize); |
1917 const uint32_t* pod = reinterpret_cast<const uint32_t*>(podData); | 1917 const uint32_t* pod = reinterpret_cast<const uint32_t*>(podData); |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2371 } | 2371 } |
2372 | 2372 |
2373 uint32_t SkPaint::getHash() const { | 2373 uint32_t SkPaint::getHash() const { |
2374 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, | 2374 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, |
2375 // so fBitfields should be 10 pointers and 6 32-bit values from the start. | 2375 // so fBitfields should be 10 pointers and 6 32-bit values from the start. |
2376 static_assert(offsetof(SkPaint, fBitfields) == 9 * sizeof(void*) + 6 * sizeo
f(uint32_t), | 2376 static_assert(offsetof(SkPaint, fBitfields) == 9 * sizeof(void*) + 6 * sizeo
f(uint32_t), |
2377 "SkPaint_notPackedTightly"); | 2377 "SkPaint_notPackedTightly"); |
2378 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), | 2378 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), |
2379 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); | 2379 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); |
2380 } | 2380 } |
OLD | NEW |