Fix nits in CFX_DIBBase and CFX_DIBitmap.
Change-Id: I9725c36d15e1c5693d1c3ab8c7efd6af118d7387
Reviewed-on: https://pdfium-review.googlesource.com/c/50997
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/dib/cfx_dibbase.cpp b/core/fxge/dib/cfx_dibbase.cpp
index f878fc4..94dfd13 100644
--- a/core/fxge/dib/cfx_dibbase.cpp
+++ b/core/fxge/dib/cfx_dibbase.cpp
@@ -1002,34 +1002,38 @@
}
if (m_bpp == 1) {
memset(dest_scan, 0, m_Pitch);
- for (int col = 0; col < m_Width; ++col)
+ for (int col = 0; col < m_Width; ++col) {
if (src_scan[col / 8] & (1 << (7 - col % 8))) {
int dest_col = m_Width - col - 1;
dest_scan[dest_col / 8] |= (1 << (7 - dest_col % 8));
}
+ }
+ continue;
+ }
+
+ dest_scan += (m_Width - 1) * Bpp;
+ if (Bpp == 1) {
+ for (int col = 0; col < m_Width; ++col) {
+ *dest_scan = *src_scan;
+ --dest_scan;
+ ++src_scan;
+ }
+ } else if (Bpp == 3) {
+ for (int col = 0; col < m_Width; ++col) {
+ dest_scan[0] = src_scan[0];
+ dest_scan[1] = src_scan[1];
+ dest_scan[2] = src_scan[2];
+ dest_scan -= 3;
+ src_scan += 3;
+ }
} else {
- dest_scan += (m_Width - 1) * Bpp;
- if (Bpp == 1) {
- for (int col = 0; col < m_Width; ++col) {
- *dest_scan = *src_scan;
- --dest_scan;
- ++src_scan;
- }
- } else if (Bpp == 3) {
- for (int col = 0; col < m_Width; ++col) {
- dest_scan[0] = src_scan[0];
- dest_scan[1] = src_scan[1];
- dest_scan[2] = src_scan[2];
- dest_scan -= 3;
- src_scan += 3;
- }
- } else {
- ASSERT(Bpp == 4);
- for (int col = 0; col < m_Width; ++col) {
- *(uint32_t*)dest_scan = *(uint32_t*)src_scan;
- dest_scan -= 4;
- src_scan += 4;
- }
+ ASSERT(Bpp == 4);
+ for (int col = 0; col < m_Width; ++col) {
+ const auto* src_scan32 = reinterpret_cast<const uint32_t*>(src_scan);
+ uint32_t* dest_scan32 = reinterpret_cast<uint32_t*>(dest_scan);
+ *dest_scan32 = *src_scan32;
+ dest_scan -= 4;
+ src_scan += 4;
}
}
}
@@ -1142,7 +1146,8 @@
const uint32_t* src_scan =
reinterpret_cast<const uint32_t*>(GetScanline(row)) + col_start;
for (int col = col_start; col < col_end; ++col) {
- *(uint32_t*)dest_scan = *src_scan++;
+ uint32_t* dest_scan32 = reinterpret_cast<uint32_t*>(dest_scan);
+ *dest_scan32 = *src_scan++;
dest_scan += dest_step;
}
} else {
diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp
index 3622c65..9f91a85 100644
--- a/core/fxge/dib/cfx_dibitmap.cpp
+++ b/core/fxge/dib/cfx_dibitmap.cpp
@@ -1020,7 +1020,7 @@
dst_color = FXCMYK_TODIB(color);
else
dst_color = FXARGB_TODIB(color);
- uint8_t* color_p = (uint8_t*)&dst_color;
+ uint8_t* color_p = reinterpret_cast<uint8_t*>(&dst_color);
if (m_bpp == 8) {
uint8_t gray = 255;
if (!IsAlphaMask()) {
@@ -1110,14 +1110,13 @@
uint8_t* dest_scan_alpha =
m_pAlphaMask ? m_pAlphaMask->GetWritableScanline(row) + rect.left
: nullptr;
- if (dest_scan_alpha) {
+ if (dest_scan_alpha)
memset(dest_scan_alpha, 0xff, width);
- }
+
if (Bpp == 4) {
- uint32_t* scan = (uint32_t*)dest_scan;
- for (int col = 0; col < width; col++) {
+ uint32_t* scan = reinterpret_cast<uint32_t*>(dest_scan);
+ for (int col = 0; col < width; col++)
*scan++ = dst_color;
- }
} else {
for (int col = 0; col < width; col++) {
*dest_scan++ = color_p[0];