Skip to content

IResourceDecoder

interface IResourceDecoder
Known subtypes: AnimatedResourceDecoder, RasterResourceDecoder, VectorResourceDecoder, VideoResourceDecoder
Package: dev.joid.lib.resource.decoder · Module: core · Source: IResourceDecoder.java

Reads the data of one resource, decodes it on a background thread and sends it to the GPU on the render thread.

An IResourceFormat creates one per resource. JOID calls prepare on the thread that first draws the resource, decode on a loading thread (or on the drawing thread for a blocking resource), then upload on the render thread; clear frees what the decoder holds. Fill the ResourceData you are given: its size, its pixels or its textures.

ReturnsSignatureSummary
voidprepare(ResourceData resource) abstractJOID calls it before each decode, on the thread that draws: create the textures there, for example with ResourceData.placeholder.
voiddecode(ResourceData resource) abstractJOID calls it on a loading thread: read the asset and set the size and the pixels of resource.
voidupload(ResourceData resource) abstractJOID calls it on the render thread once the pixels are decoded: send them to the textures, for example with ResourceData.uploadTextures.
voidclear(ResourceData resource) abstractJOID calls it when the resource is cleared or reloaded: free what the decoder holds, such as a file or a native handle.
IResourceDecoderfork() defaultReturns a decoder for a separate playback of the same file, or null when the resource has no playback to separate; null by default.
booleanisSettled() defaultIf true, the decoder has nothing left to update, so that a frame that draws it can be compared with a reference; true by default.
booleanisMipmappable() defaultIf true, the textures accept mipmaps; true by default.
ReturnsSignatureSummary
voidinit(ResourceData resource) hook defaultJOID calls it when the decoder is attached to resource; empty by default.
voidupdate(ResourceData resource) hook defaultJOID calls it each time the resource is bound for drawing, on the render thread: advance an animation there; empty by default.
voidrequest(ResourceData resource, int width, int height, boolean async, boolean resizing) hook defaultJOID calls it on each draw with the size the resource covers in screen pixels; async tells whether to work in the background and resizing that the size changed less than 200 ms ago.

void prepare(ResourceData resource) abstract

JOID calls it before each decode, on the thread that draws: create the textures there, for example with ResourceData.placeholder. An exception makes the resource fail.

void decode(ResourceData resource) abstract

JOID calls it on a loading thread: read the asset and set the size and the pixels of resource. An exception makes the resource fail, unless a reload replaced this decode.

void upload(ResourceData resource) abstract

JOID calls it on the render thread once the pixels are decoded: send them to the textures, for example with ResourceData.uploadTextures.

void clear(ResourceData resource) abstract

JOID calls it when the resource is cleared or reloaded: free what the decoder holds, such as a file or a native handle.

IResourceDecoder fork() default

Returns a decoder for a separate playback of the same file, or null when the resource has no playback to separate; null by default.

boolean isSettled() default

If true, the decoder has nothing left to update, so that a frame that draws it can be compared with a reference; true by default.

boolean isMipmappable() default

If true, the textures accept mipmaps; true by default.

void init(ResourceData resource) hook default

JOID calls it when the decoder is attached to resource; empty by default.

void update(ResourceData resource) hook default

JOID calls it each time the resource is bound for drawing, on the render thread: advance an animation there; empty by default.

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

JOID calls it on each draw with the size the resource covers in screen pixels; async tells whether to work in the background and resizing that the size changed less than 200 ms ago. A vector decoder renders again at that size; empty by default.


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