MetalRenderer


Ink renderer for iOS, using Metal.

Summary

Public constructors

MetalRenderer(
    device: MTLDeviceProtocol,
    colorPixelFormat: ULong,
    stencilPixelFormat: ULong,
    sampleCount: Int?,
    textureImageStore: TextureImageStore?
)
N

Public functions

Unit
draw(
    renderEncoder: MTLRenderCommandEncoderProtocol,
    inProgressStroke: InProgressStroke,
    modelTransform: AffineTransform,
    viewTransform: AffineTransform,
    projectionTransform: AffineTransform
)

Draws an in-progress stroke using the given render encoder.

N
Unit
draw(
    renderEncoder: MTLRenderCommandEncoderProtocol,
    stroke: Stroke,
    modelTransform: AffineTransform,
    viewTransform: AffineTransform,
    projectionTransform: AffineTransform
)

Draws a completed stroke using the given render encoder.

N

Public constructors

MetalRenderer

MetalRenderer(
    device: MTLDeviceProtocol,
    colorPixelFormat: ULong,
    stencilPixelFormat: ULong,
    sampleCount: Int? = null,
    textureImageStore: TextureImageStore? = null
)
Parameters
device: MTLDeviceProtocol

MTLDevice to use for rendering.

colorPixelFormat: ULong

Format of the color texture being rendered.

stencilPixelFormat: ULong

Format of the stencil texture being rendered. If a stencil texture is not being used, this should be MTLPixelFormatInvalid.

sampleCount: Int? = null

The number of samples per pixel for MSAA. If unset or null, shader-based antialiasing will be used instead.

textureImageStore: TextureImageStore? = null

An optional callback for retrieving texture images by ID.

Public functions

draw

fun draw(
    renderEncoder: MTLRenderCommandEncoderProtocol,
    inProgressStroke: InProgressStroke,
    modelTransform: AffineTransform = AffineTransform.IDENTITY,
    viewTransform: AffineTransform = AffineTransform.IDENTITY,
    projectionTransform: AffineTransform = AffineTransform.IDENTITY
): Unit

Draws an in-progress stroke using the given render encoder.

Parameters
renderEncoder: MTLRenderCommandEncoderProtocol

MTLRenderCommandEncoder to draw with.

inProgressStroke: InProgressStroke

The in-progress stroke to draw.

modelTransform: AffineTransform = AffineTransform.IDENTITY

Affine transform from stroke coordinates to world coordinates, an identity transform by default. Can be omitted if the stroke coordinates are all in the same world coordinate space.

viewTransform: AffineTransform = AffineTransform.IDENTITY

Affine transform from world coordinates to view coordinates, an identity transform by default. Can be omitted if the world coordinate space is the same as the view coordinate space.

projectionTransform: AffineTransform = AffineTransform.IDENTITY

The projection transform to use for drawing, an identity transform by default. Must transform from the world coordinate space to Y-up normalized device coordinates (the lower-left corner is (-1, -1) and the upper-right corner is (1, 1)).

draw

fun draw(
    renderEncoder: MTLRenderCommandEncoderProtocol,
    stroke: Stroke,
    modelTransform: AffineTransform = AffineTransform.IDENTITY,
    viewTransform: AffineTransform = AffineTransform.IDENTITY,
    projectionTransform: AffineTransform = AffineTransform.IDENTITY
): Unit

Draws a completed stroke using the given render encoder.

Parameters
renderEncoder: MTLRenderCommandEncoderProtocol

MTLRenderCommandEncoder to draw with.

stroke: Stroke

The stroke to draw.

modelTransform: AffineTransform = AffineTransform.IDENTITY

Affine transform from stroke coordinates to world coordinates, an identity transform by default. Can be omitted if the stroke coordinates are all in the same document coordinate space.

viewTransform: AffineTransform = AffineTransform.IDENTITY

Affine transform from world coordinates to view coordinates, an identity transform by default. Can be omitted if the coordinate space used for the document is the same as the view coordinate space.

projectionTransform: AffineTransform = AffineTransform.IDENTITY

The projection transform to use for drawing, an identity transform by default. Must transform from the world coordinate space to Y-up normalized device coordinates (the lower-left corner is (-1, -1) and the upper-right corner is (1, 1)).