18 void bind(DrawingRuntime& runtime) {
19 const auto generation = runtime.status().generation;
20 if (runtime_ != &runtime || lifetime_.expired() || generation_ != generation) {
23 lifetime_ = runtime.lifetime();
24 generation_ = generation;
28 bool enqueue(
const DrawingHandle& handle) {
29 if (!synchronize() || !runtime_->validQueued(handle))
31 for (std::size_t i = 0; i < count_; ++i) {
32 const auto& entry = handles_[i];
33 if (entry.kind == handle.kind && entry.slot == handle.slot &&
34 entry.slotGeneration == handle.slotGeneration &&
35 entry.runtimeGeneration == handle.runtimeGeneration)
39 runtime_->releaseQueued(handle);
40 runtime_->reject(
"performance_queue_full");
43 handles_[count_++] = handle;
52 return DrawingResult::Stale;
58 if (runtime_ && !lifetime_.expired()) {
59 for (std::size_t i = 0; i < count_; ++i)
60 runtime_->releaseQueued(handles_[i]);
68 std::size_t
size()
const {
return count_; }
71 DrawingResult drain() {
72 DrawingResult result = DrawingResult::NoChange;
74 result = runtime_->applyQueued(handles_[0]);
75 if (result == DrawingResult::Busy) {
79 if (result != DrawingResult::Applied && result != DrawingResult::NoChange)
80 runtime_->releaseQueued(handles_[0]);
81 for (std::size_t i = 1; i < count_; ++i)
82 handles_[i - 1] = handles_[i];
89 if (!runtime_ || lifetime_.expired()) {
93 if (runtime_->status().generation != generation_) {
99 for (std::size_t i = 0; i < count_; ++i) {
100 if (runtime_->validQueued(handles_[i]))
101 handles_[live++] = handles_[i];
108 DrawingRuntime* runtime_ =
nullptr;
109 DrawingRuntime::Lifetime lifetime_;
110 std::array<char, 17> generation_{};
111 std::array<DrawingHandle, capacity> handles_{};
112 std::size_t count_ = 0;
113 bool blocked_ =
false;