0

[PDF] Delete old code path that PdfPaintManagerDrawsBackground replaced

Now that https://crrev.com/1370910 has reached Stable channel, delete
the PdfPaintManagerDrawsBackground kill switch and the old code path
that is now unreachable.

Bug: 40216952
Change-Id: Idc3f5ea612e660335b08a22977e61030f5ec9cfa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6216505
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1415716}
This commit is contained in:
Lei Zhang
2025-02-04 11:33:09 -08:00
committed by Chromium LUCI CQ
parent 5d85a541f1
commit 6c6d44856c
6 changed files with 18 additions and 45 deletions

@ -289,15 +289,12 @@ void PaintManager::DoPaint() {
for (const auto& ready_rect : ready_now) {
const SkRect skia_rect = gfx::RectToSkRect(ready_rect.rect());
if (base::FeatureList::IsEnabled(
features::kPdfPaintManagerDrawsBackground)) {
// Paint the page's white background, and then paint the page's contents.
// If `ready_rect.image()` has transparencies, this is necessary to paint
// over the stale data in `skia_rect` in `surface_`.
SkPaint paint;
paint.setColor(SK_ColorWHITE);
surface_->getCanvas()->drawRect(skia_rect, paint);
}
// Paint the page's white background, and then paint the page's contents.
// If `ready_rect.image()` has transparencies, this is necessary to paint
// over the stale data in `skia_rect` in `surface_`.
SkPaint paint;
paint.setColor(SK_ColorWHITE);
surface_->getCanvas()->drawRect(skia_rect, paint);
surface_->getCanvas()->drawImageRect(
ready_rect.image(), skia_rect, skia_rect, SkSamplingOptions(), nullptr,

@ -27,12 +27,6 @@ BASE_FEATURE(kPdfIncrementalLoading,
BASE_FEATURE(kPdfOopif, "PdfOopif", base::FEATURE_DISABLED_BY_DEFAULT);
// Kill switch in case this goes horribly wrong.
// TODO(crbug.com/40216952): Remove after this lands safely in a Stable release.
BASE_FEATURE(kPdfPaintManagerDrawsBackground,
"PdfPaintManagerDrawsBackground",
base::FEATURE_ENABLED_BY_DEFAULT);
// "Partial loading" refers to loading only specific parts of the PDF.
// TODO(crbug.com/40123601): Remove this once partial loading is fixed.
BASE_FEATURE(kPdfPartialLoading,

@ -19,7 +19,6 @@ BASE_DECLARE_FEATURE(kAccessiblePDFForm);
BASE_DECLARE_FEATURE(kPdfCr23);
BASE_DECLARE_FEATURE(kPdfIncrementalLoading);
BASE_DECLARE_FEATURE(kPdfOopif);
BASE_DECLARE_FEATURE(kPdfPaintManagerDrawsBackground);
BASE_DECLARE_FEATURE(kPdfPartialLoading);
BASE_DECLARE_FEATURE(kPdfPortfolio);
BASE_DECLARE_FEATURE(kPdfSearchify);

@ -2330,17 +2330,11 @@ void PdfViewWebPlugin::OnViewportChanged(
const gfx::Size new_image_size =
PaintManager::GetNewContextSize(old_image_size, plugin_rect_.size());
if (new_image_size != old_image_size) {
SkAlphaType alpha_type;
if (base::FeatureList::IsEnabled(
features::kPdfPaintManagerDrawsBackground)) {
alpha_type = kUnpremul_SkAlphaType;
} else {
alpha_type = kPremul_SkAlphaType;
}
// Ignore the result. If the allocation fails, the image data buffer will be
// empty and the code below will handle that.
(void)image_data_.tryAllocPixels(SkImageInfo::MakeN32(
new_image_size.width(), new_image_size.height(), alpha_type));
(void)image_data_.tryAllocPixels(
SkImageInfo::MakeN32(new_image_size.width(), new_image_size.height(),
kUnpremul_SkAlphaType));
first_paint_ = true;
}

@ -3212,26 +3212,20 @@ bool PDFiumEngine::ContinuePaint(size_t progressive_index,
}
const gfx::Rect& dirty = paint.rect();
const gfx::Rect pdfium_rect = GetPDFiumRect(paint.page_index(), dirty);
const bool has_alpha = !!FPDFPage_HasTransparency(page);
uint32_t fill_color;
if (base::FeatureList::IsEnabled(features::kPdfPaintManagerDrawsBackground)) {
// When `has_alpha` is true, use a transparent bitmap to render correctly.
// If the bitmap was painted white, then certain blend operations would
// blend into the white color and draw incorrectly. Instead, PaintManager
// will draw the white page under this bitmap.
fill_color = has_alpha ? 0x00000000 : 0xFFFFFFFF;
} else {
// In the old code, which is here as a fallback, `fill_color` is always
// white, as PaintManager does not draw the page's background.
fill_color = 0xFFFFFFFF;
}
ScopedFPDFBitmap new_bitmap = CreateBitmap(dirty, has_alpha, image_data);
FPDF_BITMAP new_bitmap_ptr = new_bitmap.get();
paint.SetBitmapAndImageData(std::move(new_bitmap), image_data);
const gfx::Rect pdfium_rect = GetPDFiumRect(paint.page_index(), dirty);
// When `has_alpha` is true, use a transparent bitmap to render correctly.
// If the bitmap was painted white, then certain blend operations would
// blend into the white color and draw incorrectly. Instead, PaintManager
// will draw the white page under this bitmap.
const uint32_t fill_color = has_alpha ? 0x00000000 : 0xFFFFFFFF;
FPDFBitmap_FillRect(new_bitmap_ptr, pdfium_rect.x(), pdfium_rect.y(),
pdfium_rect.width(), pdfium_rect.height(), fill_color);
return FPDF_RenderPageBitmap_Start(
new_bitmap_ptr, page, pdfium_rect.x(), pdfium_rect.y(),
pdfium_rect.width(), pdfium_rect.height(),

@ -1833,12 +1833,6 @@ Thumbnail PDFiumPage::GenerateThumbnail(float device_pixel_ratio) {
FPDF_PAGE page = GetPage();
const bool has_alpha = !!FPDFPage_HasTransparency(page);
const int format = has_alpha ? FPDFBitmap_BGRA : FPDFBitmap_BGRx;
uint32_t fill_color;
if (base::FeatureList::IsEnabled(features::kPdfPaintManagerDrawsBackground)) {
fill_color = has_alpha ? 0x00000000 : 0xFFFFFFFF;
} else {
fill_color = 0xFFFFFFFF;
}
Thumbnail thumbnail = CreateThumbnail(device_pixel_ratio);
const gfx::Size& image_size = thumbnail.image_size();
@ -1848,6 +1842,7 @@ Thumbnail PDFiumPage::GenerateThumbnail(float device_pixel_ratio) {
FPDFBitmap_CreateEx(image_size.width(), image_size.height(), format,
thumbnail.GetImageData().data(), thumbnail.stride()));
const uint32_t fill_color = has_alpha ? 0x00000000 : 0xFFFFFFFF;
FPDFBitmap_FillRect(fpdf_bitmap.get(), /*left=*/0, /*top=*/0,
image_size.width(), image_size.height(), fill_color);