Give CFX_DIBBase::GetOverlapRect() a return value.
Change-Id: Ib27cc4b7d57d40ed46e3cba02b95add91f85e2f3
Reviewed-on: https://pdfium-review.googlesource.com/c/47270
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index ff2b387..e26121d 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -151,11 +151,11 @@
if (!pBitmap)
return;
- pBitmap->GetOverlapRect(dest_left, dest_top, width, height,
- pSrcBitmap->GetWidth(), pSrcBitmap->GetHeight(),
- src_left, src_top, nullptr);
- if (width == 0 || height == 0)
+ if (!pBitmap->GetOverlapRect(dest_left, dest_top, width, height,
+ pSrcBitmap->GetWidth(), pSrcBitmap->GetHeight(),
+ src_left, src_top, nullptr)) {
return;
+ }
int Bpp = pBitmap->GetBPP() / 8;
FXDIB_Format dest_format = pBitmap->GetFormat();
diff --git a/core/fxge/dib/cfx_dibbase.cpp b/core/fxge/dib/cfx_dibbase.cpp
index a8da398..2338cac 100644
--- a/core/fxge/dib/cfx_dibbase.cpp
+++ b/core/fxge/dib/cfx_dibbase.cpp
@@ -854,7 +854,7 @@
return -1;
}
-void CFX_DIBBase::GetOverlapRect(int& dest_left,
+bool CFX_DIBBase::GetOverlapRect(int& dest_left,
int& dest_top,
int& width,
int& height,
@@ -864,7 +864,7 @@
int& src_top,
const CFX_ClipRgn* pClipRgn) {
if (width == 0 || height == 0)
- return;
+ return false;
ASSERT(width > 0);
ASSERT(height > 0);
@@ -872,7 +872,7 @@
if (dest_left > m_Width || dest_top > m_Height) {
width = 0;
height = 0;
- return;
+ return false;
}
int x_offset = dest_left - src_left;
int y_offset = dest_top - src_top;
@@ -891,6 +891,7 @@
src_top = dest_top - y_offset;
width = dest_rect.right - dest_rect.left;
height = dest_rect.bottom - dest_rect.top;
+ return width != 0 && height != 0;
}
void CFX_DIBBase::SetPalette(const uint32_t* pSrc) {
diff --git a/core/fxge/dib/cfx_dibbase.h b/core/fxge/dib/cfx_dibbase.h
index 23d65a3..c644be6 100644
--- a/core/fxge/dib/cfx_dibbase.h
+++ b/core/fxge/dib/cfx_dibbase.h
@@ -94,7 +94,7 @@
bool SetAlphaMask(const RetainPtr<CFX_DIBBase>& pAlphaMask,
const FX_RECT* pClip);
- void GetOverlapRect(int& dest_left,
+ bool GetOverlapRect(int& dest_left,
int& dest_top,
int& width,
int& height,
diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp
index 456161c..561009e 100644
--- a/core/fxge/dib/cfx_dibitmap.cpp
+++ b/core/fxge/dib/cfx_dibitmap.cpp
@@ -190,10 +190,11 @@
if (!m_pBuffer)
return false;
- GetOverlapRect(dest_left, dest_top, width, height, pSrcBitmap->GetWidth(),
- pSrcBitmap->GetHeight(), src_left, src_top, nullptr);
- if (width == 0 || height == 0)
+ if (!GetOverlapRect(dest_left, dest_top, width, height,
+ pSrcBitmap->GetWidth(), pSrcBitmap->GetHeight(), src_left,
+ src_top, nullptr)) {
return true;
+ }
FXDIB_Format dest_format = GetFormat();
FXDIB_Format src_format = pSrcBitmap->GetFormat();
@@ -875,11 +876,12 @@
if (pSrcBitmap->IsAlphaMask() || m_bpp < 8) {
return false;
}
- GetOverlapRect(dest_left, dest_top, width, height, pSrcBitmap->GetWidth(),
- pSrcBitmap->GetHeight(), src_left, src_top, pClipRgn);
- if (width == 0 || height == 0) {
+ if (!GetOverlapRect(dest_left, dest_top, width, height,
+ pSrcBitmap->GetWidth(), pSrcBitmap->GetHeight(), src_left,
+ src_top, pClipRgn)) {
return true;
}
+
RetainPtr<CFX_DIBitmap> pClipMask;
FX_RECT clip_box;
if (pClipRgn && pClipRgn->GetType() != CFX_ClipRgn::RectI) {
@@ -948,10 +950,10 @@
if (!pMask->IsAlphaMask() || m_bpp < 8)
return false;
- GetOverlapRect(dest_left, dest_top, width, height, pMask->GetWidth(),
- pMask->GetHeight(), src_left, src_top, pClipRgn);
- if (width == 0 || height == 0)
+ if (!GetOverlapRect(dest_left, dest_top, width, height, pMask->GetWidth(),
+ pMask->GetHeight(), src_left, src_top, pClipRgn)) {
return true;
+ }
int src_alpha =
(uint8_t)(alpha_flag >> 8) ? (alpha_flag & 0xff) : FXARGB_A(color);
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 8a189f0..9888bf1 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -68,11 +68,11 @@
if (!pBitmap)
return;
- pBitmap->GetOverlapRect(dest_left, dest_top, width, height,
- pSrcBitmap->GetWidth(), pSrcBitmap->GetHeight(),
- src_left, src_top, nullptr);
- if (width == 0 || height == 0)
+ if (!pBitmap->GetOverlapRect(dest_left, dest_top, width, height,
+ pSrcBitmap->GetWidth(), pSrcBitmap->GetHeight(),
+ src_left, src_top, nullptr)) {
return;
+ }
int Bpp = pBitmap->GetBPP() / 8;
FXDIB_Format dest_format = pBitmap->GetFormat();