Re: Cairo: how do I use $cr->append_path to draw a path?



On 07.08.2011 20:05, Torsten Schoenfeld wrote:
Note that the paths returned by Cairo are implemented as tied array
references which do not support adding, removing or shuffling of path
segments.

So you might be wondering why I did not simply choose to convert paths to and from native data structures, which would sidestep all the problems the current tied representation has.

Well, I actually did just that in my first attempt. But it turned out that, with the native data structure approach, a call to $cr->copy_path is about 45 times slower than with the tied approach. And the combination of $cr->copy_path and $cr->append_path is about 25 times slower. I thought that this is too big a slowdown.

But then I stumbled upon an old Perl port of pango's cairotwisted example (now committed to master), which fetches, alters and then re-appends a rather big path. And this program is actually about 7 times faster with the native data structure approach.

So, with the native data structure approach: programs which simply do $cr->copy_path and $cr->append_path are slowed down massively, and programs which in addition actually alter the path are sped up massively.

Now, which of these behaviors is more common? I added the branch "native-paths" to the git repository: <http://git.gnome.org/browse/perl-Cairo/?h=native-paths>. Can anyone benchmark a real-world program against master and native-paths and tell us the results?



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]