Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

Snapshots within snapshots - an idea on how to remove a major current problem.
Started by rakoonic Mar 01 2015 09:53 PM

No replies to this topic
This topic has been archived. This means that you cannot reply to this topic.
[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Contributor

  • 113 posts
  • Corona SDK

One 'feature' of snapshots is that they are always a frame behind, due to the way they are updated.

Nesting snapshots means that these frames are cumulative, and are particularly notable when you resume from a suspend.


One idea I floated a long time ago but which never got picked up on would (I believe!) solve this problem very easily - you specify the order snapshots are updated in at the next render pass.


This would enable you to have all snapshots, including nested ones, drawn in the right order to ensure there is only ever the 1 frame 'delay'.


Let's say I have snapshot A as a child of snapshot B which is a child of snapshot C.


This can produce problems as upon resume they all default to black (for obvious reasons really, as snapshot contents cannot be saved between suspends).


Now, if you could ensure that upon entering the render pass that snapshot A is refreshed first, followed by B then C, you'd have no delay and everything would be drawn properly.


The solution to this is rather simple - a renderPriority (or somesuch name) property of the snapshot object.

This property is simply a number that indicates relative render order.


1 could be the default value, with higher numbers being rendered earlier. So in my case I could assign a renderPriority of 2 to B, and 3 to A, so A gets done first followed by B then C.


All that would happen is upon hitting the render pass, all invalidated snapshots are sorted into order by this property, and rendered accordingly.


The order for snapshots that share the same value would be unpredictable (pretty much how it is now - I never investigated to see if I could control the order by controlling the creation, but even if I could this would not solve the problem as I couldn't change the order dynamically), but then if you assign the same priority you are clearly not using the property correctly!