OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 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 "SkXfermode.h" | 10 #include "SkXfermode.h" |
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 } | 869 } |
870 } | 870 } |
871 | 871 |
872 void SkProcXfermode::flatten(SkWriteBuffer& buffer) const { | 872 void SkProcXfermode::flatten(SkWriteBuffer& buffer) const { |
873 this->INHERITED::flatten(buffer); | 873 this->INHERITED::flatten(buffer); |
874 if (!buffer.isCrossProcess()) { | 874 if (!buffer.isCrossProcess()) { |
875 buffer.writeFunctionPtr((void*)fProc); | 875 buffer.writeFunctionPtr((void*)fProc); |
876 } | 876 } |
877 } | 877 } |
878 | 878 |
879 #ifdef SK_DEVELOPER | 879 #ifndef SK_IGNORE_TO_STRING |
880 void SkProcXfermode::toString(SkString* str) const { | 880 void SkProcXfermode::toString(SkString* str) const { |
881 str->appendf("SkProcXfermode: %p", fProc); | 881 str->appendf("SkProcXfermode: %p", fProc); |
882 } | 882 } |
883 #endif | 883 #endif |
884 | 884 |
885 ////////////////////////////////////////////////////////////////////////////// | 885 ////////////////////////////////////////////////////////////////////////////// |
886 | 886 |
887 #if SK_SUPPORT_GPU | 887 #if SK_SUPPORT_GPU |
888 | 888 |
889 #include "GrEffect.h" | 889 #include "GrEffect.h" |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1406 "Clear", "Src", "Dst", "SrcOver", "DstOver", "SrcIn", "DstIn", | 1406 "Clear", "Src", "Dst", "SrcOver", "DstOver", "SrcIn", "DstIn", |
1407 "SrcOut", "DstOut", "SrcATop", "DstATop", "Xor", "Plus", | 1407 "SrcOut", "DstOut", "SrcATop", "DstATop", "Xor", "Plus", |
1408 "Modulate", "Screen", "Overlay", "Darken", "Lighten", "ColorDodge", | 1408 "Modulate", "Screen", "Overlay", "Darken", "Lighten", "ColorDodge", |
1409 "ColorBurn", "HardLight", "SoftLight", "Difference", "Exclusion", | 1409 "ColorBurn", "HardLight", "SoftLight", "Difference", "Exclusion", |
1410 "Multiply", "Hue", "Saturation", "Color", "Luminosity" | 1410 "Multiply", "Hue", "Saturation", "Color", "Luminosity" |
1411 }; | 1411 }; |
1412 return gModeStrings[mode]; | 1412 return gModeStrings[mode]; |
1413 SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gModeStrings) == kLastMode + 1, mode_count)
; | 1413 SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gModeStrings) == kLastMode + 1, mode_count)
; |
1414 } | 1414 } |
1415 | 1415 |
1416 #ifdef SK_DEVELOPER | 1416 #ifndef SK_IGNORE_TO_STRING |
1417 void SkProcCoeffXfermode::toString(SkString* str) const { | 1417 void SkProcCoeffXfermode::toString(SkString* str) const { |
1418 str->append("SkProcCoeffXfermode: "); | 1418 str->append("SkProcCoeffXfermode: "); |
1419 | 1419 |
1420 str->append("mode: "); | 1420 str->append("mode: "); |
1421 str->append(ModeName(fMode)); | 1421 str->append(ModeName(fMode)); |
1422 | 1422 |
1423 static const char* gCoeffStrings[kCoeffCount] = { | 1423 static const char* gCoeffStrings[kCoeffCount] = { |
1424 "Zero", "One", "SC", "ISC", "DC", "IDC", "SA", "ISA", "DA", "IDA" | 1424 "Zero", "One", "SC", "ISC", "DC", "IDC", "SA", "ISA", "DA", "IDA" |
1425 }; | 1425 }; |
1426 | 1426 |
(...skipping 17 matching lines...) Expand all Loading... |
1444 | 1444 |
1445 class SkClearXfermode : public SkProcCoeffXfermode { | 1445 class SkClearXfermode : public SkProcCoeffXfermode { |
1446 public: | 1446 public: |
1447 static SkClearXfermode* Create(const ProcCoeff& rec) { | 1447 static SkClearXfermode* Create(const ProcCoeff& rec) { |
1448 return SkNEW_ARGS(SkClearXfermode, (rec)); | 1448 return SkNEW_ARGS(SkClearXfermode, (rec)); |
1449 } | 1449 } |
1450 | 1450 |
1451 virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) const
SK_OVERRIDE; | 1451 virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) const
SK_OVERRIDE; |
1452 virtual void xferA8(SkAlpha*, const SkPMColor*, int, const SkAlpha*) const S
K_OVERRIDE; | 1452 virtual void xferA8(SkAlpha*, const SkPMColor*, int, const SkAlpha*) const S
K_OVERRIDE; |
1453 | 1453 |
1454 SK_DEVELOPER_TO_STRING() | 1454 SK_TO_STRING_OVERRIDE() |
1455 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkClearXfermode) | 1455 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkClearXfermode) |
1456 | 1456 |
1457 private: | 1457 private: |
1458 SkClearXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kClear_Mode
) {} | 1458 SkClearXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kClear_Mode
) {} |
1459 SkClearXfermode(SkReadBuffer& buffer) | 1459 SkClearXfermode(SkReadBuffer& buffer) |
1460 : SkProcCoeffXfermode(buffer) {} | 1460 : SkProcCoeffXfermode(buffer) {} |
1461 | 1461 |
1462 typedef SkProcCoeffXfermode INHERITED; | 1462 typedef SkProcCoeffXfermode INHERITED; |
1463 }; | 1463 }; |
1464 | 1464 |
(...skipping 27 matching lines...) Expand all Loading... |
1492 unsigned a = aa[i]; | 1492 unsigned a = aa[i]; |
1493 if (0xFF == a) { | 1493 if (0xFF == a) { |
1494 dst[i] = 0; | 1494 dst[i] = 0; |
1495 } else if (0 != a) { | 1495 } else if (0 != a) { |
1496 dst[i] = SkAlphaMulAlpha(dst[i], 255 - a); | 1496 dst[i] = SkAlphaMulAlpha(dst[i], 255 - a); |
1497 } | 1497 } |
1498 } | 1498 } |
1499 } | 1499 } |
1500 } | 1500 } |
1501 | 1501 |
1502 #ifdef SK_DEVELOPER | 1502 #ifndef SK_IGNORE_TO_STRING |
1503 void SkClearXfermode::toString(SkString* str) const { | 1503 void SkClearXfermode::toString(SkString* str) const { |
1504 this->INHERITED::toString(str); | 1504 this->INHERITED::toString(str); |
1505 } | 1505 } |
1506 #endif | 1506 #endif |
1507 | 1507 |
1508 /////////////////////////////////////////////////////////////////////////////// | 1508 /////////////////////////////////////////////////////////////////////////////// |
1509 | 1509 |
1510 class SkSrcXfermode : public SkProcCoeffXfermode { | 1510 class SkSrcXfermode : public SkProcCoeffXfermode { |
1511 public: | 1511 public: |
1512 static SkSrcXfermode* Create(const ProcCoeff& rec) { | 1512 static SkSrcXfermode* Create(const ProcCoeff& rec) { |
1513 return SkNEW_ARGS(SkSrcXfermode, (rec)); | 1513 return SkNEW_ARGS(SkSrcXfermode, (rec)); |
1514 } | 1514 } |
1515 | 1515 |
1516 virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) const
SK_OVERRIDE; | 1516 virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) const
SK_OVERRIDE; |
1517 virtual void xferA8(SkAlpha*, const SkPMColor*, int, const SkAlpha*) const S
K_OVERRIDE; | 1517 virtual void xferA8(SkAlpha*, const SkPMColor*, int, const SkAlpha*) const S
K_OVERRIDE; |
1518 | 1518 |
1519 SK_DEVELOPER_TO_STRING() | 1519 SK_TO_STRING_OVERRIDE() |
1520 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSrcXfermode) | 1520 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSrcXfermode) |
1521 | 1521 |
1522 private: | 1522 private: |
1523 SkSrcXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kSrc_Mode) {} | 1523 SkSrcXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kSrc_Mode) {} |
1524 SkSrcXfermode(SkReadBuffer& buffer) | 1524 SkSrcXfermode(SkReadBuffer& buffer) |
1525 : SkProcCoeffXfermode(buffer) {} | 1525 : SkProcCoeffXfermode(buffer) {} |
1526 | 1526 |
1527 typedef SkProcCoeffXfermode INHERITED; | 1527 typedef SkProcCoeffXfermode INHERITED; |
1528 }; | 1528 }; |
1529 | 1529 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1562 unsigned srcA = SkGetPackedA32(src[i]); | 1562 unsigned srcA = SkGetPackedA32(src[i]); |
1563 if (a == 0xFF) { | 1563 if (a == 0xFF) { |
1564 dst[i] = SkToU8(srcA); | 1564 dst[i] = SkToU8(srcA); |
1565 } else { | 1565 } else { |
1566 dst[i] = SkToU8(SkAlphaBlend(srcA, dst[i], a)); | 1566 dst[i] = SkToU8(SkAlphaBlend(srcA, dst[i], a)); |
1567 } | 1567 } |
1568 } | 1568 } |
1569 } | 1569 } |
1570 } | 1570 } |
1571 } | 1571 } |
1572 #ifdef SK_DEVELOPER | 1572 #ifndef SK_IGNORE_TO_STRING |
1573 void SkSrcXfermode::toString(SkString* str) const { | 1573 void SkSrcXfermode::toString(SkString* str) const { |
1574 this->INHERITED::toString(str); | 1574 this->INHERITED::toString(str); |
1575 } | 1575 } |
1576 #endif | 1576 #endif |
1577 | 1577 |
1578 /////////////////////////////////////////////////////////////////////////////// | 1578 /////////////////////////////////////////////////////////////////////////////// |
1579 | 1579 |
1580 class SkDstInXfermode : public SkProcCoeffXfermode { | 1580 class SkDstInXfermode : public SkProcCoeffXfermode { |
1581 public: | 1581 public: |
1582 static SkDstInXfermode* Create(const ProcCoeff& rec) { | 1582 static SkDstInXfermode* Create(const ProcCoeff& rec) { |
1583 return SkNEW_ARGS(SkDstInXfermode, (rec)); | 1583 return SkNEW_ARGS(SkDstInXfermode, (rec)); |
1584 } | 1584 } |
1585 | 1585 |
1586 virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) const
SK_OVERRIDE; | 1586 virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) const
SK_OVERRIDE; |
1587 | 1587 |
1588 SK_DEVELOPER_TO_STRING() | 1588 SK_TO_STRING_OVERRIDE() |
1589 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDstInXfermode) | 1589 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDstInXfermode) |
1590 | 1590 |
1591 private: | 1591 private: |
1592 SkDstInXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstIn_Mode
) {} | 1592 SkDstInXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstIn_Mode
) {} |
1593 SkDstInXfermode(SkReadBuffer& buffer) : INHERITED(buffer) {} | 1593 SkDstInXfermode(SkReadBuffer& buffer) : INHERITED(buffer) {} |
1594 | 1594 |
1595 typedef SkProcCoeffXfermode INHERITED; | 1595 typedef SkProcCoeffXfermode INHERITED; |
1596 }; | 1596 }; |
1597 | 1597 |
1598 void SkDstInXfermode::xfer32(SkPMColor* SK_RESTRICT dst, | 1598 void SkDstInXfermode::xfer32(SkPMColor* SK_RESTRICT dst, |
1599 const SkPMColor* SK_RESTRICT src, int count, | 1599 const SkPMColor* SK_RESTRICT src, int count, |
1600 const SkAlpha* SK_RESTRICT aa) const { | 1600 const SkAlpha* SK_RESTRICT aa) const { |
1601 SkASSERT(dst && src); | 1601 SkASSERT(dst && src); |
1602 | 1602 |
1603 if (count <= 0) { | 1603 if (count <= 0) { |
1604 return; | 1604 return; |
1605 } | 1605 } |
1606 if (NULL != aa) { | 1606 if (NULL != aa) { |
1607 return this->INHERITED::xfer32(dst, src, count, aa); | 1607 return this->INHERITED::xfer32(dst, src, count, aa); |
1608 } | 1608 } |
1609 | 1609 |
1610 do { | 1610 do { |
1611 unsigned a = SkGetPackedA32(*src); | 1611 unsigned a = SkGetPackedA32(*src); |
1612 *dst = SkAlphaMulQ(*dst, SkAlpha255To256(a)); | 1612 *dst = SkAlphaMulQ(*dst, SkAlpha255To256(a)); |
1613 dst++; | 1613 dst++; |
1614 src++; | 1614 src++; |
1615 } while (--count != 0); | 1615 } while (--count != 0); |
1616 } | 1616 } |
1617 | 1617 |
1618 #ifdef SK_DEVELOPER | 1618 #ifndef SK_IGNORE_TO_STRING |
1619 void SkDstInXfermode::toString(SkString* str) const { | 1619 void SkDstInXfermode::toString(SkString* str) const { |
1620 this->INHERITED::toString(str); | 1620 this->INHERITED::toString(str); |
1621 } | 1621 } |
1622 #endif | 1622 #endif |
1623 | 1623 |
1624 /////////////////////////////////////////////////////////////////////////////// | 1624 /////////////////////////////////////////////////////////////////////////////// |
1625 | 1625 |
1626 class SkDstOutXfermode : public SkProcCoeffXfermode { | 1626 class SkDstOutXfermode : public SkProcCoeffXfermode { |
1627 public: | 1627 public: |
1628 static SkDstOutXfermode* Create(const ProcCoeff& rec) { | 1628 static SkDstOutXfermode* Create(const ProcCoeff& rec) { |
1629 return SkNEW_ARGS(SkDstOutXfermode, (rec)); | 1629 return SkNEW_ARGS(SkDstOutXfermode, (rec)); |
1630 } | 1630 } |
1631 | 1631 |
1632 virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) const
SK_OVERRIDE; | 1632 virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) const
SK_OVERRIDE; |
1633 | 1633 |
1634 SK_DEVELOPER_TO_STRING() | 1634 SK_TO_STRING_OVERRIDE() |
1635 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDstOutXfermode) | 1635 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDstOutXfermode) |
1636 | 1636 |
1637 private: | 1637 private: |
1638 SkDstOutXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstOut_Mo
de) {} | 1638 SkDstOutXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstOut_Mo
de) {} |
1639 SkDstOutXfermode(SkReadBuffer& buffer) | 1639 SkDstOutXfermode(SkReadBuffer& buffer) |
1640 : INHERITED(buffer) {} | 1640 : INHERITED(buffer) {} |
1641 | 1641 |
1642 typedef SkProcCoeffXfermode INHERITED; | 1642 typedef SkProcCoeffXfermode INHERITED; |
1643 }; | 1643 }; |
1644 | 1644 |
(...skipping 10 matching lines...) Expand all Loading... |
1655 } | 1655 } |
1656 | 1656 |
1657 do { | 1657 do { |
1658 unsigned a = SkGetPackedA32(*src); | 1658 unsigned a = SkGetPackedA32(*src); |
1659 *dst = SkAlphaMulQ(*dst, SkAlpha255To256(255 - a)); | 1659 *dst = SkAlphaMulQ(*dst, SkAlpha255To256(255 - a)); |
1660 dst++; | 1660 dst++; |
1661 src++; | 1661 src++; |
1662 } while (--count != 0); | 1662 } while (--count != 0); |
1663 } | 1663 } |
1664 | 1664 |
1665 #ifdef SK_DEVELOPER | 1665 #ifndef SK_IGNORE_TO_STRING |
1666 void SkDstOutXfermode::toString(SkString* str) const { | 1666 void SkDstOutXfermode::toString(SkString* str) const { |
1667 this->INHERITED::toString(str); | 1667 this->INHERITED::toString(str); |
1668 } | 1668 } |
1669 #endif | 1669 #endif |
1670 | 1670 |
1671 /////////////////////////////////////////////////////////////////////////////// | 1671 /////////////////////////////////////////////////////////////////////////////// |
1672 | 1672 |
1673 SK_DECLARE_STATIC_MUTEX(gCachedXfermodesMutex); | 1673 SK_DECLARE_STATIC_MUTEX(gCachedXfermodesMutex); |
1674 static SkXfermode* gCachedXfermodes[SkXfermode::kLastMode + 1]; | 1674 static SkXfermode* gCachedXfermodes[SkXfermode::kLastMode + 1]; |
1675 | 1675 |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1983 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) | 1983 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) |
1984 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) | 1984 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) |
1985 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode) | 1985 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode) |
1986 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode) | 1986 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode) |
1987 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode) | 1987 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode) |
1988 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode) | 1988 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode) |
1989 #if !SK_ARM_NEON_IS_NONE | 1989 #if !SK_ARM_NEON_IS_NONE |
1990 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkNEONProcCoeffXfermode) | 1990 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkNEONProcCoeffXfermode) |
1991 #endif | 1991 #endif |
1992 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1992 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |