Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing Graphic.validateNow to work as a pre-cacher of StrokeVertices? #60

Closed
IonSwitz opened this issue Sep 24, 2013 · 5 comments
Closed
Assignees

Comments

@IonSwitz
Copy link
Member

As I was checking through the Stroke code tonight, I saw that calling validateNow
will calculate the vertex data etc for the Graphic, BUT it will run twice in a frame.

As a frame rate fiend, I like to be able to pre-calculate everything in a shape, before it renders. The way validateNow , and the building of vertices is run today, there is no way to do that, since validateNow will run within the render method, and re-generate the vertices even if no change has occured since the last time validateNow was run.

So I would suggest adding a member variable, something like:

protected var hasBeenValidatedButNeedsRender:Boolean = false;

that gets set to true after running through validateNow, regardless of where it is called from.

and, in render, we would check this flag, before running into validateNow.

override public function render( renderSupport:RenderSupport, parentAlpha:Number ):void
{
if ( hasBeenValidatedButNeedsRender == false )
validateNow();

This would allow us to precalculate everything in a Graphic class, and the only thing render would actually do would be to push the triangles to the hardware.

Doesn't that sound like a very pleasant option?

@ghost ghost assigned IonSwitz Nov 9, 2013
@jonathanrpace
Copy link
Member

Hey,

I'm not able to see how or why the stroke class would do its work twice in a frame. The validateNow() function only calls buildGeometry() if 'isInvalid == true'.

How are reproducing this?

@IonSwitz
Copy link
Member Author

The thing I was trying out was to avoid having the geometry generated during the render phase,
and instead be able to call validateNow before rendering starts, such as in a initialization stage.

However, since the "isInvalid" is only set to false in the render phase, this isn't possible.

So, even if I call validateNow in the initialization stage, the geometry will be re-generated during the first call to render(), and that can cause frame-rate hickups.

Maybe I was being unclear about the "being called twice"-reasoning, but I hope this explains the issue better?

@jonathanrpace
Copy link
Member

Gotcha - seems like a bug to me (it really shouldn't be validating the geometry again if you've already called validateNow()). Will take a look in a few days (out of the country at the moment)

@IonSwitz
Copy link
Member Author

It's a no-brainer, really, to implement. I could throw something together if you prefer.

All it needs is a boolean flag to check if the geometry has been built already.:)

@IonSwitz
Copy link
Member Author

A fix for this has been checked in. Please see separate issue for explanation of what changed.

#79

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants