diff options
author | Lei Zhang <thestig@chromium.org> | 2018-03-01 15:23:58 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-03-01 15:23:58 +0000 |
commit | 198792b7e860702840287e8d561a21dfa973aaa4 (patch) | |
tree | 83c0886f263c1ffd6910542f16d60afc764ad9bd /core/fxge | |
parent | 9002cd8cb5c95152a05a8923f0ed06c38ca0730d (diff) | |
download | pdfium-198792b7e860702840287e8d561a21dfa973aaa4.tar.xz |
Fix some nits in CFX_DIBSource::CloneConvert().
Change-Id: I25c16b7159d168bd6deb4fd9936bb242d7e8c590
Reviewed-on: https://pdfium-review.googlesource.com/27812
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxge')
-rw-r--r-- | core/fxge/dib/cfx_dibsource.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/core/fxge/dib/cfx_dibsource.cpp b/core/fxge/dib/cfx_dibsource.cpp index eda6d9efda..c91cd849a8 100644 --- a/core/fxge/dib/cfx_dibsource.cpp +++ b/core/fxge/dib/cfx_dibsource.cpp @@ -105,16 +105,15 @@ void ConvertBuffer_1bppMask2Gray(uint8_t* dest_buf, const RetainPtr<CFX_DIBSource>& pSrcBitmap, int src_left, int src_top) { - uint8_t set_gray, reset_gray; - set_gray = 0xff; - reset_gray = 0x00; + static constexpr uint8_t kSetGray = 0xff; + static constexpr uint8_t kResetGray = 0x00; for (int row = 0; row < height; ++row) { uint8_t* dest_scan = dest_buf + row * dest_pitch; - memset(dest_scan, reset_gray, width); + memset(dest_scan, kResetGray, width); const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row); for (int col = src_left; col < src_left + width; ++col) { if (src_scan[col / 8] & (1 << (7 - col % 8))) - *dest_scan = set_gray; + *dest_scan = kSetGray; ++dest_scan; } } @@ -931,25 +930,21 @@ RetainPtr<CFX_DIBitmap> CFX_DIBSource::CloneConvert(FXDIB_Format dest_format) { RetainPtr<CFX_DIBitmap> pSrcAlpha; if (HasAlpha()) { - if (GetFormat() == FXDIB_Argb) - pSrcAlpha = CloneAlphaMask(); - else - pSrcAlpha = m_pAlphaMask; - + pSrcAlpha = (GetFormat() == FXDIB_Argb) ? CloneAlphaMask() : m_pAlphaMask; if (!pSrcAlpha) return nullptr; } - bool ret = true; if (dest_format & 0x0200) { + bool ret; if (dest_format == FXDIB_Argb) { ret = pSrcAlpha ? pClone->LoadChannel(FXDIB_Alpha, pSrcAlpha, FXDIB_Alpha) : pClone->LoadChannel(FXDIB_Alpha, 0xff); } else { ret = pClone->SetAlphaMask(pSrcAlpha, nullptr); } + if (!ret) + return nullptr; } - if (!ret) - return nullptr; RetainPtr<CFX_DIBSource> holder(this); std::unique_ptr<uint32_t, FxFreeDeleter> pal_8bpp; |