Re: Updating parameters of a CI filter on a CA layer
Re: Updating parameters of a CI filter on a CA layer
- Subject: Re: Updating parameters of a CI filter on a CA layer
- From: David Duncan <email@hidden>
- Date: Mon, 12 Apr 2010 15:03:41 -0700
On Apr 12, 2010, at 1:30 PM, Kyle Sluder wrote:
> On Mon, Apr 12, 2010 at 1:22 PM, David Duncan <email@hidden> wrote:
>> You need to assign a name to each filter, then you can create keypaths like @"filters.myfiltername.property".
>
> Can we get some explanation of the magic involved in CALayer KVC
> support? Why is -setValue:forKeyPath: necessary here, rather than just
> changing the filter directly? Why does CALayer treat an array property
> as if it were a dictionary when it's part of a keypath?
>
> Some rationale would be very helpful. All we know now is "CALayer
> extends KVC for some super-secret reason."
In order to properly animate values, Core Animation needs to be notified of value changes, hence why you need to go through Core Animation to change the values of a filter if you want it to animate properly. In addition to that, we make no guarantee that the instances of the filters that you provide are the same ones used to render, so by going directly to the filter you would be changing the wrong instance (with the correct one being private to Core Animation).
A filter chain requires an order to make sense, hence the filter list needs to be an array or some more complex structure that can specify rendering order. In the end it was chosen to use an array while extending CIFilter to allow for a name property (whose usefulness in Core Animation is similar to a layer's own name property) and to extend array notation to allow you to use that name to lookup an object in the array.
For a why, the best I can come up with is to try to make the API easier to use.
--
David Duncan
Apple DTS Animation and Printing
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden