Layer
Source:
Layer.h
Layer¶
src/light/layers/Layer.h:46Inherits:
MoonModule
One rendering layer: a buffer, a mapping onto physical lights, and the effects that fill it.
The unit the render loop iterates, turning coordinates into lights. Effects write the buffer, modifiers reshape it, and Drivers composites the stack.

Public Attributes¶
uint8_t blendMode = 1
: How this layer composites onto those below it, as an index into kBlendModeOptions.
uint8_t opacity = 255
: How strongly this layer composites, from 0 for invisible to 255 for full.
Public Methods¶
virtual inline ModuleRole role() const override
: Role for type identification (no RTTI needed).
virtual inline const char * acceptsChildRoles() const override
: The child roles a layer accepts: effects that write it, modifiers that reshape it.
inline ~Layer() override
: Release the live-pass scratch this layer allocated.
virtual inline void defineControls() override
: Publish the two composition controls the Drivers container reads.
inline BlendOp blendOp() const
: The BlendMap op this layer's blendMode selects, read by Drivers.
inline void setLayouts(Layouts * lg)
: Point this layer at the shared Layouts describing the physical topology.
inline Layouts * layouts() const
: The active Layouts, for a consumer that needs per-light coordinates.
inline void setChannelsPerLight(uint8_t cpl)
: Set channels per light: 3 for RGB, 4 for RGBW, more for a fixture profile.
inline void setFixtureChannels(const FixtureChannels & fc)
: Set where this layer's fixtures keep their motion channels.
inline const FixtureChannels & fixtureChannels() const
: Where this layer's fixtures keep their motion channels.
virtual inline void prepare() override
: Cold path: size the box from the layouts, build the mapping, and clear the buffer.
virtual inline void tick() override
: The hot tick, which by default ticks every enabled child and times each.
inline void ensureLiveScratch()
: Size the live-pass snapshot to the current buffer, or free it when nothing is live.
inline void applyLivePass()
: Remap the buffer through the live modifiers, once per frame.
inline void extrude(Dim effectDim)
: Copy the effect's written slice across the axes it does not iterate.
inline Buffer & buffer()
: The logical light data every effect writes into.
inline const Buffer & buffer() const
: The logical light data, for a reader that does not write it.
inline const MappingLUT & lut() const
: The mapping from logical cells to physical light positions.
inline lengthType width() const
: The logical box width, which is what effects iterate.
inline lengthType height() const
: The logical box height.
inline lengthType depth() const
: The logical box depth.
inline uint8_t channelsPerLight() const
: Bytes per light: 3 for RGB, 4 for RGBW, more when fixtures carry motion channels.
inline uint32_t elapsed() const
: Milliseconds at the start of this frame, the clock every effect animates against.
inline void fadeToBlackBy(uint8_t amt)
: Ask for a fade of amt/255 per reference frame, collected as the gentlest across effects.
inline uint32_t bufferGen() const
: How many times anything has written the shared buffer, so a holder knows it is untouched.
inline nrOfLightsType physicalLightCount() const
: How many physical lights the mapping covers.
inline lengthType physicalWidth() const
: The physical box width, before any modifier reshapes it.
inline lengthType physicalHeight() const
: The physical box height.
inline lengthType physicalDepth() const
: The physical box depth.
inline bool lutSkipped() const
: Whether a mapping was wanted but could not be built, so the layer degraded to identity.
inline void rebuildLUT()
: Fold the box through the static modifiers and build the mapping, on the cold path.
inline bool isNaturalOrder() const
: Whether the layout emits lights in box order, which is what validates the dense fast path.
inline bool buildFoldedLUT(const Coord3D & logical, nrOfLightsType logicalCount, nrOfLightsType driverCount)
inline void clampLogical(Coord3D & logical) const
: Hold a folded box inside its legal bounds, so a modifier cannot size it away.
Public Static Attributes¶
constexpr nrOfLightsType kNoDriver = static_cast<>(-1)
Public Static Methods¶
static inline nrOfLightsType cellCount(const Coord3D & box)
: How many cells a box holds.
More info¶
What it owns¶
A buffer sized to the logical box, a MappingLUT onto physical positions, and two child lists.
Compositing happens elsewhere¶
blendMode and opacity are inert here: a layer cannot know its place in the stack. Drivers reads both, plus the child order, and composites.
The buffer persists¶
Nothing clears it per frame, which is what makes trails possible.
Two paths¶
The cold path folds the box through the static modifiers, then builds the table. The hot path runs each effect, extrudes, then applies the live modifiers.
Details: the supporting page.