diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-08-06 18:17:23 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-08-06 18:17:23 +0000 |
commit | 29201324de188dc3f88d835a90af18e10f5ff868 (patch) | |
tree | 9b7edf4fa8b878136d1d9f9fd54372fe0e670d2f /core/fxcodec/jbig2/JBig2_Image_unittest.cpp | |
parent | 475565477e431cd2925a6192b348d142beb21b4d (diff) | |
download | pdfium-29201324de188dc3f88d835a90af18e10f5ff868.tar.xz |
Small optimization in CJBig2_Image::SubImage()
We can use the memcpy() path whenever byte aligned.
Split code into helper methods.
Add test for fast path specifically.
Change-Id: I52f6129b0e788eb2da60536cfa6fce12a0609375
Reviewed-on: https://pdfium-review.googlesource.com/39432
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcodec/jbig2/JBig2_Image_unittest.cpp')
-rw-r--r-- | core/fxcodec/jbig2/JBig2_Image_unittest.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/core/fxcodec/jbig2/JBig2_Image_unittest.cpp b/core/fxcodec/jbig2/JBig2_Image_unittest.cpp index 4b078324e1..13e6eb5691 100644 --- a/core/fxcodec/jbig2/JBig2_Image_unittest.cpp +++ b/core/fxcodec/jbig2/JBig2_Image_unittest.cpp @@ -219,6 +219,15 @@ TEST(fxcodec, JBig2SubImage) { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, }; + // 1-px wide rectangle in image, offset 16 in x, 1 in y, padded. + uint8_t pattern161[5][8] = { + {0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + }; + // Image size a nice clean power of two. auto img32 = pdfium::MakeUnique<CJBig2_Image>( 32, 5, 8, reinterpret_cast<uint8_t*>(pattern)); @@ -234,6 +243,9 @@ TEST(fxcodec, JBig2SubImage) { auto expected22 = pdfium::MakeUnique<CJBig2_Image>( 30, 5, 8, reinterpret_cast<uint8_t*>(pattern22)); + auto expected161 = pdfium::MakeUnique<CJBig2_Image>( + 25, 5, 8, reinterpret_cast<uint8_t*>(pattern161)); + auto expected_zeros = pdfium::MakeUnique<CJBig2_Image>(32, 5); // Empty subimage. @@ -259,6 +271,10 @@ TEST(fxcodec, JBig2SubImage) { sub = img37->SubImage(2, 2, 30, 5); CheckImageEq(expected22.get(), sub.get(), __LINE__); + // Fast path. + sub = img37->SubImage(16, 1, 25, 5); + CheckImageEq(expected161.get(), sub.get(), __LINE__); + // Aligned Sub-image including cruft in stride beyond width. sub = img37->SubImage(32, 0, 32, 5); CheckImageEq(expected_zeros.get(), sub.get(), __LINE__); |