0

[unseasoned-pdf] Create a new PaintReadyRect constructor.

To migrate DoPaint() to PdfViewPluginBase in the future, a common
PaintReadyRect constructor that works for both Pepper and non-Pepper
plugins is needed.

Since Image can be created from either SkBitmap or pp::ImageData, this
CL creates a PaintReadyRect constructor that takes an Image as input,
and replaces the existing PaintReadyRect constructors with it.

This CL also cleans up some unused forward declaration and headers in
the modified files.

Bug: 1140629
Change-Id: Ic0da310eb7b8e9a0d7c4a17401e611db51c329b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2657787
Commit-Queue: Hui Yingst <nigi@chromium.org>
Reviewed-by: Daniel Hosseinian <dhoss@chromium.org>
Reviewed-by: K. Moon <kmoon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#848814}
This commit is contained in:
Hui Yingst
2021-01-30 00:41:15 +00:00
committed by Chromium LUCI CQ
parent a6beef5d94
commit 6af455f1ec
3 changed files with 11 additions and 24 deletions

@ -44,6 +44,7 @@
#include "pdf/ppapi_migration/bitmap.h"
#include "pdf/ppapi_migration/geometry_conversions.h"
#include "pdf/ppapi_migration/graphics.h"
#include "pdf/ppapi_migration/image.h"
#include "pdf/ppapi_migration/input_event_conversions.h"
#include "pdf/ppapi_migration/url_loader.h"
#include "pdf/ppapi_migration/value_conversions.h"
@ -1180,7 +1181,7 @@ void OutOfProcessInstance::DoPaint(const std::vector<gfx::Rect>& paint_rects,
mutable_image_data().eraseColor(GetBackgroundColor());
gfx::Rect rect(gfx::SkISizeToSize(image_data().dimensions()));
ready->push_back(
PaintReadyRect(rect, pepper_image_data_, /*flush_now=*/true));
PaintReadyRect(rect, Image(pepper_image_data_), /*flush_now=*/true));
}
if (!received_viewport_message() || !needs_reraster())
@ -1204,7 +1205,7 @@ void OutOfProcessInstance::DoPaint(const std::vector<gfx::Rect>& paint_rects,
engine()->Paint(pdf_rect, mutable_image_data(), pdf_ready, pdf_pending);
for (auto& ready_rect : pdf_ready) {
ready_rect.Offset(available_area().OffsetFromOrigin());
ready->push_back(PaintReadyRect(ready_rect, pepper_image_data_));
ready->push_back(PaintReadyRect(ready_rect, Image(pepper_image_data_)));
}
for (auto& pending_rect : pdf_pending) {
pending_rect.Offset(available_area().OffsetFromOrigin());
@ -1219,7 +1220,7 @@ void OutOfProcessInstance::DoPaint(const std::vector<gfx::Rect>& paint_rects,
if (rect.y() < first_page_ypos) {
gfx::Rect region = gfx::IntersectRects(
rect, gfx::Rect(gfx::Size(plugin_size().width(), first_page_ypos)));
ready->push_back(PaintReadyRect(region, pepper_image_data_));
ready->push_back(PaintReadyRect(region, Image(pepper_image_data_)));
mutable_image_data().erase(GetBackgroundColor(),
gfx::RectToSkIRect(region));
}
@ -1230,7 +1231,8 @@ void OutOfProcessInstance::DoPaint(const std::vector<gfx::Rect>& paint_rects,
if (!intersection.IsEmpty()) {
mutable_image_data().erase(background_part.color,
gfx::RectToSkIRect(intersection));
ready->push_back(PaintReadyRect(intersection, pepper_image_data_));
ready->push_back(
PaintReadyRect(intersection, Image(pepper_image_data_)));
}
}
}

@ -4,20 +4,15 @@
#include "pdf/paint_ready_rect.h"
#include "ppapi/cpp/image_data.h"
#include "ppapi/cpp/rect.h"
#include "pdf/ppapi_migration/image.h"
#include "ui/gfx/geometry/rect.h"
namespace chrome_pdf {
PaintReadyRect::PaintReadyRect(const gfx::Rect& rect,
const pp::ImageData& image_data,
const Image& image,
bool flush_now)
: rect_(rect), image_(image_data), flush_now_(flush_now) {}
PaintReadyRect::PaintReadyRect(const gfx::Rect& rect,
const SkBitmap& bitmap,
bool flush_now)
: rect_(rect), image_(bitmap), flush_now_(flush_now) {}
: rect_(rect), image_(image), flush_now_(flush_now) {}
PaintReadyRect::PaintReadyRect(const PaintReadyRect& other) = default;

@ -8,13 +8,6 @@
#include "pdf/ppapi_migration/image.h"
#include "ui/gfx/geometry/rect.h"
class SkBitmap;
namespace pp {
class ImageData;
class Rect;
} // namespace pp
namespace chrome_pdf {
// Stores information about a rectangle that has finished painting. The
@ -23,10 +16,7 @@ namespace chrome_pdf {
class PaintReadyRect {
public:
PaintReadyRect(const gfx::Rect& rect,
const pp::ImageData& image_data,
bool flush_now = false);
PaintReadyRect(const gfx::Rect& rect,
const SkBitmap& bitmap,
const Image& image,
bool flush_now = false);
PaintReadyRect(const PaintReadyRect& other);