package dev.photosync.mcapi.render;

import dev.photosync.core.thumbnail.ThumbImage;

import java.io.IOException;

/**
 * Turns pixels into something drawable.
 *
 * <p>Both methods must be called on the render thread, which is why the loaders
 * in {@code :shared:core} deal in bytes and leave the upload to the UI: network
 * work happens on a worker, and only the last cheap step crosses back onto the
 * thread that can actually talk to the GPU.
 */
public interface TextureSink {

    /**
     * Uploads a decoded placeholder -- at most 32x32 -- from a ThumbHash.
     *
     * <p>Kept separate from {@link #decode} because these are already pixels and
     * routing them through an image decoder would mean encoding a PNG first.
     */
    TextureHandle upload(ThumbImage image);

    /**
     * Decodes and uploads PNG or JPEG bytes.
     *
     * @throws IOException if the bytes are not an image the game can read
     */
    TextureHandle decode(byte[] encoded) throws IOException;
}
