Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 16-bit buffers and 8/16 conversion to LXLayeredComponent. #2

Closed
wants to merge 1 commit into from

Conversation

zestyping
Copy link
Collaborator

LXLayeredComponent is the base for LXEffect and LXPattern. It contains a color buffer called buffer, which exposes its array of ints as colors—that's the array that effects and patterns write to in their run() method.

It isn't practical to have to port all effects and patterns to run in 16-bit colour in one huge swoop, so it is a major goal to support existing effects and patterns unchanged alongside new 16-bit effects and patterns.

So, the first step in adding 16-bit colour support is to make LXLayeredComponent manage buffers of both bit depths—buffer and buffer16—and convert between them as needed whenever anyone requests a buffer of a different depth than what was last written. The buffersInSync flag lets us convert when needed and avoid wasting time repeating conversions that were already done.

An added twist is that LXLayeredComponent supports two modes of operation already: it can either allocate and own its own buffer (which is what patterns do), or it can write to and modify an externally provided LXBuffer object (which is what effects do). The Buffered marker interface is used to select between these two modes.

We need to support both bit depths across both modes and across all subclasses, which is hard to do with inheritance. So there's a new Uses16 marker interface that indicates whether the effect/pattern operates on the 16-bit buffer or the 8-bit buffer, and you'll see that this marker interface is used in various places to decide whether a conversion between buffers is needed and which direction to convert.

@zestyping
Copy link
Collaborator Author

Superseded by #3.

@zestyping zestyping closed this Apr 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant