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

Unified Diff: src/opts/SkPMFloat_SSE2.h

Issue 973603002: Make SkPMFloats store floats in [0,255] instead of [0,1]. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: restore comment Created 5 years, 10 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
« no previous file with comments | « src/core/SkPMFloat.h ('k') | src/opts/SkPMFloat_neon.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/opts/SkPMFloat_SSE2.h
diff --git a/src/opts/SkPMFloat_SSE2.h b/src/opts/SkPMFloat_SSE2.h
index c3dbbf2cb50d655fb77d840a7ace132f5cec7cb7..f28608079f3a4ac9a41a6c4bcc5c941261c4dbf9 100644
--- a/src/opts/SkPMFloat_SSE2.h
+++ b/src/opts/SkPMFloat_SSE2.h
@@ -2,11 +2,10 @@
#include <emmintrin.h>
// For set(), we widen our 8 bit components (fix8) to 8-bit components in 16 bits (fix8_16),
-// then widen those to 8-bit-in-32-bits (fix8_32), convert those to floats (scaled),
-// then finally scale those down from [0.0f, 255.0f] to [0.0f, 1.0f] into fColor.
+// then widen those to 8-bit-in-32-bits (fix8_32), and finally convert those to floats.
-// get() and clamped() do the opposite, working from [0.0f, 1.0f] floats to [0.0f, 255.0f],
-// to 8-bit-in-32-bit, to 8-bit-in-16-bit, back down to 8-bit components.
+// get() and clamped() do the opposite, working from floats to 8-bit-in-32-bit,
+// to 8-bit-in-16-bit, back down to 8-bit components.
// _mm_packus_epi16() gives us clamping for free while narrowing.
inline void SkPMFloat::set(SkPMColor c) {
@@ -14,8 +13,7 @@ inline void SkPMFloat::set(SkPMColor c) {
__m128i fix8 = _mm_set_epi32(0,0,0,c),
fix8_16 = _mm_unpacklo_epi8 (fix8, _mm_setzero_si128()),
fix8_32 = _mm_unpacklo_epi16(fix8_16, _mm_setzero_si128());
- __m128 scaled = _mm_cvtepi32_ps(fix8_32);
- _mm_store_ps(fColor, _mm_mul_ps(scaled, _mm_set1_ps(1.0f/255.0f)));
+ _mm_store_ps(fColor, _mm_cvtepi32_ps(fix8_32));
msarett 2015/03/03 14:34:28 I think we might be able to improve performance a
mtklein 2015/03/03 15:02:17 The reason I've shied away from intrinsics like _m
SkASSERT(this->isValid());
msarett 2015/03/03 14:34:28 I'm starting another comment for another train of
mtklein 2015/03/03 15:02:17 Yep, totally agree. We're thinking the next logic
}
@@ -25,8 +23,7 @@ inline SkPMColor SkPMFloat::get() const {
}
inline SkPMColor SkPMFloat::clamped() const {
- __m128 scaled = _mm_mul_ps(_mm_load_ps(fColor), _mm_set1_ps(255.0f));
- __m128i fix8_32 = _mm_cvtps_epi32(scaled),
+ __m128i fix8_32 = _mm_cvtps_epi32(_mm_load_ps(fColor)),
fix8_16 = _mm_packus_epi16(fix8_32, fix8_32),
fix8 = _mm_packus_epi16(fix8_16, fix8_16);
SkPMColor c = _mm_cvtsi128_si32(fix8);
« no previous file with comments | « src/core/SkPMFloat.h ('k') | src/opts/SkPMFloat_neon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698