Mac Developer Library

Developer

QuartzCore Framework Reference CIKernel Class Reference

Options
Deployment Target:

On This Page
Language:

CIKernel

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.

Inheritance


Conforms To


Import Statement


import QuartzCore @import QuartzCore;

Availability


OS X v10.4 and later
  • Creates and returns and array of CIKernel objects.

    Declaration

    Swift

    class func kernelsWithString(_ s: String!) -> [AnyObject]!

    Objective-C

    + (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.

    Import Statement

    import QuartzCore

    Availability

    OS X v10.4 and later.

  • Returns the name of a kernel routine.

    Declaration

    Swift

    func name() -> String!

    Objective-C

    - (NSString *)name

    Return Value

    The name of the kernel routine.

    Import Statement

    import QuartzCore

    Availability

    OS X v10.4 and later.

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

    Declaration

    Swift

    func setROISelector(_ aMethod: Selector)

    Objective-C

    - (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:)]

    Import Statement

    import QuartzCore

    Availability

    OS X v10.4 and later.