Bug 3615

Summary: canvas transform matrix does not apply to patterns
Product: WebKit Reporter: Randy Reddig <ydnar>
Component: Layout and RenderingAssignee: Anders Carlsson <andersca>
Status: RESOLVED FIXED    
Severity: Normal    
Priority: P2    
Version: 412   
Hardware: PC   
OS: Windows 2000   
URL: http://dev.shaderlab.com/test/canvas/scanlines.html
Attachments:
Description Flags
Create patterns lazily hyatt: review+

Description Randy Reddig 2005-06-19 22:18:25 PDT
CanvasPattern usage is more interesting when it can be transformed by the
canvas' current transform matrix. Scaling/rotation of bitmaps make interesting
effects.

The WHATWG spec on the subject is ambiguous on the subject:

http://www.whatwg.org/specs/web-apps/current-work/#canvaspattern0

In addition, it specifies the origin of the pattern to be centered on the center
of the canvas, which makes the output pixels of a rendering operation dependent
on the size of the viewport, not orthagonal as all other raster ops.
Comment 1 Ian 'Hixie' Hickson 2005-06-20 02:53:24 PDT
What's ambiguous?
Comment 2 Randy Reddig 2005-06-20 07:56:34 PDT
Whether patterns (or gradients) are subject to transformation. The document does
not specify.
Comment 3 Ian 'Hixie' Hickson 2005-06-20 17:53:26 PDT
"The transformation matrix is applied to all drawing operations prior to their
being rendered."
Comment 4 Randy Reddig 2005-06-20 19:24:35 PDT
Okay, so you agree that Safari's behavior is incorrect then?
Comment 5 Ian 'Hixie' Hickson 2005-06-21 03:35:25 PDT
I've no idea what Safari does, but if it ignores the transformation matrix when
painting patterns, then I'd say yes.
Comment 6 Joost de Valk (AlthA) 2005-06-21 23:08:03 PDT
Then i'll say yes too :)
Comment 7 John Sullivan 2005-06-24 16:19:43 PDT
This is also in Radar as <rdar://problem/4161599>
Comment 8 Anders Carlsson 2005-07-12 12:19:59 PDT
Created attachment 2930 [details]
Create patterns lazily

Here's a patch that changes the behavior so that fill and stroke patterns are
created in the respective fill and stroke functions using the current CTM.
Comment 9 Eric Seidel (no email) 2005-07-12 12:56:58 PDT
It might be interesting to compare this with how I did the (incomplete) pattern code for KCanvas.  The 
same fixes might be applicable there.

The file in question is
WebCore/kcanvas/device/quartz/KRenderingPaintServerQuartz.mm
Comment 10 Dave Hyatt 2005-07-12 13:50:42 PDT
Comment on attachment 2930 [details]
Create patterns lazily

r=me
Comment 11 Justin Garcia 2005-07-24 16:01:10 PDT
Landed this patch