Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/opts/SkPMFloat_sse.h

Issue 1295873004: SkColorCubeFilter: require alpha == 0xFF. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: just perf Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/opts/SkPMFloat_none.h ('K') | « src/opts/SkPMFloat_none.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 namespace { // See SkPMFloat.h 8 namespace { // See SkPMFloat.h
9 9
10 inline SkPMFloat::SkPMFloat(SkPMColor c) { 10 inline SkPMFloat::SkPMFloat(SkPMColor c) {
(...skipping 20 matching lines...) Expand all
31 SkPMColor c = _mm_cvtsi128_si32(fix8); 31 SkPMColor c = _mm_cvtsi128_si32(fix8);
32 SkPMColorAssert(c); 32 SkPMColorAssert(c);
33 return c; 33 return c;
34 } 34 }
35 35
36 inline Sk4f SkPMFloat::alphas() const { 36 inline Sk4f SkPMFloat::alphas() const {
37 static_assert(SK_A32_SHIFT == 24, ""); 37 static_assert(SK_A32_SHIFT == 24, "");
38 return _mm_shuffle_ps(fVec, fVec, 0xff); // Read as 11 11 11 11, copying la ne 3 to all lanes. 38 return _mm_shuffle_ps(fVec, fVec, 0xff); // Read as 11 11 11 11, copying la ne 3 to all lanes.
39 } 39 }
40 40
41 inline SkPMFloat SkPMFloat::FromBGRx(SkColor c) { 41 inline SkPMFloat SkPMFloat::FromOpaqueColor(SkColor c) {
42 SkASSERT(SkColorGetA(c) == 0xFF);
42 __m128i fix8 = _mm_cvtsi32_si128((int)c); 43 __m128i fix8 = _mm_cvtsi32_si128((int)c);
43 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSSE3 44 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSSE3
44 const char _ = ~0; // Zero these bytes. 45 const char _ = ~0; // Zero these bytes.
45 __m128i fix8_32 = _mm_shuffle_epi8(fix8, 46 __m128i fix8_32 = _mm_shuffle_epi8(fix8,
46 #if defined(SK_PMCOLOR_IS_BGRA) 47 #if defined(SK_PMCOLOR_IS_BGRA)
47 _mm_setr_epi8(0,_,_,_, 1,_,_,_, 2,_,_,_, _,_,_,_) 48 _mm_setr_epi8(0,_,_,_, 1,_,_,_, 2,_,_,_, 3,_,_,_)
48 #else 49 #else
49 _mm_setr_epi8(2,_,_,_, 1,_,_,_, 0,_,_,_, _,_,_,_) 50 _mm_setr_epi8(2,_,_,_, 1,_,_,_, 0,_,_,_, 3,_,_,_)
50 #endif 51 #endif
51 ); 52 );
52 #else 53 #else
53 __m128i fix8_16 = _mm_unpacklo_epi8 (fix8 , _mm_setzero_si128()), 54 __m128i fix8_16 = _mm_unpacklo_epi8 (fix8 , _mm_setzero_si128()),
54 fix8_32 = _mm_unpacklo_epi16(fix8_16, _mm_setzero_si128()); 55 fix8_32 = _mm_unpacklo_epi16(fix8_16, _mm_setzero_si128());
55 #if defined(SK_PMCOLOR_IS_RGBA) 56 #if defined(SK_PMCOLOR_IS_RGBA)
56 fix8_32 = _mm_shuffle_epi32(fix8_32, 0xC6); // C6 == 11 00 01 10, i.e s wap lanes 0 and 2. 57 fix8_32 = _mm_shuffle_epi32(fix8_32, 0xC6); // C6 == 11 00 01 10, i.e s wap lanes 0 and 2.
57 #endif 58 #endif
58 #endif 59 #endif
59 fix8_32 = _mm_or_si128(fix8_32, _mm_set_epi32(0xFF,0,0,0)); // Force alpha to 1.
Noel Gordon 2015/08/20 01:43:29 Very cool; less instructions generally means more
mtklein 2015/08/20 01:55:17 Yeah, _mm_set_ps doesn't really correspond to any
60
61 SkPMFloat pmf = Sk4f(_mm_mul_ps(_mm_cvtepi32_ps(fix8_32), _mm_set1_ps(1.0f/2 55))); 60 SkPMFloat pmf = Sk4f(_mm_mul_ps(_mm_cvtepi32_ps(fix8_32), _mm_set1_ps(1.0f/2 55)));
62 SkASSERT(pmf.isValid()); 61 SkASSERT(pmf.isValid());
63 return pmf; 62 return pmf;
64 } 63 }
65 64
66 } // namespace 65 } // namespace
OLDNEW
« src/opts/SkPMFloat_none.h ('K') | « src/opts/SkPMFloat_none.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698