Add PolyBuffer and use it to handle 8/16-bit conversion in LXLayeredComponent. #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It's a major goal of this project to support existing 8-bit effects and patterns unchanged alongside new 16-bit effects and patterns, because it isn't practical to have to port all effects and patterns to run in 16-bit colour in one huge swoop.
A good place to start reviewing is the new class
PolyBuffer
.This PR introduces
PolyBuffer
, a useful tool for handling 8-bit/16-bit conversions. It encapsulates a pair of colour buffers—an 8-bit colour buffer and a 16-bit colour buffer—and converts between them as needed, whenever anyone requests the data in a different colour depth than what was last written. It keeps track of which buffers are fresh or stale, so that it can automatically convert the data as needed without wasting time on unnecessary conversions.LXLayeredComponent
is the base forLXEffect
andLXPattern
. Its colour buffer is now aPolyBuffer
, and it exposes its two arrays via its typelessgetArray()
method.An added twist is that
LXLayeredComponent
supports two modes of operation already: it can either allocate and own its ownbuffer
(which is what patterns do), or it can write to and modify an externally providedLXBuffer
object (which is what effects do). TheBuffered
marker interface is used to select between these two modes.