Bug 255208 - CanvasRenderingContext2D drawImage doesn't work correctly with transform when copying from self
Summary: CanvasRenderingContext2D drawImage doesn't work correctly with transform when...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: Safari Technology Preview
Hardware: All All
: P2 Normal
Assignee: Said Abou-Hallawa
URL:
Keywords: BrowserCompat, InRadar
Depends on:
Blocks:
 
Reported: 2023-04-09 16:55 PDT by Gregg Tavares
Modified: 2023-04-11 18:55 PDT (History)
6 users (show)

See Also:


Attachments
repo of canvas drawImage issue (759 bytes, text/html)
2023-04-09 16:55 PDT, Gregg Tavares
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gregg Tavares 2023-04-09 16:55:30 PDT
Created attachment 465824 [details]
repo of canvas drawImage issue

Here's an example where a canvas is 400x200

It sets the scale to 2x2  eg: ctx.scale(2,2)
It then copies the canvas to itself with

    ctx.drawImage(ctx.canvas
      2, 0, 398, 200,    // these values are in source pixels (ie, 400x200)
      0, 0, 199, 100);   // these values are in transformed pixels (ie, 200x100)

this works in Firefox and Chrome but fails in Safari

https://jsgist.org/?src=fedaf98f88bb57622af24481944bbefc

Attached a stand alone repo
Comment 1 Radar WebKit Bug Importer 2023-04-10 12:13:05 PDT
<rdar://problem/107844963>
Comment 2 Said Abou-Hallawa 2023-04-10 12:29:12 PDT
Pull request: https://github.com/WebKit/WebKit/pull/12580
Comment 3 EWS 2023-04-11 15:01:47 PDT
Committed 262841@main (aa025e46a961): <https://commits.webkit.org/262841@main>

Reviewed commits have been landed. Closing PR #12580 and removing active labels.