Convert PaintReadyRect to a class
Switches PaintReadyRect from a struct to a class, since this type can enforce invariants like most members being immutable. Bug: 1099020 Change-Id: I79ed7dcb60273c3db0d5223a64fd5e7cdeb0e633 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2311069 Commit-Queue: K. Moon <kmoon@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Daniel Hosseinian <dhoss@chromium.org> Cr-Commit-Position: refs/heads/master@{#790634}
This commit is contained in:
@@ -43,7 +43,7 @@ class TextInput_Dev;
|
|||||||
|
|
||||||
namespace chrome_pdf {
|
namespace chrome_pdf {
|
||||||
|
|
||||||
struct PaintReadyRect;
|
class PaintReadyRect;
|
||||||
|
|
||||||
class OutOfProcessInstance : public pp::Instance,
|
class OutOfProcessInstance : public pp::Instance,
|
||||||
public pp::Find_Private,
|
public pp::Find_Private,
|
||||||
|
@@ -221,8 +221,8 @@ void PaintAggregator::ScrollRect(const gfx::Rect& clip_rect,
|
|||||||
InvalidateRectInternal(leftover_rect, false);
|
InvalidateRectInternal(leftover_rect, false);
|
||||||
|
|
||||||
for (auto& update_rect : update_.ready_rects) {
|
for (auto& update_rect : update_.ready_rects) {
|
||||||
if (update_.scroll_rect.Contains(update_rect.rect))
|
if (update_.scroll_rect.Contains(update_rect.rect()))
|
||||||
update_rect.rect = ScrollPaintRect(update_rect.rect, amount);
|
update_rect.set_rect(ScrollPaintRect(update_rect.rect(), amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update_.synthesized_scroll_damage_rect_) {
|
if (update_.synthesized_scroll_damage_rect_) {
|
||||||
@@ -249,7 +249,7 @@ void PaintAggregator::InvalidateRectInternal(const gfx::Rect& rect_old,
|
|||||||
gfx::Rect rect = rect_old;
|
gfx::Rect rect = rect_old;
|
||||||
// Check if any rects that are ready to be painted overlap.
|
// Check if any rects that are ready to be painted overlap.
|
||||||
for (size_t i = 0; i < update_.ready_rects.size(); ++i) {
|
for (size_t i = 0; i < update_.ready_rects.size(); ++i) {
|
||||||
const gfx::Rect& existing_rect = update_.ready_rects[i].rect;
|
const gfx::Rect& existing_rect = update_.ready_rects[i].rect();
|
||||||
if (rect.Intersects(existing_rect)) {
|
if (rect.Intersects(existing_rect)) {
|
||||||
// Re-invalidate in case the union intersects other paint rects.
|
// Re-invalidate in case the union intersects other paint rects.
|
||||||
rect.Union(existing_rect);
|
rect.Union(existing_rect);
|
||||||
|
@@ -249,7 +249,7 @@ void PaintManager::DoPaint() {
|
|||||||
// previous image, but if we flush, it'll revert to using the blank image.
|
// previous image, but if we flush, it'll revert to using the blank image.
|
||||||
// We make an exception for the first paint since we want to show the
|
// We make an exception for the first paint since we want to show the
|
||||||
// default background color instead of the pepper default of black.
|
// default background color instead of the pepper default of black.
|
||||||
if (ready_rect.flush_now &&
|
if (ready_rect.flush_now() &&
|
||||||
(!view_size_changed_waiting_for_paint_ || first_paint_)) {
|
(!view_size_changed_waiting_for_paint_ || first_paint_)) {
|
||||||
ready_now.push_back(ready_rect);
|
ready_now.push_back(ready_rect);
|
||||||
} else {
|
} else {
|
||||||
@@ -267,8 +267,8 @@ void PaintManager::DoPaint() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& ready_rect : ready_now) {
|
for (const auto& ready_rect : ready_now) {
|
||||||
graphics_.PaintImageData(ready_rect.image_data, pp::Point(),
|
graphics_.PaintImageData(ready_rect.image_data(), pp::Point(),
|
||||||
PPRectFromRect(ready_rect.rect));
|
PPRectFromRect(ready_rect.rect()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Flush();
|
Flush();
|
||||||
|
@@ -13,13 +13,15 @@ namespace chrome_pdf {
|
|||||||
PaintReadyRect::PaintReadyRect(const pp::Rect& rect,
|
PaintReadyRect::PaintReadyRect(const pp::Rect& rect,
|
||||||
const pp::ImageData& image_data,
|
const pp::ImageData& image_data,
|
||||||
bool flush_now)
|
bool flush_now)
|
||||||
: rect(RectFromPPRect(rect)),
|
: rect_(RectFromPPRect(rect)),
|
||||||
image_data(image_data),
|
image_data_(image_data),
|
||||||
flush_now(flush_now) {}
|
flush_now_(flush_now) {}
|
||||||
|
|
||||||
PaintReadyRect::PaintReadyRect(const PaintReadyRect& other) = default;
|
PaintReadyRect::PaintReadyRect(const PaintReadyRect& other) = default;
|
||||||
|
|
||||||
PaintReadyRect& PaintReadyRect::operator=(const PaintReadyRect& other) =
|
PaintReadyRect& PaintReadyRect::operator=(const PaintReadyRect& other) =
|
||||||
default;
|
default;
|
||||||
|
|
||||||
|
PaintReadyRect::~PaintReadyRect() = default;
|
||||||
|
|
||||||
} // namespace chrome_pdf
|
} // namespace chrome_pdf
|
||||||
|
@@ -17,19 +17,28 @@ namespace chrome_pdf {
|
|||||||
// Stores information about a rectangle that has finished painting. The
|
// Stores information about a rectangle that has finished painting. The
|
||||||
// `PaintManager` will paint it only when everything else on the screen is also
|
// `PaintManager` will paint it only when everything else on the screen is also
|
||||||
// ready.
|
// ready.
|
||||||
struct PaintReadyRect {
|
class PaintReadyRect {
|
||||||
|
public:
|
||||||
PaintReadyRect(const pp::Rect& rect,
|
PaintReadyRect(const pp::Rect& rect,
|
||||||
const pp::ImageData& image_data,
|
const pp::ImageData& image_data,
|
||||||
bool flush_now = false);
|
bool flush_now = false);
|
||||||
PaintReadyRect(const PaintReadyRect& other);
|
PaintReadyRect(const PaintReadyRect& other);
|
||||||
PaintReadyRect& operator=(const PaintReadyRect& other);
|
PaintReadyRect& operator=(const PaintReadyRect& other);
|
||||||
|
~PaintReadyRect();
|
||||||
|
|
||||||
gfx::Rect rect;
|
const gfx::Rect& rect() const { return rect_; }
|
||||||
pp::ImageData image_data;
|
void set_rect(const gfx::Rect& rect) { rect_ = rect; }
|
||||||
|
|
||||||
|
const pp::ImageData& image_data() const { return image_data_; }
|
||||||
|
|
||||||
// Whether to flush to screen immediately; otherwise, when the rest of the
|
// Whether to flush to screen immediately; otherwise, when the rest of the
|
||||||
// plugin viewport is ready.
|
// plugin viewport is ready.
|
||||||
bool flush_now;
|
bool flush_now() const { return flush_now_; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
gfx::Rect rect_;
|
||||||
|
pp::ImageData image_data_;
|
||||||
|
bool flush_now_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chrome_pdf
|
} // namespace chrome_pdf
|
||||||
|
Reference in New Issue
Block a user