Bug 1189593 - Only use SSE2 in image::Downscaler if we're running on an SSE2-capable machine. r=tn, a=sledru
authorSeth Fowler <mark.seth.fowler@gmail.com>
Thu, 30 Jul 2015 19:48:22 -0700
changeset 291361 525d29ba77a74fb822674d2e3ce2ec7ee04b72fa
parent 291360 160be60325190b765549a02858192051f64f1a36
child 291362 34e00eb800c52e33059d37f6e41fb255b4bae6b8
push id5246
push usermozilla@noorenberghe.ca
push dateWed, 09 Sep 2015 21:17:14 +0000
reviewerstn, sledru
bugs1189593
milestone40.0
Bug 1189593 - Only use SSE2 in image::Downscaler if we're running on an SSE2-capable machine. r=tn, a=sledru
image/src/Downscaler.cpp
--- a/image/src/Downscaler.cpp
+++ b/image/src/Downscaler.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "Downscaler.h"
 
 #include <algorithm>
 #include <ctime>
 #include "gfxPrefs.h"
 #include "image_operations.h"
+#include "mozilla/SSE.h"
 #include "convolver.h"
 #include "skia/SkTypes.h"
 
 using std::max;
 using std::swap;
 
 namespace mozilla {
 namespace image {
@@ -154,17 +155,17 @@ Downscaler::CommitRow()
   GetFilterOffsetAndLength(mYFilter, mCurrentOutLine,
                            &filterOffset, &filterLength);
 
   int32_t inLineToRead = filterOffset + mLinesInBuffer;
   MOZ_ASSERT(mCurrentInLine <= inLineToRead, "Reading past end of input");
   if (mCurrentInLine == inLineToRead) {
     skia::ConvolveHorizontally(mRowBuffer.get(), *mXFilter,
                                mWindow[mLinesInBuffer++], mHasAlpha,
-                               /* use_sse2 = */ true);
+                               supports_sse2());
   }
 
   MOZ_ASSERT(mCurrentOutLine < mTargetSize.height,
              "Writing past end of output");
 
   while (mLinesInBuffer == filterLength) {
     DownscaleInputLine();
 
@@ -221,17 +222,17 @@ Downscaler::DownscaleInputLine()
   MOZ_ASSERT(mCurrentOutLine < mYFilter->num_values());
   auto filterValues =
     mYFilter->FilterForValue(mCurrentOutLine, &filterOffset, &filterLength);
 
   uint8_t* outputLine =
     &mOutputBuffer[mCurrentOutLine * mTargetSize.width * sizeof(uint32_t)];
   skia::ConvolveVertically(static_cast<const FilterValue*>(filterValues),
                            filterLength, mWindow.get(), mXFilter->num_values(),
-                           outputLine, mHasAlpha, /* use_sse2 = */ true);
+                           outputLine, mHasAlpha, supports_sse2());
 
   mCurrentOutLine += 1;
 
   if (mCurrentOutLine == mTargetSize.height) {
     // We're done.
     return;
   }