servo / pathfinder

A fast, practical GPU rasterizer for fonts and vector graphics
Apache License 2.0
3.54k stars 198 forks source link

Scale offset in source image's own coordinate space #482

Closed Adjective-Object closed 2 years ago

Adjective-Object commented 2 years ago

At present pathfinder_canvas treats the offset of sx/sy in draw_subimage as offsets in the destination canvas's coordinate space (See #481).

In order to match the behaviour of the html canvas API, these should be treated as offsets in the source image's coordinate space.

This fixes https://github.com/servo/pathfinder/issues/481. You can check the implementation against https://github.com/Adjective-Object/pathfinder_canvas_drawimage_repro.

For a quick visual reference, in these before/after images, the right side is made with the web canvas API In firefox, and the left side is the equivalent code in pathfinder_canvas. Before: image After: image