Bug 1300656 - Optimize gfxUtils::ConvertBGRAtoRGBA() r=jrmuizel
authorSotaro Ikeda <sotaro.ikeda.g@gmail.com>
Mon, 12 Sep 2016 22:19:29 -0700
changeset 313655 c75b43f81d5c17eed6f888b1b0de1cfe06bec333
parent 313654 db9b0546e3d48632b0d33361786dc894d23f9dd1
child 313656 dac96d576734fbbeb06ecd236fb473e22c430136
push id20528
push userryanvm@gmail.com
push dateWed, 14 Sep 2016 00:48:16 +0000
treeherderfx-team@8a996d7c71a2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1300656
milestone51.0a1
Bug 1300656 - Optimize gfxUtils::ConvertBGRAtoRGBA() r=jrmuizel
gfx/thebes/gfxUtils.cpp
gfx/thebes/moz.build
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -7,16 +7,17 @@
 
 #include "cairo.h"
 #include "gfxContext.h"
 #include "gfxEnv.h"
 #include "gfxImageSurface.h"
 #include "gfxPlatform.h"
 #include "gfxDrawable.h"
 #include "imgIEncoder.h"
+#include "libyuv.h"
 #include "mozilla/Base64.h"
 #include "mozilla/dom/ImageEncoder.h"
 #include "mozilla/dom/WorkerPrivate.h"
 #include "mozilla/dom/WorkerRunnable.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/DataSurfaceHelpers.h"
 #include "mozilla/gfx/Logging.h"
 #include "mozilla/Maybe.h"
@@ -368,30 +369,17 @@ gfxUtils::CreateUnpremultipliedDataSurfa
     UnmapSrcDest(srcSurf, destSurf);
     return destSurf.forget();
 }
 
 void
 gfxUtils::ConvertBGRAtoRGBA(uint8_t* aData, uint32_t aLength)
 {
     MOZ_ASSERT((aLength % 4) == 0, "Loop below will pass srcEnd!");
-
-    uint8_t *src = aData;
-    uint8_t *srcEnd = src + aLength;
-
-    uint8_t buffer[4];
-    for (; src != srcEnd; src += 4) {
-        buffer[0] = src[2];
-        buffer[1] = src[1];
-        buffer[2] = src[0];
-
-        src[0] = buffer[0];
-        src[1] = buffer[1];
-        src[2] = buffer[2];
-    }
+    libyuv::ABGRToARGB(aData, aLength, aData, aLength, aLength / 4, 1);
 }
 
 #if !defined(MOZ_GFX_OPTIMIZE_MOBILE)
 /**
  * This returns the fastest operator to use for solid surfaces which have no
  * alpha channel or their alpha channel is uniformly opaque.
  * This differs per render mode.
  */
--- a/gfx/thebes/moz.build
+++ b/gfx/thebes/moz.build
@@ -279,14 +279,15 @@ CFLAGS += CONFIG['TK_CFLAGS']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gonk'):
     CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3'):
     CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
 
 LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES']
+LOCAL_INCLUDES += ['/media/libyuv/include']
 
 DEFINES['GRAPHITE2_STATIC'] = True
 
 if CONFIG['CLANG_CXX']:
     # Suppress warnings from Skia header files.
     SOURCES['gfxPlatform.cpp'].flags += ['-Wno-implicit-fallthrough']