[osg-users] Speeding Up osgText?

Kawicki, Ryan H Ryan.H.Kawicki at boeing.com
Mon Sep 8 08:24:57 PDT 2008


Nope, we rarely use the backdrop feature.  I'll look into optimizing the
code based on the comment.

If I do make some modifications that seem to benefit, what procedures do
I need to take to get these changes integrated into the OSG baseline?
Are the procedures posted on the website?

Thanks.

Ryan H. Kawicki
The Boeing Company
Training Systems & Services
Software Engineer

-----Original Message-----
From: E. Wing [mailto:ewmailing at gmail.com] 
Sent: Saturday, September 06, 2008 6:46 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] Speeding Up osgText?

> void Text::computePositions()
> {
>     unsigned int size =
> osg::maximum(osg::DisplaySettings::instance()->getMaxNumberOfGraphicsC
> on
> texts(),_autoTransformCache.size());
>
>     // FIXME: OPTIMIZE: This would be one of the ideal locations to
>     // call computeAverageGlypthWidthAndHeight(). It is out of the 
> contextID loop
>     // so the value would be computed fewer times. But the code will 
> need changes
>     // to get the value down to the locations it is needed. (Either 
> pass through parameters
>     // or member variables, but we would need a system to know if the 
> values are stale.)
>
>     for(unsigned int i=0;i<size;++i)
>     {
>          computePositions(i);
>     }
> }

So I am not an expert on the osgText implementation, but I think I am
the one that wrote that comment. I wrote that when I added the backdrop
text and gradient feature to osgText. My strategy was to make the least
amount of structural changes as possible because the implementation was
sufficiently complicated enough, so optimization wasn't my goal.

I think that above block already existed in some form before my changes,
but as I was refactoring trying to fit in the new features, I think I
took note of that block of code and added that comment realizing it
could be faster. I suggest if you are looking for a way to speed things
up, you could try to do exactly what that comment says. I honestly don't
remember the code at this point, and I never really profiled how much
time was spent in that loop. But I think it is one of the more
staightforward and obvious places that can be optimized (but probably
tedious).

Another thing to note is with the backdrop feature on, it isn't terribly
efficient if I recall, because it needs to repeat for every direction of
the shadow. So if you do outline text, you multiply by 8 or 9 passes. So
don't turn on backdrop text if there are performance problems.

-Eric
_______________________________________________
osg-users mailing list
osg-users at lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g



More information about the osg-users mailing list