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

performance optimize Surface.draw #84

Open
oberhamsi opened this issue Apr 16, 2013 · 1 comment
Open

performance optimize Surface.draw #84

oberhamsi opened this issue Apr 16, 2013 · 1 comment
Labels

Comments

@oberhamsi
Copy link
Member

Right now, everything runs through one code path, which understands all of the following situations. Some of which are very expensive and may only happen rarely:

  • destination area is only part of the destination surface
  • source area is only part of the source surface
  • source surface has rotation applied (this is especially expensive because we need to do translate to origin and subsequenet rotation in JS. maybe this too can be improved with canvas-trickery?)

I would leave what we currently have as the slowest code path and add faster paths if possible.

For exmple, on obviously shitty thing we should not do is create objects for default situations like rDest = new Rect([0,0], src.getSize());, that's just a waste because if we want to use the whole destination surface, that should be hardcoded in an IF-path and not create an expensive Rect and then run that through our do-it-all codepath.

@oberhamsi
Copy link
Member Author

https://github.com/oberhamsi/gamejs/tree/performance-blit

gives ~10% performance improvement in best case, which is destination.blit(source, array) and it gets worse the more arguments you give it. this works pretty well because w3c context gives us an overloaded drawImage, which fits exactly our argument cases.

0% improvement for rotation. rotation will always be inherently so much slower with JS matrix manipulation that I don't think i'll do much about that case.

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

No branches or pull requests

1 participant