Bug 232527 - Factor out didDraw / didDrawEntireCanvas calls in canvas drawing functions
Summary: Factor out didDraw / didDrawEntireCanvas calls in canvas drawing functions
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Cameron McCormack (:heycam)
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-10-30 00:08 PDT by Cameron McCormack (:heycam)
Modified: 2021-11-04 21:52 PDT (History)
8 users (show)

See Also:


Attachments
Patch (8.36 KB, patch)
2021-10-30 00:13 PDT, Cameron McCormack (:heycam)
no flags Details | Formatted Diff | Diff
Patch for landing (2.72 KB, patch)
2021-11-04 20:34 PDT, Cameron McCormack (:heycam)
no flags Details | Formatted Diff | Diff
Patch for landing (8.37 KB, patch)
2021-11-04 21:08 PDT, Cameron McCormack (:heycam)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cameron McCormack (:heycam) 2021-10-30 00:08:57 PDT
There are various canvas drawing functions in CanvasRenderingContext2DBase that end similarly:

```
    if (isEntireBackingStoreDirty())
        didDraw(std::nullopt);
    else if (repaintEntireCanvas)
        didDrawEntireCanvas();
    else
        didDraw(... some rect calculation ...);
```

We can factor out the commonality.
Comment 1 Radar WebKit Bug Importer 2021-10-30 00:09:25 PDT
<rdar://problem/84834950>
Comment 2 Cameron McCormack (:heycam) 2021-10-30 00:13:41 PDT
Created attachment 442904 [details]
Patch
Comment 3 Antti Koivisto 2021-11-04 00:00:26 PDT
Comment on attachment 442904 [details]
Patch

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

> Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:1065
> +        return path.fastBoundingRect();

I suppose this is the case where computing the rect is expensive? (thus the lambda)
Comment 4 Cameron McCormack (:heycam) 2021-11-04 00:10:57 PDT
(In reply to Antti Koivisto from comment #3)
> > Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:1065
> > +        return path.fastBoundingRect();
> 
> I suppose this is the case where computing the rect is expensive? (thus the
> lambda)

I imagine so.  I didn't measure.  But I know Simon was careful previously not to compute it if not needed.
Comment 5 EWS 2021-11-04 00:12:39 PDT
Tools/Scripts/svn-apply failed to apply attachment 442904 [details] to trunk.
Please resolve the conflicts and upload a new patch.
Comment 6 Cameron McCormack (:heycam) 2021-11-04 20:34:15 PDT
Created attachment 443371 [details]
Patch for landing
Comment 7 Cameron McCormack (:heycam) 2021-11-04 21:08:37 PDT
Created attachment 443374 [details]
Patch for landing
Comment 8 EWS 2021-11-04 21:52:48 PDT
Committed r285334 (243897@main): <https://commits.webkit.org/243897@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 443374 [details].