Bug 255208

Summary: CanvasRenderingContext2D drawImage doesn't work correctly with transform when copying from self
Product: WebKit Reporter: Gregg Tavares <gman>
Component: CanvasAssignee: Said Abou-Hallawa <sabouhallawa>
Status: RESOLVED FIXED    
Severity: Normal CC: dino, heycam, karlcow, sabouhallawa, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: BrowserCompat, InRadar
Version: Safari Technology Preview   
Hardware: All   
OS: All   
Attachments:
Description Flags
repo of canvas drawImage issue none

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.