0

Refactor PDFiumEngine::ContinuePaint()

- Use a reference to refer to `progressive_paints_[progressive_index]`
  as `paint`. There are no lifetime issues in this method since the
  `progressive_paints_` container is not being modified.
- With `paint`, `page_index` can go away, since calling
  `paint.page_index()` is not that more verbose.
- Take a references to `paint.rect()` instead of copying it.
- Get rid of the `rv` variable.

Change-Id: I07f12048bcef29614ba02dc17d2c7d9b28d8e5da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5874105
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1357737}
This commit is contained in:
Lei Zhang
2024-09-19 18:21:14 +00:00
committed by Chromium LUCI CQ
parent 4821f48f5a
commit 9e05d16644

@ -3179,32 +3179,30 @@ size_t PDFiumEngine::StartPaint(int page_index, const gfx::Rect& dirty) {
bool PDFiumEngine::ContinuePaint(size_t progressive_index,
SkBitmap& image_data) {
CHECK_LT(progressive_index, progressive_paints_.size());
auto& paint = progressive_paints_[progressive_index];
last_progressive_start_time_ = base::Time::Now();
int page_index = progressive_paints_[progressive_index].page_index();
CHECK(PageIndexInBounds(page_index));
FPDF_PAGE page = pages_[page_index]->GetPage();
if (progressive_paints_[progressive_index].bitmap()) {
CHECK(PageIndexInBounds(paint.page_index()));
FPDF_PAGE page = pages_[paint.page_index()]->GetPage();
if (paint.bitmap()) {
return FPDF_RenderPage_Continue(page, this) != FPDF_RENDER_TOBECONTINUED;
}
gfx::Rect dirty = progressive_paints_[progressive_index].rect();
const gfx::Rect pdfium_rect = GetPDFiumRect(page_index, dirty);
const gfx::Rect& dirty = paint.rect();
const gfx::Rect pdfium_rect = GetPDFiumRect(paint.page_index(), dirty);
bool has_alpha = !!FPDFPage_HasTransparency(page);
ScopedFPDFBitmap new_bitmap = CreateBitmap(dirty, has_alpha, image_data);
FPDFBitmap_FillRect(new_bitmap.get(), pdfium_rect.x(), pdfium_rect.y(),
FPDF_BITMAP new_bitmap_ptr = new_bitmap.get();
paint.SetBitmapAndImageData(std::move(new_bitmap), image_data);
FPDFBitmap_FillRect(new_bitmap_ptr, pdfium_rect.x(), pdfium_rect.y(),
pdfium_rect.width(), pdfium_rect.height(), 0xFFFFFFFF);
int rv = FPDF_RenderPageBitmap_Start(
new_bitmap.get(), page, pdfium_rect.x(), pdfium_rect.y(),
pdfium_rect.width(), pdfium_rect.height(),
ToPDFiumRotation(layout_.options().default_page_orientation()),
GetRenderingFlags(), this);
progressive_paints_[progressive_index].SetBitmapAndImageData(
std::move(new_bitmap), image_data);
return rv != FPDF_RENDER_TOBECONTINUED;
return FPDF_RenderPageBitmap_Start(
new_bitmap_ptr, page, pdfium_rect.x(), pdfium_rect.y(),
pdfium_rect.width(), pdfium_rect.height(),
ToPDFiumRotation(layout_.options().default_page_orientation()),
GetRenderingFlags(), this) != FPDF_RENDER_TOBECONTINUED;
}
void PDFiumEngine::FinishPaint(size_t progressive_index, SkBitmap& image_data) {