diff options
author | thestig <thestig@chromium.org> | 2016-05-20 11:50:06 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-20 11:50:06 -0700 |
commit | 1b99b2dcde9d8bf1a5944a7e0dac81ca33459af5 (patch) | |
tree | 50ce9fbd5fadac593fc0af976de6841e55e22fdf /core/fxge/skia | |
parent | 3cbb6fbcc7077d94161ec95b7bc1421671317c65 (diff) | |
download | pdfium-1b99b2dcde9d8bf1a5944a7e0dac81ca33459af5.tar.xz |
Merge GetBits32() impls into one. Put it in fxcrt.
Review-Url: https://codereview.chromium.org/1990153003
Diffstat (limited to 'core/fxge/skia')
-rw-r--r-- | core/fxge/skia/fx_skia_device.cpp | 30 | ||||
-rw-r--r-- | core/fxge/skia/fx_skia_device_unittest.cpp | 31 |
2 files changed, 0 insertions, 61 deletions
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index 3168e2251b..177f10c5b9 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -174,36 +174,6 @@ bool AddColors(const CPDF_ExpIntFunc* pFunc, SkTDArray<SkColor>* skColors) { return true; } -uint32_t GetBits32(const uint8_t* pData, int bitpos, int nbits) { - ASSERT(0 < nbits && nbits <= 32); - const uint8_t* dataPtr = &pData[bitpos / 8]; - int bitShift; - int bitMask; - int dstShift; - int bitCount = bitpos & 0x07; - if (nbits < 8 && nbits + bitCount <= 8) { - bitShift = 8 - nbits - bitCount; - bitMask = (1 << nbits) - 1; - dstShift = 0; - } else { - bitShift = 0; - int bitOffset = 8 - bitCount; - bitMask = (1 << SkTMin(bitOffset, nbits)) - 1; - dstShift = nbits - bitOffset; - } - uint32_t result = (uint32_t)(*dataPtr++ >> bitShift & bitMask) << dstShift; - while (dstShift >= 8) { - dstShift -= 8; - result |= *dataPtr++ << dstShift; - } - if (dstShift > 0) { - bitShift = 8 - dstShift; - bitMask = (1 << dstShift) - 1; - result |= *dataPtr++ >> bitShift & bitMask; - } - return result; -} - uint8_t FloatToByte(FX_FLOAT f) { ASSERT(0 <= f && f <= 1); return (uint8_t)(f * 255.99f); diff --git a/core/fxge/skia/fx_skia_device_unittest.cpp b/core/fxge/skia/fx_skia_device_unittest.cpp deleted file mode 100644 index 57a4ec140b..0000000000 --- a/core/fxge/skia/fx_skia_device_unittest.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "core/fxge/skia/fx_skia_device.cpp" -#include "testing/fx_string_testhelpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -uint32_t _GetBits32(const uint8_t* pData, int bitpos, int nbits) { - int result = 0; - for (int i = 0; i < nbits; i++) - if (pData[(bitpos + i) / 8] & (1 << (7 - (bitpos + i) % 8))) { - result |= 1 << (nbits - i - 1); - } - return result; -} - -} // namespace - -TEST(fxge, GetBits32) { - unsigned char data[] = {0xDE, 0x3F, 0xB1, 0x7C, 0x12, 0x9A, 0x04, 0x56}; - for (int nbits = 1; nbits <= 32; ++nbits) { - for (int bitpos = 0; bitpos < (int)sizeof(data) * 8 - nbits; ++bitpos) { - uint32_t ref = _GetBits32(data, bitpos, nbits); - uint32_t test = GetBits32(data, bitpos, nbits); - EXPECT_TRUE(ref == test); - } - } -} |