| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * This file is part of the Falcon Player (FPP) and is Copyright (C) | ||
| 4 | * 2013-2022 by the Falcon Player Developers. | ||
| 5 | * | ||
| 6 | * The Falcon Player (FPP) is free software, and is covered under | ||
| 7 | * multiple Open Source licenses. Please see the included 'LICENSES' | ||
| 8 | * file for descriptions of what files are covered by each license. | ||
| 9 | * | ||
| 10 | * This source file is covered under the LGPL v2.1 as described in the | ||
| 11 | * included LICENSE.LGPL file. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include <memory> | ||
| 15 | #include <mutex> | ||
| 16 | #include <vector> | ||
| 17 | |||
| 18 | #include "PixelOverlayModel.h" | ||
| 19 | #include "fpp-json-fwd.h" | ||
| 20 | |||
| 21 | class PixelOverlayModelSub : public PixelOverlayModel { | ||
| 22 | public: | ||
| 23 | PixelOverlayModelSub(const Json::Value& config); | ||
| 24 | virtual ~PixelOverlayModelSub(); | ||
| 25 | |||
| 26 | virtual void doOverlay(uint8_t* channels) override; | ||
| 27 | virtual void setData(const uint8_t* data) override; | ||
| 28 | |||
| 29 | virtual void setState(const PixelOverlayState& st) override; | ||
| 30 | |||
| 31 | void resetParent(); | ||
| 32 | std::string getParentName() const; | ||
| 33 | // For getPolarMap(): a rectangle submodel needs its parent to place its | ||
| 34 | // cells. Not from the channel output thread, as foundParent(). | ||
| 35 |
3/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
4 | bool readyForPolarJoin() { return gridMode || foundParent(); } |
| 36 | |||
| 37 | protected: | ||
| 38 | // Grid submodels and groups SCATTER: a buffer cell lands on an arbitrary | ||
| 39 | // parent/member channel rather than at a fixed offset from a start channel, | ||
| 40 | // so the base class's contiguous assumption does not hold. Both scatter | ||
| 41 | // tables are indexed by channelData slot, which is what this receives. | ||
| 42 | uint32_t outputChannelForData(uint32_t dataOffset) const override; | ||
| 43 | |||
| 44 | private: | ||
| 45 | bool foundParent(); | ||
| 46 | |||
| 47 | // `parent` is the raw pointer doOverlay() uses on the output thread (made | ||
| 48 | // safe there by the active list, see resetParent()); `parentRef` owns a | ||
| 49 | // share of the same model, so setState() can call into the parent from | ||
| 50 | // any thread without modelsLock. Both are set and cleared together under | ||
| 51 | // parentLock (a leaf lock), always with modelsLock held as well. | ||
| 52 | PixelOverlayModel* parent = nullptr; | ||
| 53 | std::weak_ptr<PixelOverlayModel> parentRef; | ||
| 54 | std::mutex parentLock; | ||
| 55 | |||
| 56 | int xOffset = 0; | ||
| 57 | int yOffset = 0; | ||
| 58 | |||
| 59 | // Grid-mode (xLights submodel) support. When set, the submodel is a sparse | ||
| 60 | // subset of its parent's nodes defined by a grid of parent node numbers. | ||
| 61 | // The base class builds a dense width*height buffer + channelData; outputMap | ||
| 62 | // scatters each buffer cell's color to the parent's absolute output channel. | ||
| 63 | // See docs/PixelOverlaySubModels.md. | ||
| 64 | bool gridMode = false; | ||
| 65 | std::vector<uint32_t> outputMap; // one entry per buffer cell -> absolute output channel base (or FPPD_OFF_CHANNEL) | ||
| 66 | |||
| 67 | // Channel-grid mode (xLights model groups): a combined buffer whose cells | ||
| 68 | // each map to one OR MORE absolute output channels (member pixels binned by | ||
| 69 | // world position). See docs/PixelOverlaySubModels.md. | ||
| 70 | bool channelGridMode = false; | ||
| 71 | std::vector<std::vector<uint32_t>> outputCells; // per buffer cell -> list of absolute output channel bases | ||
| 72 | |||
| 73 | void buildGrid(); | ||
| 74 | void buildChannelGrid(); | ||
| 75 | void doGridOverlay(uint8_t* channels); | ||
| 76 | }; | ||
| 77 |