Skip to content

VectorResourceDecoder

class VectorResourceDecoder
Implements: IResourceDecoder
Package: dev.joid.lib.resource.decoder.impl · Module: core · Source: VectorResourceDecoder.java

Decodes an SVG document and renders it again at the size it is drawn at, so that it stays sharp.

SvgResourceFormat picks it. The first render has the size of the document; each draw then asks for its size in screen pixels, at most 4096 on the longer side, rendered on a background thread and kept with the last 8 sizes. While the size keeps changing, the closest texture already rendered is drawn, so an animated size does not render on every frame. Every render gives the same pixels on every JDK, from Java 8 to the latest: the shapes are filled without antialiasing at 8 samples per pixel on each axis, fewer above 512 pixels but at least 2, then averaged, and JOID outlines the strokes itself instead of the JDK.

ReturnsSignatureSummary
VectorResourceDecodercreate(Asset asset) factoryCreates a decoder of the SVG asset.
VectorResourceDecoder(Asset asset) protectedCreates the decoder, for a subclass.

ReturnsSignatureSummary
voidprepare(ResourceData resource)Gives the data a transparent placeholder texture until the document is rendered.
voiddecode(ResourceData resource)Parses the document and renders it at its own size.
voidupload(ResourceData resource)Uploads the first render.
voidclear(ResourceData resource)Frees every rendered texture and the parsed document.
booleanisSettled()If true, no render is in progress or waiting for its upload.
booleanisMipmappable()Always false: a vector image renders at the size it is drawn at instead.
AssetgetAsset()Returns the SVG file.
ReturnsSignatureSummary
voidupdate(ResourceData resource) hookUploads a render finished in the background, unless the document was replaced since.
voidrequest(ResourceData resource, int width, int height, boolean async, boolean resizing) hookShows the texture of that size when it is already rendered, otherwise renders it: on the background thread when async is true, at once otherwise.
Inherited from IResourceDecoder (1)

fork

VectorResourceDecoder create(Asset asset) factory

Creates a decoder of the SVG asset.

VectorResourceDecoder(Asset asset) protected

Creates the decoder, for a subclass.

void prepare(ResourceData resource)

Gives the data a transparent placeholder texture until the document is rendered.

void decode(ResourceData resource)

Throws:

  • UncheckedIOException: The SVG … cannot be read
  • IllegalArgumentException: … is not an SVG document that can be parsed

Parses the document and renders it at its own size. Throws UncheckedIOException when the asset cannot be read, and IllegalArgumentException when it is not an SVG document.

void upload(ResourceData resource)

Uploads the first render.

void clear(ResourceData resource)

Frees every rendered texture and the parsed document.

boolean isSettled()

If true, no render is in progress or waiting for its upload.

boolean isMipmappable()

Always false: a vector image renders at the size it is drawn at instead.

Asset getAsset()

Returns the SVG file.

void update(ResourceData resource) hook

Uploads a render finished in the background, unless the document was replaced since.

void request(ResourceData resource, int width, int height, boolean async, boolean resizing) hook

Shows the texture of that size when it is already rendered, otherwise renders it: on the background thread when async is true, at once otherwise. While resizing, it shows the closest larger texture or renders 25 % larger, so that a growing size does not render on every frame.


fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses

Report a problem with this page