0

Change PDFiumEngine::GetPDFiumRect() to return gfx::Rect

Make GetPDFiumRect() return a gfx::Rect instead of writing the values
that make up a gfx::Rect to 4 separate out-parameters. Then update
callers to use the returned gfx::Rect's accessors instead, and remove
all the int variables that are now unnecessary.

Change-Id: Ie05268598eca5d41429b6c03c9626ba2f9628a51
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5875101
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1357722}
This commit is contained in:
Lei Zhang
2024-09-19 18:04:17 +00:00
committed by Chromium LUCI CQ
parent 883347cb25
commit 0ba11e4bad
2 changed files with 15 additions and 39 deletions

@ -3190,19 +3190,16 @@ bool PDFiumEngine::ContinuePaint(size_t progressive_index,
return FPDF_RenderPage_Continue(page, this) != FPDF_RENDER_TOBECONTINUED;
}
int start_x;
int start_y;
int size_x;
int size_y;
gfx::Rect dirty = progressive_paints_[progressive_index].rect();
GetPDFiumRect(page_index, dirty, &start_x, &start_y, &size_x, &size_y);
const gfx::Rect pdfium_rect = GetPDFiumRect(page_index, dirty);
bool has_alpha = !!FPDFPage_HasTransparency(page);
ScopedFPDFBitmap new_bitmap = CreateBitmap(dirty, has_alpha, image_data);
FPDFBitmap_FillRect(new_bitmap.get(), start_x, start_y, size_x, size_y,
0xFFFFFFFF);
FPDFBitmap_FillRect(new_bitmap.get(), pdfium_rect.x(), pdfium_rect.y(),
pdfium_rect.width(), pdfium_rect.height(), 0xFFFFFFFF);
int rv = FPDF_RenderPageBitmap_Start(
new_bitmap.get(), page, start_x, start_y, size_x, size_y,
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(
@ -3216,17 +3213,12 @@ void PDFiumEngine::FinishPaint(size_t progressive_index, SkBitmap& image_data) {
int page_index = progressive_paints_[progressive_index].page_index();
gfx::Rect dirty_in_screen = progressive_paints_[progressive_index].rect();
int start_x;
int start_y;
int size_x;
int size_y;
FPDF_BITMAP bitmap = progressive_paints_[progressive_index].bitmap();
GetPDFiumRect(page_index, dirty_in_screen, &start_x, &start_y, &size_x,
&size_y);
const gfx::Rect pdfium_rect = GetPDFiumRect(page_index, dirty_in_screen);
// Draw the forms.
FPDF_FFLDraw(form(), bitmap, pages_[page_index]->GetPage(), start_x, start_y,
size_x, size_y,
FPDF_FFLDraw(form(), bitmap, pages_[page_index]->GetPage(), pdfium_rect.x(),
pdfium_rect.y(), pdfium_rect.width(), pdfium_rect.height(),
ToPDFiumRotation(layout_.options().default_page_orientation()),
GetRenderingFlags());
@ -3384,13 +3376,10 @@ void PDFiumEngine::DrawSelections(size_t progressive_index,
void PDFiumEngine::PaintUnavailablePage(int page_index,
const gfx::Rect& dirty,
SkBitmap& image_data) {
int start_x;
int start_y;
int size_x;
int size_y;
GetPDFiumRect(page_index, dirty, &start_x, &start_y, &size_x, &size_y);
const gfx::Rect pdfium_rect = GetPDFiumRect(page_index, dirty);
ScopedFPDFBitmap bitmap(CreateBitmap(dirty, /*has_alpha=*/false, image_data));
FPDFBitmap_FillRect(bitmap.get(), start_x, start_y, size_x, size_y,
FPDFBitmap_FillRect(bitmap.get(), pdfium_rect.x(), pdfium_rect.y(),
pdfium_rect.width(), pdfium_rect.height(),
kPendingPageColor);
gfx::Rect loading_text_in_screen(
@ -3420,19 +3409,11 @@ ScopedFPDFBitmap PDFiumEngine::CreateBitmap(const gfx::Rect& rect,
base::checked_cast<int>(region.value().stride)));
}
void PDFiumEngine::GetPDFiumRect(int page_index,
const gfx::Rect& rect,
int* start_x,
int* start_y,
int* size_x,
int* size_y) const {
gfx::Rect PDFiumEngine::GetPDFiumRect(int page_index,
const gfx::Rect& rect) const {
gfx::Rect page_rect = GetScreenRect(pages_[page_index]->rect());
page_rect.Offset(-rect.x(), -rect.y());
*start_x = page_rect.x();
*start_y = page_rect.y();
*size_x = page_rect.width();
*size_y = page_rect.height();
return page_rect;
}
int PDFiumEngine::GetRenderingFlags() const {

@ -704,12 +704,7 @@ class PDFiumEngine : public DocumentLoader::Client, public IFSDK_PAUSE {
// Given a rectangle in screen coordinates, returns the coordinates in the
// units that PDFium rendering functions expect.
void GetPDFiumRect(int page_index,
const gfx::Rect& rect,
int* start_x,
int* start_y,
int* size_x,
int* size_y) const;
gfx::Rect GetPDFiumRect(int page_index, const gfx::Rect& rect) const;
// Returns the rendering flags to pass to PDFium.
int GetRenderingFlags() const;