Re: [Solution] backgroundFilters on layer backed views?
Re: [Solution] backgroundFilters on layer backed views?
- Subject: Re: [Solution] backgroundFilters on layer backed views?
- From: Bill Dudney <email@hidden>
- Date: Tue, 20 Nov 2007 09:30:16 -0700
Hi All,
The solution for posterity;
I had the controls view layer backed but not its superview so the
filter was not applied to the superview and thus no effect. IOW, both
the view with the 'backgroundFilters' and its superview must be layer
backed for the background filters to be applied. Which makes total
sense now that I've found the problem...
TTFN,
-bd-
http://bill.dudney.net/roller/objc
On Nov 19, 2007, at 11:45 PM, Bill Dudney wrote:
Hi All,
I'm having trouble getting the backgroundFilters for layer backed
views to work as I expect. The release notes (quoted below) made me
think that the backgroundFilters would apply the filter(s) to the
part of the superview that is not obscured by a subview. But the
docs from NSView.backgroundFilters (and experimentation) make me
think this is not the case.
Here is my code;
CIVector *center = [CIVector vectorWithX:NSMidX([self bounds])
Y:NSMidY([self bounds])];
CIFilter *pointalize = [CIFilter
filterWithName:@"CIPointillize"
keysAndValues:kCIInputRadiusKey,
[NSNumber numberWithFloat:1.0f],
kCIInputCenterKey, center, nil];
pointalize.name = @"pointalize";
[controls setBackgroundFilters:[NSArray
arrayWithObjects:pointalize, nil]];
The 'controls' view performs no drawing (empty drawRect:) and simply
holds a group of simple controls (couple of buttons etc).
In the debugger I'm finding things contrary to my reading of the
NSView docs, the layer does not have a background filters array (its
nil) but the view does. The view has been drawn at least once when
I'm checking for the filters (if that matters).
I'm not seeing any change to the 'controls' view at all. I put the
pointalize filter into the 'contentFilters' array just to make sure
that I was not simply configuring the filter incorrectly and I got
pointalized content (pop-ups look weird pointalized:).
Now some questions:
- Has anyone had success applying a background filter to a view?
- Does anyone see anything obviously silly that I've done here that
could be causing stuff not to work?
- Does anyone know what the background filters are really suppose to
do, apply a filter to the unobscured superview content or apply to
the background color of the layer?
Thanks in advance!
-bd-
http://bill.dudney.net/roller/objc
The docs in NSView.setBackgroundFilters:;
This method sets the value of the backgroundFilters property of the
receiver’s layer.
Sending this message to a view that is not managing a Core Animation
layer causes an exception.
The release notes;
- (NSArray *)backgroundFilters;
- (void)setBackgroundFilters:(NSArray *)filters;
Allows the background behind the view's subtree to be filtered
through an optional chain of CIFilters before the view subtree is
composited into it. The supplied array of filters needn't be
connected to one another, as they will be connected in series
automatically by Core Animation. Defaults to nil. This setting only
has an effect for Core Animation-based view compositing.
_______________________________________________
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
_______________________________________________
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