CIKernel Class Reference

Inherits from
Conforms to
Framework
Library/Frameworks/QuartzCore.framework
Availability
OS X v10.4 and later
Declared in
CIKernel.h
Companion guides
Related sample code

Overview

The CIKernel class maintains kernel routines that process individual pixels. The kernel routines in a CIKernel object use a subset of the OpenGL Shading Language and Core Image extensions to this language. You use a CIKernel object in conjunction with other Core Image classes, such as CIFilter, CIFilterShape, and CISampler, to create custom filters.

Tasks

Creating a Kernel

Getting a Kernel Name

Setting a Selector

Class Methods

kernelsWithString:

Creates and returns and array of CIKernel objects.

+ (NSArray *)kernelsWithString:(NSString *)s
Parameters
s

A program in the Core Image dialect of the OpenGL Shading Language that contains one or more routines, each of which is marked using the kernel keyword.

Return Value

An array of CIKernel objects. The array contains one CIKernel objects for each kernel routine in the supplied string.

Discussion

See Core Image Kernel Language Reference for more details.

Availability
  • OS X v10.4 and later.
Declared In
CIKernel.h

Instance Methods

name

Returns the name of a kernel routine.

- (NSString *)name
Return Value

The name of the kernel routine.

Availability
  • OS X v10.4 and later.
Declared In
CIKernel.h

setROISelector:

Sets the selector used to query the region of interest of the kernel.

- (void)setROISelector:(SEL)aMethod
Parameters
aMethod

A selector name.

Discussion

The aMethod argument must use the signature that is defined for the regionOf:destRect:userInfo: method, which is as follows:

- (CGRect) regionOf:(int)samplerIndex destRect:(CGRect)r userInfo:obj;

where:

  • samplerIndex defines the sampler to query

  • destRect is the extent of the region, in working space coordinates, to render.

  • userInfo is the object associated with the kCIApplyOptionUserInfo option when the kernel is applied to its arguments. The userInfo is important because instance variables can’t be used by the defining class. Instance variables must be passed through the userInfo argument.

The regionOf:destRect:userInfo: method of the CIFilter object is called by the framework. This method returns the rectangle that contains the region of the sampler that the kernel needs to render the specified destination rectangle.

A sample regionOf:destRect:userInfo: method might look as follows:

- (CGRect)regionOf:(int)sampler destRect:(CGRect)r userInfo:params
{
  float scale = fabs ([params X]);
  return CGRectInset (r, scale * -1.3333, scale * -1.3333);
}

In the filter code, you set the selector using the following:

kernel setROISelector:@selector(regionOf:destRect:userInfo:)]

Availability
  • OS X v10.4 and later.
Related Sample Code
Declared In
CIKernel.h