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 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 } else { | 1437 } else { |
1438 str->append(gCoeffStrings[fDstCoeff]); | 1438 str->append(gCoeffStrings[fDstCoeff]); |
1439 } | 1439 } |
1440 } | 1440 } |
1441 #endif | 1441 #endif |
1442 | 1442 |
1443 /////////////////////////////////////////////////////////////////////////////// | 1443 /////////////////////////////////////////////////////////////////////////////// |
1444 | 1444 |
1445 class SkClearXfermode : public SkProcCoeffXfermode { | 1445 class SkClearXfermode : public SkProcCoeffXfermode { |
1446 public: | 1446 public: |
1447 SkClearXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kClear_Mode
) {} | 1447 static SkClearXfermode* Create(const ProcCoeff& rec) { |
| 1448 return SkNEW_ARGS(SkClearXfermode, (rec)); |
| 1449 } |
1448 | 1450 |
1449 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; |
1450 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; |
1451 | 1453 |
1452 SK_DEVELOPER_TO_STRING() | 1454 SK_DEVELOPER_TO_STRING() |
1453 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkClearXfermode) | 1455 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkClearXfermode) |
1454 | 1456 |
1455 private: | 1457 private: |
| 1458 SkClearXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kClear_Mode
) {} |
1456 SkClearXfermode(SkReadBuffer& buffer) | 1459 SkClearXfermode(SkReadBuffer& buffer) |
1457 : SkProcCoeffXfermode(buffer) {} | 1460 : SkProcCoeffXfermode(buffer) {} |
1458 | 1461 |
1459 typedef SkProcCoeffXfermode INHERITED; | 1462 typedef SkProcCoeffXfermode INHERITED; |
1460 }; | 1463 }; |
1461 | 1464 |
1462 void SkClearXfermode::xfer32(SkPMColor* SK_RESTRICT dst, | 1465 void SkClearXfermode::xfer32(SkPMColor* SK_RESTRICT dst, |
1463 const SkPMColor* SK_RESTRICT, int count, | 1466 const SkPMColor* SK_RESTRICT, int count, |
1464 const SkAlpha* SK_RESTRICT aa) const { | 1467 const SkAlpha* SK_RESTRICT aa) const { |
1465 SkASSERT(dst && count >= 0); | 1468 SkASSERT(dst && count >= 0); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1499 #ifdef SK_DEVELOPER | 1502 #ifdef SK_DEVELOPER |
1500 void SkClearXfermode::toString(SkString* str) const { | 1503 void SkClearXfermode::toString(SkString* str) const { |
1501 this->INHERITED::toString(str); | 1504 this->INHERITED::toString(str); |
1502 } | 1505 } |
1503 #endif | 1506 #endif |
1504 | 1507 |
1505 /////////////////////////////////////////////////////////////////////////////// | 1508 /////////////////////////////////////////////////////////////////////////////// |
1506 | 1509 |
1507 class SkSrcXfermode : public SkProcCoeffXfermode { | 1510 class SkSrcXfermode : public SkProcCoeffXfermode { |
1508 public: | 1511 public: |
1509 SkSrcXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kSrc_Mode) {} | 1512 static SkSrcXfermode* Create(const ProcCoeff& rec) { |
| 1513 return SkNEW_ARGS(SkSrcXfermode, (rec)); |
| 1514 } |
1510 | 1515 |
1511 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; |
1512 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; |
1513 | 1518 |
1514 SK_DEVELOPER_TO_STRING() | 1519 SK_DEVELOPER_TO_STRING() |
1515 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSrcXfermode) | 1520 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSrcXfermode) |
1516 | 1521 |
1517 private: | 1522 private: |
| 1523 SkSrcXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kSrc_Mode) {} |
1518 SkSrcXfermode(SkReadBuffer& buffer) | 1524 SkSrcXfermode(SkReadBuffer& buffer) |
1519 : SkProcCoeffXfermode(buffer) {} | 1525 : SkProcCoeffXfermode(buffer) {} |
1520 | 1526 |
1521 typedef SkProcCoeffXfermode INHERITED; | 1527 typedef SkProcCoeffXfermode INHERITED; |
1522 }; | 1528 }; |
1523 | 1529 |
1524 void SkSrcXfermode::xfer32(SkPMColor* SK_RESTRICT dst, | 1530 void SkSrcXfermode::xfer32(SkPMColor* SK_RESTRICT dst, |
1525 const SkPMColor* SK_RESTRICT src, int count, | 1531 const SkPMColor* SK_RESTRICT src, int count, |
1526 const SkAlpha* SK_RESTRICT aa) const { | 1532 const SkAlpha* SK_RESTRICT aa) const { |
1527 SkASSERT(dst && src && count >= 0); | 1533 SkASSERT(dst && src && count >= 0); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1566 #ifdef SK_DEVELOPER | 1572 #ifdef SK_DEVELOPER |
1567 void SkSrcXfermode::toString(SkString* str) const { | 1573 void SkSrcXfermode::toString(SkString* str) const { |
1568 this->INHERITED::toString(str); | 1574 this->INHERITED::toString(str); |
1569 } | 1575 } |
1570 #endif | 1576 #endif |
1571 | 1577 |
1572 /////////////////////////////////////////////////////////////////////////////// | 1578 /////////////////////////////////////////////////////////////////////////////// |
1573 | 1579 |
1574 class SkDstInXfermode : public SkProcCoeffXfermode { | 1580 class SkDstInXfermode : public SkProcCoeffXfermode { |
1575 public: | 1581 public: |
1576 SkDstInXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstIn_Mode
) {} | 1582 static SkDstInXfermode* Create(const ProcCoeff& rec) { |
| 1583 return SkNEW_ARGS(SkDstInXfermode, (rec)); |
| 1584 } |
1577 | 1585 |
1578 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; |
1579 | 1587 |
1580 SK_DEVELOPER_TO_STRING() | 1588 SK_DEVELOPER_TO_STRING() |
1581 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDstInXfermode) | 1589 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDstInXfermode) |
1582 | 1590 |
1583 private: | 1591 private: |
| 1592 SkDstInXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstIn_Mode
) {} |
1584 SkDstInXfermode(SkReadBuffer& buffer) : INHERITED(buffer) {} | 1593 SkDstInXfermode(SkReadBuffer& buffer) : INHERITED(buffer) {} |
1585 | 1594 |
1586 typedef SkProcCoeffXfermode INHERITED; | 1595 typedef SkProcCoeffXfermode INHERITED; |
1587 }; | 1596 }; |
1588 | 1597 |
1589 void SkDstInXfermode::xfer32(SkPMColor* SK_RESTRICT dst, | 1598 void SkDstInXfermode::xfer32(SkPMColor* SK_RESTRICT dst, |
1590 const SkPMColor* SK_RESTRICT src, int count, | 1599 const SkPMColor* SK_RESTRICT src, int count, |
1591 const SkAlpha* SK_RESTRICT aa) const { | 1600 const SkAlpha* SK_RESTRICT aa) const { |
1592 SkASSERT(dst && src); | 1601 SkASSERT(dst && src); |
1593 | 1602 |
(...skipping 15 matching lines...) Expand all Loading... |
1609 #ifdef SK_DEVELOPER | 1618 #ifdef SK_DEVELOPER |
1610 void SkDstInXfermode::toString(SkString* str) const { | 1619 void SkDstInXfermode::toString(SkString* str) const { |
1611 this->INHERITED::toString(str); | 1620 this->INHERITED::toString(str); |
1612 } | 1621 } |
1613 #endif | 1622 #endif |
1614 | 1623 |
1615 /////////////////////////////////////////////////////////////////////////////// | 1624 /////////////////////////////////////////////////////////////////////////////// |
1616 | 1625 |
1617 class SkDstOutXfermode : public SkProcCoeffXfermode { | 1626 class SkDstOutXfermode : public SkProcCoeffXfermode { |
1618 public: | 1627 public: |
1619 SkDstOutXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstOut_Mo
de) {} | 1628 static SkDstOutXfermode* Create(const ProcCoeff& rec) { |
| 1629 return SkNEW_ARGS(SkDstOutXfermode, (rec)); |
| 1630 } |
1620 | 1631 |
1621 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; |
1622 | 1633 |
1623 SK_DEVELOPER_TO_STRING() | 1634 SK_DEVELOPER_TO_STRING() |
1624 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDstOutXfermode) | 1635 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDstOutXfermode) |
1625 | 1636 |
1626 private: | 1637 private: |
| 1638 SkDstOutXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstOut_Mo
de) {} |
1627 SkDstOutXfermode(SkReadBuffer& buffer) | 1639 SkDstOutXfermode(SkReadBuffer& buffer) |
1628 : INHERITED(buffer) {} | 1640 : INHERITED(buffer) {} |
1629 | 1641 |
1630 typedef SkProcCoeffXfermode INHERITED; | 1642 typedef SkProcCoeffXfermode INHERITED; |
1631 }; | 1643 }; |
1632 | 1644 |
1633 void SkDstOutXfermode::xfer32(SkPMColor* SK_RESTRICT dst, | 1645 void SkDstOutXfermode::xfer32(SkPMColor* SK_RESTRICT dst, |
1634 const SkPMColor* SK_RESTRICT src, int count, | 1646 const SkPMColor* SK_RESTRICT src, int count, |
1635 const SkAlpha* SK_RESTRICT aa) const { | 1647 const SkAlpha* SK_RESTRICT aa) const { |
1636 SkASSERT(dst && src); | 1648 SkASSERT(dst && src); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1705 // check if we have a platform optim for that | 1717 // check if we have a platform optim for that |
1706 SkProcCoeffXfermode* xfm = SkPlatformXfermodeFactory(rec, mode); | 1718 SkProcCoeffXfermode* xfm = SkPlatformXfermodeFactory(rec, mode); |
1707 if (xfm != NULL) { | 1719 if (xfm != NULL) { |
1708 xfer = xfm; | 1720 xfer = xfm; |
1709 } else { | 1721 } else { |
1710 // All modes can in theory be represented by the ProcCoeff rec, sinc
e | 1722 // All modes can in theory be represented by the ProcCoeff rec, sinc
e |
1711 // it contains function ptrs. However, a few modes are both simple a
nd | 1723 // it contains function ptrs. However, a few modes are both simple a
nd |
1712 // commonly used, so we call those out for their own subclasses here
. | 1724 // commonly used, so we call those out for their own subclasses here
. |
1713 switch (mode) { | 1725 switch (mode) { |
1714 case kClear_Mode: | 1726 case kClear_Mode: |
1715 xfer = SkNEW_ARGS(SkClearXfermode, (rec)); | 1727 xfer = SkClearXfermode::Create(rec); |
1716 break; | 1728 break; |
1717 case kSrc_Mode: | 1729 case kSrc_Mode: |
1718 xfer = SkNEW_ARGS(SkSrcXfermode, (rec)); | 1730 xfer = SkSrcXfermode::Create(rec); |
1719 break; | 1731 break; |
1720 case kSrcOver_Mode: | 1732 case kSrcOver_Mode: |
1721 SkASSERT(false); // should not land here | 1733 SkASSERT(false); // should not land here |
1722 break; | 1734 break; |
1723 case kDstIn_Mode: | 1735 case kDstIn_Mode: |
1724 xfer = SkNEW_ARGS(SkDstInXfermode, (rec)); | 1736 xfer = SkDstInXfermode::Create(rec); |
1725 break; | 1737 break; |
1726 case kDstOut_Mode: | 1738 case kDstOut_Mode: |
1727 xfer = SkNEW_ARGS(SkDstOutXfermode, (rec)); | 1739 xfer = SkDstOutXfermode::Create(rec); |
1728 break; | 1740 break; |
1729 default: | 1741 default: |
1730 // no special-case, just rely in the rec and its function-pt
rs | 1742 // no special-case, just rely in the rec and its function-pt
rs |
1731 xfer = SkNEW_ARGS(SkProcCoeffXfermode, (rec, mode)); | 1743 xfer = SkProcCoeffXfermode::Create(rec, mode); |
1732 break; | 1744 break; |
1733 } | 1745 } |
1734 } | 1746 } |
1735 gCachedXfermodes[mode] = xfer; | 1747 gCachedXfermodes[mode] = xfer; |
1736 } | 1748 } |
1737 return SkSafeRef(xfer); | 1749 return SkSafeRef(xfer); |
1738 } | 1750 } |
1739 | 1751 |
1740 SkXfermodeProc SkXfermode::GetProc(Mode mode) { | 1752 SkXfermodeProc SkXfermode::GetProc(Mode mode) { |
1741 SkXfermodeProc proc = NULL; | 1753 SkXfermodeProc proc = NULL; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1971 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) | 1983 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) |
1972 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) | 1984 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) |
1973 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode) | 1985 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode) |
1974 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode) | 1986 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode) |
1975 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode) | 1987 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode) |
1976 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode) | 1988 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode) |
1977 #if !SK_ARM_NEON_IS_NONE | 1989 #if !SK_ARM_NEON_IS_NONE |
1978 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkNEONProcCoeffXfermode) | 1990 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkNEONProcCoeffXfermode) |
1979 #endif | 1991 #endif |
1980 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1992 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |