Pass source rect parameter to SetDIBits() by const-ref.
In RenderDeviceDriverIface() implementations.
Change-Id: Ic5e0239a29e7fa7b70e9ef65c82df7e773f8e363
Reviewed-on: https://pdfium-review.googlesource.com/c/44610
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index b20e46d..5571076 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -1493,7 +1493,7 @@
bool CFX_AggDeviceDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
uint32_t argb,
- const FX_RECT* pSrcRect,
+ const FX_RECT& src_rect,
int left,
int top,
BlendMode blend_type) {
@@ -1501,14 +1501,14 @@
return true;
if (pBitmap->IsAlphaMask()) {
- return m_pBitmap->CompositeMask(left, top, pSrcRect->Width(),
- pSrcRect->Height(), pBitmap, argb,
- pSrcRect->left, pSrcRect->top, blend_type,
+ return m_pBitmap->CompositeMask(left, top, src_rect.Width(),
+ src_rect.Height(), pBitmap, argb,
+ src_rect.left, src_rect.top, blend_type,
m_pClipRgn.get(), m_bRgbByteOrder, 0);
}
return m_pBitmap->CompositeBitmap(
- left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, pSrcRect->left,
- pSrcRect->top, blend_type, m_pClipRgn.get(), m_bRgbByteOrder);
+ left, top, src_rect.Width(), src_rect.Height(), pBitmap, src_rect.left,
+ src_rect.top, blend_type, m_pClipRgn.get(), m_bRgbByteOrder);
}
bool CFX_AggDeviceDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource,
@@ -1526,7 +1526,7 @@
if (dest_width == pSource->GetWidth() &&
dest_height == pSource->GetHeight()) {
FX_RECT rect(0, 0, dest_width, dest_height);
- return SetDIBits(pSource, argb, &rect, dest_left, dest_top, blend_type);
+ return SetDIBits(pSource, argb, rect, dest_left, dest_top, blend_type);
}
FX_RECT dest_rect(dest_left, dest_top, dest_left + dest_width,
dest_top + dest_height);
diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h
index bb3062b..00cae08 100644
--- a/core/fxge/agg/fx_agg_driver.h
+++ b/core/fxge/agg/fx_agg_driver.h
@@ -69,7 +69,7 @@
RetainPtr<CFX_DIBitmap> GetBackDrop() override;
bool SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
uint32_t color,
- const FX_RECT* pSrcRect,
+ const FX_RECT& src_rect,
int left,
int top,
BlendMode blend_type) override;
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp
index 11b5c4c..4b082a3 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -664,7 +664,7 @@
bitmap_device.GetDeviceDriver()->Flush();
#endif
FX_RECT src_rect(0, 0, rect.Width(), rect.Height());
- return m_pDeviceDriver->SetDIBits(bitmap, 0, &src_rect, rect.left, rect.top,
+ return m_pDeviceDriver->SetDIBits(bitmap, 0, src_rect, rect.left, rect.top,
BlendMode::kNormal);
}
@@ -689,7 +689,7 @@
return false;
}
FX_RECT src_rect(0, 0, rect.Width(), rect.Height());
- m_pDeviceDriver->SetDIBits(bitmap, 0, &src_rect, rect.left, rect.top,
+ m_pDeviceDriver->SetDIBits(bitmap, 0, src_rect, rect.left, rect.top,
BlendMode::kNormal);
return true;
}
@@ -738,7 +738,7 @@
dest_rect.top - top + dest_rect.Height());
if ((blend_mode == BlendMode::kNormal || (m_RenderCaps & FXRC_BLEND_MODE)) &&
(!pBitmap->HasAlpha() || (m_RenderCaps & FXRC_ALPHA_IMAGE))) {
- return m_pDeviceDriver->SetDIBits(pBitmap, 0, &src_rect, dest_rect.left,
+ return m_pDeviceDriver->SetDIBits(pBitmap, 0, src_rect, dest_rect.left,
dest_rect.top, blend_mode);
}
if (!(m_RenderCaps & FXRC_GET_BITS))
@@ -761,7 +761,7 @@
return false;
}
FX_RECT rect(0, 0, bg_pixel_width, bg_pixel_height);
- return m_pDeviceDriver->SetDIBits(background, 0, &rect, dest_rect.left,
+ return m_pDeviceDriver->SetDIBits(background, 0, rect, dest_rect.left,
dest_rect.top, BlendMode::kNormal);
}
@@ -786,7 +786,7 @@
int top,
uint32_t argb) {
FX_RECT src_rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight());
- return m_pDeviceDriver->SetDIBits(pBitmap, argb, &src_rect, left, top,
+ return m_pDeviceDriver->SetDIBits(pBitmap, argb, src_rect, left, top,
BlendMode::kNormal);
}
diff --git a/core/fxge/renderdevicedriver_iface.h b/core/fxge/renderdevicedriver_iface.h
index 17aa10f..8513f31 100644
--- a/core/fxge/renderdevicedriver_iface.h
+++ b/core/fxge/renderdevicedriver_iface.h
@@ -66,7 +66,7 @@
virtual RetainPtr<CFX_DIBitmap> GetBackDrop();
virtual bool SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
uint32_t color,
- const FX_RECT* pSrcRect,
+ const FX_RECT& src_rect,
int dest_left,
int dest_top,
BlendMode blend_type) = 0;
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index d4a67be..e0010cd 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -2238,7 +2238,7 @@
bool CFX_SkiaDeviceDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
uint32_t argb,
- const FX_RECT* pSrcRect,
+ const FX_RECT& src_rect,
int left,
int top,
BlendMode blend_type) {
@@ -2255,14 +2255,14 @@
#ifdef _SKIA_SUPPORT_PATHS_
Flush();
if (pBitmap->IsAlphaMask()) {
- return m_pBitmap->CompositeMask(left, top, pSrcRect->Width(),
- pSrcRect->Height(), pBitmap, argb,
- pSrcRect->left, pSrcRect->top, blend_type,
+ return m_pBitmap->CompositeMask(left, top, src_rect.Width(),
+ src_rect.Height(), pBitmap, argb,
+ src_rect.left, src_rect.top, blend_type,
m_pClipRgn.get(), m_bRgbByteOrder, 0);
}
return m_pBitmap->CompositeBitmap(
- left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, pSrcRect->left,
- pSrcRect->top, blend_type, m_pClipRgn.get(), m_bRgbByteOrder);
+ left, top, src_rect.Width(), src_rect.Height(), pBitmap, src_rect.left,
+ src_rect.top, blend_type, m_pClipRgn.get(), m_bRgbByteOrder);
#endif // _SKIA_SUPPORT_PATHS_
}
@@ -2297,7 +2297,7 @@
if (dest_width == pSource->GetWidth() &&
dest_height == pSource->GetHeight()) {
FX_RECT rect(0, 0, dest_width, dest_height);
- return SetDIBits(pSource, argb, &rect, dest_left, dest_top, blend_type);
+ return SetDIBits(pSource, argb, rect, dest_left, dest_top, blend_type);
}
Flush();
FX_RECT dest_rect(dest_left, dest_top, dest_left + dest_width,
diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h
index e3a48b1..7c9dfec 100644
--- a/core/fxge/skia/fx_skia_device.h
+++ b/core/fxge/skia/fx_skia_device.h
@@ -85,7 +85,7 @@
bool SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
uint32_t color,
- const FX_RECT* pSrcRect,
+ const FX_RECT& src_rect,
int dest_left,
int dest_top,
BlendMode blend_type) override;
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index 4b0b01e..2bacc44 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -767,7 +767,7 @@
}
bool CGdiDeviceDriver::GDI_SetDIBits(const RetainPtr<CFX_DIBitmap>& pBitmap1,
- const FX_RECT* pSrcRect,
+ const FX_RECT& src_rect,
int left,
int top) {
if (m_DeviceClass == FXDC_PRINTER) {
@@ -778,32 +778,31 @@
if (pBitmap->IsCmykImage() && !pBitmap->ConvertFormat(FXDIB_Rgb))
return false;
- int width = pSrcRect->Width(), height = pSrcRect->Height();
LPBYTE pBuffer = pBitmap->GetBuffer();
ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
((BITMAPINFOHEADER*)info.c_str())->biHeight *= -1;
- FX_RECT dst_rect(0, 0, width, height);
+ FX_RECT dst_rect(0, 0, src_rect.Width(), src_rect.Height());
dst_rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight());
int dst_width = dst_rect.Width();
int dst_height = dst_rect.Height();
::StretchDIBits(m_hDC, left, top, dst_width, dst_height, 0, 0, dst_width,
dst_height, pBuffer, (BITMAPINFO*)info.c_str(),
DIB_RGB_COLORS, SRCCOPY);
- } else {
- RetainPtr<CFX_DIBitmap> pBitmap = pBitmap1;
- if (pBitmap->IsCmykImage()) {
- pBitmap = pBitmap->CloneConvert(FXDIB_Rgb);
- if (!pBitmap)
- return false;
- }
- int width = pSrcRect->Width(), height = pSrcRect->Height();
- LPBYTE pBuffer = pBitmap->GetBuffer();
- ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
- ::SetDIBitsToDevice(m_hDC, left, top, width, height, pSrcRect->left,
- pBitmap->GetHeight() - pSrcRect->bottom, 0,
- pBitmap->GetHeight(), pBuffer,
- (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS);
+ return true;
}
+
+ RetainPtr<CFX_DIBitmap> pBitmap = pBitmap1;
+ if (pBitmap->IsCmykImage()) {
+ pBitmap = pBitmap->CloneConvert(FXDIB_Rgb);
+ if (!pBitmap)
+ return false;
+ }
+ LPBYTE pBuffer = pBitmap->GetBuffer();
+ ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
+ ::SetDIBitsToDevice(m_hDC, left, top, src_rect.Width(), src_rect.Height(),
+ src_rect.left, pBitmap->GetHeight() - src_rect.bottom, 0,
+ pBitmap->GetHeight(), pBuffer, (BITMAPINFO*)info.c_str(),
+ DIB_RGB_COLORS);
return true;
}
@@ -1188,7 +1187,7 @@
bool CGdiDisplayDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pSource,
uint32_t color,
- const FX_RECT* pSrcRect,
+ const FX_RECT& src_rect,
int left,
int top,
BlendMode blend_type) {
@@ -1204,33 +1203,35 @@
BlendMode::kNormal, nullptr, false, 0)) {
return false;
}
- FX_RECT src_rect(0, 0, width, height);
- return SetDIBits(background, 0, &src_rect, left, top, BlendMode::kNormal);
+ FX_RECT alpha_src_rect(0, 0, width, height);
+ return SetDIBits(background, 0, alpha_src_rect, left, top,
+ BlendMode::kNormal);
}
- FX_RECT clip_rect(left, top, left + pSrcRect->Width(),
- top + pSrcRect->Height());
- return StretchDIBits(pSource, color, left - pSrcRect->left,
- top - pSrcRect->top, width, height, &clip_rect, 0,
+ FX_RECT clip_rect(left, top, left + src_rect.Width(),
+ top + src_rect.Height());
+ return StretchDIBits(pSource, color, left - src_rect.left,
+ top - src_rect.top, width, height, &clip_rect, 0,
BlendMode::kNormal);
}
- int width = pSrcRect->Width(), height = pSrcRect->Height();
+ int width = src_rect.Width();
+ int height = src_rect.Height();
if (pSource->HasAlpha()) {
auto bitmap = pdfium::MakeRetain<CFX_DIBitmap>();
if (!bitmap->Create(width, height, FXDIB_Rgb) ||
!GetDIBits(bitmap, left, top) ||
- !bitmap->CompositeBitmap(0, 0, width, height, pSource, pSrcRect->left,
- pSrcRect->top, BlendMode::kNormal, nullptr,
+ !bitmap->CompositeBitmap(0, 0, width, height, pSource, src_rect.left,
+ src_rect.top, BlendMode::kNormal, nullptr,
false)) {
return false;
}
- FX_RECT src_rect(0, 0, width, height);
- return SetDIBits(bitmap, 0, &src_rect, left, top, BlendMode::kNormal);
+ FX_RECT alpha_src_rect(0, 0, width, height);
+ return SetDIBits(bitmap, 0, alpha_src_rect, left, top, BlendMode::kNormal);
}
CFX_DIBExtractor temp(pSource);
RetainPtr<CFX_DIBitmap> pBitmap = temp.GetBitmap();
if (!pBitmap)
return false;
- return GDI_SetDIBits(pBitmap, pSrcRect, left, top);
+ return GDI_SetDIBits(pBitmap, src_rect, left, top);
}
bool CGdiDisplayDriver::UseFoxitStretchEngine(
@@ -1256,8 +1257,8 @@
return true;
FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight());
- return SetDIBits(pStretched, color, &src_rect, pClipRect->left,
- pClipRect->top, BlendMode::kNormal);
+ return SetDIBits(pStretched, color, src_rect, pClipRect->left, pClipRect->top,
+ BlendMode::kNormal);
}
bool CGdiDisplayDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource,
@@ -1301,7 +1302,7 @@
}
FX_RECT src_rect(0, 0, clip_width, clip_height);
- return SetDIBits(background, 0, &src_rect, image_rect.left + clip_rect.left,
+ return SetDIBits(background, 0, src_rect, image_rect.left + clip_rect.left,
image_rect.top + clip_rect.top, BlendMode::kNormal);
}
if (pSource->HasAlpha()) {
diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp
index b92a46d..fce378c 100644
--- a/core/fxge/win32/fx_win32_print.cpp
+++ b/core/fxge/win32/fx_win32_print.cpp
@@ -70,19 +70,19 @@
bool CGdiPrinterDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pSource,
uint32_t color,
- const FX_RECT* pSrcRect,
+ const FX_RECT& src_rect,
int left,
int top,
BlendMode blend_type) {
if (pSource->IsAlphaMask()) {
- FX_RECT clip_rect(left, top, left + pSrcRect->Width(),
- top + pSrcRect->Height());
- return StretchDIBits(pSource, color, left - pSrcRect->left,
- top - pSrcRect->top, pSource->GetWidth(),
+ FX_RECT clip_rect(left, top, left + src_rect.Width(),
+ top + src_rect.Height());
+ return StretchDIBits(pSource, color, left - src_rect.left,
+ top - src_rect.top, pSource->GetWidth(),
pSource->GetHeight(), &clip_rect, 0,
BlendMode::kNormal);
}
- ASSERT(pSource && !pSource->IsAlphaMask() && pSrcRect);
+ ASSERT(pSource && !pSource->IsAlphaMask());
ASSERT(blend_type == BlendMode::kNormal);
if (pSource->HasAlpha())
return false;
@@ -92,7 +92,7 @@
if (!pBitmap)
return false;
- return GDI_SetDIBits(pBitmap, pSrcRect, left, top);
+ return GDI_SetDIBits(pBitmap, src_rect, left, top);
}
bool CGdiPrinterDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource,
@@ -455,7 +455,7 @@
bool CPSPrinterDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
uint32_t color,
- const FX_RECT* pSrcRect,
+ const FX_RECT& src_rect,
int left,
int top,
BlendMode blend_type) {
@@ -566,7 +566,7 @@
bool CTextOnlyPrinterDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
uint32_t color,
- const FX_RECT* pSrcRect,
+ const FX_RECT& src_rect,
int left,
int top,
BlendMode blend_type) {
diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h
index c23cc8b..43ec605 100644
--- a/core/fxge/win32/win32_int.h
+++ b/core/fxge/win32/win32_int.h
@@ -98,7 +98,7 @@
void DrawLine(float x1, float y1, float x2, float y2);
bool GDI_SetDIBits(const RetainPtr<CFX_DIBitmap>& pBitmap,
- const FX_RECT* pSrcRect,
+ const FX_RECT& src_rect,
int left,
int top);
bool GDI_StretchDIBits(const RetainPtr<CFX_DIBitmap>& pBitmap,
@@ -135,7 +135,7 @@
int top) override;
bool SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
uint32_t color,
- const FX_RECT* pSrcRect,
+ const FX_RECT& src_rect,
int left,
int top,
BlendMode blend_type) override;
@@ -174,7 +174,7 @@
int GetDeviceCaps(int caps_id) const override;
bool SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
uint32_t color,
- const FX_RECT* pSrcRect,
+ const FX_RECT& src_rect,
int left,
int top,
BlendMode blend_type) override;
@@ -233,7 +233,7 @@
bool GetClipBox(FX_RECT* pRect) override;
bool SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
uint32_t color,
- const FX_RECT* pSrcRect,
+ const FX_RECT& src_rect,
int left,
int top,
BlendMode blend_type) override;
@@ -296,7 +296,7 @@
bool GetClipBox(FX_RECT* pRect) override;
bool SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
uint32_t color,
- const FX_RECT* pSrcRect,
+ const FX_RECT& src_rect,
int left,
int top,
BlendMode blend_type) override;