Open Bug 843224 Opened 11 years ago Updated 2 years ago

Use CopyOnWrite for async 2D Canvas swap

Categories

(Core :: Graphics: Layers, defect)

x86
macOS
defect

Tracking

()

People

(Reporter: BenWa, Unassigned)

References

Details

We currently do this for tiling and it works well. When we need to send an update to the compositor we mark it as read only and send it asynchronously. The compositor will then release the read lock after it's uploaded the image. If in the mean time content needs to use that surface it check the read lock and does a copy if required.

We could do something similar for canvas. We can even check if the first call is a fillRect and avoid the copy entirely and allocate a blank surface. In the average case we might skip a lot of copies even if the context doesn't fillRect because the compositor might upload it before it's needed by content.
As request by brad here's are example of this issued in the code base:
mxr.mozilla.org/mozilla-central/source/gfx/layers/basic/BasicTiledThebesLayer.cpp#573

line 573 we paint into the tiles.
line 574 we lock the tiles are read only.
line 585 we send the tiles to the compositor

on the compositor we when we're done with the tiles we unlock then here:
http://mxr.mozilla.org/mozilla-central/source/gfx/layers/opengl/TiledThebesLayerOGL.cpp#167

meanwhile the main thread will race towards updating the tile in the next paint:
http://mxr.mozilla.org/mozilla-central/source/gfx/layers/basic/BasicTiledThebesLayer.cpp#178

If the tile has been unlocked first then the tile is reused. If the tile is still locked then it is copied first and a new tile is used for drawing.
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.