chrono_batch_render/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
20 / 20
100.0%
Branches:
6 / 6
100.0%
Functions:
3 / 3
100.0%

scene/tables/regions.cpp
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2 #include "chrono_batch_render/scene/tables/regions.h"
3
4 #include <algorithm>
5
6 #include "chrono_batch_render/stage/schema/ids.h"
7
8 namespace chrono::batch_render {
9
10 namespace {
11
12 861 uint32_t Room(uint32_t count) {
13
2/2
✓ Branch 0 taken 851 times.
✓ Branch 1 taken 10 times.
861 return std::max(count + count / 2, count + 8);
14 }
15
16 }
17
18 642 void Regions::Assign(std::vector<std::vector<uint32_t>> lists) {
19 642 m_items.clear();
20 642 m_starts = {0};
21 642 m_counts.clear();
22
2/2
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 642 times.
1503 for (const std::vector<uint32_t>& list : lists) {
23 861 const uint32_t room = Room(uint32_t(list.size()));
24 861 m_items.insert(m_items.end(), list.begin(), list.end());
25 861 m_items.resize(m_items.size() + room - list.size(), kNoRow);
26 861 m_starts.push_back(uint32_t(m_items.size()));
27 861 m_counts.push_back(uint32_t(list.size()));
28 }
29 642 }
30
31 285 bool Regions::Replace(uint32_t region, std::span<const uint32_t> items) {
32
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 6 times.
285 if (items.size() > Capacity(region)) {
33 return false;
34 }
35 279 const auto start = m_items.begin() + m_starts[region];
36 279 std::copy(items.begin(), items.end(), start);
37 279 std::fill(start + ptrdiff_t(items.size()), m_items.begin() + m_starts[region + 1], kNoRow);
38 279 m_counts[region] = uint32_t(items.size());
39 279 return true;
40 }
41
42 }
43