| 48 | } |
| 49 | |
| 50 | bool RectangularDrawBuffer::onQueuingDone() { |
| 51 | if (mQueueState == QUEUE_DONE) { |
| 52 | return false; |
| 53 | } |
| 54 | mQueueState = QUEUE_DONE; |
| 55 | mDrawListChangedThisFrame = mDrawList != mPrevDrawList; |
| 56 | // iterator through the current draw objects and calculate the total |
| 57 | // number of bytes (representing RGB or RGBW) that will be drawn this frame. |
| 58 | u32 total_bytes = 0; |
| 59 | u32 max_bytes_in_strip = 0; |
| 60 | u32 num_strips = 0; |
| 61 | getBlockInfo(&num_strips, &max_bytes_in_strip, &total_bytes); |
| 62 | if (total_bytes > mAllLedsBufferUint8Size) { |
| 63 | u8 *old_ptr = mAllLedsBufferUint8.release(); |
| 64 | fl::PSRamAllocator<u8>::Free(old_ptr); |
| 65 | u8 *ptr = fl::PSRamAllocator<u8>::Alloc(total_bytes); |
| 66 | mAllLedsBufferUint8.reset(ptr); |
| 67 | } |
| 68 | mAllLedsBufferUint8Size = total_bytes; |
| 69 | u32 offset = 0; |
| 70 | for (auto it = mDrawList.begin(); it != mDrawList.end(); ++it) { |
| 71 | u8 pin = it->mPin; |
| 72 | span<u8> slice(mAllLedsBufferUint8.get() + offset, |
| 73 | max_bytes_in_strip); |
| 74 | mPinToLedSegment[pin] = slice; |
| 75 | offset += max_bytes_in_strip; |
| 76 | } |
| 77 | return true; |
| 78 | } |
| 79 | |
| 80 | u32 RectangularDrawBuffer::getMaxBytesInStrip() const { |
| 81 | u32 max_bytes = 0; |