Classes

The following classes are available globally.

  • Bitmap describes a two-dimensional raster pixel array. Bitmap is built on ImageInfo, containing integer width and height, ColorType and AlphaType describing the pixel format, and ColorSpace describing the range of colors. Bitmap points to PixelRef, which describes the physical array of pixels. ImageInfo bounds may be located anywhere fully inside PixelRef bounds.

    Bitmap can be drawn using Canvas. Bitmap can be a drawing destination for Canvas draw member functions. Bitmap flexibility as a pixel container limits some optimizations available to the target platform.

    If pixel array is primarily read-only, use Image for better performance. If pixel array is primarily written to, use Surface for better performance.

    Bitmap is not thread safe. Each thread must have its own copy of Bitmap fields, although threads may share the underlying pixel array.

    See more

    Declaration

    Swift

    public final class Bitmap
  • Canvas provides an interface for drawing, and how the drawing is clipped and transformed. Canvas contains a stack of Matrix and clip values.

    Canvas and Paint together provide the state to draw into Surface or BaseDevice. Each Canvas draw call transforms the geometry of the object by the concatenation of all Matrix values in the stack. The transformed geometry is clipped by the intersection of all of clip values in the stack. The Canvas draw calls use Paint to supply drawing state such as color, Typeface, text size, stroke width, Shader and so on.

    To draw to a pixel-based destination, create raster surface or GPU surface. Request Canvas from Surface to obtain the interface to draw. Canvas generated by raster surface draws to memory visible to the CPU. Canvas generated by GPU surface uses Vulkan or OpenGL to draw to the GPU.

    To draw to a document, obtain Canvas from SVG canvas, document PDF, or PictureRecorder. Document based Canvas and other Canvas subclasses reference BaseDevice describing the destination.

    Typically you create the Canvas from a bitmap, but an empty canvas can be created with the some fo the static make methods, and serve special purposes:

    • makeEmpty(width:height) - creates an empty canvas that ignores all drawing commands
    • makeOverdraw(canvas:) - A canvas that captures all drawing commands, and rather than draw the actual content, it increments the alpha channel of each pixel every time it would have been touched by a draw call.
    • makeNway(width:height:) - will create a passthrough n-way canvas. Once created you can add canvas with addCanvas, and remove them with removeCanvas
    See more

    Declaration

    Swift

    public final class Canvas
  • SKData holds an immutable data buffer. Not only is the data immutable, but the actual ptr that is returned (by data)) is guaranteed to always be the same for the life of this instance.

    See more

    Declaration

    Swift

    public final class SKData
  • Skia’s FontManager The default font manager can be accessed via the default static property of FontManager.

    See more

    Declaration

    Swift

    public final class FontManager
  • Image describes a two dimensional array of pixels to draw. The pixels may be decoded in a raster bitmap, encoded in a Picture or compressed data stream, or located in GPU memory as a GPU texture.

    Image cannot be modified after it is created. Image may allocate additional storage as needed; for instance, an encoded Image may decode when drawn.

    Image width and height are greater than zero. Creating an Image with zero width or height returns Image equal to nil.

    Image may be created from Bitmap, Pixmap, Surface, Picture, encoded streams, GPU texture, YUV_ColorSpace data, or hardware buffer. Encoded streams supported include BMP, GIF, HEIF, ICO, JPEG, PNG, WBMP, WebP. Supported encoding details vary with platform.

    See more

    Declaration

    Swift

    public final class Image
  • Paint controls options applied when drawing. Paint collects all options outside of the Canvas clip and Canvas matrix. Various options apply to strokes and fills, and images. Paint collects effects and filters that describe single-pass and multiple-pass algorithms that alter the drawing geometry, color, and transparency. For instance, Paint does not directly implement dashing or blur, but contains the objects that do so.

    See more

    Declaration

    Swift

    public final class Paint
  • Path contain geometry. Path may be empty, or contain one or more verbs that outline a figure. Path always starts with a move verb to a Cartesian coordinate, and may be followed by additional verbs that add lines or curves. Adding a close verb makes the geometry into a continuous loop, a closed contour. Path may contain any number of contours, each beginning with a move verb.

    Path contours may contain only a move verb, or may also contain lines, quadratic beziers, conics, and cubic beziers. Path contours may be open or closed.

    When used to draw a filled area, Path describes whether the fill is inside or outside the geometry. Path also describes the winding rule used to fill overlapping contours.

    The various commands that add to the path provide a fluid interface, meaning that calling the methods return the instance on which it was invoked, easily allowing the drawing operations to be concatenated.

    See more

    Declaration

    Swift

    public final class Path
  • PathEffect is the base class for objects in the Paint that affect the geometry of a drawing primitive before it is transformed by the canvas’ matrix and drawn. Dashing is implemented as a subclass of PathEffect.

    See more

    Declaration

    Swift

    public final class PathEffect
  • The picture recorder is used to record drawing operations made to a SKCanvas and stored in a SKPicture. call the beginRecording method to start, issue your commands into the returned Canvas and then call the endRecording method to get the Picture that has the recording on it.

    See more

    Declaration

    Swift

    public final class PictureRecorder
  • Region describes the set of pixels used to clip Canvas. Region is compact, efficiently storing a single integer rectangle, or a run length encoded array of rectangles. Region may reduce the current Canvas clip, or may be drawn as one or more integer rectangles. Region iterator returns the scan lines or rectangles contained by it, optionally intersecting a bounding rectangle.

    See more

    Declaration

    Swift

    public final class Region
  • bstraction for a source of bytes. Subclasses can be backed by memory, or a file, or something else.

    Classic streams APIs are sort of async, in that on a request for N bytes, they may return fewer than N bytes on a given call, in which case the caller can try again to get more bytes, eventually (modulo an error) receiving their total N bytes.

    Skia streams behave differently. They are effectively synchronous, and will always return all N bytes of the request if possible. If they return fewer (the read call returns the number of bytes read) then that means there is no more data (at EOF or hit an error). The caller should not call again in hopes of fulfilling more of the request.

    See more

    Declaration

    Swift

    public class SKStream
  • A reading stream that wraps a native file. To write use SKFileWStream

    See more

    Declaration

    Swift

    public final class SKFileStream : SKStream
  • A memory-based stream.

    See more

    Declaration

    Swift

    public final class SKMemoryStream : SKStream
  • Undocumented

    See more

    Declaration

    Swift

    public class SKWStream
  • Opens a write-only stream to the specified file. To read use SKFileStream

    See more

    Declaration

    Swift

    public final class SKFileWStream : SKWStream
  • A writeable, dynamically-sized, memory-based stream.

    See more

    Declaration

    Swift

    public final class SKDynamicMemoryWStream : SKWStream
  • Shaders specify the source color(s) for what is being drawn. If a paint has no shader, then the paint’s color is used. If the paint has a shader, then the shader’s color(s) are use instead, but they are modulated by the paint’s alpha. This makes it easy to create a shader once (e.g. bitmap tiling or gradient) and then change its transparency w/o having to modify the original shader… only the paint’s alpha needs to be modified.

    Use any of the various static make methods to create the shader

    See more

    Declaration

    Swift

    public final class Shader
  • Surface is responsible for managing the pixels that a canvas draws into. The pixels can be allocated either in CPU memory (a raster surface) or on the GPU (a GrRenderTarget surface).

    Surface takes care of allocating a Canvas that will draw into the surface. Call surface->getCanvas() to use that canvas (but don’t delete it, it is owned by the surface).

    Surface always has non-zero dimensions. If there is a request for a new surface, and either of the requested dimensions are zero, then nil will be returned.

    Use one of the static make methods to create instances of Surface

    See more

    Declaration

    Swift

    public final class Surface
  • Describes properties and constraints of a given Surface. The rendering engine can parse these during drawing, and can sometimes optimize its performance (e.g. disabling an expensive feature).

    See more

    Declaration

    Swift

    public final class SurfaceProperties
  • The Typeface class specifies the typeface and intrinsic style of a font. This is used in the paint, along with optionally algorithmic settings like textSize, textskewX, textScaleX, FakeBoldText_Mask, to specify how text appears when drawn (and measured).

    Typeface objects are immutable, and so they can be shared between threads.

    See more

    Declaration

    Swift

    public final class Typeface
  • SkiaView is a UIView that you can add to your programs that can render some Skia content for you. To do this, create an instance of this class, and then set the drawingCallback property to point to a function that takes a Surface and an ImageInfo as parameter, and this will be called when the view needs to render itself.

    You can set the ignorePixelScaling to ignore the built-in scaling that uses the UIView‘s contentScaleFactor

    See more

    Declaration

    Swift

    public class SkiaView : UIView