summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-25 22:25:51 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-25 22:25:51 +0000
commitcde8b8cb0db2784d8f591fbfa7cfe7a67092b5fa (patch)
tree1cb46057fb039e390e8b18d37473081185417d16
parent84a534d9473af1d47767e9e576304a5a6c6bbff2 (diff)
downloadpdfium-cde8b8cb0db2784d8f591fbfa7cfe7a67092b5fa.tar.xz
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>
-rw-r--r--core/fxge/agg/fx_agg_driver.cpp14
-rw-r--r--core/fxge/agg/fx_agg_driver.h2
-rw-r--r--core/fxge/cfx_renderdevice.cpp10
-rw-r--r--core/fxge/renderdevicedriver_iface.h2
-rw-r--r--core/fxge/skia/fx_skia_device.cpp14
-rw-r--r--core/fxge/skia/fx_skia_device.h2
-rw-r--r--core/fxge/win32/fx_win32_device.cpp67
-rw-r--r--core/fxge/win32/fx_win32_print.cpp18
-rw-r--r--core/fxge/win32/win32_int.h10
9 files changed, 70 insertions, 69 deletions
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index b20e46d978..55710763e5 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -1493,7 +1493,7 @@ RetainPtr<CFX_DIBitmap> CFX_AggDeviceDriver::GetBackDrop() {
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 @@ bool CFX_AggDeviceDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
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 @@ bool CFX_AggDeviceDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource,
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 bb3062b4ac..00cae08be6 100644
--- a/core/fxge/agg/fx_agg_driver.h
+++ b/core/fxge/agg/fx_agg_driver.h
@@ -69,7 +69,7 @@ class CFX_AggDeviceDriver final : public RenderDeviceDriverIface {
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 11b5c4c536..4b082a3349 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -664,7 +664,7 @@ bool CFX_RenderDevice::DrawFillStrokePath(const CFX_PathData* pPathData,
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 @@ bool CFX_RenderDevice::FillRectWithBlend(const FX_RECT& rect,
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 @@ bool CFX_RenderDevice::SetDIBitsWithBlend(const RetainPtr<CFX_DIBBase>& pBitmap,
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 @@ bool CFX_RenderDevice::SetDIBitsWithBlend(const RetainPtr<CFX_DIBBase>& pBitmap,
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 @@ bool CFX_RenderDevice::SetBitMask(const RetainPtr<CFX_DIBBase>& pBitmap,
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 17aa10fe71..8513f31428 100644
--- a/core/fxge/renderdevicedriver_iface.h
+++ b/core/fxge/renderdevicedriver_iface.h
@@ -66,7 +66,7 @@ class RenderDeviceDriverIface {
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 d4a67be98a..e0010cdf78 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -2238,7 +2238,7 @@ RetainPtr<CFX_DIBitmap> CFX_SkiaDeviceDriver::GetBackDrop() {
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 @@ bool CFX_SkiaDeviceDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap,
#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 @@ bool CFX_SkiaDeviceDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource,
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 e3a48b19d1..7c9dfeccbd 100644
--- a/core/fxge/skia/fx_skia_device.h
+++ b/core/fxge/skia/fx_skia_device.h
@@ -85,7 +85,7 @@ class CFX_SkiaDeviceDriver final : public RenderDeviceDriverIface {
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 4b0b01e56e..2bacc4485c 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -767,7 +767,7 @@ void CGdiDeviceDriver::RestoreState(bool bKeepSaved) {
}
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 @@ bool CGdiDeviceDriver::GDI_SetDIBits(const RetainPtr<CFX_DIBitmap>& pBitmap1,
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::GetDIBits(const RetainPtr<CFX_DIBitmap>& pBitmap,
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 @@ bool CGdiDisplayDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pSource,
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 @@ bool CGdiDisplayDriver::UseFoxitStretchEngine(
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 @@ bool CGdiDisplayDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource,
}
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 b92a46d08f..fce378cd4d 100644
--- a/core/fxge/win32/fx_win32_print.cpp
+++ b/core/fxge/win32/fx_win32_print.cpp
@@ -70,19 +70,19 @@ int CGdiPrinterDriver::GetDeviceCaps(int caps_id) const {
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 @@ bool CGdiPrinterDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pSource,
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::GetClipBox(FX_RECT* pRect) {
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::DrawPath(const CFX_PathData* pPathData,
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 c23cc8bdda..43ec6056fd 100644
--- a/core/fxge/win32/win32_int.h
+++ b/core/fxge/win32/win32_int.h
@@ -98,7 +98,7 @@ class CGdiDeviceDriver : public RenderDeviceDriverIface {
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 @@ class CGdiDisplayDriver final : public CGdiDeviceDriver {
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 @@ class CGdiPrinterDriver final : public CGdiDeviceDriver {
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 @@ class CPSPrinterDriver final : public RenderDeviceDriverIface {
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 @@ class CTextOnlyPrinterDriver final : public RenderDeviceDriverIface {
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;