Skia.Compact (Skia v0.1.1)

Copy Markdown View Source

Compact command batch encoding and rendering.

Compact batches are useful for storage, transport, and native decode benchmarking. They are explicit API, not the default renderer path.

batch = Skia.Compact.encode(document)
binary = Skia.Compact.encode_binary(document)
{:ok, raw} = Skia.Compact.to_raw(document)

Summary

Types

batch()

@type batch() :: {pos_integer(), pos_integer(), [compact_command()]}

compact_command()

@type compact_command() ::
  {pos_integer(), [compact_value()], keyword(compact_value())}

compact_value()

@type compact_value() :: term()

Functions

encode(document)

@spec encode(Skia.Document.t()) :: batch()

encode_binary(document)

@spec encode_binary(Skia.Document.t()) :: binary()

encode_command(command)

@spec encode_command(Skia.Command.t()) :: compact_command()

op_id(op)

@spec op_id(atom()) :: pos_integer()

render(document, opts \\ [])

@spec render(Skia.Document.t(), keyword() | Skia.RenderOptions.t()) ::
  {:ok, binary() | map()} | {:error, atom(), map()}

to_png(document)

@spec to_png(Skia.Document.t()) :: {:ok, binary()} | {:error, atom(), batch()}

to_raw(document)

@spec to_raw(Skia.Document.t()) ::
  {:ok,
   %{
     width: pos_integer(),
     height: pos_integer(),
     stride: pos_integer(),
     data: binary()
   }}
  | {:error, atom(), batch()}