RESOLVED FIXED 53085
[cairo] Fix LayoutTests/fast/canvas/patternfill-repeat.html
https://bugs.webkit.org/show_bug.cgi?id=53085
Summary [cairo] Fix LayoutTests/fast/canvas/patternfill-repeat.html
Carlos Garcia Campos
Reported 2011-01-25 07:12:00 PST
This test is using the different background repeat modes: repeat, repeat-x, repeat-y and no-repeat. The problem is that cairo doesn't have a extend mode for repeat-x/y and we are always using EXTEND_REPEAT. We could use EXTEND_NONE for repeat-x/y and paint the pattern multiple times ourselves, or we could try to clip the row/column we want to draw.
Attachments
Clipping repeats. (11.75 KB, patch)
2012-06-15 03:19 PDT, Dominik Röttsches (drott)
no flags
Clipping repeats, v2, OwnPtr for path. (11.77 KB, patch)
2012-06-15 05:02 PDT, Dominik Röttsches (drott)
no flags
Clipping repeats, v3 (7.92 KB, patch)
2012-06-18 04:30 PDT, Dominik Röttsches (drott)
no flags
Clipping repeats, v4, OwnPtrCairo free fix. (8.11 KB, patch)
2012-06-19 03:32 PDT, Dominik Röttsches (drott)
no flags
Carlos Garcia Campos
Comment 1 2011-01-25 07:46:43 PST
Carlos Garcia Campos
Comment 2 2011-01-25 07:48:04 PST
Reopening, webkit-patch fixed it when I committed r76593
Zan Dobersek
Comment 3 2012-05-05 09:29:19 PDT
The following tests were found to be passing consistently after moving from using the Skipped list to using test_expectations.txt: fast/canvas/patternfill-repeat.html Their expectations were removed in r116122[1] (covered by bug #85591). Tests that are covered by this bug and are still failing are the following: canvas/philip/tests/2d.pattern.paint.repeatx.coord1.html canvas/philip/tests/2d.pattern.paint.repeatx.outside.html canvas/philip/tests/2d.pattern.paint.repeaty.coord1.html canvas/philip/tests/2d.pattern.paint.repeaty.outside.html 1: http://trac.webkit.org/changeset/116122
Dominik Röttsches (drott)
Comment 4 2012-06-15 03:19:00 PDT
Created attachment 147780 [details] Clipping repeats.
Carlos Garcia Campos
Comment 5 2012-06-15 04:22:51 PDT
Comment on attachment 147780 [details] Clipping repeats. View in context: https://bugs.webkit.org/attachment.cgi?id=147780&action=review > Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp:305 > + cairo_append_path(m_cr.get(), currentPath); > +} I think you are leaking the path here, you should call cairo_path_destroy(), or even better you could use OwnPtr.
Dominik Röttsches (drott)
Comment 6 2012-06-15 05:02:23 PDT
Created attachment 147794 [details] Clipping repeats, v2, OwnPtr for path.
Carlos Garcia Campos
Comment 7 2012-06-15 05:52:26 PDT
Comment on attachment 147794 [details] Clipping repeats, v2, OwnPtr for path. Thanks for the patch, it looks good to me in general, but I prefer that martin or alex review it since they know this code much better than me.
Martin Robinson
Comment 8 2012-06-15 10:35:17 PDT
Comment on attachment 147794 [details] Clipping repeats, v2, OwnPtr for path. View in context: https://bugs.webkit.org/attachment.cgi?id=147794&action=review Great work, just a few comments. > Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp:277 > + int patternWidth = patternImage->width(); > + int patternHeight = patternImage->height(); There's no need to cache these values, you only use them once. > Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp:280 > + bool repeatX = state.fillPattern->repeatX(); > + bool repeatY = state.fillPattern->repeatY(); I would recommend moving these and patternImage down to right before you use them. > Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp:283 > + OwnPtr<cairo_path_t> currentPath = adoptPtr(cairo_copy_path(m_cr.get())); > + cairo_new_path(m_cr.get()); Probably should drop a comment here that says something like "We need to preserve any pre-existing paths." > Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp:285 > + FloatRect clipRect = targetRect; Why not just start with the cairo_clip_extents?
Dominik Röttsches (drott)
Comment 9 2012-06-18 04:30:42 PDT
Created attachment 148081 [details] Clipping repeats, v3
Dominik Röttsches (drott)
Comment 10 2012-06-18 04:33:49 PDT
Thanks for the review and positive feedback, Martin. Here's an updated patch. (In reply to comment #8) > (From update of attachment 147794 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=147794&action=review > > Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp:277 > > + int patternWidth = patternImage->width(); > > + int patternHeight = patternImage->height(); > > There's no need to cache these values, you only use them once. Moved down into where they are used. > > Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp:280 > > + bool repeatX = state.fillPattern->repeatX(); > > + bool repeatY = state.fillPattern->repeatY(); > > I would recommend moving these and patternImage down to right before you use them. Done. > > Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp:283 > > + OwnPtr<cairo_path_t> currentPath = adoptPtr(cairo_copy_path(m_cr.get())); > > + cairo_new_path(m_cr.get()); > > Probably should drop a comment here that says something like "We need to preserve any pre-existing paths." Comment on saving and restoring added. > > Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp:285 > > + FloatRect clipRect = targetRect; > > Why not just start with the cairo_clip_extents? Thanks - Yes, much better, very useful suggestion. I hope the double to float conversion there is alright for all practical purposes.
WebKit Review Bot
Comment 11 2012-06-18 08:41:23 PDT
Comment on attachment 148081 [details] Clipping repeats, v3 Clearing flags on attachment: 148081 Committed r120598: <http://trac.webkit.org/changeset/120598>
WebKit Review Bot
Comment 12 2012-06-18 08:41:29 PDT
All reviewed patches have been landed. Closing bug.
WebKit Review Bot
Comment 13 2012-06-18 10:09:34 PDT
Re-opened since this is blocked by 89359
Zan Dobersek
Comment 14 2012-06-18 10:13:07 PDT
Dominik Röttsches (drott)
Comment 15 2012-06-19 03:32:42 PDT
Created attachment 148302 [details] Clipping repeats, v4, OwnPtrCairo free fix.
Dominik Röttsches (drott)
Comment 16 2012-06-19 03:34:16 PDT
(In reply to comment #15) > Created an attachment (id=148302) [details] > Clipping repeats, v4, OwnPtrCairo free fix. #include "OwnPtrCairo.h" was missing from PlatformContextCairo.cpp - leading to the wrong free function being called. Zan or Martin - could I ask you to re-land? Thanks.
Martin Robinson
Comment 17 2012-06-19 13:53:37 PDT
Comment on attachment 148302 [details] Clipping repeats, v4, OwnPtrCairo free fix. Sorry, I should have caught that in my previous review.
Dominik Röttsches (drott)
Comment 18 2012-06-19 14:06:55 PDT
(In reply to comment #17) > (From update of attachment 148302 [details]) > Sorry, I should have caught that in my previous review. No problem, thanks for the r+ - I tested this locally on EFL and GTK Debug builds - and I guess this was one of the few cases where due to WTF::fastFree the badness happens only in Release.
WebKit Review Bot
Comment 19 2012-06-19 14:34:13 PDT
Comment on attachment 148302 [details] Clipping repeats, v4, OwnPtrCairo free fix. Clearing flags on attachment: 148302 Committed r120755: <http://trac.webkit.org/changeset/120755>
WebKit Review Bot
Comment 20 2012-06-19 14:34:19 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.