зеркало из https://github.com/mozilla/moz-skia.git
Revert of Xfermode: SSE2 implementation of multiply_modeproc (https://codereview.chromium.org/202903004/)
Reason for revert: It looks like serialization is broken. The serialize and pipe-cross-process tests are failing and turning (at least the Ubuntu12 and Win7) bots red Original issue's description: > Xfermode: SSE2 implementation of multiply_modeproc > > This patch implements basics for Xfermode SSE optimization. Based on > these basics, SSE2 implementation of multiply_modeproc is provided. SSE2 > implementation for other modes will come in future. With this patch > performance of Xfermode_Multiply will improve about 45%. Here are the > data on desktop i7-3770. > before: > Xfermode_Multiply 8888: cmsecs = 33.30 565: cmsecs = 45.65 > after: > Xfermode_Multiply 8888: cmsecs = 17.18 565: cmsecs = 24.87 > > BUG= > > Committed: http://code.google.com/p/skia/source/detail?r=14006 > > Committed: http://code.google.com/p/skia/source/detail?r=14050 R=mtklein@google.com, qiankun.miao@intel.com TBR=mtklein@google.com, qiankun.miao@intel.com NOTREECHECKS=true NOTRY=true BUG= Author: robertphillips@google.com Review URL: https://codereview.chromium.org/224253003 git-svn-id: http://skia.googlecode.com/svn/trunk@14053 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
f3c4182156
Коммит
77815fd74d
|
@ -56,7 +56,7 @@
|
|||
'../src/opts/SkBlurImage_opts_SSE2.cpp',
|
||||
'../src/opts/SkMorphology_opts_SSE2.cpp',
|
||||
'../src/opts/SkUtils_opts_SSE2.cpp',
|
||||
'../src/opts/SkXfermode_opts_SSE2.cpp',
|
||||
'../src/opts/SkXfermode_opts_none.cpp',
|
||||
],
|
||||
}],
|
||||
[ 'skia_arch_type == "arm" and arm_version >= 7', {
|
||||
|
|
|
@ -17,10 +17,6 @@
|
|||
#include "SkUtilsArm.h"
|
||||
#include "SkWriteBuffer.h"
|
||||
|
||||
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
|
||||
#include "SkXfermode_opts_SSE2.h"
|
||||
#endif
|
||||
|
||||
#if !SK_ARM_NEON_IS_NONE
|
||||
#include "SkXfermode_opts_arm_neon.h"
|
||||
#endif
|
||||
|
@ -1997,7 +1993,4 @@ SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode)
|
|||
#if !SK_ARM_NEON_IS_NONE
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkNEONProcCoeffXfermode)
|
||||
#endif
|
||||
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSSE2ProcCoeffXfermode)
|
||||
#endif
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
|
||||
|
|
|
@ -914,7 +914,7 @@ void S32_D565_Opaque_SSE2(uint16_t* SK_RESTRICT dst,
|
|||
__m128i b = _mm_packs_epi32(b1, b2);
|
||||
|
||||
// Store 8 16-bit colors in dst.
|
||||
__m128i d_pixel = SkPackRGB16_SSE2(r, g, b);
|
||||
__m128i d_pixel = SkPackRGB16_SSE(r, g, b);
|
||||
_mm_store_si128(d++, d_pixel);
|
||||
count -= 8;
|
||||
}
|
||||
|
@ -983,54 +983,54 @@ void S32A_D565_Opaque_SSE2(uint16_t* SK_RESTRICT dst,
|
|||
__m128i dst_pixel = _mm_load_si128(d);
|
||||
|
||||
// Extract A from src.
|
||||
__m128i sa1 = _mm_slli_epi32(src_pixel1, (24 - SK_A32_SHIFT));
|
||||
__m128i sa1 = _mm_slli_epi32(src_pixel1,(24 - SK_A32_SHIFT));
|
||||
sa1 = _mm_srli_epi32(sa1, 24);
|
||||
__m128i sa2 = _mm_slli_epi32(src_pixel2, (24 - SK_A32_SHIFT));
|
||||
__m128i sa2 = _mm_slli_epi32(src_pixel2,(24 - SK_A32_SHIFT));
|
||||
sa2 = _mm_srli_epi32(sa2, 24);
|
||||
__m128i sa = _mm_packs_epi32(sa1, sa2);
|
||||
|
||||
// Extract R from src.
|
||||
__m128i sr1 = _mm_slli_epi32(src_pixel1, (24 - SK_R32_SHIFT));
|
||||
__m128i sr1 = _mm_slli_epi32(src_pixel1,(24 - SK_R32_SHIFT));
|
||||
sr1 = _mm_srli_epi32(sr1, 24);
|
||||
__m128i sr2 = _mm_slli_epi32(src_pixel2, (24 - SK_R32_SHIFT));
|
||||
__m128i sr2 = _mm_slli_epi32(src_pixel2,(24 - SK_R32_SHIFT));
|
||||
sr2 = _mm_srli_epi32(sr2, 24);
|
||||
__m128i sr = _mm_packs_epi32(sr1, sr2);
|
||||
|
||||
// Extract G from src.
|
||||
__m128i sg1 = _mm_slli_epi32(src_pixel1, (24 - SK_G32_SHIFT));
|
||||
__m128i sg1 = _mm_slli_epi32(src_pixel1,(24 - SK_G32_SHIFT));
|
||||
sg1 = _mm_srli_epi32(sg1, 24);
|
||||
__m128i sg2 = _mm_slli_epi32(src_pixel2, (24 - SK_G32_SHIFT));
|
||||
__m128i sg2 = _mm_slli_epi32(src_pixel2,(24 - SK_G32_SHIFT));
|
||||
sg2 = _mm_srli_epi32(sg2, 24);
|
||||
__m128i sg = _mm_packs_epi32(sg1, sg2);
|
||||
|
||||
// Extract B from src.
|
||||
__m128i sb1 = _mm_slli_epi32(src_pixel1, (24 - SK_B32_SHIFT));
|
||||
__m128i sb1 = _mm_slli_epi32(src_pixel1,(24 - SK_B32_SHIFT));
|
||||
sb1 = _mm_srli_epi32(sb1, 24);
|
||||
__m128i sb2 = _mm_slli_epi32(src_pixel2, (24 - SK_B32_SHIFT));
|
||||
__m128i sb2 = _mm_slli_epi32(src_pixel2,(24 - SK_B32_SHIFT));
|
||||
sb2 = _mm_srli_epi32(sb2, 24);
|
||||
__m128i sb = _mm_packs_epi32(sb1, sb2);
|
||||
|
||||
// Extract R G B from dst.
|
||||
__m128i dr = _mm_srli_epi16(dst_pixel, SK_R16_SHIFT);
|
||||
__m128i dr = _mm_srli_epi16(dst_pixel,SK_R16_SHIFT);
|
||||
dr = _mm_and_si128(dr, r16_mask);
|
||||
__m128i dg = _mm_srli_epi16(dst_pixel, SK_G16_SHIFT);
|
||||
__m128i dg = _mm_srli_epi16(dst_pixel,SK_G16_SHIFT);
|
||||
dg = _mm_and_si128(dg, g16_mask);
|
||||
__m128i db = _mm_srli_epi16(dst_pixel, SK_B16_SHIFT);
|
||||
__m128i db = _mm_srli_epi16(dst_pixel,SK_B16_SHIFT);
|
||||
db = _mm_and_si128(db, b16_mask);
|
||||
|
||||
__m128i isa = _mm_sub_epi16(var255, sa); // 255 -sa
|
||||
|
||||
// Calculate R G B of result.
|
||||
// Original algorithm is in SkSrcOver32To16().
|
||||
dr = _mm_add_epi16(sr, SkMul16ShiftRound_SSE2(dr, isa, SK_R16_BITS));
|
||||
dr = _mm_add_epi16(sr, SkMul16ShiftRound_SSE(dr, isa, SK_R16_BITS));
|
||||
dr = _mm_srli_epi16(dr, 8 - SK_R16_BITS);
|
||||
dg = _mm_add_epi16(sg, SkMul16ShiftRound_SSE2(dg, isa, SK_G16_BITS));
|
||||
dg = _mm_add_epi16(sg, SkMul16ShiftRound_SSE(dg, isa, SK_G16_BITS));
|
||||
dg = _mm_srli_epi16(dg, 8 - SK_G16_BITS);
|
||||
db = _mm_add_epi16(sb, SkMul16ShiftRound_SSE2(db, isa, SK_B16_BITS));
|
||||
db = _mm_add_epi16(sb, SkMul16ShiftRound_SSE(db, isa, SK_B16_BITS));
|
||||
db = _mm_srli_epi16(db, 8 - SK_B16_BITS);
|
||||
|
||||
// Pack R G B into 16-bit color.
|
||||
__m128i d_pixel = SkPackRGB16_SSE2(dr, dg, db);
|
||||
__m128i d_pixel = SkPackRGB16_SSE(dr, dg, db);
|
||||
|
||||
// Store 8 16-bit colors in dst.
|
||||
_mm_store_si128(d++, d_pixel);
|
||||
|
@ -1143,7 +1143,7 @@ void S32_D565_Opaque_Dither_SSE2(uint16_t* SK_RESTRICT dst,
|
|||
sb = _mm_srli_epi16(sb, SK_B32_BITS - SK_B16_BITS);
|
||||
|
||||
// Pack and store 16-bit dst pixel.
|
||||
__m128i d_pixel = SkPackRGB16_SSE2(sr, sg, sb);
|
||||
__m128i d_pixel = SkPackRGB16_SSE(sr, sg, sb);
|
||||
_mm_store_si128(d++, d_pixel);
|
||||
|
||||
count -= 8;
|
||||
|
@ -1242,9 +1242,9 @@ void S32A_D565_Opaque_Dither_SSE2(uint16_t* SK_RESTRICT dst,
|
|||
__m128i dst_pixel = _mm_load_si128(d);
|
||||
|
||||
// Extract A from src.
|
||||
__m128i sa1 = _mm_slli_epi32(src_pixel1, (24 - SK_A32_SHIFT));
|
||||
__m128i sa1 = _mm_slli_epi32(src_pixel1,(24 - SK_A32_SHIFT));
|
||||
sa1 = _mm_srli_epi32(sa1, 24);
|
||||
__m128i sa2 = _mm_slli_epi32(src_pixel2, (24 - SK_A32_SHIFT));
|
||||
__m128i sa2 = _mm_slli_epi32(src_pixel2,(24 - SK_A32_SHIFT));
|
||||
sa2 = _mm_srli_epi32(sa2, 24);
|
||||
__m128i sa = _mm_packs_epi32(sa1, sa2);
|
||||
|
||||
|
@ -1323,7 +1323,7 @@ void S32A_D565_Opaque_Dither_SSE2(uint16_t* SK_RESTRICT dst,
|
|||
db = _mm_srli_epi16(db, 5);
|
||||
|
||||
// Package and store dst pixel.
|
||||
__m128i d_pixel = SkPackRGB16_SSE2(dr, dg, db);
|
||||
__m128i d_pixel = SkPackRGB16_SSE(dr, dg, db);
|
||||
_mm_store_si128(d++, d_pixel);
|
||||
|
||||
count -= 8;
|
||||
|
|
|
@ -10,39 +10,7 @@
|
|||
|
||||
#include <emmintrin.h>
|
||||
|
||||
// See #define SkAlphaMulAlpha(a, b) SkMulDiv255Round(a, b) in SkXfermode.cpp.
|
||||
static inline __m128i SkAlphaMulAlpha_SSE2(const __m128i& a,
|
||||
const __m128i& b) {
|
||||
__m128i prod = _mm_mullo_epi16(a, b);
|
||||
prod = _mm_add_epi32(prod, _mm_set1_epi32(128));
|
||||
prod = _mm_add_epi32(prod, _mm_srli_epi32(prod, 8));
|
||||
prod = _mm_srli_epi32(prod, 8);
|
||||
|
||||
return prod;
|
||||
}
|
||||
|
||||
static inline __m128i SkGetPackedA32_SSE2(const __m128i& src) {
|
||||
__m128i a = _mm_slli_epi32(src, (24 - SK_A32_SHIFT));
|
||||
return _mm_srli_epi32(a, 24);
|
||||
}
|
||||
|
||||
static inline __m128i SkGetPackedR32_SSE2(const __m128i& src) {
|
||||
__m128i r = _mm_slli_epi32(src, (24 - SK_R32_SHIFT));
|
||||
return _mm_srli_epi32(r, 24);
|
||||
}
|
||||
|
||||
static inline __m128i SkGetPackedG32_SSE2(const __m128i& src) {
|
||||
__m128i g = _mm_slli_epi32(src, (24 - SK_G32_SHIFT));
|
||||
return _mm_srli_epi32(g, 24);
|
||||
}
|
||||
|
||||
static inline __m128i SkGetPackedB32_SSE2(const __m128i& src) {
|
||||
__m128i b = _mm_slli_epi32(src, (24 - SK_B32_SHIFT));
|
||||
return _mm_srli_epi32(b, 24);
|
||||
}
|
||||
|
||||
static inline __m128i SkMul16ShiftRound_SSE2(const __m128i& a,
|
||||
const __m128i& b, int shift) {
|
||||
static inline __m128i SkMul16ShiftRound_SSE(__m128i a, __m128i b, int shift) {
|
||||
__m128i prod = _mm_mullo_epi16(a, b);
|
||||
prod = _mm_add_epi16(prod, _mm_set1_epi16(1 << (shift - 1)));
|
||||
prod = _mm_add_epi16(prod, _mm_srli_epi16(prod, shift));
|
||||
|
@ -51,96 +19,13 @@ static inline __m128i SkMul16ShiftRound_SSE2(const __m128i& a,
|
|||
return prod;
|
||||
}
|
||||
|
||||
static inline __m128i SkPackRGB16_SSE2(const __m128i& r,
|
||||
const __m128i& g, const __m128i& b) {
|
||||
__m128i dr = _mm_slli_epi16(r, SK_R16_SHIFT);
|
||||
__m128i dg = _mm_slli_epi16(g, SK_G16_SHIFT);
|
||||
__m128i db = _mm_slli_epi16(b, SK_B16_SHIFT);
|
||||
static inline __m128i SkPackRGB16_SSE(__m128i r, __m128i g, __m128i b) {
|
||||
r = _mm_slli_epi16(r, SK_R16_SHIFT);
|
||||
g = _mm_slli_epi16(g, SK_G16_SHIFT);
|
||||
b = _mm_slli_epi16(b, SK_B16_SHIFT);
|
||||
|
||||
__m128i c = _mm_or_si128(dr, dg);
|
||||
return _mm_or_si128(c, db);
|
||||
__m128i c = _mm_or_si128(r, g);
|
||||
return _mm_or_si128(c, b);
|
||||
}
|
||||
|
||||
static inline __m128i SkPackARGB32_SSE2(const __m128i& a, const __m128i& r,
|
||||
const __m128i& g, const __m128i& b) {
|
||||
__m128i da = _mm_slli_epi32(a, SK_A32_SHIFT);
|
||||
__m128i dr = _mm_slli_epi32(r, SK_R32_SHIFT);
|
||||
__m128i dg = _mm_slli_epi32(g, SK_G32_SHIFT);
|
||||
__m128i db = _mm_slli_epi32(b, SK_B32_SHIFT);
|
||||
|
||||
__m128i c = _mm_or_si128(da, dr);
|
||||
c = _mm_or_si128(c, dg);
|
||||
return _mm_or_si128(c, db);
|
||||
}
|
||||
|
||||
static inline __m128i SkPacked16ToR32_SSE2(const __m128i& src) {
|
||||
__m128i r = _mm_srli_epi32(src, SK_R16_SHIFT);
|
||||
r = _mm_and_si128(r, _mm_set1_epi32(SK_R16_MASK));
|
||||
r = _mm_or_si128(_mm_slli_epi32(r, (8 - SK_R16_BITS)),
|
||||
_mm_srli_epi32(r, (2 * SK_R16_BITS - 8)));
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline __m128i SkPacked16ToG32_SSE2(const __m128i& src) {
|
||||
__m128i g = _mm_srli_epi32(src, SK_G16_SHIFT);
|
||||
g = _mm_and_si128(g, _mm_set1_epi32(SK_G16_MASK));
|
||||
g = _mm_or_si128(_mm_slli_epi32(g, (8 - SK_G16_BITS)),
|
||||
_mm_srli_epi32(g, (2 * SK_G16_BITS - 8)));
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
static inline __m128i SkPacked16ToB32_SSE2(const __m128i& src) {
|
||||
__m128i b = _mm_srli_epi32(src, SK_B16_SHIFT);
|
||||
b = _mm_and_si128(b, _mm_set1_epi32(SK_B16_MASK));
|
||||
b = _mm_or_si128(_mm_slli_epi32(b, (8 - SK_B16_BITS)),
|
||||
_mm_srli_epi32(b, (2 * SK_B16_BITS - 8)));
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
static inline __m128i SkPixel16ToPixel32_SSE2(const __m128i& src) {
|
||||
__m128i r = SkPacked16ToR32_SSE2(src);
|
||||
__m128i g = SkPacked16ToG32_SSE2(src);
|
||||
__m128i b = SkPacked16ToB32_SSE2(src);
|
||||
|
||||
return SkPackARGB32_SSE2(_mm_set1_epi32(0xFF), r, g, b);
|
||||
}
|
||||
|
||||
static inline __m128i SkPixel32ToPixel16_ToU16_SSE2(const __m128i& src_pixel1,
|
||||
const __m128i& src_pixel2) {
|
||||
// Calculate result r.
|
||||
__m128i r1 = _mm_srli_epi32(src_pixel1,
|
||||
SK_R32_SHIFT + (8 - SK_R16_BITS));
|
||||
r1 = _mm_and_si128(r1, _mm_set1_epi32(SK_R16_MASK));
|
||||
__m128i r2 = _mm_srli_epi32(src_pixel2,
|
||||
SK_R32_SHIFT + (8 - SK_R16_BITS));
|
||||
r2 = _mm_and_si128(r2, _mm_set1_epi32(SK_R16_MASK));
|
||||
__m128i r = _mm_packs_epi32(r1, r2);
|
||||
|
||||
// Calculate result g.
|
||||
__m128i g1 = _mm_srli_epi32(src_pixel1,
|
||||
SK_G32_SHIFT + (8 - SK_G16_BITS));
|
||||
g1 = _mm_and_si128(g1, _mm_set1_epi32(SK_G16_MASK));
|
||||
__m128i g2 = _mm_srli_epi32(src_pixel2,
|
||||
SK_G32_SHIFT + (8 - SK_G16_BITS));
|
||||
g2 = _mm_and_si128(g2, _mm_set1_epi32(SK_G16_MASK));
|
||||
__m128i g = _mm_packs_epi32(g1, g2);
|
||||
|
||||
// Calculate result b.
|
||||
__m128i b1 = _mm_srli_epi32(src_pixel1,
|
||||
SK_B32_SHIFT + (8 - SK_B16_BITS));
|
||||
b1 = _mm_and_si128(b1, _mm_set1_epi32(SK_B16_MASK));
|
||||
__m128i b2 = _mm_srli_epi32(src_pixel2,
|
||||
SK_B32_SHIFT + (8 - SK_B16_BITS));
|
||||
b2 = _mm_and_si128(b2, _mm_set1_epi32(SK_B16_MASK));
|
||||
__m128i b = _mm_packs_epi32(b1, b2);
|
||||
|
||||
// Store 8 16-bit colors in dst.
|
||||
__m128i d_pixel = SkPackRGB16_SSE2(r, g, b);
|
||||
|
||||
return d_pixel;
|
||||
}
|
||||
|
||||
#endif // SkColor_opts_SSE2_DEFINED
|
||||
#endif//SkColor_opts_SSE2_DEFINED
|
||||
|
|
|
@ -1,265 +0,0 @@
|
|||
#include "SkColorPriv.h"
|
||||
#include "SkColor_opts_SSE2.h"
|
||||
#include "SkMathPriv.h"
|
||||
#include "SkXfermode.h"
|
||||
#include "SkXfermode_opts_SSE2.h"
|
||||
#include "SkXfermode_proccoeff.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 4 pixels SSE2 version functions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static inline __m128i SkDiv255Round_SSE2(const __m128i& a) {
|
||||
__m128i prod = _mm_add_epi32(a, _mm_set1_epi32(128)); // prod += 128;
|
||||
prod = _mm_add_epi32(prod, _mm_srli_epi32(prod, 8)); // prod + (prod >> 8)
|
||||
prod = _mm_srli_epi32(prod, 8); // >> 8
|
||||
|
||||
return prod;
|
||||
}
|
||||
|
||||
static inline __m128i clamp_div255round_SSE2(const __m128i& prod) {
|
||||
// test if > 0
|
||||
__m128i cmp1 = _mm_cmpgt_epi32(prod, _mm_setzero_si128());
|
||||
// test if < 255*255
|
||||
__m128i cmp2 = _mm_cmplt_epi32(prod, _mm_set1_epi32(255*255));
|
||||
|
||||
__m128i ret = _mm_setzero_si128();
|
||||
|
||||
// if value >= 255*255, value = 255
|
||||
ret = _mm_andnot_si128(cmp2, _mm_set1_epi32(255));
|
||||
|
||||
__m128i div = SkDiv255Round_SSE2(prod);
|
||||
|
||||
// test if > 0 && < 255*255
|
||||
__m128i cmp = _mm_and_si128(cmp1, cmp2);
|
||||
|
||||
ret = _mm_or_si128(_mm_and_si128(cmp, div), _mm_andnot_si128(cmp, ret));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline __m128i srcover_byte_SSE2(const __m128i& a, const __m128i& b) {
|
||||
// a + b - SkAlphaMulAlpha(a, b);
|
||||
return _mm_sub_epi32(_mm_add_epi32(a, b), SkAlphaMulAlpha_SSE2(a, b));
|
||||
|
||||
}
|
||||
|
||||
static inline __m128i blendfunc_multiply_byte_SSE2(const __m128i& sc, const __m128i& dc,
|
||||
const __m128i& sa, const __m128i& da) {
|
||||
// sc * (255 - da)
|
||||
__m128i ret1 = _mm_sub_epi32(_mm_set1_epi32(255), da);
|
||||
ret1 = _mm_mullo_epi16(sc, ret1);
|
||||
|
||||
// dc * (255 - sa)
|
||||
__m128i ret2 = _mm_sub_epi32(_mm_set1_epi32(255), sa);
|
||||
ret2 = _mm_mullo_epi16(dc, ret2);
|
||||
|
||||
// sc * dc
|
||||
__m128i ret3 = _mm_mullo_epi16(sc, dc);
|
||||
|
||||
__m128i ret = _mm_add_epi32(ret1, ret2);
|
||||
ret = _mm_add_epi32(ret, ret3);
|
||||
|
||||
return clamp_div255round_SSE2(ret);
|
||||
}
|
||||
|
||||
static __m128i multiply_modeproc_SSE2(const __m128i& src, const __m128i& dst) {
|
||||
__m128i sa = SkGetPackedA32_SSE2(src);
|
||||
__m128i da = SkGetPackedA32_SSE2(dst);
|
||||
__m128i a = srcover_byte_SSE2(sa, da);
|
||||
|
||||
__m128i sr = SkGetPackedR32_SSE2(src);
|
||||
__m128i dr = SkGetPackedR32_SSE2(dst);
|
||||
__m128i r = blendfunc_multiply_byte_SSE2(sr, dr, sa, da);
|
||||
|
||||
__m128i sg = SkGetPackedG32_SSE2(src);
|
||||
__m128i dg = SkGetPackedG32_SSE2(dst);
|
||||
__m128i g = blendfunc_multiply_byte_SSE2(sg, dg, sa, da);
|
||||
|
||||
|
||||
__m128i sb = SkGetPackedB32_SSE2(src);
|
||||
__m128i db = SkGetPackedB32_SSE2(dst);
|
||||
__m128i b = blendfunc_multiply_byte_SSE2(sb, db, sa, da);
|
||||
|
||||
return SkPackARGB32_SSE2(a, r, g, b);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern SkXfermodeProcSIMD gSSE2XfermodeProcs[];
|
||||
|
||||
SkSSE2ProcCoeffXfermode::SkSSE2ProcCoeffXfermode(SkReadBuffer& buffer)
|
||||
: INHERITED(buffer) {
|
||||
fProcSIMD = gSSE2XfermodeProcs[this->getMode()];
|
||||
}
|
||||
|
||||
void SkSSE2ProcCoeffXfermode::xfer32(SkPMColor dst[], const SkPMColor src[],
|
||||
int count, const SkAlpha aa[]) const {
|
||||
SkASSERT(dst && src && count >= 0);
|
||||
|
||||
SkXfermodeProc proc = this->getProc();
|
||||
SkXfermodeProcSIMD procSIMD = fProcSIMD;
|
||||
SkASSERT(procSIMD != NULL);
|
||||
|
||||
if (NULL == aa) {
|
||||
if (count >= 4) {
|
||||
while (((size_t)dst & 0x0F) != 0) {
|
||||
*dst = proc(*src, *dst);
|
||||
dst++;
|
||||
src++;
|
||||
count--;
|
||||
}
|
||||
|
||||
const __m128i* s = reinterpret_cast<const __m128i*>(src);
|
||||
__m128i* d = reinterpret_cast<__m128i*>(dst);
|
||||
|
||||
while (count >= 4) {
|
||||
__m128i src_pixel = _mm_loadu_si128(s++);
|
||||
__m128i dst_pixel = _mm_load_si128(d);
|
||||
|
||||
dst_pixel = procSIMD(src_pixel, dst_pixel);
|
||||
_mm_store_si128(d++, dst_pixel);
|
||||
count -= 4;
|
||||
}
|
||||
|
||||
src = reinterpret_cast<const SkPMColor*>(s);
|
||||
dst = reinterpret_cast<SkPMColor*>(d);
|
||||
}
|
||||
|
||||
for (int i = count - 1; i >= 0; --i) {
|
||||
*dst = proc(*src, *dst);
|
||||
dst++;
|
||||
src++;
|
||||
}
|
||||
} else {
|
||||
for (int i = count - 1; i >= 0; --i) {
|
||||
unsigned a = aa[i];
|
||||
if (0 != a) {
|
||||
SkPMColor dstC = dst[i];
|
||||
SkPMColor C = proc(src[i], dstC);
|
||||
if (a != 0xFF) {
|
||||
C = SkFourByteInterp(C, dstC, a);
|
||||
}
|
||||
dst[i] = C;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SkSSE2ProcCoeffXfermode::xfer16(uint16_t dst[], const SkPMColor src[],
|
||||
int count, const SkAlpha aa[]) const {
|
||||
SkASSERT(dst && src && count >= 0);
|
||||
|
||||
SkXfermodeProc proc = this->getProc();
|
||||
SkXfermodeProcSIMD procSIMD = fProcSIMD;
|
||||
SkASSERT(procSIMD != NULL);
|
||||
|
||||
if (NULL == aa) {
|
||||
if (count >= 8) {
|
||||
while (((size_t)dst & 0x0F) != 0) {
|
||||
SkPMColor dstC = SkPixel16ToPixel32(*dst);
|
||||
*dst = SkPixel32ToPixel16_ToU16(proc(*src, dstC));
|
||||
dst++;
|
||||
src++;
|
||||
count--;
|
||||
}
|
||||
|
||||
const __m128i* s = reinterpret_cast<const __m128i*>(src);
|
||||
__m128i* d = reinterpret_cast<__m128i*>(dst);
|
||||
|
||||
while (count >= 8) {
|
||||
__m128i src_pixel1 = _mm_loadu_si128(s++);
|
||||
__m128i src_pixel2 = _mm_loadu_si128(s++);
|
||||
__m128i dst_pixel = _mm_load_si128(d);
|
||||
|
||||
__m128i dst_pixel1 = _mm_unpacklo_epi16(dst_pixel, _mm_setzero_si128());
|
||||
__m128i dst_pixel2 = _mm_unpackhi_epi16(dst_pixel, _mm_setzero_si128());
|
||||
|
||||
__m128i dstC1 = SkPixel16ToPixel32_SSE2(dst_pixel1);
|
||||
__m128i dstC2 = SkPixel16ToPixel32_SSE2(dst_pixel2);
|
||||
|
||||
dst_pixel1 = procSIMD(src_pixel1, dstC1);
|
||||
dst_pixel2 = procSIMD(src_pixel2, dstC2);
|
||||
dst_pixel = SkPixel32ToPixel16_ToU16_SSE2(dst_pixel1, dst_pixel2);
|
||||
|
||||
_mm_store_si128(d++, dst_pixel);
|
||||
count -= 8;
|
||||
}
|
||||
|
||||
src = reinterpret_cast<const SkPMColor*>(s);
|
||||
dst = reinterpret_cast<uint16_t*>(d);
|
||||
}
|
||||
|
||||
for (int i = count - 1; i >= 0; --i) {
|
||||
SkPMColor dstC = SkPixel16ToPixel32(*dst);
|
||||
*dst = SkPixel32ToPixel16_ToU16(proc(*src, dstC));
|
||||
dst++;
|
||||
src++;
|
||||
}
|
||||
} else {
|
||||
for (int i = count - 1; i >= 0; --i) {
|
||||
unsigned a = aa[i];
|
||||
if (0 != a) {
|
||||
SkPMColor dstC = SkPixel16ToPixel32(dst[i]);
|
||||
SkPMColor C = proc(src[i], dstC);
|
||||
if (0xFF != a) {
|
||||
C = SkFourByteInterp(C, dstC, a);
|
||||
}
|
||||
dst[i] = SkPixel32ToPixel16_ToU16(C);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef SK_IGNORE_TO_STRING
|
||||
void SkSSE2ProcCoeffXfermode::toString(SkString* str) const {
|
||||
this->INHERITED::toString(str);
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// 4 pixels modeprocs with SSE2
|
||||
SkXfermodeProcSIMD gSSE2XfermodeProcs[] = {
|
||||
NULL, // kClear_Mode
|
||||
NULL, // kSrc_Mode
|
||||
NULL, // kDst_Mode
|
||||
NULL, // kSrcOver_Mode
|
||||
NULL, // kDstOver_Mode
|
||||
NULL, // kSrcIn_Mode
|
||||
NULL, // kDstIn_Mode
|
||||
NULL, // kSrcOut_Mode
|
||||
NULL, // kDstOut_Mode
|
||||
NULL, // kSrcATop_Mode
|
||||
NULL, // kDstATop_Mode
|
||||
NULL, // kXor_Mode
|
||||
NULL, // kPlus_Mode
|
||||
NULL, // kModulate_Mode
|
||||
NULL, // kScreen_Mode
|
||||
|
||||
NULL, // kOverlay_Mode
|
||||
NULL, // kDarken_Mode
|
||||
NULL, // kLighten_Mode
|
||||
NULL, // kColorDodge_Mode
|
||||
NULL, // kColorBurn_Mode
|
||||
NULL, // kHardLight_Mode
|
||||
NULL, // kSoftLight_Mode
|
||||
NULL, // kDifference_Mode
|
||||
NULL, // kExclusion_Mode
|
||||
multiply_modeproc_SSE2,
|
||||
|
||||
NULL, // kHue_Mode
|
||||
NULL, // kSaturation_Mode
|
||||
NULL, // kColor_Mode
|
||||
NULL, // kLuminosity_Mode
|
||||
};
|
||||
|
||||
SkProcCoeffXfermode* SkPlatformXfermodeFactory_impl_SSE2(const ProcCoeff& rec,
|
||||
SkXfermode::Mode mode) {
|
||||
SkXfermodeProcSIMD procSIMD = gSSE2XfermodeProcs[mode];
|
||||
|
||||
if (procSIMD != NULL) {
|
||||
return SkNEW_ARGS(SkSSE2ProcCoeffXfermode, (rec, mode, procSIMD));
|
||||
}
|
||||
return NULL;
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
#ifndef SkXfermode_opts_SSE2_DEFINED
|
||||
#define SkXfermode_opts_SSE2_DEFINED
|
||||
|
||||
#include "SkXfermode_proccoeff.h"
|
||||
|
||||
typedef __m128i (*SkXfermodeProcSIMD)(const __m128i& src, const __m128i& dst);
|
||||
|
||||
class SkSSE2ProcCoeffXfermode : public SkProcCoeffXfermode {
|
||||
public:
|
||||
SkSSE2ProcCoeffXfermode(const ProcCoeff& rec, SkXfermode::Mode mode,
|
||||
SkXfermodeProcSIMD procSIMD)
|
||||
: INHERITED(rec, mode), fProcSIMD(procSIMD) {}
|
||||
|
||||
virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
|
||||
const SkAlpha aa[]) const SK_OVERRIDE;
|
||||
virtual void xfer16(uint16_t dst[], const SkPMColor src[],
|
||||
int count, const SkAlpha aa[]) const SK_OVERRIDE;
|
||||
|
||||
SK_TO_STRING_OVERRIDE()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSSE2ProcCoeffXfermode)
|
||||
|
||||
private:
|
||||
SkSSE2ProcCoeffXfermode(SkReadBuffer& buffer);
|
||||
|
||||
SkXfermodeProcSIMD fProcSIMD;
|
||||
typedef SkProcCoeffXfermode INHERITED;
|
||||
};
|
||||
|
||||
SkProcCoeffXfermode* SkPlatformXfermodeFactory_impl_SSE2(const ProcCoeff& rec,
|
||||
SkXfermode::Mode mode);
|
||||
|
||||
#endif // SkXfermode_opts_SSE2_DEFINED
|
|
@ -17,8 +17,6 @@
|
|||
#include "SkUtils.h"
|
||||
#include "SkMorphology_opts.h"
|
||||
#include "SkMorphology_opts_SSE2.h"
|
||||
#include "SkXfermode.h"
|
||||
#include "SkXfermode_proccoeff.h"
|
||||
|
||||
#include "SkRTConf.h"
|
||||
|
||||
|
@ -309,32 +307,3 @@ SkBlitRow::ColorRectProc PlatformColorRectProcFactory() {
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
extern SkProcCoeffXfermode* SkPlatformXfermodeFactory_impl_SSE2(const ProcCoeff& rec,
|
||||
SkXfermode::Mode mode);
|
||||
|
||||
SkProcCoeffXfermode* SkPlatformXfermodeFactory_impl(const ProcCoeff& rec,
|
||||
SkXfermode::Mode mode);
|
||||
|
||||
SkProcCoeffXfermode* SkPlatformXfermodeFactory_impl(const ProcCoeff& rec,
|
||||
SkXfermode::Mode mode) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SkProcCoeffXfermode* SkPlatformXfermodeFactory(const ProcCoeff& rec,
|
||||
SkXfermode::Mode mode);
|
||||
|
||||
SkProcCoeffXfermode* SkPlatformXfermodeFactory(const ProcCoeff& rec,
|
||||
SkXfermode::Mode mode) {
|
||||
if (cachedHasSSE2()) {
|
||||
return SkPlatformXfermodeFactory_impl_SSE2(rec, mode);
|
||||
} else {
|
||||
return SkPlatformXfermodeFactory_impl(rec, mode);
|
||||
}
|
||||
}
|
||||
|
||||
SkXfermodeProc SkPlatformXfermodeProcFactory(SkXfermode::Mode mode);
|
||||
|
||||
SkXfermodeProc SkPlatformXfermodeProcFactory(SkXfermode::Mode mode) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче