Issues with CIFilters and CALayers

2014-02-23 Thread Gordon Apple
We have run into a number is issues trying to use CIFilters with CALayers:

1. When a layer is hidden, its filters, especially background filters,
should be temporarily removed, or at least bypassed.  Hiding the layer
should make if effectively non-existent in the displayed layer stack.

2. The docs should tell you that in a CIFilter you cannot auto-synthesize
filter input parameters. This simply does not work, especially for
inputImage.

3. The docs for CALayer filters and background filters say you should name
your filters for use in changing parameters. I.e., filter.name =
@²myFilter².  Amazingly, this works, in spite of the fact that there is no
public property called ³name² for a CIFilter.

4. The example keyPath makes no sense whatsoever, unless we just don¹t
understand keyPaths:

[layer setValue:XXX forKeyPath:@²backgroundFilters.myFilter.filterParam²];

backgroundFilters is an array of filters. myFilter is a property value of
some element of the array. (huh?)

5. We need some decent documentation of what in GL Shading Language is
actually relevant to writing ciKernels, besides the one page addendum
provided.

6. And, of course, the problem we have already mentioned in a previous post
about getting a CALayer to update when a filter parameter is changed.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Issues with CIFilters and CALayers

2014-02-24 Thread David Duncan

On Feb 23, 2014, at 1:06 PM, Gordon Apple  wrote:

> We have run into a number is issues trying to use CIFilters with CALayers:
> 
> 1. When a layer is hidden, its filters, especially background filters,
> should be temporarily removed, or at least bypassed.  Hiding the layer
> should make if effectively non-existent in the displayed layer stack.

Is this a statement or a question?

> 2. The docs should tell you that in a CIFilter you cannot auto-synthesize
> filter input parameters. This simply does not work, especially for
> inputImage.

Bug?

> 3. The docs for CALayer filters and background filters say you should name
> your filters for use in changing parameters. I.e., filter.name =
> @²myFilter².  Amazingly, this works, in spite of the fact that there is no
> public property called ³name² for a CIFilter.

There is a public property, but it isn’t declare in CIFilter.h if I recall 
correctly.

> 4. The example keyPath makes no sense whatsoever, unless we just don¹t
> understand keyPaths:
> 
> [layer setValue:XXX forKeyPath:@²backgroundFilters.myFilter.filterParam²];
> 
> backgroundFilters is an array of filters. myFilter is a property value of
> some element of the array. (huh?)

Core Animation extension to KVC.

> 5. We need some decent documentation of what in GL Shading Language is
> actually relevant to writing ciKernels, besides the one page addendum
> provided.

Bug (I don’t know myself, but a bug is the only way you are going to tell the 
folks in charge of that it is needed).

> 6. And, of course, the problem we have already mentioned in a previous post
> about getting a CALayer to update when a filter parameter is changed.


You have to go through the key-value path in Core Animation. If you update the 
CIFilter directly you have no guarantee that CA will notice the change.
--
David Duncan


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Issues with CIFilters and CALayers

2014-02-24 Thread Gordon Apple
Apparently, my comment about not understanding this construct for
setValueForKeyPath was correct.  It actually works. I finally got the
highlighting filter to work and update properly. Now I¹m trying to do
something much simpler, i.e., construct a freezeFilter.  Nothing I¹ve tried
so far works.  Apparently, a CIFilter is expected to be stateless function
such as outputImage = f(inputImage, parameters). Not accepting this premiss,
I decided to try caching the first output image ( from the outputImage
method), then return the cashed image thereafter, an ultra simple concept,
except that it does not work. Any reason, besides what I postulated, why
this shouldn¹t work?


On 2/23/14 3:06 PM, "Gordon Apple"  wrote:

> We have run into a number is issues trying to use CIFilters with CALayers:
> 
> 1. When a layer is hidden, its filters, especially background filters, should
> be temporarily removed, or at least bypassed.  Hiding the layer should make if
> effectively non-existent in the displayed layer stack.
> 
> 2. The docs should tell you that in a CIFilter you cannot auto-synthesize
> filter input parameters. This simply does not work, especially for inputImage.
> 
> 3. The docs for CALayer filters and background filters say you should name
> your filters for use in changing parameters. I.e., filter.name = @²myFilter².
> Amazingly, this works, in spite of the fact that there is no public property
> called ³name² for a CIFilter.
> 
> 4. The example keyPath makes no sense whatsoever, unless we just don¹t
> understand keyPaths:
> 
> [layer setValue:XXX forKeyPath:@²backgroundFilters.myFilter.filterParam²];
> 
> backgroundFilters is an array of filters. myFilter is a property value of some
> element of the array. (huh?)
> 
> 5. We need some decent documentation of what in GL Shading Language is
> actually relevant to writing ciKernels, besides the one page addendum
> provided.
> 
> 6. And, of course, the problem we have already mentioned in a previous post
> about getting a CALayer to update when a filter parameter is changed.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Issues with CIFilters and CALayers

2014-02-27 Thread Kevin Meaney
First a note. The name property is declared as a CACIFilterAdditions in 
CACIFilterAdditions.h.

I think you will need to draw the CIImage to your CIContext and then generate a 
CGImage to capture its state for future reference and then generate a new 
CIImage from the CGImage. I believe the CIImage that is the output of a filter 
is more a recipe about how to generate an image and not a bitmap representation 
of the image which I think is where your problem lies.

Kevin

Sent from my iPhone

On 24 Feb 2014, at 17:28, Gordon Apple  wrote:

> Apparently, my comment about not understanding this construct for
> setValueForKeyPath was correct.  It actually works. I finally got the
> highlighting filter to work and update properly. Now I¹m trying to do
> something much simpler, i.e., construct a freezeFilter.  Nothing I¹ve tried
> so far works.  Apparently, a CIFilter is expected to be stateless function
> such as outputImage = f(inputImage, parameters). Not accepting this premiss,
> I decided to try caching the first output image ( from the outputImage
> method), then return the cashed image thereafter, an ultra simple concept,
> except that it does not work. Any reason, besides what I postulated, why
> this shouldn¹t work?
> 
> 
> On 2/23/14 3:06 PM, "Gordon Apple"  wrote:
> 
>> We have run into a number is issues trying to use CIFilters with CALayers:
>> 
>> 1. When a layer is hidden, its filters, especially background filters, should
>> be temporarily removed, or at least bypassed.  Hiding the layer should make 
>> if
>> effectively non-existent in the displayed layer stack.
>> 
>> 2. The docs should tell you that in a CIFilter you cannot auto-synthesize
>> filter input parameters. This simply does not work, especially for 
>> inputImage.
>> 
>> 3. The docs for CALayer filters and background filters say you should name
>> your filters for use in changing parameters. I.e., filter.name = @²myFilter².
>> Amazingly, this works, in spite of the fact that there is no public property
>> called ³name² for a CIFilter.
>> 
>> 4. The example keyPath makes no sense whatsoever, unless we just don¹t
>> understand keyPaths:
>> 
>> [layer setValue:XXX forKeyPath:@²backgroundFilters.myFilter.filterParam²];
>> 
>> backgroundFilters is an array of filters. myFilter is a property value of 
>> some
>> element of the array. (huh?)
>> 
>> 5. We need some decent documentation of what in GL Shading Language is
>> actually relevant to writing ciKernels, besides the one page addendum
>> provided.
>> 
>> 6. And, of course, the problem we have already mentioned in a previous post
>> about getting a CALayer to update when a filter parameter is changed.
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/ktam%40yvs.eu.com
> 
> This email sent to k...@yvs.eu.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Issues with CIFilters and CALayers

2014-02-27 Thread Gordon Apple
Thank you.   I would have never found that. But what does “enabled” do?  Or,
more precisely, what does “not enabled” do? If a filter is not enabled, does
that mean it is transparent and simply passes input to output?  I can’t
believe something so simple in concept as a freeze filter is so difficult to
implement.  CIFilters are black magic. They just don’t seem to follow the
usual expectations of software constructs.

I did get my highlighting filter to work, using color blend and/or a
GaussianBlur embedded filter for the background, with controllable
parameters. The user can even live-draw and edit the clear areas of the
filter (used as a transient layer in a presentation layer stack).  It
provides a very nice effect for drawing attention to specific areas.


On 2/27/14 9:42 AM, "Kevin Meaney"  wrote:

> First a note. The name property is declared as a CACIFilterAdditions in
> CACIFilterAdditions.h.
> 
> I think you will need to draw the CIImage to your CIContext and then generate
> a CGImage to capture its state for future reference and then generate a new
> CIImage from the CGImage. I believe the CIImage that is the output of a filter
> is more a recipe about how to generate an image and not a bitmap
> representation of the image which I think is where your problem lies.
> 
> Kevin
> 
> Sent from my iPhone
> 
> On 24 Feb 2014, at 17:28, Gordon Apple  wrote:
> 
>> > Apparently, my comment about not understanding this construct for
>> > setValueForKeyPath was correct.  It actually works. I finally got the
>> > highlighting filter to work and update properly. Now I¹m trying to do
>> > something much simpler, i.e., construct a freezeFilter.  Nothing I¹ve tried
>> > so far works.  Apparently, a CIFilter is expected to be stateless function
>> > such as outputImage = f(inputImage, parameters). Not accepting this
>> premiss,
>> > I decided to try caching the first output image ( from the outputImage
>> > method), then return the cashed image thereafter, an ultra simple concept,
>> > except that it does not work. Any reason, besides what I postulated, why
>> > this shouldn¹t work?
>> > 
>> > 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Issues with CIFilters and CALayers

2014-02-27 Thread Kevin Meaney
I don't know. I'm not actually trying to integrate CIFilters and Core Animation 
in the way that you are doing. I remembered that you had mentioned the name 
property of the CIFilter because that property is actually useful to me, 
because I need a way to refer to filters which are earlier in the filter chain 
and the name seems like a useful way to find a filter that I want.

Kevin

On 27 Feb 2014, at 17:38, Gordon Apple  wrote:

> Thank you.   I would have never found that. But what does “enabled” do?  Or, 
> more precisely, what does “not enabled” do? If a filter is not enabled, does 
> that mean it is transparent and simply passes input to output?  I can’t 
> believe something so simple in concept as a freeze filter is so difficult to 
> implement.  CIFilters are black magic. They just don’t seem to follow the 
> usual expectations of software constructs.
> 
> I did get my highlighting filter to work, using color blend and/or a 
> GaussianBlur embedded filter for the background, with controllable 
> parameters. The user can even live-draw and edit the clear areas of the 
> filter (used as a transient layer in a presentation layer stack).  It 
> provides a very nice effect for drawing attention to specific areas.
> 
> 
> On 2/27/14 9:42 AM, "Kevin Meaney"  wrote:
> 
>> First a note. The name property is declared as a CACIFilterAdditions in 
>> CACIFilterAdditions.h.
>> 
>> I think you will need to draw the CIImage to your CIContext and then 
>> generate a CGImage to capture its state for future reference and then 
>> generate a new CIImage from the CGImage. I believe the CIImage that is the 
>> output of a filter is more a recipe about how to generate an image and not a 
>> bitmap representation of the image which I think is where your problem lies.
>> 
>> Kevin
>> 
>> Sent from my iPhone
>> 
>> On 24 Feb 2014, at 17:28, Gordon Apple  wrote:
>> 
>> > Apparently, my comment about not understanding this construct for
>> > setValueForKeyPath was correct.  It actually works. I finally got the
>> > highlighting filter to work and update properly. Now I¹m trying to do
>> > something much simpler, i.e., construct a freezeFilter.  Nothing I¹ve tried
>> > so far works.  Apparently, a CIFilter is expected to be stateless function
>> > such as outputImage = f(inputImage, parameters). Not accepting this 
>> > premiss,
>> > I decided to try caching the first output image ( from the outputImage
>> > method), then return the cashed image thereafter, an ultra simple concept,
>> > except that it does not work. Any reason, besides what I postulated, why
>> > this shouldn¹t work?
>> > 
>> > 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com