Bug 123043 - Remote Layer Tree: Double-buffering and minimization of repaints
Summary: Remote Layer Tree: Double-buffering and minimization of repaints
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tim Horton
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-18 16:02 PDT by Tim Horton
Modified: 2013-10-18 17:49 PDT (History)
3 users (show)

See Also:


Attachments
patch (18.38 KB, patch)
2013-10-18 16:19 PDT, Tim Horton
simon.fraser: review+
Details | Formatted Diff | Diff
revised (19.41 KB, patch)
2013-10-18 17:36 PDT, Tim Horton
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Horton 2013-10-18 16:02:46 PDT
We should not repaint the entirety of a layer every time it is dirtied.
Comment 1 Tim Horton 2013-10-18 16:19:40 PDT
Created attachment 214611 [details]
patch
Comment 2 WebKit Commit Bot 2013-10-18 16:21:41 PDT
Attachment 214611 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCore/WebCore.exp.in', u'Source/WebCore/WebCore.xcodeproj/project.pbxproj', u'Source/WebCore/platform/graphics/mac/WebLayer.h', u'Source/WebCore/platform/graphics/mac/WebLayer.mm', u'Source/WebKit2/ChangeLog', u'Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp', u'Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerBackingStore.h', u'Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerBackingStore.mm']" exit_code: 1
Source/WebCore/platform/graphics/mac/WebLayer.h:47:  The parameter name "context" adds no information, so it should be removed.  [readability/parameter_name] [5]
Total errors found: 1 in 9 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Simon Fraser (smfr) 2013-10-18 16:35:31 PDT
Comment on attachment 214611 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=214611&action=review

> Source/WebCore/platform/graphics/mac/WebLayer.mm:64
> +    bool isTiledLayer = [layer isKindOfClass:[CATiledLayer class]];

Move this down.

> Source/WebCore/platform/graphics/mac/WebLayer.mm:117
> +    // If we have no dirty rects, repaint the whole layer.

Comment is the reverse of the immediately following statement which is confusing.

> Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerBackingStore.mm:124
> +        Region cleanRegion(layerBounds);
> +        cleanRegion.subtract(m_dirtyRegion);
> +
> +        RetainPtr<CGImageRef> frontImage = m_frontBuffer->makeCGImage();
> +
> +        for (const auto& rect : cleanRegion.rects())
> +            context->drawNativeImage(frontImage.get(), m_frontBuffer->size(), ColorSpaceDeviceRGB, rect, rect);

Seems like this could be much slower than copying over the entire layer in many cases.
Comment 4 Tim Horton 2013-10-18 17:00:52 PDT
(In reply to comment #3)
> (From update of attachment 214611 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=214611&action=review
> 
> > Source/WebCore/platform/graphics/mac/WebLayer.mm:64
> > +    bool isTiledLayer = [layer isKindOfClass:[CATiledLayer class]];
> 
> Move this down.
> 
> > Source/WebCore/platform/graphics/mac/WebLayer.mm:117
> > +    // If we have no dirty rects, repaint the whole layer.
> 
> Comment is the reverse of the immediately following statement which is confusing.

OK, I'll flip it around.

> > Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerBackingStore.mm:124
> > +        Region cleanRegion(layerBounds);
> > +        cleanRegion.subtract(m_dirtyRegion);
> > +
> > +        RetainPtr<CGImageRef> frontImage = m_frontBuffer->makeCGImage();
> > +
> > +        for (const auto& rect : cleanRegion.rects())
> > +            context->drawNativeImage(frontImage.get(), m_frontBuffer->size(), ColorSpaceDeviceRGB, rect, rect);
> 
> Seems like this could be much slower than copying over the entire layer in many cases.

Yeah. I meant to use the five-or-less rect set, not the raw set.
Comment 5 Tim Horton 2013-10-18 17:36:03 PDT
Created attachment 214622 [details]
revised
Comment 6 Simon Fraser (smfr) 2013-10-18 17:44:41 PDT
Comment on attachment 214622 [details]
revised

View in context: https://bugs.webkit.org/attachment.cgi?id=214622&action=review

> Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerBackingStore.mm:99
> +        setNeedsDisplay();

It's odd to call setNeedsDisplay() inside of display().

> Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerBackingStore.mm:108
> +        setNeedsDisplay(indicatorRect);

Ditto.
Comment 7 Tim Horton 2013-10-18 17:49:39 PDT
http://trac.webkit.org/changeset/157658