/* Cell — базовый абстрактный класс ячейки композитора (Phase 11b). * * Cell — это прямоугольная область output frame, рисуемая в свою geom_. * Реализации (CameraCell, WidgetCell, BlankCell) определяют content-рендер; * декорации (Label, Border) добавляются композицией через add_decoration(). * * Lifecycle: * 1. Layout::apply_template() создаёт нужные Cell-подклассы. * 2. На каждом compose: cell.draw(stream, dst) рисует свой контент * + все decorations. * 3. Layout уничтожает cells при apply нового template'а. * * Лицензия: LGPL-2.1+ */ #ifndef CUFRAMES_COMPOSER_CPP_CELL_HPP #define CUFRAMES_COMPOSER_CPP_CELL_HPP #include "decoration.hpp" #include "types.hpp" #include #include namespace cfc { class Cell { public: explicit Cell(const Rect& geom) : geom_(geom) {} virtual ~Cell() = default; Cell(const Cell&) = delete; Cell& operator=(const Cell&) = delete; /* Геометрия cell в pixel-координатах output frame. */ const Rect& geometry() const noexcept { return geom_; } void set_geometry(const Rect& r) noexcept { geom_ = r; } /* Добавить decoration (cell takes ownership). */ void add_decoration(std::unique_ptr d) { decorations_.push_back(std::move(d)); } /* Основной hook: рисует content + все decorations. Реализации обычно * переопределяют только draw_content(), а draw_decorations() общий. */ void draw(CUstream stream, NV12Ref& dst) { if (geom_.empty()) return; draw_content(stream, dst); for (auto& dec : decorations_) { dec->draw(stream, dst, geom_); } } protected: /* Реализуется подклассом. */ virtual void draw_content(CUstream stream, NV12Ref& dst) = 0; Rect geom_; std::vector> decorations_; }; } // namespace cfc #endif /* CUFRAMES_COMPOSER_CPP_CELL_HPP */