Make RenderDeviceDriverIface::SetBitsWithMask() bitmap params const
Use const RetainPtrs, since the bitmaps are not changing. Also pass
RetainPtrs around by value and change their names to better follow the
style guide.
Change-Id: If441f63b119f98c7f0a03b3b57efaf6fb92e7cdd
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/115493
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp
index eb0df57..6e4994c 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -1001,14 +1001,14 @@
}
#if defined(PDF_USE_SKIA)
-bool CFX_RenderDevice::SetBitsWithMask(const RetainPtr<CFX_DIBBase>& pBitmap,
- const RetainPtr<CFX_DIBBase>& pMask,
+bool CFX_RenderDevice::SetBitsWithMask(RetainPtr<const CFX_DIBBase> bitmap,
+ RetainPtr<const CFX_DIBBase> mask,
int left,
int top,
float alpha,
BlendMode blend_type) {
- return m_pDeviceDriver->SetBitsWithMask(pBitmap, pMask, left, top, alpha,
- blend_type);
+ return m_pDeviceDriver->SetBitsWithMask(std::move(bitmap), std::move(mask),
+ left, top, alpha, blend_type);
}
bool CFX_RenderDevice::SyncInternalBitmaps() {
diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h
index 6ded93f..14ae479 100644
--- a/core/fxge/cfx_renderdevice.h
+++ b/core/fxge/cfx_renderdevice.h
@@ -218,8 +218,8 @@
bool MultiplyAlphaMask(const RetainPtr<const CFX_DIBBase>& mask);
#if defined(PDF_USE_SKIA)
- bool SetBitsWithMask(const RetainPtr<CFX_DIBBase>& pBitmap,
- const RetainPtr<CFX_DIBBase>& pMask,
+ bool SetBitsWithMask(RetainPtr<const CFX_DIBBase> bitmap,
+ RetainPtr<const CFX_DIBBase> mask,
int left,
int top,
float alpha,
diff --git a/core/fxge/renderdevicedriver_iface.cpp b/core/fxge/renderdevicedriver_iface.cpp
index faff0b4..e9db61a 100644
--- a/core/fxge/renderdevicedriver_iface.cpp
+++ b/core/fxge/renderdevicedriver_iface.cpp
@@ -73,8 +73,8 @@
#if defined(PDF_USE_SKIA)
bool RenderDeviceDriverIface::SetBitsWithMask(
- const RetainPtr<CFX_DIBBase>& pBitmap,
- const RetainPtr<CFX_DIBBase>& pMask,
+ RetainPtr<const CFX_DIBBase> bitmap,
+ RetainPtr<const CFX_DIBBase> mask,
int left,
int top,
float alpha,
diff --git a/core/fxge/renderdevicedriver_iface.h b/core/fxge/renderdevicedriver_iface.h
index ffb68a3..206ad43 100644
--- a/core/fxge/renderdevicedriver_iface.h
+++ b/core/fxge/renderdevicedriver_iface.h
@@ -109,8 +109,8 @@
int alpha,
bool bAlphaMode);
#if defined(PDF_USE_SKIA)
- virtual bool SetBitsWithMask(const RetainPtr<CFX_DIBBase>& pBitmap,
- const RetainPtr<CFX_DIBBase>& pMask,
+ virtual bool SetBitsWithMask(RetainPtr<const CFX_DIBBase> bitmap,
+ RetainPtr<const CFX_DIBBase> mask,
int left,
int top,
float alpha,
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index b0b211e..2c39b5c 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -1485,21 +1485,20 @@
return m_nFormat == Format::kPreMultiplied;
}
-bool CFX_SkiaDeviceDriver::DrawBitsWithMask(
- const RetainPtr<CFX_DIBBase>& pSource,
- const RetainPtr<CFX_DIBBase>& pMask,
- float alpha,
- const CFX_Matrix& matrix,
- BlendMode blend_type) {
+bool CFX_SkiaDeviceDriver::DrawBitsWithMask(RetainPtr<const CFX_DIBBase> bitmap,
+ RetainPtr<const CFX_DIBBase> mask,
+ float alpha,
+ const CFX_Matrix& matrix,
+ BlendMode blend_type) {
DebugValidate(m_pBitmap);
- sk_sp<SkImage> skia_source = pSource->RealizeSkImage();
+ sk_sp<SkImage> skia_source = bitmap->RealizeSkImage();
if (!skia_source) {
return false;
}
- DCHECK(pMask->IsMaskFormat());
- sk_sp<SkImage> skia_mask = pMask->RealizeSkImage();
+ DCHECK(mask->IsMaskFormat());
+ sk_sp<SkImage> skia_mask = mask->RealizeSkImage();
if (!skia_mask) {
return false;
}
@@ -1508,13 +1507,13 @@
{
SkAutoCanvasRestore scoped_save_restore(m_pCanvas, /*doSave=*/true);
- const int src_width = pSource->GetWidth();
- const int src_height = pSource->GetHeight();
+ const int src_width = bitmap->GetWidth();
+ const int src_height = bitmap->GetHeight();
SkMatrix skMatrix;
SetBitmapMatrix(matrix, src_width, src_height, &skMatrix);
m_pCanvas->concat(skMatrix);
SkPaint paint;
- SetBitmapPaintForMerge(pSource->IsMaskFormat(), !m_FillOptions.aliased_path,
+ SetBitmapPaintForMerge(bitmap->IsMaskFormat(), !m_FillOptions.aliased_path,
alpha, blend_type, &paint);
sk_sp<SkShader> source_shader = skia_source->makeShader(
SkTileMode::kClamp, SkTileMode::kClamp, SkSamplingOptions());
@@ -1531,20 +1530,20 @@
return true;
}
-bool CFX_SkiaDeviceDriver::SetBitsWithMask(
- const RetainPtr<CFX_DIBBase>& pBitmap,
- const RetainPtr<CFX_DIBBase>& pMask,
- int dest_left,
- int dest_top,
- float alpha,
- BlendMode blend_type) {
+bool CFX_SkiaDeviceDriver::SetBitsWithMask(RetainPtr<const CFX_DIBBase> bitmap,
+ RetainPtr<const CFX_DIBBase> mask,
+ int dest_left,
+ int dest_top,
+ float alpha,
+ BlendMode blend_type) {
if (m_pBitmap->GetBuffer().empty()) {
return true;
}
CFX_Matrix matrix = CFX_RenderDevice::GetFlipMatrix(
- pBitmap->GetWidth(), pBitmap->GetHeight(), dest_left, dest_top);
- return DrawBitsWithMask(pBitmap, pMask, alpha, matrix, blend_type);
+ bitmap->GetWidth(), bitmap->GetHeight(), dest_left, dest_top);
+ return DrawBitsWithMask(std::move(bitmap), std::move(mask), alpha, matrix,
+ blend_type);
}
void CFX_SkiaDeviceDriver::SetGroupKnockout(bool group_knockout) {
diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h
index 6ce4bd8..fbecb16 100644
--- a/core/fxge/skia/fx_skia_device.h
+++ b/core/fxge/skia/fx_skia_device.h
@@ -101,8 +101,8 @@
int dest_left,
int dest_top,
BlendMode blend_type) override;
- bool SetBitsWithMask(const RetainPtr<CFX_DIBBase>& pBitmap,
- const RetainPtr<CFX_DIBBase>& pMask,
+ bool SetBitsWithMask(RetainPtr<const CFX_DIBBase> bitmap,
+ RetainPtr<const CFX_DIBBase> mask,
int dest_left,
int dest_top,
float alpha,
@@ -131,8 +131,8 @@
bool ContinueDIBits(CFX_ImageRenderer* handle,
PauseIndicatorIface* pPause) override;
- bool DrawBitsWithMask(const RetainPtr<CFX_DIBBase>& pSource,
- const RetainPtr<CFX_DIBBase>& pMask,
+ bool DrawBitsWithMask(RetainPtr<const CFX_DIBBase> bitmap,
+ RetainPtr<const CFX_DIBBase> mask,
float alpha,
const CFX_Matrix& matrix,
BlendMode blend_type);