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

Unified Diff: src/opts/SkPMFloat_sse.h

Issue 1288323004: Patches on top of Radu's latest. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: const 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 side-by-side diff with in-line comments
Download patch
« src/opts/SkColorCubeFilter_opts.h ('K') | « src/opts/SkPMFloat_none.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/opts/SkPMFloat_sse.h
diff --git a/src/opts/SkPMFloat_sse.h b/src/opts/SkPMFloat_sse.h
index 85503886a66b5e3cdf19decaf0468fc6e4af6931..6cfee1da6fe8df4f24f6df23be921e8c20e55d17 100644
--- a/src/opts/SkPMFloat_sse.h
+++ b/src/opts/SkPMFloat_sse.h
@@ -38,4 +38,29 @@ inline Sk4f SkPMFloat::alphas() const {
return _mm_shuffle_ps(fVec, fVec, 0xff); // Read as 11 11 11 11, copying lane 3 to all lanes.
}
+inline SkPMFloat SkPMFloat::FromBGRx(SkColor c) {
+ __m128i fix8 = _mm_cvtsi32_si128((int)c);
+#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSSE3
+ const char _ = ~0; // Zero these bytes.
+ __m128i fix8_32 = _mm_shuffle_epi8(fix8,
+ #if defined(SK_PMCOLOR_IS_BGRA)
+ _mm_setr_epi8(0,_,_,_, 1,_,_,_, 2,_,_,_, _,_,_,_)
+ #else
+ _mm_setr_epi8(2,_,_,_, 1,_,_,_, 0,_,_,_, _,_,_,_)
+ #endif
+ );
+#else
+ __m128i fix8_16 = _mm_unpacklo_epi8 (fix8 , _mm_setzero_si128()),
+ fix8_32 = _mm_unpacklo_epi16(fix8_16, _mm_setzero_si128());
+ #if defined(SK_PMCOLOR_IS_RGBA)
+ fix8_32 = _mm_shuffle_epi32(fix8_32, 0xC6); // C6 == 11 00 01 10, i.e swap lanes 0 and 2.
+ #endif
+#endif
+ fix8_32 = _mm_or_si128(fix8_32, _mm_set_epi32(0xFF,0,0,0)); // Force alpha to 1.
+
+ SkPMFloat pmf = Sk4f(_mm_mul_ps(_mm_cvtepi32_ps(fix8_32), _mm_set1_ps(1.0f/255)));
+ SkASSERT(pmf.isValid());
+ return pmf;
+}
+
} // namespace
« src/opts/SkColorCubeFilter_opts.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