[Experiment] Implement code to detect high frequency painting
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Nov 2017 16:11:55 +0000 (16:11 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Nov 2017 16:11:55 +0000 (16:11 +0000)
commit274795cf6ef026031ee348144c3b2feee498af6f
tree0290587c4678bb00b14f06a890fc46f7b7efc0f2
parent7be9baadc7732852dc11ad40e04a37dfaac8879f
[Experiment] Implement code to detect high frequency painting
https://bugs.webkit.org/show_bug.cgi?id=179118
Source/WebCore:

<rdar://problem/35347068>

Reviewed by Simon Fraser.

This patch implements a model for detecting that objects whose
graphics resources we want to cache (like glyphs or paths) are painting
frequently enough that it's worth taking the memory hit to cache them.

Paint frequency detection is done at the self-painting RenderLayer level, since
a lower level of granularity (e.g., per-RenderObject) would be too memory-intensive.

* rendering/PaintInfo.h:
(WebCore::PaintInfo::PaintInfo):
(WebCore::PaintInfo::enclosingSelfPaintingLayer):
Add the enclosing self-painting layer that is currently painting to the PaintInfo
so that objects that have cachaeble graphics resources can notify the layer when
they actually paint them.

* rendering/RenderLayer.cpp:
(WebCore::PaintFrequencyInfo::PaintFrequencyInfo):
(WebCore::PaintFrequencyInfo::paintingFrequently const):
(WebCore::PaintFrequencyInfo::updatePaintFrequency):
(WebCore::PaintFrequencyInfo::paintingCacheableResource):
RenderLayers have a pointer to PaintFrequencyInfo that is allocated once you've
painted cachaeble resources.

(WebCore::RenderLayer::paintLayerContents):
(WebCore::RenderLayer::paintBackgroundForFragments):
(WebCore::RenderLayer::paintForegroundForFragmentsWithPhase):
(WebCore::RenderLayer::paintOutlineForFragments):
(WebCore::RenderLayer::paintMaskForFragments):
(WebCore::RenderLayer::paintChildClippingMaskForFragments):
(WebCore::RenderLayer::calculateClipRects const):
* rendering/RenderLayer.h:
Patch to pass the layer with the PaintInfo.

* testing/Internals.cpp:
(WebCore::Internals::isPaintingFrequently):
(WebCore::Internals::incrementFrequentPaintCounter):
* testing/Internals.h:
* testing/Internals.idl:
Test methods for making layout tests to ensure we go into the mode properly.

LayoutTests:

Reviewed by Simon Fraser.

* fast/block/block-move-frequent-paint-expected.txt: Added.
* fast/block/block-move-frequent-paint.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224582 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/block/block-move-frequent-paint-expected.txt [new file with mode: 0644]
LayoutTests/fast/block/block-move-frequent-paint.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/PaintInfo.h
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl