You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by noni_4444 <na...@gmail.com> on 2007/10/04 10:03:20 UTC

Re: Help ! how to make updates to dom more efficient ?

I performed the same animation by directly modifying GVT and reduced the CPU
by more than 50%. Ofcourse painting is responsible for only 50% of the CPU
usage and the other 50% is being consumed by either
                  a. DOM changes
                  b. The batik code listening for dom changes

The only problem i face with directly modifying the GVT is that i cann't do
repaint of GVT. How to handle it?

Naveed


noni_4444 wrote:
> 
> I have a routine where i update several DOM elements inside an update
> manager thread. The problem faced
> is that setAttribute and setNodeValue methods take a lot of CPU time.
> 
> An earlier post says:
> 
> "Disconnect the tree from the document before making the changes.  This
> avoids the overhead of keeping the GVT tree in synch with every change"
> 
> In my case i am updating the multiple attributes of different Elements
> repeatedly. How can i detach the attributes of an element before making
> the changes. 
> If i do it, it would mean that i do something like
>  
> for (1 -> n)
> {
>  Get current element from array
>  Detach attributes of element             //which dom api method to
> call????
>  Update multiple attributes of this element
>  Attach attributes of element             //which dom api method to
> call????
> }
> 
> I wrote something like following ... but even this doesn't improve the
> performace. With following code append child is taking alot of CPU time.
> 
>                 for (int i = (oArrObjsToAnimate.size() - 1); i > -1; i--)
> {
>                                     Node pnode =
> oAnimObject.oFgElm.getParentNode();
>                                     pnode.removeChild(oAnimObject.oFgElm);
>                                     
>                                     NamedNodeMap nmap =
> oAnimObject.oFgElm.getAttributes();
>                                     fill(nmap, strExpValue, oAnimObject,
> oObject, oAnim);
>                                     
>                                     pnode.appendChild(oAnimObject.oFgElm);
>                             }
>                     }
>                 }
>  
> Any pointers, links, references would be helpful.
> 
> Thanks
> Naveed
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Help-%21-how-to-make-updates-to-dom-more-efficient---tf4528109.html#a13034464
Sent from the Batik - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Help ! how to make updates to dom more efficient ?

Posted by th...@kodak.com.
Hi Naveed,

noni_4444 <na...@gmail.com> wrote on 10/04/2007 04:03:20 AM:

> I performed the same animation by directly modifying GVT and reduced the 
CPU
> by more than 50%. Ofcourse painting is responsible for only 50% of the 
CPU
> usage and the other 50% is being consumed by either
>                   a. DOM changes
>                   b. The batik code listening for dom changes

   Or the handling of dirty regions, transforms, offscreen buffer 
rendering
swapping, etc.

> The only problem i face with directly modifying the GVT is that i cann't 
do
> repaint of GVT. How to handle it?

   You need to modify the GVT Nodes, which I'm fairly confident will give 
you
very similar performance to the DOM modifications.  It may be that you 
don't
want to do your animation with the GVT/DOM and just draw your stuff on top 
of
the JSVGCanvas (subclass and override the paintComponent method).  You 
might
also look at using Overlays.

   But then you will need to build your own model for where the rects and 
lines
need to be and manage the paint cycle yourself.

> 
> Naveed
> 
> 
> noni_4444 wrote:
> > 
> > I have a routine where i update several DOM elements inside an update
> > manager thread. The problem faced
> > is that setAttribute and setNodeValue methods take a lot of CPU time.
> > 
> > An earlier post says:
> > 
> > "Disconnect the tree from the document before making the changes. This
> > avoids the overhead of keeping the GVT tree in synch with every 
change"
> > 
> > In my case i am updating the multiple attributes of different Elements
> > repeatedly. How can i detach the attributes of an element before 
making
> > the changes. 
> > If i do it, it would mean that i do something like
> > 
> > for (1 -> n)
> > {
> >  Get current element from array
> >  Detach attributes of element             //which dom api method to
> > call????
> >  Update multiple attributes of this element
> >  Attach attributes of element             //which dom api method to
> > call????
> > }
> > 
> > I wrote something like following ... but even this doesn't improve the
> > performace. With following code append child is taking alot of CPU 
time.
> > 
> >                 for (int i = (oArrObjsToAnimate.size() - 1); i > -1; 
i--)
> > {
> >                                     Node pnode =
> > oAnimObject.oFgElm.getParentNode();
> > pnode.removeChild(oAnimObject.oFgElm);
> > 
> >                                     NamedNodeMap nmap =
> > oAnimObject.oFgElm.getAttributes();
> >                                     fill(nmap, strExpValue, 
oAnimObject,
> > oObject, oAnim);
> > 
> > pnode.appendChild(oAnimObject.oFgElm);
> >                             }
> >                     }
> >                 }
> > 
> > Any pointers, links, references would be helpful.
> > 
> > Thanks
> > Naveed
> > 
> > 
> > 
> > 
> 
> -- 
> View this message in context: http://www.nabble.com/Help-%21-how-to-
> make-updates-to-dom-more-efficient---tf4528109.html#a13034464
> Sent from the Batik - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>