Bug 232527

Summary: Factor out didDraw / didDrawEntireCanvas calls in canvas drawing functions
Product: WebKit Reporter: Cameron McCormack (:heycam) <heycam>
Component: CanvasAssignee: Cameron McCormack (:heycam) <heycam>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, changseok, dino, esprehn+autocc, ews-watchlist, gyuyoung.kim, koivisto, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch for landing
none
Patch for landing none

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].