MCPcopy Create free account
hub / github.com/FastLED/FastLED / writeWithPadding

Method writeWithPadding

src/fl/channels/data.cpp.hpp:62–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60{}
61
62void ChannelData::writeWithPadding(fl::span<u8> dst) FL_NOEXCEPT {
63 size_t targetSize = dst.size();
64 size_t currentSize = mEncodedData.size();
65
66 // Destination must be at least as large as current data
67 if (targetSize < currentSize) {
68 return; // or throw? For now, silently fail
69 }
70
71 // Create source span from encoded data
72 fl::span<const u8> src(mEncodedData.data(), currentSize);
73
74 if (mPaddingGenerator) {
75 // Use custom padding generator (writes directly to dst)
76 mPaddingGenerator(src, dst);
77 } else {
78 // Default behavior: left-pad with zeros, then memcopy data
79 // Padding bytes go out first to non-existent pixels
80 size_t paddingSize = targetSize - currentSize;
81 if (paddingSize > 0) {
82 fl::fill(dst.begin(), dst.begin() + paddingSize, u8(0));
83 }
84 fl::memcopy(dst.data() + paddingSize, src.data(), currentSize);
85 }
86}
87
88ChannelData::~ChannelData() FL_NOEXCEPT = default;
89

Callers 2

FL_TEST_FILEFunction · 0.80

Calls 5

fillFunction · 0.85
memcopyFunction · 0.85
sizeMethod · 0.45
dataMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected