WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
82800
Support pattern transformations in canvas
https://bugs.webkit.org/show_bug.cgi?id=82800
Summary
Support pattern transformations in canvas
Dean Jackson
Reported
2012-03-30 16:00:23 PDT
Canvas v5 supports transformations in patterns - ability to transform a pattern var identity = new SVGMatrix(); context.fillStyle = context.createPattern(img, 'repeat'); context.fillStyle.setTransform(identity.rotate(angle)); context.fillRect(0, 0, canvas.width, canvas.height);
Attachments
patch
(7.37 KB, patch)
2012-06-27 19:49 PDT
,
Dongseong Hwang
webkit.review.bot
: commit-queue-
Details
Formatted Diff
Diff
patch v.2
(7.97 KB, patch)
2012-06-28 04:30 PDT
,
Dongseong Hwang
no flags
Details
Formatted Diff
Diff
patch v.3
(8.02 KB, patch)
2012-06-28 05:15 PDT
,
Dongseong Hwang
no flags
Details
Formatted Diff
Diff
patch v.4
(8.51 KB, patch)
2012-06-28 17:46 PDT
,
Dongseong Hwang
simon.fraser
: review-
simon.fraser
: commit-queue-
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2012-03-30 16:00:56 PDT
<
rdar://problem/11159356
>
Dongseong Hwang
Comment 2
2012-06-27 19:49:42 PDT
Created
attachment 149858
[details]
patch
Dongseong Hwang
Comment 3
2012-06-27 19:50:04 PDT
Canvas v5 [1] supports transformations in patterns. [1]
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-canvaspattern-settransform
WebKit Review Bot
Comment 4
2012-06-27 20:40:48 PDT
Comment on
attachment 149858
[details]
patch
Attachment 149858
[details]
did not pass chromium-ews (chromium-xvfb): Output:
http://queues.webkit.org/results/13098972
Dongseong Hwang
Comment 5
2012-06-27 23:18:25 PDT
Oops, I'll survey how to solve and patch again. Actually, I don't know why V8 does not compile but I'll survey. I'll be very glad if someone give me hints.
Dongseong Hwang
Comment 6
2012-06-28 04:30:20 PDT
Created
attachment 149923
[details]
patch v.2
Dongseong Hwang
Comment 7
2012-06-28 04:31:36 PDT
CanvasPattern::setTransform needs ENABLE(SVG) because it uses SVGMatrix.
Dongseong Hwang
Comment 8
2012-06-28 05:15:16 PDT
Created
attachment 149930
[details]
patch v.3
Dongseong Hwang
Comment 9
2012-06-28 05:17:15 PDT
Comment on
attachment 149930
[details]
patch v.3 View in context:
https://bugs.webkit.org/attachment.cgi?id=149930&action=review
> Source/WebCore/html/canvas/CanvasPattern.h:32 > +#include "SVGPropertyTearOff.h"
It is solution that I found for building with V8. However, it is ugly. Is it Ok? or I need advice. Sorry for lack of knowledge of binding.
WebKit Review Bot
Comment 10
2012-06-28 08:56:52 PDT
Attachment 149930
[details]
did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/fast..." exit_code: 1 Source/WebCore/html/canvas/CanvasPattern.h:54: The parameter name "transform" adds no information, so it should be removed. [readability/parameter_name] [5] Total errors found: 1 in 8 files If any of these errors are false positives, please file a bug against check-webkit-style.
Dongseong Hwang
Comment 11
2012-06-28 17:46:37 PDT
Created
attachment 150051
[details]
patch v.4
Dongseong Hwang
Comment 12
2012-06-28 17:47:29 PDT
Comment on
attachment 150051
[details]
patch v.4 View in context:
https://bugs.webkit.org/attachment.cgi?id=150051&action=review
> Source/WebCore/svg/SVGMatrix.h:28 > +#include "SVGPropertyTearOff.h"
It is solution that I found for building with V8. Is it Ok? or I need advice, again.
Dongseong Hwang
Comment 13
2012-07-13 19:14:05 PDT
I'll very appreciate if Dean or Simon take a look at this bug.
Simon Fraser (smfr)
Comment 14
2012-07-16 11:05:05 PDT
Comment on
attachment 150051
[details]
patch v.4 View in context:
https://bugs.webkit.org/attachment.cgi?id=150051&action=review
> LayoutTests/fast/canvas/script-tests/pattern-with-settransform.js:53 > +var svgElement = document.createElementNS("
http://www.w3.org/2000/svg
", "svg"); > +var matrix = svgElement.createSVGMatrix();
Does new SVGMatrix() not work?
> LayoutTests/fast/canvas/script-tests/pattern-with-settransform.js:55 > +matrix = matrix.translate(20, 20); > +pattern.setTransform(matrix);
I think you need some more complex tests here. e.g. drawing a transformed pattern when the context is already transformed. Testing transforms like rotates and skews. Testing that clipping of such transforms works.
> Source/WebCore/html/canvas/CanvasPattern.cpp:70 > + m_pattern->setPatternSpaceTransform(static_cast<const AffineTransform&>(transform));
Why is the cast necessary? SVGMatrix _is_ a AffineTransform.
> Source/WebCore/html/canvas/CanvasPattern.h:52 > +#if ENABLE(SVG) > + void setTransform(const SVGMatrix&); > +#endif
It's unfortunate that this feature is tied to SVG, but I guess that's how the spec is.
>> Source/WebCore/svg/SVGMatrix.h:28 >> +#if USE(V8) >> +// Only used from the bindings. >> +#include "SVGPropertyTearOff.h" > > It is solution that I found for building with V8. > > Is it Ok? or I need advice, again.
Seems like this should be fixed on the V8 side, not here.
Dongseong Hwang
Comment 15
2012-07-16 21:18:39 PDT
Thank you for reviewing. (In reply to
comment #14
)
> (From update of
attachment 150051
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=150051&action=review
> > > LayoutTests/fast/canvas/script-tests/pattern-with-settransform.js:53 > > +var svgElement = document.createElementNS("
http://www.w3.org/2000/svg
", "svg"); > > +var matrix = svgElement.createSVGMatrix(); > > Does new SVGMatrix() not work?
Yes, 'new SVGMatrix()' works! sorry.
> > > LayoutTests/fast/canvas/script-tests/pattern-with-settransform.js:55 > > +matrix = matrix.translate(20, 20); > > +pattern.setTransform(matrix); > > I think you need some more complex tests here. e.g. drawing a transformed pattern when the context is already transformed. Testing transforms like rotates and skews. Testing that clipping of such transforms works.
Ok, I'll update.
> > > Source/WebCore/html/canvas/CanvasPattern.cpp:70 > > + m_pattern->setPatternSpaceTransform(static_cast<const AffineTransform&>(transform)); > > Why is the cast necessary? SVGMatrix _is_ a AffineTransform.
It is not necessary. I'll fix it.
> > > Source/WebCore/html/canvas/CanvasPattern.h:52 > > +#if ENABLE(SVG) > > + void setTransform(const SVGMatrix&); > > +#endif > > It's unfortunate that this feature is tied to SVG, but I guess that's how the spec is.
Do You mean "#if ENABLE(SVG)" is proper and I don't need to change it?
> > >> Source/WebCore/svg/SVGMatrix.h:28 > >> +#if USE(V8) > >> +// Only used from the bindings. > >> +#include "SVGPropertyTearOff.h" > > > > It is solution that I found for building with V8. > > > > Is it Ok? or I need advice, again. > > Seems like this should be fixed on the V8 side, not here.
I'll implement v8 binding in V8CanvasPatternCustom.cpp. Is it Ok? However, I think the correct solution is to amend CodeGeneratorV8.pm, but I don't have enough knowledge. If you think the later is correct, I'll guard '#if !USE(V8)' to CanvasPattern::setTransform and create new bug to enable CanvasPattern::setTransform on V8.
kangax
Comment 16
2013-02-11 10:54:02 PST
@Huang Dongsung Any progress on this?
Dongseong Hwang
Comment 17
2013-02-11 15:46:34 PST
(In reply to
comment #16
)
> @Huang Dongsung Any progress on this?
Sorry. I forgot this. I'll update soon.
Ahmad Saleem
Comment 18
2024-05-17 04:21:10 PDT
Isn't it supported now?
https://searchfox.org/wubkat/rev/7051b8f5cd90af80f03a58d74741cdb04c800b6e/Source/WebCore/html/canvas/CanvasPattern.cpp#75
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug