Write DataVariant bytes into the pixel buffer at the region bounds.
The region's SPATIAL_Y / SPATIAL_X coordinates are used as the destination rectangle. The first DataVariant in data must hold std::vector<uint8_t> with exactly region_width * region_height * channels bytes.
519{
520 if (data.empty())
521 return;
522 if (region.start_coordinates.size() < 2 || region.end_coordinates.size() < 2)
523 return;
524
525 const uint64_t y0 = region.start_coordinates[0];
526 const uint64_t x0 = region.start_coordinates[1];
527 const uint64_t y1 = std::min(region.end_coordinates[0],
static_cast<uint64_t
>(
m_height - 1));
528 const uint64_t x1 = std::min(region.end_coordinates[1],
static_cast<uint64_t
>(
m_width - 1));
529
531
532 std::visit(
533 [&](auto& dst_vec) {
534 using T =
typename std::decay_t<
decltype(dst_vec)>::value_type;
535 if constexpr (std::is_same_v<T, uint8_t>
536 || std::is_same_v<T, uint16_t>
537 || std::is_same_v<T, float>) {
538 const auto* src = std::get_if<std::vector<T>>(&data[0]);
539 if (!src || src->empty()) {
541 "TextureContainer::set_region_data source variant does not match "
542 "container element type");
543 return;
544 }
545
546 size_t src_idx = 0;
547 for (uint64_t y = y0; y <= y1 && src_idx < src->size(); ++y) {
548 for (uint64_t x = x0; x <= x1 && src_idx < src->size(); ++x) {
550 for (uint32_t c = 0; c <
m_channels && src_idx < src->size(); ++c, ++src_idx) {
551 if (dst_idx + c < dst_vec.size())
552 dst_vec[dst_idx + c] = (*src)[src_idx];
553 }
554 }
555 }
556 }
557 },
559
561}
#define MF_ERROR(comp, ctx,...)
void lock() override
Acquire a lock for thread-safe access.
std::vector< DataVariant > m_processed_data
std::shared_mutex m_data_mutex
std::vector< DataVariant > m_data
@ ContainerProcessing
Container operations (Kakshya - file/stream/region processing)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.