RESOLVED FIXED 223056
Optimize canvas repaints
https://bugs.webkit.org/show_bug.cgi?id=223056
Summary Optimize canvas repaints
Simon Fraser (smfr)
Reported 2021-03-10 21:40:10 PST
Optimize canvas repaints
Attachments
For EWS (19.18 KB, patch)
2021-03-10 21:47 PST, Simon Fraser (smfr)
ews-feeder: commit-queue-
For EWS (30.17 KB, patch)
2021-03-11 17:19 PST, Simon Fraser (smfr)
no flags
Patch (21.80 KB, patch)
2021-03-15 14:50 PDT, Simon Fraser (smfr)
no flags
Patch (21.89 KB, patch)
2021-03-15 14:51 PDT, Simon Fraser (smfr)
sabouhallawa: review+
Simon Fraser (smfr)
Comment 1 2021-03-10 21:47:17 PST
Simon Fraser (smfr)
Comment 2 2021-03-11 17:19:19 PST
Simon Fraser (smfr)
Comment 3 2021-03-15 14:50:43 PDT
Simon Fraser (smfr)
Comment 4 2021-03-15 14:51:36 PDT
Said Abou-Hallawa
Comment 5 2021-03-15 16:45:25 PDT
Comment on attachment 423245 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=423245&action=review > Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:1322 > boundingRect.inflate(state().lineWidth / 2); Should we call inflateStrokeRect() since it handles the miterLimit and lineCap of the stroke? > Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:2094 > + if (m_dirtyRect == oldDirtyRect) > + canvasBase().didDraw(WTF::nullopt); > + else > + canvasBase().didDraw(m_dirtyRect); Maybe if (m_dirtyRect.contains(oldDirtyRect)) canvasBase().didDraw(WTF::nullopt); else { m_dirtyRect.unite(dirtyRect); canvasBase().didDraw(m_dirtyRect); } > Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:2104 > + return m_dirtyRect == backingStoreBounds(); Is it okay to check for FloatRect equality like this? Should we use some sort of areEssentiallyEqual()? Or maybe comparing enclosingIntRect() instead? > Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:2549 > + if (isEntireBackingStoreDirty()) > + didDraw(WTF::nullopt); > + else if (repaintEntireCanvas) > + didDrawEntireCanvas(); > + else > didDraw(textRect); This code was repeated multiple times in this patch. Can't this logic be moved to didDraw()? For example, pass 'repaintEntireCanvas' to didDraw() and make didDraw() check for isEntireBackingStoreDirty().
Simon Fraser (smfr)
Comment 6 2021-03-15 17:36:47 PDT
> > Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:2549 > > + if (isEntireBackingStoreDirty()) > > + didDraw(WTF::nullopt); > > + else if (repaintEntireCanvas) > > + didDrawEntireCanvas(); > > + else > > didDraw(textRect); > > This code was repeated multiple times in this patch. Can't this logic be > moved to didDraw()? For example, pass 'repaintEntireCanvas' to didDraw() and > make didDraw() check for isEntireBackingStoreDirty(). I need to avoid computing the rect in this case: didDraw(path.fastBoundingRect()); which hampers refactoring this (hence my comment in the change log about WTF::function<> approaches).
Simon Fraser (smfr)
Comment 7 2021-03-15 20:07:53 PDT
Radar WebKit Bug Importer
Comment 8 2021-03-15 20:08:15 PDT
Note You need to log in before you can comment on or make changes to this bug.