When does it make sense to use Snapshots?

Simply put, I have a background that I want to work similar to iOS7 Control Center; which is basically a heavily blurred copy (display.capture) of whatever is on the background.

  1. If I don’t animate the blur object itself, does it keep re-calculating every frame? Or does it calculate only once? (Performance seems affected but can’t be sure…)

  2. If I wanted to move the blur panel and recalculate as it goes (as Control Center does if you drag it up), is there a best approach to that?

It seems that filter.blueGaussian is the only method of achieving enough of a blur, but performance with it seems really bad, so I’m at a loss of how to replicate the effect.

Ingemar came up with a rather elegant solution, which was to have nested snapshots.

Place what you want to blur in one snapshot, and apply the blur to it.

Place this snapshot within another snapshot, and it will store the blur, which can then be disabled, so you only get the hit once.

It will require a little bit of jiggling to get the right timing (you must invalidate, then blur, then invalidate the top level snapshot), but will do what you want without a constant speed hit.

Yeah, I saw ingemar’s idea. It’s a really good method for static blurs, but it’s also a lot of code and doesn’t manage to answer either of my questions:

a. Does a blur keep recalculating? (I’m guessing yes, though it’s a little counter-intuitive)

b. Is there any reasonable way to slide a blur on-screen? (I’m guessing no, though Apple seems to have achieved it in some manner)

As far as I’m aware all filters are dynamic, IE they update constantly each frame (so yeah, they have the overhead).

It may be that they only update if they detect a change within themselves (in the case of a snapshot), or in the case of filters that affect more than just their own internal space (eg a blur that affects an alpha channel), but I doubt it in the first case, and definitely don’t think it works like this in the second.

As for the slide, you’d have to combine a snapshot with a mask or a container, but in theory it should be doable.

Ingemar came up with a rather elegant solution, which was to have nested snapshots.

Place what you want to blur in one snapshot, and apply the blur to it.

Place this snapshot within another snapshot, and it will store the blur, which can then be disabled, so you only get the hit once.

It will require a little bit of jiggling to get the right timing (you must invalidate, then blur, then invalidate the top level snapshot), but will do what you want without a constant speed hit.

Yeah, I saw ingemar’s idea. It’s a really good method for static blurs, but it’s also a lot of code and doesn’t manage to answer either of my questions:

a. Does a blur keep recalculating? (I’m guessing yes, though it’s a little counter-intuitive)

b. Is there any reasonable way to slide a blur on-screen? (I’m guessing no, though Apple seems to have achieved it in some manner)

As far as I’m aware all filters are dynamic, IE they update constantly each frame (so yeah, they have the overhead).

It may be that they only update if they detect a change within themselves (in the case of a snapshot), or in the case of filters that affect more than just their own internal space (eg a blur that affects an alpha channel), but I doubt it in the first case, and definitely don’t think it works like this in the second.

As for the slide, you’d have to combine a snapshot with a mask or a container, but in theory it should be doable.