Bug 130580 - [Cairo] Implement Path::addPath
Summary: [Cairo] Implement Path::addPath
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jinwoo Song
URL:
Keywords:
: 130464 (view as bug list)
Depends on: 131531
Blocks:
  Show dependency treegraph
 
Reported: 2014-03-21 04:44 PDT by Jae Hyun Park
Modified: 2015-04-21 17:39 PDT (History)
14 users (show)

See Also:


Attachments
Patch (3.69 KB, patch)
2014-03-21 04:50 PDT, Jae Hyun Park
no flags Details | Formatted Diff | Diff
Patch (5.62 KB, patch)
2014-03-23 08:21 PDT, Jae Hyun Park
no flags Details | Formatted Diff | Diff
Patch (6.08 KB, patch)
2014-03-24 05:01 PDT, Jae Hyun Park
no flags Details | Formatted Diff | Diff
Patch (6.07 KB, patch)
2014-03-24 17:39 PDT, Jae Hyun Park
no flags Details | Formatted Diff | Diff
Patch (5.74 KB, patch)
2014-03-24 19:59 PDT, Jae Hyun Park
no flags Details | Formatted Diff | Diff
Patch (3.66 KB, patch)
2015-04-20 23:22 PDT, Jinwoo Song
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jae Hyun Park 2014-03-21 04:44:22 PDT
Add support for addPath method for platforms using cairo.
Comment 1 Jae Hyun Park 2014-03-21 04:50:56 PDT
Created attachment 227415 [details]
Patch
Comment 2 WebKit Commit Bot 2014-03-21 04:53:53 PDT
Attachment 227415 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/cairo/PathCairo.cpp:302:  c_matrix is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
Total errors found: 1 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Darin Adler 2014-03-21 10:16:47 PDT
Comment on attachment 227415 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=227415&action=review

> Source/WebCore/platform/graphics/cairo/PathCairo.cpp:310
> +        OwnPtr<cairo_path_t> pathCopy = adoptPtr(cairo_copy_path(cr));

Please don’t use OwnPtr in new code. We are trying to get rid of OwnPtr. You should used std::unique_ptr in new code. I’m also surprised that it’s safe to call delete on a path returned from cairo_copy_path, but I guess that’s what the surrounding code already does. I think the way to write this with unique_ptr is something like this:

    std::unique_ptr<cairo_path_t> pathCopy { cairo_copy_path(cr) };
Comment 4 Martin Robinson 2014-03-21 10:23:25 PDT
Comment on attachment 227415 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=227415&action=review

>> Source/WebCore/platform/graphics/cairo/PathCairo.cpp:310
>> +        OwnPtr<cairo_path_t> pathCopy = adoptPtr(cairo_copy_path(cr));
> 
> Please don’t use OwnPtr in new code. We are trying to get rid of OwnPtr. You should used std::unique_ptr in new code. I’m also surprised that it’s safe to call delete on a path returned from cairo_copy_path, but I guess that’s what the surrounding code already does. I think the way to write this with unique_ptr is something like this:
> 
>     std::unique_ptr<cairo_path_t> pathCopy { cairo_copy_path(cr) };

This works because we have a template specialization for cairo_path_t (template <> void deleteOwnedPtr<cairo_path_t>(cairo_path_t*);) in OwnPtrCairo.h. I think we could use GUniquePtr here, but we'd need to make a deleter using WTF_DEFINE_GPTR_DELETER.
Comment 5 Jae Hyun Park 2014-03-23 08:21:57 PDT
Created attachment 227610 [details]
Patch
Comment 6 WebKit Commit Bot 2014-03-23 08:24:20 PDT
Attachment 227610 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/cairo/PathCairo.cpp:302:  c_matrix is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
Total errors found: 1 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Martin Robinson 2014-03-23 08:32:09 PDT
Comment on attachment 227610 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=227610&action=review

> Source/WTF/wtf/gobject/GUniquePtr.h:41
> +    macro(cairo_path_t, cairo_path_destroy) \

This isn't really the right place for this. We want to add this in a file alongside OwnPtrCairo.h, I think.
Comment 8 Jae Hyun Park 2014-03-24 05:01:44 PDT
Created attachment 227637 [details]
Patch
Comment 9 WebKit Commit Bot 2014-03-24 05:02:38 PDT
Attachment 227637 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/cairo/PathCairo.cpp:302:  c_matrix is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
Total errors found: 1 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 10 Jae Hyun Park 2014-03-24 05:08:25 PDT
It seems like other cairo_matrix_t in PathCairo.cpp is named c_matrix, which is not in accordance with webkit style.

Would it be better if I rename cairo_matrix_t c_matrix to matrix to pass the style check? Or is it a convention for cairo_matrix_t?
Comment 11 Martin Robinson 2014-03-24 08:59:29 PDT
(In reply to comment #10)
> It seems like other cairo_matrix_t in PathCairo.cpp is named c_matrix, which is not in accordance with webkit style.
> 
> Would it be better if I rename cairo_matrix_t c_matrix to matrix to pass the style check? Or is it a convention for cairo_matrix_t?

I think it would be better to fix the name.
Comment 12 Jae Hyun Park 2014-03-24 17:39:22 PDT
Created attachment 227708 [details]
Patch
Comment 13 Martin Robinson 2014-03-24 18:37:58 PDT
Comment on attachment 227708 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=227708&action=review

> Source/WebCore/platform/graphics/cairo/PathCairo.cpp:302
> +    cairo_matrix_t matrix = cairo_matrix_t(transform);

Do you need to use the explicit constructor here or is assignment enough?

> Source/WebCore/platform/graphics/cairo/PathCairo.cpp:317
> +    if (path.platformPath() == ensurePlatformPath()) {
> +        Path clonePath(path);
> +        cairo_t* cr = clonePath.platformPath()->context();
> +        cairo_transform(cr, &matrix);
> +        GUniquePtr<cairo_path_t> pathCopy(cairo_copy_path(cr));
> +        cairo_append_path(ensurePlatformPath()->context(), pathCopy.get());
> +    } else {
> +        cairo_t* cr = path.platformPath()->context();
> +        cairo_transform(cr, &matrix);
> +        GUniquePtr<cairo_path_t> pathCopy(cairo_copy_path(cr));
> +        cairo_append_path(ensurePlatformPath()->context(), pathCopy.get());
> +    }

I don't know if you need a special case for appending the path to itself. You always make a copy of the cairo_path_t anyway. There's a bug here, which is that you transform the Path and then don't restore the previous transformation.
Comment 14 Jae Hyun Park 2014-03-24 19:59:39 PDT
Created attachment 227717 [details]
Patch
Comment 15 Jae Hyun Park 2014-03-24 20:05:57 PDT
(In reply to comment #13)
> (From update of attachment 227708 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=227708&action=review
> 
> > Source/WebCore/platform/graphics/cairo/PathCairo.cpp:302
> > +    cairo_matrix_t matrix = cairo_matrix_t(transform);
> 
> Do you need to use the explicit constructor here or is assignment enough?
I used one constructor instead of constructor + assignment in the latest patch. 
> 
> > Source/WebCore/platform/graphics/cairo/PathCairo.cpp:317
> > +    if (path.platformPath() == ensurePlatformPath()) {
> > +        Path clonePath(path);
> > +        cairo_t* cr = clonePath.platformPath()->context();
> > +        cairo_transform(cr, &matrix);
> > +        GUniquePtr<cairo_path_t> pathCopy(cairo_copy_path(cr));
> > +        cairo_append_path(ensurePlatformPath()->context(), pathCopy.get());
> > +    } else {
> > +        cairo_t* cr = path.platformPath()->context();
> > +        cairo_transform(cr, &matrix);
> > +        GUniquePtr<cairo_path_t> pathCopy(cairo_copy_path(cr));
> > +        cairo_append_path(ensurePlatformPath()->context(), pathCopy.get());
> > +    }
> 
> I don't know if you need a special case for appending the path to itself. You always make a copy of the cairo_path_t anyway. There's a bug here, which is that you transform the Path and then don't restore the previous transformation.

Fixed.

Thanks for the review!
Comment 16 Dirk Schulze 2014-04-03 01:16:33 PDT
*** Bug 130464 has been marked as a duplicate of this bug. ***
Comment 17 Dirk Schulze 2014-04-03 01:19:39 PDT
Comment on attachment 227717 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=227717&action=review

> Source/WebCore/platform/graphics/cairo/PathCairo.cpp:309
> +    GUniquePtr<cairo_path_t> pathCopy(cairo_copy_path(cr));

Are you sure that you need a copy of the path? We had addPath implemented in the past. I don't think we copied it.
Comment 18 Jae Hyun Park 2014-04-03 08:19:24 PDT
(In reply to comment #17)
> (From update of attachment 227717 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=227717&action=review
> Are you sure that you need a copy of the path? We had addPath implemented in the past. I don't think we copied it.

If you mean addPath that was implemented in GraphicsContextCairo, it used appendWebCorePathToCairoContext(), which calls appendPathToCairoContext().
In appendPathToCairoContext, it calls cairo_copy_path() and cairo_append_path.
Comment 19 Dirk Schulze 2014-05-07 06:02:37 PDT
Comment on attachment 227717 [details]
Patch

r=me
Comment 20 Jae Hyun Park 2014-05-10 00:36:18 PDT
(In reply to comment #19)
> (From update of attachment 227717 [details])
> r=me
Thanks for the review.

However, this patch cannot be committed right now because we cannot use GUniquePtr for cairo_path_t as WinCairo port does not glib.

Would it be ok if i used OwnPtr<cairo_path_t> for now, and change the use of OwnPtrCairo altogether in 131531 bug?
Comment 21 Jinwoo Song 2015-04-20 22:48:21 PDT
Jae Hyun Park, is there any progress? If you don't mind, I'd like to propose to use std::unique_ptr with custom deleter.
Comment 22 Jae Hyun Park 2015-04-20 22:55:12 PDT
(In reply to comment #21)
> Jae Hyun Park, is there any progress? If you don't mind, I'd like to propose
> to use std::unique_ptr with custom deleter.

Please go ahead. I'm in no condition to work on this for a while.
Comment 23 Jinwoo Song 2015-04-20 23:22:02 PDT
Created attachment 251219 [details]
Patch
Comment 24 Jinwoo Song 2015-04-20 23:24:33 PDT
Martin, Dirk, could you review this patch?
Comment 25 Dirk Schulze 2015-04-21 02:45:01 PDT
Comment on attachment 251219 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=251219&action=review

r=me with comment.

> LayoutTests/platform/efl/TestExpectations:-221
> -webkit.org/b/130464 fast/canvas/canvas-path-addPath.html

What about the Gtk port? Doesn't it have such a line as well?
Comment 26 Jinwoo Song 2015-04-21 02:54:28 PDT
Comment on attachment 251219 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=251219&action=review

>> LayoutTests/platform/efl/TestExpectations:-221
>> -webkit.org/b/130464 fast/canvas/canvas-path-addPath.html
> 
> What about the Gtk port? Doesn't it have such a line as well?

Yes, but GTK port disabled this feature as default. GTK guys may update TestExpectations after enable CANVAS_PATH in another patch.

cmake/OptionsGTK.cmake:159:WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CANVAS_PATH OFF)
Comment 27 WebKit Commit Bot 2015-04-21 17:39:12 PDT
Comment on attachment 251219 [details]
Patch

Clearing flags on attachment: 251219

Committed r183088: <http://trac.webkit.org/changeset/183088>
Comment 28 WebKit Commit Bot 2015-04-21 17:39:20 PDT
All reviewed patches have been landed.  Closing bug.