Changeset 181710 in webkit


Ignore:
Timestamp:
Mar 18, 2015 3:17:34 PM (9 years ago)
Author:
Simon Fraser
Message:

Avoid repaints when changing transform on an element with multiple background images
https://bugs.webkit.org/show_bug.cgi?id=142841

Reviewed by Zalan Bujtas.

Source/WebCore:

Replace the cheap test for changed images in RenderElement::updateFillImages()
with an exhaustive test that walks the entire list of background images,
since any ensuing repaint is way more expensive than a slightly more expensive check here.

Test: fast/repaint/multiple-backgrounds-style-change.html

  • rendering/RenderElement.cpp:

(WebCore::RenderElement::updateFillImages):

  • rendering/style/FillLayer.cpp:

(WebCore::layerImagesIdentical): See if both images are the same (either none
or both mask images, and same image pointer).
(WebCore::FillLayer::imagesIdentical): Walk the two FillLayer lists, checking the images
on each one. Returns false if we reach the end of one list before the other, or the images
are different.

  • rendering/style/FillLayer.h: New static function; static because

it compares two FillLayer lists, and I think that makes more sense than
a member function.

LayoutTests:

Test that changes transform on a composited element with 2 background images,
and tests for no repaints.

  • fast/repaint/multiple-backgrounds-style-change-expected.txt: Added.
  • fast/repaint/multiple-backgrounds-style-change.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r181701 r181710  
     12015-03-18  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Avoid repaints when changing transform on an element with multiple background images
     4        https://bugs.webkit.org/show_bug.cgi?id=142841
     5
     6        Reviewed by Zalan Bujtas.
     7       
     8        Test that changes transform on a composited element with 2 background images,
     9        and tests for no repaints.
     10
     11        * fast/repaint/multiple-backgrounds-style-change-expected.txt: Added.
     12        * fast/repaint/multiple-backgrounds-style-change.html: Added.
     13
    1142015-03-18  Marcos Chavarría Teijeiro  <chavarria1991@gmail.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r181709 r181710  
     12015-03-18  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Avoid repaints when changing transform on an element with multiple background images
     4        https://bugs.webkit.org/show_bug.cgi?id=142841
     5
     6        Reviewed by Zalan Bujtas.
     7       
     8        Replace the cheap test for changed images in RenderElement::updateFillImages()
     9        with an exhaustive test that walks the entire list of background images,
     10        since any ensuing repaint is way more expensive than a slightly more expensive check here.
     11       
     12        Test: fast/repaint/multiple-backgrounds-style-change.html
     13
     14        * rendering/RenderElement.cpp:
     15        (WebCore::RenderElement::updateFillImages):
     16        * rendering/style/FillLayer.cpp:
     17        (WebCore::layerImagesIdentical): See if both images are the same (either none
     18        or both mask images, and same image pointer).
     19        (WebCore::FillLayer::imagesIdentical): Walk the two FillLayer lists, checking the images
     20        on each one. Returns false if we reach the end of one list before the other, or the images
     21        are different.
     22        * rendering/style/FillLayer.h: New static function; static because
     23        it compares two FillLayer lists, and I think that makes more sense than
     24        a member function.
     25
    1262015-03-18  Anders Carlsson  <andersca@apple.com>
    227
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r181691 r181710  
    338338{
    339339    // Optimize the common case
    340     if (oldLayers && !oldLayers->next() && newLayers && !newLayers->next() && oldLayers->image() == newLayers->image() && oldLayers->maskImage() == newLayers->maskImage())
     340    if (FillLayer::imagesIdentical(oldLayers, newLayers))
    341341        return;
    342342   
  • trunk/Source/WebCore/rendering/style/FillLayer.cpp

    r179413 r181710  
    393393}
    394394
     395static inline bool layerImagesIdentical(const FillLayer& layer1, const FillLayer& layer2)
     396{
     397    // We just care about pointer equivalency.
     398    return layer1.hasMaskImage() == layer2.hasMaskImage() && layer1.image() == layer2.image();
     399}
     400
     401bool FillLayer::imagesIdentical(const FillLayer* layer1, const FillLayer* layer2)
     402{
     403    for (; layer1 && layer2; layer1 = layer1->next(), layer2 = layer2->next()) {
     404        if (!layerImagesIdentical(*layer1, *layer2))
     405            return false;
     406    }
     407
     408    return !layer1 && !layer2;
     409}
     410
    395411} // namespace WebCore
  • trunk/Source/WebCore/rendering/style/FillLayer.h

    r179413 r181710  
    160160    void cullEmptyLayers();
    161161
     162    static bool imagesIdentical(const FillLayer*, const FillLayer*);
     163
    162164    static EFillAttachment initialFillAttachment(EFillLayerType) { return ScrollBackgroundAttachment; }
    163165    static EFillBox initialFillClip(EFillLayerType) { return BorderFillBox; }
Note: See TracChangeset for help on using the changeset viewer.