SkiaCanvas

class SkiaCanvas(canvas: Canvas) : KiteCanvas(source)

KiteCanvas backed by a raw org.jetbrains.skia.Canvas (Skiko).

Same rendering engine Compose Multiplatform rides on for JVM Desktop and iOS, minus the Compose runtime. Pure-Skia means this adapter is the right choice for:

  • Server-side rasterization: PDF → PNG, headless thumbnail generation, CI pipelines.

  • CLI tools: anything that needs pixels without adding androidx.compose.runtime.

  • Smaller dependency footprint: Skiko alone is significantly less than Compose Multiplatform.

Pair with PdfPageRasterizer for the common "give me a ByteArray of a page's PNG" use case.

Constructors

Link copied to clipboard
constructor(canvas: Canvas)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open override fun applySoftMask(kind: SoftMask.Kind, maskBBox: KiteRectangle, maskCtm: KiteMatrix, render: () -> Unit, renderMask: (KiteCanvas) -> Unit)
open override fun applySoftMask(kind: SoftMask.Kind, maskBBox: KiteRectangle, maskCtm: KiteMatrix, transfer: KiteMaskTransfer?, render: () -> Unit, renderMask: (KiteCanvas) -> Unit)
Link copied to clipboard
open override fun beginPage(widthPt: Double, heightPt: Double, deviceCtm: KiteMatrix)
Link copied to clipboard
open override fun beginTransparencyGroup(bbox: KiteRectangle, ctm: KiteMatrix, isolated: Boolean, knockout: Boolean, alpha: Double, blendMode: KiteBlendMode)

A non-isolated group at full alpha in Normal paints straight onto its backdrop, so its blend modes see what lies under it (ISO 32000-1, 11.4.5, #125). Any other group paints into a layer. A non-isolated group's layer starts as a copy of the backdrop, and at the end mixes with it by alpha, which is exact over an opaque backdrop. In a knockout group (11.4.6) each paint replaces what lies under it inside its shape.

Link copied to clipboard
open override fun drawGlyphs(glyphs: List<TextGlyph>, fontSize: Double, unitsPerEm: Int, hasOutlines: Boolean, fontSpec: FontSpec, textToDevice: KiteMatrix, color: RgbColor, alpha: Double, blendMode: KiteBlendMode)
Link copied to clipboard
open override fun drawImage(image: KiteImageData, ctm: KiteMatrix, alpha: Double)
open override fun drawImage(image: KiteImageData, ctm: KiteMatrix, alpha: Double, blendMode: KiteBlendMode)
Link copied to clipboard
open override fun endPage()
Link copied to clipboard
open override fun endTransparencyGroup()
Link copied to clipboard
open override fun fillPath(path: KitePath, ctm: KiteMatrix, color: RgbColor, evenOdd: Boolean, alpha: Double, blendMode: KiteBlendMode)
Link copied to clipboard
open override fun fillShading(shading: KiteShading, ctm: KiteMatrix, clipPath: KitePath?, alpha: Double, blendMode: KiteBlendMode)
Link copied to clipboard
open override fun hostGlyphOutline(text: String, fontSpec: FontSpec): KitePath?

The outline of text in the host typeface drawGlyphs draws a font without embedded outlines in, at 1000 units per em with y up (#85).

Link copied to clipboard
open override fun popClip()
Link copied to clipboard
open override fun pushClip(path: KitePath, ctm: KiteMatrix, evenOdd: Boolean)
Link copied to clipboard
open override fun rasterStep(region: KiteRectangle, ctm: KiteMatrix, step: KiteRasterStep): Boolean

The raster step (#209, #308): its box is region under the canvas's matrix, cut to the device clip and rounded out to whole pixels. A render paints into a raster surface of the box. Skia reads back only the canvas under every layer, so inside a group's or a soft mask's layer the step gets no backdrop. Past MAX_STEP_PIXELS it works at a lower resolution, and then reads no backdrop either.

Link copied to clipboard
open override fun strokePath(path: KitePath, ctm: KiteMatrix, color: RgbColor, lineWidth: Double, alpha: Double, blendMode: KiteBlendMode, dashArray: List<Double>?, dashPhase: Double, lineCap: Int, lineJoin: Int, miterLimit: Double)