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.
Description
Section titled “Description”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.
Learn more
Section titled “Learn more”Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
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. |
void | decode(ResourceData resource) abstract | JOID calls it on a loading thread: read the asset and set the size and the pixels of resource. |
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. |
For subclasses
Section titled “For subclasses”| Returns | Signature | Summary |
|---|---|---|
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. |
Method details
Section titled “Method details”prepare
Section titled “prepare”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.
decode
Section titled “decode”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.
upload
Section titled “upload”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.
isSettled
Section titled “isSettled”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.
isMipmappable
Section titled “isMipmappable”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.
update
Section titled “update”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.
request
Section titled “request”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
