Commit d7209bb8 authored by Xianzhu Wang's avatar Xianzhu Wang

[PE] Don't validate DisplayItemClients if PaintController changed nothing

This is mainly a performance optimization because we don't need
FinishCycle() if PaintController has nothing changed.

By the way it can also avoid the immediate bad effect (but not the
root cause) of bug 859294.

Bug: 859294
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I3a4d26253fef2b04adc805ef94b93c5479c88759
Reviewed-on: https://chromium-review.googlesource.com/1124980
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572376}
parent eaa38da0
......@@ -825,6 +825,35 @@ TEST_P(PaintAndRasterInvalidationTest, UpdateVisualRectWhenPrinting) {
EXPECT_EQ(LayoutRect(300, 0, 150, 20), c->FirstFragment().VisualRect());
};
TEST_P(PaintAndRasterInvalidationTest, PaintPropertyChange) {
SetUpHTML(*this);
Element* target = GetDocument().getElementById("target");
auto* object = target->GetLayoutObject();
target->setAttribute(HTMLNames::classAttr, "background transform");
GetDocument().View()->UpdateAllLifecyclePhases();
auto* layer = ToLayoutBoxModelObject(object)->Layer();
GetDocument().View()->SetTracksPaintInvalidations(true);
target->setAttribute(HTMLNames::styleAttr, "transform: scale(3)");
GetDocument().View()->UpdateAllLifecyclePhasesExceptPaint();
EXPECT_FALSE(layer->NeedsRepaint());
const auto* transform =
object->FirstFragment().PaintProperties()->Transform();
EXPECT_TRUE(transform->Changed(*transform->Parent()));
GetDocument().View()->UpdateAllLifecyclePhases();
EXPECT_THAT(GetRasterInvalidationTracking()->Invalidations(),
UnorderedElementsAre(
RasterInvalidationInfo{
layer, layer->DebugName(), IntRect(0, 0, 100, 200),
PaintInvalidationReason::kPaintProperty},
RasterInvalidationInfo{
layer, layer->DebugName(), IntRect(0, 0, 150, 300),
PaintInvalidationReason::kPaintProperty}));
EXPECT_FALSE(transform->Changed(*transform->Parent()));
GetDocument().View()->SetTracksPaintInvalidations(false);
}
class PaintInvalidatorTestClient : public EmptyChromeClient {
public:
void InvalidateRect(const IntRect&) override {
......
......@@ -497,6 +497,7 @@ void PaintController::CommitNewDisplayItems() {
#endif
cache_is_all_invalid_ = false;
committed_ = true;
new_cached_subsequences_.swap(current_cached_subsequences_);
new_cached_subsequences_.clear();
......@@ -528,21 +529,25 @@ void PaintController::FinishCycle() {
DCHECK(new_display_item_list_.IsEmpty());
DCHECK(new_paint_chunks_.IsInInitialState());
// Validate display item clients that have validly cached subsequence or
// display items in this PaintController.
for (auto& item : current_cached_subsequences_) {
if (item.key->IsCacheable())
item.key->Validate();
}
for (const auto& item : current_paint_artifact_->GetDisplayItemList()) {
const auto& client = item.Client();
client.ClearPartialInvalidationVisualRect();
if (client.IsCacheable())
client.Validate();
}
for (const auto& chunk : current_paint_artifact_->PaintChunks()) {
if (chunk.id.client.IsCacheable())
chunk.id.client.Validate();
if (committed_) {
committed_ = false;
// Validate display item clients that have validly cached subsequence or
// display items in this PaintController.
for (auto& item : current_cached_subsequences_) {
if (item.key->IsCacheable())
item.key->Validate();
}
for (const auto& item : current_paint_artifact_->GetDisplayItemList()) {
const auto& client = item.Client();
client.ClearPartialInvalidationVisualRect();
if (client.IsCacheable())
client.Validate();
}
for (const auto& chunk : current_paint_artifact_->PaintChunks()) {
if (chunk.id.client.IsCacheable())
chunk.id.client.Validate();
}
}
current_paint_artifact_->FinishCycle();
......
......@@ -347,6 +347,7 @@ class PLATFORM_EXPORT PaintController {
bool subsequence_caching_disabled_ = false;
bool cache_is_all_invalid_ = true;
bool committed_ = false;
// A stack recording current frames' first paints.
Vector<FrameFirstPaint> frame_first_paints_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment