daimons / androidsvg

Automatically exported from code.google.com/p/androidsvg
1 stars 0 forks source link

Provide copy constructor or allow rendering to multiple viewBox at once #56

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm trying to render different parts of the same SVG on different threads. The 
rendering is working fine, but is very slow. In order to speed it up, I've had 
to create several SVG instances from the same asset to use across the threads. 
I am guessing that creating these is slowed down a lot by having to re-parse 
the SVG file...

So I see two solutions...
1. a copy constructor, preventing re-parsing of the SVG file. But still causing 
me to have to alloc the same objects 2/3/4 times.
2. allow different parts of the same SVG to be rendered simultaneously, 
specifying a viewBox/viewPort in the render call. This could essentially use 
the same interface as "renderViewToCanvas()" but allow you to pass in a view. 
(OR allow views to be dynamically added!)

Obviously option 1 is the quick and dirty way, with 2 being the more complex. I 
am not familiar with your code base so I can't gauge how easy 2 would be...

"Why don't you break you SVG file up?"
I don't know the parts I require ahead of time, I'm rendering tiles of a map.

"Why don't you add 'views' into the SVG?"
As above.

What version of the product are you using? On what operating system?
1.2.1 and 1.2.2-beta-1

Original issue reported on code.google.com by sd...@airsource.co.uk on 19 Mar 2015 at 2:16

GoogleCodeExporter commented 9 years ago
So basically you are asking for a version of renderViewToX() where you pass in 
a viewBox instead of a viewId?

Have you tried using setDocumentViewBox() before rendering to change which 
parts of the SVG get rendered?  It should be pretty much equivalent to what you 
are asking.

Original comment by paul.leb...@gmail.com on 24 Mar 2015 at 12:08

GoogleCodeExporter commented 9 years ago
Actually that won't be thread safe, so it isn't a workable solution.

Original comment by paul.leb...@gmail.com on 24 Mar 2015 at 12:09

GoogleCodeExporter commented 9 years ago
>So basically you are asking for a version of renderViewToX() where you pass in 
a viewBox instead of a viewId?

Yes, that would be the ideal solution.

Actually that won't be thread safe, so it isn't a workable solution

Yea, that's what I found unfortunately. Therefore I'm constructing several SVG 
objects to render different view boxes in different threads. Any speed up to 
the construction of the SVG objects would be a great start (e.g. via a copy 
constructor)

Original comment by samduke...@gmail.com on 28 Mar 2015 at 7:27