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 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1664 SkAutoMutexAcquire ac(gCachedXfermodesMutex); | 1664 SkAutoMutexAcquire ac(gCachedXfermodesMutex); |
1665 | 1665 |
1666 for (size_t i = 0; i < SK_ARRAY_COUNT(gCachedXfermodes); ++i) { | 1666 for (size_t i = 0; i < SK_ARRAY_COUNT(gCachedXfermodes); ++i) { |
1667 SkSafeUnref(gCachedXfermodes[i]); | 1667 SkSafeUnref(gCachedXfermodes[i]); |
1668 gCachedXfermodes[i] = NULL; | 1668 gCachedXfermodes[i] = NULL; |
1669 } | 1669 } |
1670 } | 1670 } |
1671 | 1671 |
1672 extern SkProcCoeffXfermode* SkPlatformXfermodeFactory(const ProcCoeff& rec, | 1672 extern SkProcCoeffXfermode* SkPlatformXfermodeFactory(const ProcCoeff& rec, |
1673 SkXfermode::Mode mode); | 1673 SkXfermode::Mode mode); |
| 1674 extern SkXfermodeProc SkPlatformXfermodeProcFactory(SkXfermode::Mode mode); |
1674 | 1675 |
1675 SkXfermode* SkXfermode::Create(Mode mode) { | 1676 SkXfermode* SkXfermode::Create(Mode mode) { |
1676 SkASSERT(SK_ARRAY_COUNT(gProcCoeffs) == kModeCount); | 1677 SkASSERT(SK_ARRAY_COUNT(gProcCoeffs) == kModeCount); |
1677 SkASSERT(SK_ARRAY_COUNT(gCachedXfermodes) == kModeCount); | 1678 SkASSERT(SK_ARRAY_COUNT(gCachedXfermodes) == kModeCount); |
1678 | 1679 |
1679 if ((unsigned)mode >= kModeCount) { | 1680 if ((unsigned)mode >= kModeCount) { |
1680 // report error | 1681 // report error |
1681 return NULL; | 1682 return NULL; |
1682 } | 1683 } |
1683 | 1684 |
1684 // Skia's "defaut" mode is srcover. NULL in SkPaint is interpreted as srcove
r | 1685 // Skia's "defaut" mode is srcover. NULL in SkPaint is interpreted as srcove
r |
1685 // so we can just return NULL from the factory. | 1686 // so we can just return NULL from the factory. |
1686 if (kSrcOver_Mode == mode) { | 1687 if (kSrcOver_Mode == mode) { |
1687 return NULL; | 1688 return NULL; |
1688 } | 1689 } |
1689 | 1690 |
1690 // guard our access to gCachedXfermodes, since we may write into it | 1691 // guard our access to gCachedXfermodes, since we may write into it |
1691 SkAutoMutexAcquire ac(gCachedXfermodesMutex); | 1692 SkAutoMutexAcquire ac(gCachedXfermodesMutex); |
1692 | 1693 |
1693 SkXfermode* xfer = gCachedXfermodes[mode]; | 1694 SkXfermode* xfer = gCachedXfermodes[mode]; |
1694 if (NULL == xfer) { | 1695 if (NULL == xfer) { |
1695 const ProcCoeff& rec = gProcCoeffs[mode]; | 1696 ProcCoeff rec = gProcCoeffs[mode]; |
| 1697 |
| 1698 SkXfermodeProc pp = SkPlatformXfermodeProcFactory(mode); |
| 1699 |
| 1700 if (pp != NULL) { |
| 1701 rec.fProc = pp; |
| 1702 } |
1696 | 1703 |
1697 // check if we have a platform optim for that | 1704 // check if we have a platform optim for that |
1698 SkProcCoeffXfermode* xfm = SkPlatformXfermodeFactory(rec, mode); | 1705 SkProcCoeffXfermode* xfm = SkPlatformXfermodeFactory(rec, mode); |
1699 if (xfm != NULL) { | 1706 if (xfm != NULL) { |
1700 xfer = xfm; | 1707 xfer = xfm; |
1701 } else { | 1708 } else { |
1702 // All modes can in theory be represented by the ProcCoeff rec, sinc
e | 1709 // All modes can in theory be represented by the ProcCoeff rec, sinc
e |
1703 // it contains function ptrs. However, a few modes are both simple a
nd | 1710 // it contains function ptrs. However, a few modes are both simple a
nd |
1704 // commonly used, so we call those out for their own subclasses here
. | 1711 // commonly used, so we call those out for their own subclasses here
. |
1705 switch (mode) { | 1712 switch (mode) { |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1963 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) | 1970 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) |
1964 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) | 1971 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) |
1965 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode) | 1972 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkClearXfermode) |
1966 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode) | 1973 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSrcXfermode) |
1967 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode) | 1974 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstInXfermode) |
1968 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode) | 1975 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDstOutXfermode) |
1969 #if !SK_ARM_NEON_IS_NONE | 1976 #if !SK_ARM_NEON_IS_NONE |
1970 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkNEONProcCoeffXfermode) | 1977 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkNEONProcCoeffXfermode) |
1971 #endif | 1978 #endif |
1972 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 1979 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |