Commit 5e8d978c authored by Vladimir Levin's avatar Vladimir Levin Committed by Commit Bot

[PE] Remove GetDocument() calls from a frequently used PaintInvalidator func.

This patch removes GetDocument() call which loads a large object into
memory for every PaintInvalidator::InvalidatePaint call on a LayoutObject.

Instead, it stores this value on the paint invalidator and updates it
whwnever we encounter a new LocalFrameView during the prepaint walk.

On small dom / small invalidation this only has a small benefit, but
for complicated dom, my local perf tests show large improvements.

R=chrishtr@chromium.org

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I51139b8f8a802d608b583656d0be8bd2b7f13022
Reviewed-on: https://chromium-review.googlesource.com/924277Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: vmpstr <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537414}
parent ed096ee3
...@@ -557,8 +557,7 @@ void PaintInvalidator::InvalidatePaint( ...@@ -557,8 +557,7 @@ void PaintInvalidator::InvalidatePaint(
UpdatePaintingLayer(object, context); UpdatePaintingLayer(object, context);
if (object.GetDocument().Printing() && if (document_printing_ && !RuntimeEnabledFeatures::PrintBrowserEnabled())
!RuntimeEnabledFeatures::PrintBrowserEnabled())
return; // Don't invalidate paints if we're printing. return; // Don't invalidate paints if we're printing.
// TODO(chrishtr): refactor to remove these slow paths by expanding their // TODO(chrishtr): refactor to remove these slow paths by expanding their
......
...@@ -153,6 +153,7 @@ class PaintInvalidator { ...@@ -153,6 +153,7 @@ class PaintInvalidator {
private: private:
friend struct PaintInvalidatorContext; friend struct PaintInvalidatorContext;
friend class PrePaintTreeWalk;
template <typename Rect, typename Point> template <typename Rect, typename Point>
static LayoutRect MapLocalRectToVisualRectInBacking( static LayoutRect MapLocalRectToVisualRectInBacking(
const LayoutObject&, const LayoutObject&,
...@@ -175,6 +176,7 @@ class PaintInvalidator { ...@@ -175,6 +176,7 @@ class PaintInvalidator {
PaintInvalidatorContext&); PaintInvalidatorContext&);
Vector<const LayoutObject*> pending_delayed_paint_invalidations_; Vector<const LayoutObject*> pending_delayed_paint_invalidations_;
bool document_printing_ = false;
}; };
} // namespace blink } // namespace blink
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "core/paint/compositing/CompositingLayerPropertyUpdater.h" #include "core/paint/compositing/CompositingLayerPropertyUpdater.h"
#include "core/paint/ng/ng_paint_fragment.h" #include "core/paint/ng/ng_paint_fragment.h"
#include "platform/graphics/paint/GeometryMapper.h" #include "platform/graphics/paint/GeometryMapper.h"
#include "platform/wtf/AutoReset.h"
namespace blink { namespace blink {
...@@ -88,6 +89,9 @@ void PrePaintTreeWalk::Walk(LocalFrameView& frame_view) { ...@@ -88,6 +89,9 @@ void PrePaintTreeWalk::Walk(LocalFrameView& frame_view) {
auto context = [this]() -> PrePaintTreeWalkContext& { auto context = [this]() -> PrePaintTreeWalkContext& {
return context_storage_.back(); return context_storage_.back();
}; };
AutoReset<bool> printing_reset(
&paint_invalidator_.document_printing_,
frame_view.GetFrame().GetDocument()->Printing());
// ancestorOverflowLayer does not cross frame boundaries. // ancestorOverflowLayer does not cross frame boundaries.
context().ancestor_overflow_paint_layer = nullptr; context().ancestor_overflow_paint_layer = nullptr;
......
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