diff options
author | 2009-08-07 19:14:34 +0000 | |
---|---|---|
committer | 2009-08-07 19:14:34 +0000 | |
commit | 152f748386143475daf9da31aceb424dc7c8a7e6 (patch) | |
tree | 430b0796eacb8cc6f5eb35d7aeecd1b66c549654 /src/core/SkBitmapProcState.cpp | |
parent | cf45bf84392e05b137d1fa18dca3fc3e4b7a864e (diff) |
more neon work:
- remove neon-specific functions that were not faster than the C version
- move the neon filter function to its own header, so it could be use in more places
git-svn-id: http://skia.googlecode.com/svn/trunk@309 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkBitmapProcState.cpp')
-rw-r--r-- | src/core/SkBitmapProcState.cpp | 126 |
1 files changed, 66 insertions, 60 deletions
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp index 3e5b927684..3c5833dd25 100644 --- a/src/core/SkBitmapProcState.cpp +++ b/src/core/SkBitmapProcState.cpp @@ -1,4 +1,5 @@ #include "SkBitmapProcState.h" +#include "SkBitmapProcState_filter.h" #include "SkColorPriv.h" #include "SkFilterProc.h" #include "SkPaint.h" @@ -12,33 +13,6 @@ #define UNPACK_SECONDARY_SHORT(packed) ((uint32_t)(packed) >> 16) #endif -static inline SkPMColor Filter_32(unsigned x, unsigned y, - SkPMColor a00, SkPMColor a01, - SkPMColor a10, SkPMColor a11) { - SkASSERT((unsigned)x <= 0xF); - SkASSERT((unsigned)y <= 0xF); - - int xy = x * y; - uint32_t mask = gMask_00FF00FF; //0xFF00FF; - - int scale = 256 - 16*y - 16*x + xy; - uint32_t lo = (a00 & mask) * scale; - uint32_t hi = ((a00 >> 8) & mask) * scale; - - scale = 16*x - xy; - lo += (a01 & mask) * scale; - hi += ((a01 >> 8) & mask) * scale; - - scale = 16*y - xy; - lo += (a10 & mask) * scale; - hi += ((a10 >> 8) & mask) * scale; - - lo += (a11 & mask) * xy; - hi += ((a11 >> 8) & mask) * xy; - - return ((lo >> 8) & mask) | (hi & ~mask); -} - // returns expanded * 5bits static inline uint32_t Filter_565_Expanded(unsigned x, unsigned y, uint32_t a00, uint32_t a01, @@ -111,7 +85,7 @@ static inline U8CPU Filter_8(unsigned x, unsigned y, // SRC == 8888 -#define FILTER_PROC(x, y, a, b, c, d) Filter_32(x, y, a, b, c, d) +#define FILTER_PROC(x, y, a, b, c, d, dst) Filter_32_opaque(x, y, a, b, c, d, dst) #define MAKENAME(suffix) S32_opaque_D32 ## suffix #define DSTSIZE 32 @@ -120,24 +94,29 @@ static inline U8CPU Filter_8(unsigned x, unsigned y, SkASSERT(state.fAlphaScale == 256) #define RETURNDST(src) src #define SRC_TO_FILTER(src) src -#define FILTER_TO_DST(c) c #include "SkBitmapProcState_sample.h" +#undef FILTER_PROC +#define FILTER_PROC(x, y, a, b, c, d, dst) Filter_32_alpha(x, y, a, b, c, d, dst, alphaScale) + #define MAKENAME(suffix) S32_alpha_D32 ## suffix #define DSTSIZE 32 #define SRCTYPE SkPMColor #define CHECKSTATE(state) SkASSERT(state.fBitmap->config() == SkBitmap::kARGB_8888_Config); \ SkASSERT(state.fAlphaScale < 256) -#define PREAMBLE(state) unsigned scale = state.fAlphaScale -#define RETURNDST(src) SkAlphaMulQ(src, scale) +#define PREAMBLE(state) unsigned alphaScale = state.fAlphaScale +#define RETURNDST(src) SkAlphaMulQ(src, alphaScale) #define SRC_TO_FILTER(src) src -#define FILTER_TO_DST(c) SkAlphaMulQ(c, scale) #include "SkBitmapProcState_sample.h" // SRC == 565 #undef FILTER_PROC -#define FILTER_PROC(x, y, a, b, c, d) Filter_565_Expanded(x, y, a, b, c, d) +#define FILTER_PROC(x, y, a, b, c, d, dst) \ + do { \ + uint32_t tmp = Filter_565_Expanded(x, y, a, b, c, d); \ + *(dst) = SkExpanded_565_To_PMColor(tmp); \ + } while (0) #define MAKENAME(suffix) S16_opaque_D32 ## suffix #define DSTSIZE 32 @@ -146,24 +125,29 @@ static inline U8CPU Filter_8(unsigned x, unsigned y, SkASSERT(state.fAlphaScale == 256) #define RETURNDST(src) SkPixel16ToPixel32(src) #define SRC_TO_FILTER(src) src -#define FILTER_TO_DST(c) SkExpanded_565_To_PMColor(c) #include "SkBitmapProcState_sample.h" +#undef FILTER_PROC +#define FILTER_PROC(x, y, a, b, c, d, dst) \ + do { \ + uint32_t tmp = Filter_565_Expanded(x, y, a, b, c, d); \ + *(dst) = SkAlphaMulQ(SkExpanded_565_To_PMColor(tmp), alphaScale); \ + } while (0) + #define MAKENAME(suffix) S16_alpha_D32 ## suffix #define DSTSIZE 32 #define SRCTYPE uint16_t #define CHECKSTATE(state) SkASSERT(state.fBitmap->config() == SkBitmap::kRGB_565_Config); \ SkASSERT(state.fAlphaScale < 256) -#define PREAMBLE(state) unsigned scale = state.fAlphaScale -#define RETURNDST(src) SkAlphaMulQ(SkPixel16ToPixel32(src), scale) +#define PREAMBLE(state) unsigned alphaScale = state.fAlphaScale +#define RETURNDST(src) SkAlphaMulQ(SkPixel16ToPixel32(src), alphaScale) #define SRC_TO_FILTER(src) src -#define FILTER_TO_DST(c) SkAlphaMulQ(SkExpanded_565_To_PMColor(c), scale) #include "SkBitmapProcState_sample.h" // SRC == Index8 #undef FILTER_PROC -#define FILTER_PROC(x, y, a, b, c, d) Filter_32(x, y, a, b, c, d) +#define FILTER_PROC(x, y, a, b, c, d, dst) Filter_32_opaque(x, y, a, b, c, d, dst) #define MAKENAME(suffix) SI8_opaque_D32 ## suffix #define DSTSIZE 32 @@ -173,53 +157,63 @@ static inline U8CPU Filter_8(unsigned x, unsigned y, #define PREAMBLE(state) const SkPMColor* SK_RESTRICT table = state.fBitmap->getColorTable()->lockColors() #define RETURNDST(src) table[src] #define SRC_TO_FILTER(src) table[src] -#define FILTER_TO_DST(c) c #define POSTAMBLE(state) state.fBitmap->getColorTable()->unlockColors(false) #include "SkBitmapProcState_sample.h" +#undef FILTER_PROC +#define FILTER_PROC(x, y, a, b, c, d, dst) Filter_32_alpha(x, y, a, b, c, d, dst, alphaScale) + #define MAKENAME(suffix) SI8_alpha_D32 ## suffix #define DSTSIZE 32 #define SRCTYPE uint8_t #define CHECKSTATE(state) SkASSERT(state.fBitmap->config() == SkBitmap::kIndex8_Config); \ SkASSERT(state.fAlphaScale < 256) -#define PREAMBLE(state) unsigned scale = state.fAlphaScale; \ +#define PREAMBLE(state) unsigned alphaScale = state.fAlphaScale; \ const SkPMColor* SK_RESTRICT table = state.fBitmap->getColorTable()->lockColors() -#define RETURNDST(src) SkAlphaMulQ(table[src], scale) +#define RETURNDST(src) SkAlphaMulQ(table[src], alphaScale) #define SRC_TO_FILTER(src) table[src] -#define FILTER_TO_DST(c) SkAlphaMulQ(c, scale) #define POSTAMBLE(state) state.fBitmap->getColorTable()->unlockColors(false) #include "SkBitmapProcState_sample.h" // SRC == 4444 #undef FILTER_PROC -#define FILTER_PROC(x, y, a, b, c, d) Filter_4444_D32(x, y, a, b, c, d) +#define FILTER_PROC(x, y, a, b, c, d, dst) *(dst) = Filter_4444_D32(x, y, a, b, c, d) #define MAKENAME(suffix) S4444_opaque_D32 ## suffix #define DSTSIZE 32 #define SRCTYPE SkPMColor16 #define CHECKSTATE(state) SkASSERT(state.fBitmap->config() == SkBitmap::kARGB_4444_Config); \ -SkASSERT(state.fAlphaScale == 256) + SkASSERT(state.fAlphaScale == 256) #define RETURNDST(src) SkPixel4444ToPixel32(src) #define SRC_TO_FILTER(src) src -#define FILTER_TO_DST(c) c #include "SkBitmapProcState_sample.h" +#undef FILTER_PROC +#define FILTER_PROC(x, y, a, b, c, d, dst) \ + do { \ + uint32_t tmp = Filter_4444_D32(x, y, a, b, c, d); \ + *(dst) = SkAlphaMulQ(tmp, alphaScale); \ + } while (0) + #define MAKENAME(suffix) S4444_alpha_D32 ## suffix #define DSTSIZE 32 #define SRCTYPE SkPMColor16 #define CHECKSTATE(state) SkASSERT(state.fBitmap->config() == SkBitmap::kARGB_4444_Config); \ -SkASSERT(state.fAlphaScale < 256) -#define PREAMBLE(state) unsigned scale = state.fAlphaScale -#define RETURNDST(src) SkAlphaMulQ(SkPixel4444ToPixel32(src), scale) + SkASSERT(state.fAlphaScale < 256) +#define PREAMBLE(state) unsigned alphaScale = state.fAlphaScale +#define RETURNDST(src) SkAlphaMulQ(SkPixel4444ToPixel32(src), alphaScale) #define SRC_TO_FILTER(src) src -#define FILTER_TO_DST(c) SkAlphaMulQ(c, scale) #include "SkBitmapProcState_sample.h" // SRC == A8 #undef FILTER_PROC -#define FILTER_PROC(x, y, a, b, c, d) Filter_8(x, y, a, b, c, d) +#define FILTER_PROC(x, y, a, b, c, d, dst) \ + do { \ + unsigned tmp = Filter_8(x, y, a, b, c, d); \ + *(dst) = SkAlphaMulQ(pmColor, SkAlpha255To256(tmp)); \ + } while (0) #define MAKENAME(suffix) SA8_alpha_D32 ## suffix #define DSTSIZE 32 @@ -229,7 +223,6 @@ SkASSERT(state.fAlphaScale < 256) #define PREAMBLE(state) const SkPMColor pmColor = state.fPaintPMColor; #define RETURNDST(src) SkAlphaMulQ(pmColor, SkAlpha255To256(src)) #define SRC_TO_FILTER(src) src -#define FILTER_TO_DST(c) SkAlphaMulQ(pmColor, SkAlpha255To256(c)) #include "SkBitmapProcState_sample.h" /***************************************************************************** @@ -241,7 +234,12 @@ SkASSERT(state.fAlphaScale < 256) // SRC == 8888 #undef FILTER_PROC -#define FILTER_PROC(x, y, a, b, c, d) Filter_32(x, y, a, b, c, d) +#define FILTER_PROC(x, y, a, b, c, d, dst) \ + do { \ + SkPMColor dstColor; \ + Filter_32_opaque(x, y, a, b, c, d, &dstColor); \ + (*dst) = SkPixel32ToPixel16(dstColor); \ + } while (0) #define MAKENAME(suffix) S32_D16 ## suffix #define DSTSIZE 16 @@ -250,13 +248,16 @@ SkASSERT(state.fAlphaScale < 256) SkASSERT(state.fBitmap->isOpaque()) #define RETURNDST(src) SkPixel32ToPixel16(src) #define SRC_TO_FILTER(src) src -#define FILTER_TO_DST(c) SkPixel32ToPixel16(c) #include "SkBitmapProcState_sample.h" // SRC == 565 #undef FILTER_PROC -#define FILTER_PROC(x, y, a, b, c, d) Filter_565_Expanded(x, y, a, b, c, d) +#define FILTER_PROC(x, y, a, b, c, d, dst) \ + do { \ + uint32_t tmp = Filter_565_Expanded(x, y, a, b, c, d); \ + *(dst) = SkCompact_rgb_16((tmp) >> 5); \ + } while (0) #define MAKENAME(suffix) S16_D16 ## suffix #define DSTSIZE 16 @@ -264,13 +265,16 @@ SkASSERT(state.fAlphaScale < 256) #define CHECKSTATE(state) SkASSERT(state.fBitmap->config() == SkBitmap::kRGB_565_Config) #define RETURNDST(src) src #define SRC_TO_FILTER(src) src -#define FILTER_TO_DST(c) SkCompact_rgb_16((c) >> 5) #include "SkBitmapProcState_sample.h" // SRC == Index8 #undef FILTER_PROC -#define FILTER_PROC(x, y, a, b, c, d) Filter_565_Expanded(x, y, a, b, c, d) +#define FILTER_PROC(x, y, a, b, c, d, dst) \ + do { \ + uint32_t tmp = Filter_565_Expanded(x, y, a, b, c, d); \ + *(dst) = SkCompact_rgb_16((tmp) >> 5); \ + } while (0) #define MAKENAME(suffix) SI8_D16 ## suffix #define DSTSIZE 16 @@ -280,14 +284,18 @@ SkASSERT(state.fAlphaScale < 256) #define PREAMBLE(state) const uint16_t* SK_RESTRICT table = state.fBitmap->getColorTable()->lock16BitCache() #define RETURNDST(src) table[src] #define SRC_TO_FILTER(src) table[src] -#define FILTER_TO_DST(c) SkCompact_rgb_16(c >> 5) #define POSTAMBLE(state) state.fBitmap->getColorTable()->unlock16BitCache() #include "SkBitmapProcState_sample.h" /////////////////////////////////////////////////////////////////////////////// #undef FILTER_PROC -#define FILTER_PROC(x, y, a, b, c, d) Filter_565_Expanded(x, y, a, b, c, d) +#define FILTER_PROC(x, y, a, b, c, d, dst) \ + do { \ + uint32_t tmp = Filter_565_Expanded(x, y, a, b, c, d); \ + *(dst) = SkCompact_rgb_16((tmp) >> 5); \ + } while (0) + #define TILEX_PROCF(fx, max) SkClampMax((fx) >> 16, max) #define TILEY_PROCF(fy, max) SkClampMax((fy) >> 16, max) @@ -299,7 +307,6 @@ SkASSERT(state.fAlphaScale < 256) #define DSTTYPE uint16_t #define CHECKSTATE(state) SkASSERT(state.fBitmap->config() == SkBitmap::kRGB_565_Config) #define SRC_TO_FILTER(src) src -#define FILTER_TO_DST(c) SkCompact_rgb_16((c) >> 5) #include "SkBitmapProcState_shaderproc.h" @@ -313,7 +320,6 @@ SkASSERT(state.fAlphaScale < 256) #define DSTTYPE uint16_t #define CHECKSTATE(state) SkASSERT(state.fBitmap->config() == SkBitmap::kRGB_565_Config) #define SRC_TO_FILTER(src) src -#define FILTER_TO_DST(c) SkCompact_rgb_16((c) >> 5) #include "SkBitmapProcState_shaderproc.h" /////////////////////////////////////////////////////////////////////////////// |