summaryrefslogtreecommitdiff
path: root/core/fxge/dib/cfx_dibitmap.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-03-21 17:24:46 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-03-21 17:24:46 +0000
commit3851aff62c7ad2f9c942b4d5d095ec0e6610bb84 (patch)
treec15c662f2f9ac851c33fe1603057088d4eb319b5 /core/fxge/dib/cfx_dibitmap.cpp
parentbf85feeafdd8791f9dab7bfcd14ff850e015be26 (diff)
downloadpdfium-3851aff62c7ad2f9c942b4d5d095ec0e6610bb84.tar.xz
Add helpers to work with FXDIB_Format.
Helper functions make getting the bpp and component count more readable. Change-Id: Ie0f97d52136d11ef5251f6e22748e87aea289ae1 Reviewed-on: https://pdfium-review.googlesource.com/28572 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'core/fxge/dib/cfx_dibitmap.cpp')
-rw-r--r--core/fxge/dib/cfx_dibitmap.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp
index ae9bf244f0..9fa9776df0 100644
--- a/core/fxge/dib/cfx_dibitmap.cpp
+++ b/core/fxge/dib/cfx_dibitmap.cpp
@@ -19,7 +19,7 @@
namespace {
-const int8_t g_ChannelOffset[] = {0, 2, 1, 0, 0, 1, 2, 3, 3};
+const int8_t kChannelOffset[] = {0, 2, 1, 0, 0, 1, 2, 3, 3};
} // namespace
@@ -274,7 +274,7 @@ bool CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel,
if (!pSrcClone)
return false;
}
- srcOffset = g_ChannelOffset[srcChannel];
+ srcOffset = kChannelOffset[srcChannel];
}
int destOffset = 0;
if (destChannel == FXDIB_Alpha) {
@@ -304,7 +304,7 @@ bool CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel,
return false;
}
}
- destOffset = g_ChannelOffset[destChannel];
+ destOffset = kChannelOffset[destChannel];
}
if (srcChannel == FXDIB_Alpha && pSrcClone->m_pAlphaMask) {
RetainPtr<CFX_DIBSource> pAlphaMask = pSrcClone->m_pAlphaMask;
@@ -383,7 +383,7 @@ bool CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, int value) {
return false;
}
}
- destOffset = g_ChannelOffset[destChannel];
+ destOffset = kChannelOffset[destChannel];
}
int Bpp = GetBPP() / 8;
if (Bpp == 1) {
@@ -819,14 +819,15 @@ bool CFX_DIBitmap::CalculatePitchAndSize(int height,
if (width <= 0 || height <= 0)
return false;
- if (!(format & 0xff))
+ int bpp = GetBppFromFormat(format);
+ if (!bpp)
return false;
- if ((INT_MAX - 31) / width < (format & 0xff))
+ if ((INT_MAX - 31) / width < bpp)
return false;
if (!*pitch)
- *pitch = static_cast<uint32_t>((width * (format & 0xff) + 31) / 32 * 4);
+ *pitch = static_cast<uint32_t>((width * bpp + 31) / 32 * 4);
if ((1 << 30) / *pitch < static_cast<uint32_t>(height))
return false;
@@ -1190,7 +1191,7 @@ bool CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format) {
}
return true;
}
- int dest_bpp = dest_format & 0xff;
+ int dest_bpp = GetBppFromFormat(dest_format);
int dest_pitch = (dest_bpp * m_Width + 31) / 32 * 4;
std::unique_ptr<uint8_t, FxFreeDeleter> dest_buf(
FX_TryAlloc(uint8_t, dest_pitch * m_Height + 4));