Make RenderDeviceDriverIface::SetDIBits() take RetainPtrs by value
More consistently pass bitmaps around by value, with move semantics,
rather than by const-ref. Change related code in the call stack to do
the same. e.g. Update CGdiDeviceDriver::GDI_SetDIBits(),
CPDF_RenderStatus::CompositeDIBitmap(), and
CFX_RenderDevice::SetBitMask() in the same manner.
Also change variable names to follow the style guide.
Change-Id: I42fa64135c8c2f786883492eb31e4e4d44f8f479
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/116330
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index faa2896..ef68a33 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.cpp
+++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -462,10 +462,10 @@
FX_RECT dest_clip(
dest_rect.left - image_rect->left, dest_rect.top - image_rect->top,
dest_rect.right - image_rect->left, dest_rect.bottom - image_rect->top);
- RetainPtr<CFX_DIBitmap> pStretched = m_pDIBBase->StretchTo(
+ RetainPtr<CFX_DIBitmap> stretched = m_pDIBBase->StretchTo(
dest_width, dest_height, m_ResampleOptions, &dest_clip);
- if (pStretched) {
- m_pRenderStatus->CompositeDIBitmap(pStretched, dest_rect.left,
+ if (stretched) {
+ m_pRenderStatus->CompositeDIBitmap(std::move(stretched), dest_rect.left,
dest_rect.top, m_FillArgb, m_Alpha,
m_BlendType, CPDF_Transparency());
}
@@ -558,22 +558,23 @@
if (m_pTransformer->Continue(pPause))
return true;
- RetainPtr<CFX_DIBitmap> pBitmap = m_pTransformer->DetachBitmap();
- if (!pBitmap)
+ RetainPtr<CFX_DIBitmap> bitmap = m_pTransformer->DetachBitmap();
+ if (!bitmap) {
return false;
+ }
- if (pBitmap->IsMaskFormat()) {
+ if (bitmap->IsMaskFormat()) {
if (m_Alpha != 1.0f) {
m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, FXSYS_roundf(m_Alpha * 255));
}
m_Result = m_pRenderStatus->GetRenderDevice()->SetBitMask(
- pBitmap, m_pTransformer->result().left, m_pTransformer->result().top,
- m_FillArgb);
+ std::move(bitmap), m_pTransformer->result().left,
+ m_pTransformer->result().top, m_FillArgb);
} else {
- pBitmap->MultiplyAlpha(m_Alpha);
+ bitmap->MultiplyAlpha(m_Alpha);
m_Result = m_pRenderStatus->GetRenderDevice()->SetDIBitsWithBlend(
- pBitmap, m_pTransformer->result().left, m_pTransformer->result().top,
- m_BlendType);
+ std::move(bitmap), m_pTransformer->result().left,
+ m_pTransformer->result().top, m_BlendType);
}
return false;
}
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index a80676d..0aa97c4 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1017,9 +1017,10 @@
return true;
FX_RECT rect = GetGlyphsBBox(glyphs, 0);
- auto pBitmap = pdfium::MakeRetain<CFX_DIBitmap>();
- if (!pBitmap->Create(rect.Width(), rect.Height(), FXDIB_Format::k8bppMask))
+ auto bitmap = pdfium::MakeRetain<CFX_DIBitmap>();
+ if (!bitmap->Create(rect.Width(), rect.Height(), FXDIB_Format::k8bppMask)) {
return true;
+ }
for (const TextGlyphPos& glyph : glyphs) {
if (!glyph.m_pGlyph || !glyph.m_pGlyph->GetBitmap()->IsMaskFormat())
@@ -1029,12 +1030,12 @@
if (!point.has_value())
continue;
- pBitmap->CompositeMask(
+ bitmap->CompositeMask(
point->x, point->y, glyph.m_pGlyph->GetBitmap()->GetWidth(),
glyph.m_pGlyph->GetBitmap()->GetHeight(), glyph.m_pGlyph->GetBitmap(),
fill_argb, 0, 0, BlendMode::kNormal, nullptr, false);
}
- m_pDevice->SetBitMask(pBitmap, rect.left, rect.top, fill_argb);
+ m_pDevice->SetBitMask(std::move(bitmap), rect.left, rect.top, fill_argb);
return true;
}
@@ -1142,15 +1143,16 @@
if (clip_box.IsEmpty())
return;
- RetainPtr<CFX_DIBitmap> pScreen =
+ RetainPtr<CFX_DIBitmap> screen =
CPDF_RenderTiling::Draw(this, pPageObj, pattern, pPatternForm.get(),
mtObj2Device, clip_box, stroke);
- if (!pScreen)
+ if (!screen) {
return;
+ }
constexpr FX_ARGB kMask = 0;
- CompositeDIBitmap(pScreen, clip_box.left, clip_box.top, kMask, /*alpha=*/1.0f,
- BlendMode::kNormal, CPDF_Transparency());
+ CompositeDIBitmap(std::move(screen), clip_box.left, clip_box.top, kMask,
+ /*alpha=*/1.0f, BlendMode::kNormal, CPDF_Transparency());
}
void CPDF_RenderStatus::DrawPathWithPattern(CPDF_PathObject* path_obj,
@@ -1200,29 +1202,29 @@
}
void CPDF_RenderStatus::CompositeDIBitmap(
- const RetainPtr<CFX_DIBitmap>& pDIBitmap,
+ RetainPtr<CFX_DIBitmap> bitmap,
int left,
int top,
FX_ARGB mask_argb,
float alpha,
BlendMode blend_mode,
const CPDF_Transparency& transparency) {
- CHECK(pDIBitmap);
+ CHECK(bitmap);
if (blend_mode == BlendMode::kNormal) {
- if (!pDIBitmap->IsMaskFormat()) {
+ if (!bitmap->IsMaskFormat()) {
if (alpha != 1.0f) {
if (CFX_DefaultRenderDevice::UseSkiaRenderer()) {
std::unique_ptr<CFX_ImageRenderer> dummy;
CFX_Matrix matrix = CFX_RenderDevice::GetFlipMatrix(
- pDIBitmap->GetWidth(), pDIBitmap->GetHeight(), left, top);
- m_pDevice->StartDIBits(std::move(pDIBitmap), alpha, /*argb=*/0,
- matrix, FXDIB_ResampleOptions(), &dummy);
+ bitmap->GetWidth(), bitmap->GetHeight(), left, top);
+ m_pDevice->StartDIBits(std::move(bitmap), alpha, /*argb=*/0, matrix,
+ FXDIB_ResampleOptions(), &dummy);
return;
}
- pDIBitmap->MultiplyAlpha(alpha);
+ bitmap->MultiplyAlpha(alpha);
}
- if (m_pDevice->SetDIBits(pDIBitmap, left, top)) {
+ if (m_pDevice->SetDIBits(std::move(bitmap), left, top)) {
return;
}
} else {
@@ -1231,7 +1233,7 @@
uint8_t* fill_argb8 = reinterpret_cast<uint8_t*>(&fill_argb);
fill_argb8[3] *= FXSYS_roundf(alpha * 255) / 255;
}
- if (m_pDevice->SetBitMask(pDIBitmap, left, top, fill_argb)) {
+ if (m_pDevice->SetBitMask(std::move(bitmap), left, top, fill_argb)) {
return;
}
}
@@ -1245,13 +1247,14 @@
(m_pDevice->GetRenderCaps() & FXRC_GET_BITS) && !bBackAlphaRequired);
if (bGetBackGround) {
if (bIsolated || !transparency.IsGroup()) {
- if (!pDIBitmap->IsMaskFormat())
- m_pDevice->SetDIBitsWithBlend(pDIBitmap, left, top, blend_mode);
+ if (!bitmap->IsMaskFormat()) {
+ m_pDevice->SetDIBitsWithBlend(std::move(bitmap), left, top, blend_mode);
+ }
return;
}
- FX_RECT rect(left, top, left + pDIBitmap->GetWidth(),
- top + pDIBitmap->GetHeight());
+ FX_RECT rect(left, top, left + bitmap->GetWidth(),
+ top + bitmap->GetHeight());
rect.Intersect(m_pDevice->GetClipBox());
RetainPtr<CFX_DIBitmap> pClone;
if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) {
@@ -1264,55 +1267,56 @@
BlendMode::kNormal, nullptr, false);
left = std::min(left, 0);
top = std::min(top, 0);
- if (pDIBitmap->IsMaskFormat()) {
+ if (bitmap->IsMaskFormat()) {
pClone->CompositeMask(0, 0, pClone->GetWidth(), pClone->GetHeight(),
- pDIBitmap, mask_argb, left, top, blend_mode,
- nullptr, false);
+ bitmap, mask_argb, left, top, blend_mode, nullptr,
+ false);
} else {
pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(),
- pDIBitmap, left, top, blend_mode, nullptr,
- false);
+ bitmap, left, top, blend_mode, nullptr, false);
}
} else {
- pClone = pDIBitmap;
+ pClone = bitmap;
}
if (m_pDevice->GetBackDrop()) {
m_pDevice->SetDIBits(pClone, rect.left, rect.top);
} else {
- if (!pDIBitmap->IsMaskFormat()) {
- m_pDevice->SetDIBitsWithBlend(pDIBitmap, rect.left, rect.top,
+ if (!bitmap->IsMaskFormat()) {
+ m_pDevice->SetDIBitsWithBlend(std::move(bitmap), rect.left, rect.top,
blend_mode);
}
}
return;
}
- FX_RECT bbox = GetClippedBBox(FX_RECT(left, top, left + pDIBitmap->GetWidth(),
- top + pDIBitmap->GetHeight()));
- RetainPtr<CFX_DIBitmap> pBackdrop = GetBackdrop(
- m_pCurObj, bbox, blend_mode != BlendMode::kNormal && bIsolated);
- if (!pBackdrop)
- return;
- if (pDIBitmap->IsMaskFormat()) {
- pBackdrop->CompositeMask(left - bbox.left, top - bbox.top,
- pDIBitmap->GetWidth(), pDIBitmap->GetHeight(),
- pDIBitmap, mask_argb, 0, 0, blend_mode, nullptr,
- false);
- } else {
- pBackdrop->CompositeBitmap(left - bbox.left, top - bbox.top,
- pDIBitmap->GetWidth(), pDIBitmap->GetHeight(),
- pDIBitmap, 0, 0, blend_mode, nullptr, false);
+ FX_RECT bbox = GetClippedBBox(
+ FX_RECT(left, top, left + bitmap->GetWidth(), top + bitmap->GetHeight()));
+ RetainPtr<CFX_DIBitmap> backdrop = GetBackdrop(
+ m_pCurObj, bbox, blend_mode != BlendMode::kNormal && bIsolated);
+ if (!backdrop) {
+ return;
}
- auto pBackdrop1 = pdfium::MakeRetain<CFX_DIBitmap>();
- pBackdrop1->Create(pBackdrop->GetWidth(), pBackdrop->GetHeight(),
- FXDIB_Format::kRgb32);
- pBackdrop1->Clear((uint32_t)-1);
- pBackdrop1->CompositeBitmap(0, 0, pBackdrop->GetWidth(),
- pBackdrop->GetHeight(), pBackdrop, 0, 0,
- BlendMode::kNormal, nullptr, false);
- pBackdrop = std::move(pBackdrop1);
- m_pDevice->SetDIBits(pBackdrop, bbox.left, bbox.top);
+ const int width = bitmap->GetWidth();
+ const int height = bitmap->GetHeight();
+ if (bitmap->IsMaskFormat()) {
+ backdrop->CompositeMask(left - bbox.left, top - bbox.top, width, height,
+ std::move(bitmap), mask_argb, 0, 0, blend_mode,
+ nullptr, false);
+ } else {
+ backdrop->CompositeBitmap(left - bbox.left, top - bbox.top, width, height,
+ std::move(bitmap), 0, 0, blend_mode, nullptr,
+ false);
+ }
+
+ auto new_backdrop = pdfium::MakeRetain<CFX_DIBitmap>();
+ new_backdrop->Create(backdrop->GetWidth(), backdrop->GetHeight(),
+ FXDIB_Format::kRgb32);
+ new_backdrop->Clear(0xffffffff);
+ new_backdrop->CompositeBitmap(0, 0, new_backdrop->GetWidth(),
+ new_backdrop->GetHeight(), std::move(backdrop),
+ 0, 0, BlendMode::kNormal, nullptr, false);
+ m_pDevice->SetDIBits(std::move(new_backdrop), bbox.left, bbox.top);
}
RetainPtr<CFX_DIBitmap> CPDF_RenderStatus::LoadSMask(
diff --git a/core/fpdfapi/render/cpdf_renderstatus.h b/core/fpdfapi/render/cpdf_renderstatus.h
index 0a2f5c0..3dc9df1 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.h
+++ b/core/fpdfapi/render/cpdf_renderstatus.h
@@ -113,7 +113,7 @@
const CFX_Matrix& mtObj2Device,
bool stroke);
// `pDIBitmap` must be non-null.
- void CompositeDIBitmap(const RetainPtr<CFX_DIBitmap>& pDIBitmap,
+ void CompositeDIBitmap(RetainPtr<CFX_DIBitmap> bitmap,
int left,
int top,
FX_ARGB mask_argb,
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index 3a2a627..0be44eb 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -1305,7 +1305,7 @@
return m_pBackdropBitmap;
}
-bool CFX_AggDeviceDriver::SetDIBits(const RetainPtr<const CFX_DIBBase>& pBitmap,
+bool CFX_AggDeviceDriver::SetDIBits(RetainPtr<const CFX_DIBBase> bitmap,
uint32_t argb,
const FX_RECT& src_rect,
int left,
@@ -1314,14 +1314,14 @@
if (m_pBitmap->GetBuffer().empty())
return true;
- if (pBitmap->IsMaskFormat()) {
+ if (bitmap->IsMaskFormat()) {
return m_pBitmap->CompositeMask(left, top, src_rect.Width(),
- src_rect.Height(), std::move(pBitmap), argb,
+ src_rect.Height(), std::move(bitmap), argb,
src_rect.left, src_rect.top, blend_type,
m_pClipRgn.get(), m_bRgbByteOrder);
}
return m_pBitmap->CompositeBitmap(left, top, src_rect.Width(),
- src_rect.Height(), std::move(pBitmap),
+ src_rect.Height(), std::move(bitmap),
src_rect.left, src_rect.top, blend_type,
m_pClipRgn.get(), m_bRgbByteOrder);
}
diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h
index 0d38405..47281c8 100644
--- a/core/fxge/agg/fx_agg_driver.h
+++ b/core/fxge/agg/fx_agg_driver.h
@@ -67,7 +67,7 @@
int left,
int top) override;
RetainPtr<CFX_DIBitmap> GetBackDrop() override;
- bool SetDIBits(const RetainPtr<const CFX_DIBBase>& pBitmap,
+ bool SetDIBits(RetainPtr<const CFX_DIBBase> bitmap,
uint32_t argb,
const FX_RECT& src_rect,
int left,
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp
index 1776461..4dc06a8 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -793,8 +793,8 @@
return false;
}
FX_RECT src_rect(0, 0, rect.Width(), rect.Height());
- return m_pDeviceDriver->SetDIBits(std::move(bitmap), 0, src_rect, rect.left,
- rect.top, BlendMode::kNormal);
+ return m_pDeviceDriver->SetDIBits(std::move(bitmap), /*color=*/0, src_rect,
+ rect.left, rect.top, BlendMode::kNormal);
}
bool CFX_RenderDevice::FillRectWithBlend(const FX_RECT& rect,
@@ -817,8 +817,8 @@
return false;
FX_RECT src_rect(0, 0, rect.Width(), rect.Height());
- m_pDeviceDriver->SetDIBits(bitmap, 0, src_rect, rect.left, rect.top,
- BlendMode::kNormal);
+ m_pDeviceDriver->SetDIBits(std::move(bitmap), /*color=*/0, src_rect,
+ rect.left, rect.top, BlendMode::kNormal);
return true;
}
@@ -884,18 +884,23 @@
m_pDeviceDriver->GetDIBits(pBitmap, left, top);
}
+bool CFX_RenderDevice::SetDIBits(RetainPtr<const CFX_DIBBase> bitmap,
+ int left,
+ int top) {
+ return SetDIBitsWithBlend(std::move(bitmap), left, top, BlendMode::kNormal);
+}
+
RetainPtr<CFX_DIBitmap> CFX_RenderDevice::GetBackDrop() {
return m_pDeviceDriver->GetBackDrop();
}
-bool CFX_RenderDevice::SetDIBitsWithBlend(
- const RetainPtr<const CFX_DIBBase>& pBitmap,
- int left,
- int top,
- BlendMode blend_mode) {
- DCHECK(!pBitmap->IsMaskFormat());
- FX_RECT dest_rect(left, top, left + pBitmap->GetWidth(),
- top + pBitmap->GetHeight());
+bool CFX_RenderDevice::SetDIBitsWithBlend(RetainPtr<const CFX_DIBBase> bitmap,
+ int left,
+ int top,
+ BlendMode blend_mode) {
+ DCHECK(!bitmap->IsMaskFormat());
+ FX_RECT dest_rect(left, top, left + bitmap->GetWidth(),
+ top + bitmap->GetHeight());
dest_rect.Intersect(m_ClipBox);
if (dest_rect.IsEmpty())
return true;
@@ -904,8 +909,8 @@
dest_rect.left - left + dest_rect.Width(),
dest_rect.top - top + dest_rect.Height());
if ((blend_mode == BlendMode::kNormal || (m_RenderCaps & FXRC_BLEND_MODE)) &&
- (!pBitmap->IsAlphaFormat() || (m_RenderCaps & FXRC_ALPHA_IMAGE))) {
- return m_pDeviceDriver->SetDIBits(std::move(pBitmap), 0, src_rect,
+ (!bitmap->IsAlphaFormat() || (m_RenderCaps & FXRC_ALPHA_IMAGE))) {
+ return m_pDeviceDriver->SetDIBits(std::move(bitmap), /*color=*/0, src_rect,
dest_rect.left, dest_rect.top,
blend_mode);
}
@@ -923,13 +928,14 @@
return false;
if (!background->CompositeBitmap(0, 0, bg_pixel_width, bg_pixel_height,
- std::move(pBitmap), src_rect.left,
+ std::move(bitmap), src_rect.left,
src_rect.top, blend_mode, nullptr, false)) {
return false;
}
FX_RECT rect(0, 0, bg_pixel_width, bg_pixel_height);
- return m_pDeviceDriver->SetDIBits(background, 0, rect, dest_rect.left,
- dest_rect.top, BlendMode::kNormal);
+ return m_pDeviceDriver->SetDIBits(std::move(background), /*color=*/0, rect,
+ dest_rect.left, dest_rect.top,
+ BlendMode::kNormal);
}
bool CFX_RenderDevice::StretchDIBits(RetainPtr<const CFX_DIBBase> bitmap,
@@ -958,13 +964,13 @@
dest_height, &clip_box, options, blend_mode);
}
-bool CFX_RenderDevice::SetBitMask(const RetainPtr<CFX_DIBBase>& pBitmap,
+bool CFX_RenderDevice::SetBitMask(RetainPtr<const CFX_DIBBase> bitmap,
int left,
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,
- BlendMode::kNormal);
+ FX_RECT src_rect(0, 0, bitmap->GetWidth(), bitmap->GetHeight());
+ return m_pDeviceDriver->SetDIBits(std::move(bitmap), argb, src_rect, left,
+ top, BlendMode::kNormal);
}
bool CFX_RenderDevice::StretchBitMask(RetainPtr<CFX_DIBBase> bitmap,
@@ -1159,7 +1165,8 @@
pGlyph->GetWidth(), pGlyph->GetHeight(),
pGlyph, 0, 0);
}
- return SetBitMask(bitmap, bmp_rect.left, bmp_rect.top, fill_color);
+ return SetBitMask(std::move(bitmap), bmp_rect.left, bmp_rect.top,
+ fill_color);
}
auto bitmap = pdfium::MakeRetain<CFX_DIBitmap>();
if (m_bpp == 8) {
@@ -1217,10 +1224,11 @@
end_col, normalize, x_subpixel, a, r, g, b);
}
- if (bitmap->IsMaskFormat())
- SetBitMask(bitmap, bmp_rect.left, bmp_rect.top, fill_color);
- else
- SetDIBits(bitmap, bmp_rect.left, bmp_rect.top);
+ if (bitmap->IsMaskFormat()) {
+ SetBitMask(std::move(bitmap), bmp_rect.left, bmp_rect.top, fill_color);
+ } else {
+ SetDIBits(std::move(bitmap), bmp_rect.left, bmp_rect.top);
+ }
return true;
}
diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h
index 0eba712..c4495ad 100644
--- a/core/fxge/cfx_renderdevice.h
+++ b/core/fxge/cfx_renderdevice.h
@@ -95,12 +95,8 @@
RetainPtr<CFX_DIBitmap> GetBackDrop();
bool GetDIBits(const RetainPtr<CFX_DIBitmap>& pBitmap, int left, int top);
- bool SetDIBits(const RetainPtr<const CFX_DIBBase>& pBitmap,
- int left,
- int top) {
- return SetDIBitsWithBlend(pBitmap, left, top, BlendMode::kNormal);
- }
- bool SetDIBitsWithBlend(const RetainPtr<const CFX_DIBBase>& pBitmap,
+ bool SetDIBits(RetainPtr<const CFX_DIBBase> bitmap, int left, int top);
+ bool SetDIBitsWithBlend(RetainPtr<const CFX_DIBBase> bitmap,
int left,
int top,
BlendMode blend_mode);
@@ -116,7 +112,7 @@
int dest_height,
const FXDIB_ResampleOptions& options,
BlendMode blend_mode);
- bool SetBitMask(const RetainPtr<CFX_DIBBase>& pBitmap,
+ bool SetBitMask(RetainPtr<const CFX_DIBBase> bitmap,
int left,
int top,
uint32_t argb);
diff --git a/core/fxge/renderdevicedriver_iface.h b/core/fxge/renderdevicedriver_iface.h
index 134d869..6fef089 100644
--- a/core/fxge/renderdevicedriver_iface.h
+++ b/core/fxge/renderdevicedriver_iface.h
@@ -72,7 +72,7 @@
int left,
int top);
virtual RetainPtr<CFX_DIBitmap> GetBackDrop();
- virtual bool SetDIBits(const RetainPtr<const CFX_DIBBase>& pBitmap,
+ virtual bool SetDIBits(RetainPtr<const CFX_DIBBase> bitmap,
uint32_t color,
const FX_RECT& src_rect,
int dest_left,
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 73e18ca..3ccd202 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -1390,25 +1390,24 @@
return m_pBackdropBitmap;
}
-bool CFX_SkiaDeviceDriver::SetDIBits(
- const RetainPtr<const CFX_DIBBase>& pBitmap,
- uint32_t color,
- const FX_RECT& src_rect,
- int left,
- int top,
- BlendMode blend_type) {
+bool CFX_SkiaDeviceDriver::SetDIBits(RetainPtr<const CFX_DIBBase> bitmap,
+ uint32_t color,
+ const FX_RECT& src_rect,
+ int left,
+ int top,
+ BlendMode blend_type) {
if (m_pBitmap->GetBuffer().empty()) {
return true;
}
CFX_Matrix matrix = CFX_RenderDevice::GetFlipMatrix(
- pBitmap->GetWidth(), pBitmap->GetHeight(), left, top);
+ bitmap->GetWidth(), bitmap->GetHeight(), left, top);
// `bNoSmoothing` prevents linear sampling when rendering bitmaps.
FXDIB_ResampleOptions sampling_options;
sampling_options.bNoSmoothing = true;
- return StartDIBitsSkia(std::move(pBitmap), src_rect, /*alpha=*/1.0f, color,
+ return StartDIBitsSkia(std::move(bitmap), src_rect, /*alpha=*/1.0f, color,
matrix, sampling_options, blend_type);
}
diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h
index ac871c1..af98e5b 100644
--- a/core/fxge/skia/fx_skia_device.h
+++ b/core/fxge/skia/fx_skia_device.h
@@ -95,7 +95,7 @@
RetainPtr<CFX_DIBitmap> GetBackDrop() override;
- bool SetDIBits(const RetainPtr<const CFX_DIBBase>& pBitmap,
+ bool SetDIBits(RetainPtr<const CFX_DIBBase> bitmap,
uint32_t color,
const FX_RECT& src_rect,
int dest_left,
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp
index b536730..8f86bfb 100644
--- a/core/fxge/win32/cfx_psrenderer.cpp
+++ b/core/fxge/win32/cfx_psrenderer.cpp
@@ -478,14 +478,14 @@
WriteStream(buf);
}
-bool CFX_PSRenderer::SetDIBits(const RetainPtr<const CFX_DIBBase>& pSource,
+bool CFX_PSRenderer::SetDIBits(RetainPtr<const CFX_DIBBase> bitmap,
uint32_t color,
int left,
int top) {
StartRendering();
CFX_Matrix matrix = CFX_RenderDevice::GetFlipMatrix(
- pSource->GetWidth(), pSource->GetHeight(), left, top);
- return DrawDIBits(std::move(pSource), color, matrix, FXDIB_ResampleOptions());
+ bitmap->GetWidth(), bitmap->GetHeight(), left, top);
+ return DrawDIBits(std::move(bitmap), color, matrix, FXDIB_ResampleOptions());
}
bool CFX_PSRenderer::StretchDIBits(RetainPtr<const CFX_DIBBase> bitmap,
diff --git a/core/fxge/win32/cfx_psrenderer.h b/core/fxge/win32/cfx_psrenderer.h
index 87ce8c4..de978f2 100644
--- a/core/fxge/win32/cfx_psrenderer.h
+++ b/core/fxge/win32/cfx_psrenderer.h
@@ -77,7 +77,7 @@
uint32_t fill_color,
uint32_t stroke_color,
const CFX_FillRenderOptions& fill_options);
- bool SetDIBits(const RetainPtr<const CFX_DIBBase>& pBitmap,
+ bool SetDIBits(RetainPtr<const CFX_DIBBase> bitmap,
uint32_t color,
int dest_left,
int dest_top);
diff --git a/core/fxge/win32/cgdi_device_driver.cpp b/core/fxge/win32/cgdi_device_driver.cpp
index 6c0433b..b6de01f 100644
--- a/core/fxge/win32/cgdi_device_driver.cpp
+++ b/core/fxge/win32/cgdi_device_driver.cpp
@@ -388,7 +388,7 @@
SaveDC(m_hDC);
}
-bool CGdiDeviceDriver::GDI_SetDIBits(const RetainPtr<const CFX_DIBBase>& source,
+bool CGdiDeviceDriver::GDI_SetDIBits(RetainPtr<const CFX_DIBBase> source,
const FX_RECT& src_rect,
int left,
int top) {
diff --git a/core/fxge/win32/cgdi_device_driver.h b/core/fxge/win32/cgdi_device_driver.h
index fe6415f..ef837f4 100644
--- a/core/fxge/win32/cgdi_device_driver.h
+++ b/core/fxge/win32/cgdi_device_driver.h
@@ -53,7 +53,7 @@
void DrawLine(float x1, float y1, float x2, float y2);
- bool GDI_SetDIBits(const RetainPtr<const CFX_DIBBase>& source,
+ bool GDI_SetDIBits(RetainPtr<const CFX_DIBBase> source,
const FX_RECT& src_rect,
int left,
int top);
diff --git a/core/fxge/win32/cgdi_display_driver.cpp b/core/fxge/win32/cgdi_display_driver.cpp
index 58cd1cd..bb63a56 100644
--- a/core/fxge/win32/cgdi_display_driver.cpp
+++ b/core/fxge/win32/cgdi_display_driver.cpp
@@ -76,51 +76,52 @@
return ret;
}
-bool CGdiDisplayDriver::SetDIBits(const RetainPtr<const CFX_DIBBase>& pSource,
+bool CGdiDisplayDriver::SetDIBits(RetainPtr<const CFX_DIBBase> bitmap,
uint32_t color,
const FX_RECT& src_rect,
int left,
int top,
BlendMode blend_type) {
DCHECK_EQ(blend_type, BlendMode::kNormal);
- if (pSource->IsMaskFormat()) {
- int width = pSource->GetWidth();
- int height = pSource->GetHeight();
+ if (bitmap->IsMaskFormat()) {
+ int width = bitmap->GetWidth();
+ int height = bitmap->GetHeight();
int alpha = FXARGB_A(color);
- if (pSource->GetBPP() != 1 || alpha != 255) {
+ if (bitmap->GetBPP() != 1 || alpha != 255) {
auto background = pdfium::MakeRetain<CFX_DIBitmap>();
if (!background->Create(width, height, FXDIB_Format::kRgb32) ||
!GetDIBits(background, left, top) ||
- !background->CompositeMask(0, 0, width, height, std::move(pSource),
+ !background->CompositeMask(0, 0, width, height, std::move(bitmap),
color, 0, 0, BlendMode::kNormal, nullptr,
false)) {
return false;
}
FX_RECT alpha_src_rect(0, 0, width, height);
- return SetDIBits(background, 0, alpha_src_rect, left, top,
- BlendMode::kNormal);
+ return SetDIBits(std::move(background), /*color=*/0, alpha_src_rect, left,
+ top, BlendMode::kNormal);
}
FX_RECT clip_rect(left, top, left + src_rect.Width(),
top + src_rect.Height());
- return StretchDIBits(std::move(pSource), color, left - src_rect.left,
+ return StretchDIBits(std::move(bitmap), color, left - src_rect.left,
top - src_rect.top, width, height, &clip_rect,
FXDIB_ResampleOptions(), BlendMode::kNormal);
}
int width = src_rect.Width();
int height = src_rect.Height();
- if (pSource->IsAlphaFormat()) {
- auto bitmap = pdfium::MakeRetain<CFX_DIBitmap>();
- if (!bitmap->Create(width, height, FXDIB_Format::kRgb) ||
- !GetDIBits(bitmap, left, top) ||
- !bitmap->CompositeBitmap(0, 0, width, height, std::move(pSource),
- src_rect.left, src_rect.top,
- BlendMode::kNormal, nullptr, false)) {
+ if (bitmap->IsAlphaFormat()) {
+ auto rgb_bitmap = pdfium::MakeRetain<CFX_DIBitmap>();
+ if (!rgb_bitmap->Create(width, height, FXDIB_Format::kRgb) ||
+ !GetDIBits(rgb_bitmap, left, top) ||
+ !rgb_bitmap->CompositeBitmap(0, 0, width, height, std::move(bitmap),
+ src_rect.left, src_rect.top,
+ BlendMode::kNormal, nullptr, false)) {
return false;
}
FX_RECT alpha_src_rect(0, 0, width, height);
- return SetDIBits(bitmap, 0, alpha_src_rect, left, top, BlendMode::kNormal);
+ return SetDIBits(std::move(rgb_bitmap), /*color=*/0, alpha_src_rect, left,
+ top, BlendMode::kNormal);
}
- return GDI_SetDIBits(std::move(pSource), src_rect, left, top);
+ return GDI_SetDIBits(std::move(bitmap), src_rect, left, top);
}
bool CGdiDisplayDriver::UseFoxitStretchEngine(
diff --git a/core/fxge/win32/cgdi_display_driver.h b/core/fxge/win32/cgdi_display_driver.h
index f44bd56..27b982f 100644
--- a/core/fxge/win32/cgdi_display_driver.h
+++ b/core/fxge/win32/cgdi_display_driver.h
@@ -30,7 +30,7 @@
bool GetDIBits(const RetainPtr<CFX_DIBitmap>& pBitmap,
int left,
int top) override;
- bool SetDIBits(const RetainPtr<const CFX_DIBBase>& pBitmap,
+ bool SetDIBits(RetainPtr<const CFX_DIBBase> bitmap,
uint32_t color,
const FX_RECT& src_rect,
int left,
diff --git a/core/fxge/win32/cgdi_printer_driver.cpp b/core/fxge/win32/cgdi_printer_driver.cpp
index e20d805..696209f 100644
--- a/core/fxge/win32/cgdi_printer_driver.cpp
+++ b/core/fxge/win32/cgdi_printer_driver.cpp
@@ -40,28 +40,29 @@
return CGdiDeviceDriver::GetDeviceCaps(caps_id);
}
-bool CGdiPrinterDriver::SetDIBits(const RetainPtr<const CFX_DIBBase>& pSource,
+bool CGdiPrinterDriver::SetDIBits(RetainPtr<const CFX_DIBBase> bitmap,
uint32_t color,
const FX_RECT& src_rect,
int left,
int top,
BlendMode blend_type) {
- if (pSource->IsMaskFormat()) {
+ if (bitmap->IsMaskFormat()) {
FX_RECT clip_rect(left, top, left + src_rect.Width(),
top + src_rect.Height());
- int dest_width = pSource->GetWidth();
- int dest_height = pSource->GetHeight();
- return StretchDIBits(std::move(pSource), color, left - src_rect.left,
+ int dest_width = bitmap->GetWidth();
+ int dest_height = bitmap->GetHeight();
+ return StretchDIBits(std::move(bitmap), color, left - src_rect.left,
top - src_rect.top, dest_width, dest_height,
&clip_rect, FXDIB_ResampleOptions(),
BlendMode::kNormal);
}
DCHECK_EQ(blend_type, BlendMode::kNormal);
- if (pSource->IsAlphaFormat())
+ if (bitmap->IsAlphaFormat()) {
return false;
+ }
- return GDI_SetDIBits(pSource, src_rect, left, top);
+ return GDI_SetDIBits(std::move(bitmap), src_rect, left, top);
}
bool CGdiPrinterDriver::StretchDIBits(RetainPtr<const CFX_DIBBase> bitmap,
diff --git a/core/fxge/win32/cgdi_printer_driver.h b/core/fxge/win32/cgdi_printer_driver.h
index bab2fea..961a93c 100644
--- a/core/fxge/win32/cgdi_printer_driver.h
+++ b/core/fxge/win32/cgdi_printer_driver.h
@@ -21,7 +21,7 @@
private:
// CGdiPrinterDriver:
int GetDeviceCaps(int caps_id) const override;
- bool SetDIBits(const RetainPtr<const CFX_DIBBase>& pBitmap,
+ bool SetDIBits(RetainPtr<const CFX_DIBBase> bitmap,
uint32_t color,
const FX_RECT& src_rect,
int left,
diff --git a/core/fxge/win32/cps_printer_driver.cpp b/core/fxge/win32/cps_printer_driver.cpp
index 8e0f914..87c3f84 100644
--- a/core/fxge/win32/cps_printer_driver.cpp
+++ b/core/fxge/win32/cps_printer_driver.cpp
@@ -158,7 +158,7 @@
return true;
}
-bool CPSPrinterDriver::SetDIBits(const RetainPtr<const CFX_DIBBase>& pBitmap,
+bool CPSPrinterDriver::SetDIBits(RetainPtr<const CFX_DIBBase> bitmap,
uint32_t color,
const FX_RECT& src_rect,
int left,
@@ -166,7 +166,7 @@
BlendMode blend_type) {
if (blend_type != BlendMode::kNormal)
return false;
- return m_PSRenderer.SetDIBits(pBitmap, color, left, top);
+ return m_PSRenderer.SetDIBits(std::move(bitmap), color, left, top);
}
bool CPSPrinterDriver::StretchDIBits(RetainPtr<const CFX_DIBBase> bitmap,
diff --git a/core/fxge/win32/cps_printer_driver.h b/core/fxge/win32/cps_printer_driver.h
index aa2ddf4..dee5d7b 100644
--- a/core/fxge/win32/cps_printer_driver.h
+++ b/core/fxge/win32/cps_printer_driver.h
@@ -45,7 +45,7 @@
const CFX_FillRenderOptions& fill_options,
BlendMode blend_type) override;
bool GetClipBox(FX_RECT* pRect) override;
- bool SetDIBits(const RetainPtr<const CFX_DIBBase>& pBitmap,
+ bool SetDIBits(RetainPtr<const CFX_DIBBase> bitmap,
uint32_t color,
const FX_RECT& src_rect,
int left,
diff --git a/core/fxge/win32/ctext_only_printer_driver.cpp b/core/fxge/win32/ctext_only_printer_driver.cpp
index c5a4903..83594af 100644
--- a/core/fxge/win32/ctext_only_printer_driver.cpp
+++ b/core/fxge/win32/ctext_only_printer_driver.cpp
@@ -84,13 +84,12 @@
return false;
}
-bool CTextOnlyPrinterDriver::SetDIBits(
- const RetainPtr<const CFX_DIBBase>& pBitmap,
- uint32_t color,
- const FX_RECT& src_rect,
- int left,
- int top,
- BlendMode blend_type) {
+bool CTextOnlyPrinterDriver::SetDIBits(RetainPtr<const CFX_DIBBase> bitmap,
+ uint32_t color,
+ const FX_RECT& src_rect,
+ int left,
+ int top,
+ BlendMode blend_type) {
return false;
}
diff --git a/core/fxge/win32/ctext_only_printer_driver.h b/core/fxge/win32/ctext_only_printer_driver.h
index aa287f7..21f8ed5 100644
--- a/core/fxge/win32/ctext_only_printer_driver.h
+++ b/core/fxge/win32/ctext_only_printer_driver.h
@@ -36,7 +36,7 @@
const CFX_FillRenderOptions& fill_options,
BlendMode blend_type) override;
bool GetClipBox(FX_RECT* pRect) override;
- bool SetDIBits(const RetainPtr<const CFX_DIBBase>& pBitmap,
+ bool SetDIBits(RetainPtr<const CFX_DIBBase> bitmap,
uint32_t color,
const FX_RECT& src_rect,
int left,
diff --git a/xfa/fxfa/cxfa_imagerenderer.cpp b/xfa/fxfa/cxfa_imagerenderer.cpp
index 6c0cda6..7c40f50 100644
--- a/xfa/fxfa/cxfa_imagerenderer.cpp
+++ b/xfa/fxfa/cxfa_imagerenderer.cpp
@@ -8,6 +8,8 @@
#include <math.h>
+#include <utility>
+
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/dib/cfx_dibbase.h"
#include "core/fxge/dib/cfx_dibitmap.h"
@@ -84,8 +86,9 @@
dest_rect.right - image_rect.left, dest_rect.bottom - image_rect.top);
RetainPtr<CFX_DIBitmap> pStretched =
m_pDIBBase->StretchTo(dest_width, dest_height, options, &dest_clip);
- if (pStretched)
- CompositeDIBitmap(pStretched, dest_rect.left, dest_rect.top);
+ if (pStretched) {
+ CompositeDIBitmap(std::move(pStretched), dest_rect.left, dest_rect.top);
+ }
return false;
}
@@ -95,17 +98,18 @@
if (m_pTransformer->Continue(nullptr))
return true;
- RetainPtr<CFX_DIBitmap> pBitmap = m_pTransformer->DetachBitmap();
- if (!pBitmap)
+ RetainPtr<CFX_DIBitmap> bitmap = m_pTransformer->DetachBitmap();
+ if (!bitmap) {
return false;
+ }
- if (pBitmap->IsMaskFormat()) {
- m_pDevice->SetBitMask(pBitmap, m_pTransformer->result().left,
+ if (bitmap->IsMaskFormat()) {
+ m_pDevice->SetBitMask(std::move(bitmap), m_pTransformer->result().left,
m_pTransformer->result().top, 0);
} else {
- m_pDevice->SetDIBitsWithBlend(pBitmap, m_pTransformer->result().left,
- m_pTransformer->result().top,
- BlendMode::kNormal);
+ m_pDevice->SetDIBitsWithBlend(
+ std::move(bitmap), m_pTransformer->result().left,
+ m_pTransformer->result().top, BlendMode::kNormal);
}
return false;
}
@@ -115,17 +119,16 @@
return false;
}
-void CXFA_ImageRenderer::CompositeDIBitmap(
- const RetainPtr<CFX_DIBitmap>& pDIBitmap,
- int left,
- int top) {
- if (!pDIBitmap)
- return;
+void CXFA_ImageRenderer::CompositeDIBitmap(RetainPtr<CFX_DIBitmap> bitmap,
+ int left,
+ int top) {
+ CHECK(bitmap);
- if (!pDIBitmap->IsMaskFormat()) {
- if (m_pDevice->SetDIBits(pDIBitmap, left, top))
+ if (!bitmap->IsMaskFormat()) {
+ if (m_pDevice->SetDIBits(std::move(bitmap), left, top)) {
return;
- } else if (m_pDevice->SetBitMask(pDIBitmap, left, top, 0)) {
+ }
+ } else if (m_pDevice->SetBitMask(bitmap, left, top, 0)) {
return;
}
@@ -133,25 +136,31 @@
(!(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT) &&
(m_pDevice->GetRenderCaps() & FXRC_GET_BITS));
if (bGetBackGround) {
- if (pDIBitmap->IsMaskFormat())
+ if (bitmap->IsMaskFormat()) {
return;
+ }
- m_pDevice->SetDIBitsWithBlend(pDIBitmap, left, top, BlendMode::kNormal);
+ m_pDevice->SetDIBitsWithBlend(std::move(bitmap), left, top,
+ BlendMode::kNormal);
return;
}
- if (!pDIBitmap->IsAlphaFormat() ||
+ if (!bitmap->IsAlphaFormat() ||
(m_pDevice->GetRenderCaps() & FXRC_ALPHA_IMAGE)) {
return;
}
- RetainPtr<CFX_DIBitmap> pConverted = pDIBitmap->ConvertTo(FXDIB_Format::kRgb);
- if (!pConverted)
+ bitmap = bitmap->ConvertTo(FXDIB_Format::kRgb);
+ if (!bitmap) {
return;
+ }
- CXFA_ImageRenderer imageRender(m_pDevice, pConverted, m_ImageMatrix);
- if (!imageRender.Start())
+ CXFA_ImageRenderer image_renderer(m_pDevice, std::move(bitmap),
+ m_ImageMatrix);
+ if (!image_renderer.Start()) {
return;
+ }
- while (imageRender.Continue())
+ while (image_renderer.Continue()) {
continue;
+ }
}
diff --git a/xfa/fxfa/cxfa_imagerenderer.h b/xfa/fxfa/cxfa_imagerenderer.h
index 32c9490..1785410 100644
--- a/xfa/fxfa/cxfa_imagerenderer.h
+++ b/xfa/fxfa/cxfa_imagerenderer.h
@@ -32,9 +32,7 @@
private:
enum class State : uint8_t { kInitial = 0, kTransforming, kStarted };
- void CompositeDIBitmap(const RetainPtr<CFX_DIBitmap>& pDIBitmap,
- int left,
- int top);
+ void CompositeDIBitmap(RetainPtr<CFX_DIBitmap> bitmap, int left, int top);
State m_State = State::kInitial;
CFX_Matrix m_ImageMatrix;