Remove unnecessary Clear(0) from CPDF_RenderStatus
Removes unnecessary CFX_DIBitmap::Clear(0) calls from CPDF_RenderStatus,
since a newly-created CFX_DIBitmap already starts cleared to 0. This
holds for all pixel formats except FXDIB_Format::kRgb32 on Skia, which
clears alpha to 0xFF (fully opaque).
This seems to have a particularly large impact on system time on Linux,
possibly because the kernel doesn't need to zero unwritten memory pages.
Bug: pdfium:2016
Change-Id: I73e2dd0adfd45989bbd17e511320703bceab6ae2
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/105390
Reviewed-by: Nigi <nigi@chromium.org>
Auto-Submit: K. Moon <kmoon@chromium.org>
Commit-Queue: Nigi <nigi@chromium.org>
Commit-Queue: K. Moon <kmoon@chromium.org>
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 4bd8248..dd0e228 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -627,9 +627,6 @@
if (!bitmap_device.Create(width, height, FXDIB_Format::kArgb, backdrop))
return true;
- RetainPtr<CFX_DIBitmap> bitmap = bitmap_device.GetBitmap();
- bitmap->Clear(0);
-
CFX_Matrix new_matrix = mtObj2Device;
new_matrix.Translate(-rect.left, -rect.top);
@@ -639,7 +636,6 @@
if (!pTextMask->Create(width, height, FXDIB_Format::k8bppMask))
return true;
- pTextMask->Clear(0);
CFX_DefaultRenderDevice text_device;
text_device.Attach(pTextMask);
for (size_t i = 0; i < pPageObj->m_ClipPath.GetTextCount(); ++i) {
@@ -668,7 +664,7 @@
if (CFX_DefaultRenderDevice::SkiaIsDefaultRenderer()) {
// Safe because `CFX_SkiaDeviceDriver` always uses pre-multiplied alpha.
// TODO(crbug.com/pdfium/2011): Remove the need for this.
- bitmap->ForcePreMultiply();
+ bitmap_device.GetBitmap()->ForcePreMultiply();
}
#endif // _SKIA_SUPPORT
m_bStopped = bitmap_render.m_bStopped;
@@ -691,8 +687,8 @@
if (pPageObj->IsForm()) {
transparency.SetGroup();
}
- CompositeDIBitmap(bitmap, rect.left, rect.top, 0, 255, blend_type,
- transparency);
+ CompositeDIBitmap(bitmap_device.GetBitmap(), rect.left, rect.top, 0, 255,
+ blend_type, transparency);
return true;
}
@@ -949,7 +945,6 @@
FXDIB_Format::kArgb, nullptr)) {
return true;
}
- bitmap_device.GetBitmap()->Clear(0);
CPDF_RenderStatus status(m_pContext, &bitmap_device);
status.SetOptions(options);
status.SetTransparency(pForm->GetTransparency());
@@ -1015,7 +1010,6 @@
if (!pBitmap->Create(rect.Width(), rect.Height(), FXDIB_Format::k8bppMask))
return true;
- pBitmap->Clear(0);
for (const TextGlyphPos& glyph : glyphs) {
if (!glyph.m_pGlyph || !glyph.m_pGlyph->GetBitmap()->IsMaskFormat())
continue;