diff options
author | tomhudson <tomhudson@google.com> | 2016-03-25 06:35:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-25 13:36:26 +0000 |
commit | 0e04f751520635f9af9f0bee203d93149d131466 (patch) | |
tree | 2dd322fc48f7c2c8044752d13500f9211f146367 /content | |
parent | 20e9046de67126b2c5c4699466675b3f0b1fc356 (diff) | |
download | chromium_src-0e04f751520635f9af9f0bee203d93149d131466.zip chromium_src-0e04f751520635f9af9f0bee203d93149d131466.tar.gz chromium_src-0e04f751520635f9af9f0bee203d93149d131466.tar.bz2 |
Use Skia's NEON/SSSE3 accelerated swizzles
In image decoding benchmarks these have provided 3x-12x (!) speedup to the swizzle step with SSSE3 support (~15% speedup to the entire image decode), and a more modest 5%-20% with NEON.
BUG=543755
Review URL: https://codereview.chromium.org/1821393004
Cr-Commit-Position: refs/heads/master@{#383274}
Diffstat (limited to 'content')
-rw-r--r-- | content/renderer/pepper/pepper_graphics_2d_host.cc | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/content/renderer/pepper/pepper_graphics_2d_host.cc b/content/renderer/pepper/pepper_graphics_2d_host.cc index c6451a1..1398942 100644 --- a/content/renderer/pepper/pepper_graphics_2d_host.cc +++ b/content/renderer/pepper/pepper_graphics_2d_host.cc @@ -36,6 +36,7 @@ #include "ppapi/thunk/enter.h" #include "skia/ext/platform_canvas.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "third_party/skia/include/core/SkSwizzle.h" #include "ui/gfx/blit.h" #include "ui/gfx/geometry/point_conversions.h" #include "ui/gfx/geometry/rect.h" @@ -89,21 +90,6 @@ bool ValidateAndConvertRect(const PP_Rect* rect, return true; } -// Converts BGRA <-> RGBA. -void ConvertBetweenBGRAandRGBA(const uint32_t* input, - int pixel_length, - uint32_t* output) { - for (int i = 0; i < pixel_length; i++) { - const unsigned char* pixel_in = - reinterpret_cast<const unsigned char*>(&input[i]); - unsigned char* pixel_out = reinterpret_cast<unsigned char*>(&output[i]); - pixel_out[0] = pixel_in[2]; - pixel_out[1] = pixel_in[1]; - pixel_out[2] = pixel_in[0]; - pixel_out[3] = pixel_in[3]; - } -} - // Converts ImageData from PP_IMAGEDATAFORMAT_BGRA_PREMUL to // PP_IMAGEDATAFORMAT_RGBA_PREMUL, or reverse. It's assumed that the // destination image is always mapped (so will have non-NULL data). @@ -121,22 +107,22 @@ void ConvertImageData(PPB_ImageData_Impl* src_image, const SkBitmap* dest_bitmap = dest_image->GetMappedBitmap(); if (src_rect.width() == src_image->width() && dest_rect.width() == dest_image->width()) { - // Fast path if the full line needs to be converted. - ConvertBetweenBGRAandRGBA( + // Fast path if the full frame can be converted at once. + SkSwapRB( + dest_bitmap->getAddr32(static_cast<int>(dest_rect.fLeft), + static_cast<int>(dest_rect.fTop)), src_bitmap->getAddr32(static_cast<int>(src_rect.fLeft), static_cast<int>(src_rect.fTop)), - src_rect.width() * src_rect.height(), - dest_bitmap->getAddr32(static_cast<int>(dest_rect.fLeft), - static_cast<int>(dest_rect.fTop))); + src_rect.width() * src_rect.height()); } else { // Slow path where we convert line by line. for (int y = 0; y < src_rect.height(); y++) { - ConvertBetweenBGRAandRGBA( + SkSwapRB( + dest_bitmap->getAddr32(static_cast<int>(dest_rect.fLeft), + static_cast<int>(dest_rect.fTop + y)), src_bitmap->getAddr32(static_cast<int>(src_rect.fLeft), static_cast<int>(src_rect.fTop + y)), - src_rect.width(), - dest_bitmap->getAddr32(static_cast<int>(dest_rect.fLeft), - static_cast<int>(dest_rect.fTop + y))); + src_rect.width()); } } } |