策略抽离
This commit is contained in:
@@ -10,10 +10,10 @@ struct Explicit_Render_Surface_Handle final : Render_Frame_Surface_Handle {
|
||||
std::shared_ptr<Render_Output> output;
|
||||
};
|
||||
|
||||
struct Explicit_Present_Surface_Handle final : Present_Surface_Handle {
|
||||
struct Explicit_Present_Surface_Handle final {
|
||||
explicit Explicit_Present_Surface_Handle(std::shared_ptr<Render_Output> output) : output_value(std::move(output)) {}
|
||||
|
||||
[[nodiscard]] Render_Output* output() const override {
|
||||
[[nodiscard]] Render_Output* output() const {
|
||||
return output_value.get();
|
||||
}
|
||||
|
||||
@@ -110,15 +110,15 @@ Render_Surface_Publish_Result Explicit_Frame_Flow::publish_rendered_frame(Render
|
||||
result.update_request_id = handle->output->metadata->update_request_id;
|
||||
result.update_request_time = now_ns;
|
||||
}
|
||||
std::shared_ptr<Render_Output> output = std::move(handle->output);
|
||||
Size size = output ? output->image.size() : Size{};
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(surface_mutex);
|
||||
present_surface = std::move(handle->output);
|
||||
present_surface = output;
|
||||
}
|
||||
rendered_version = surface.input_version;
|
||||
frame_ready.store(true, std::memory_order_release);
|
||||
paint_request_pending.store(true, std::memory_order_release);
|
||||
render_job_active.store(false, std::memory_order_release);
|
||||
Size size = present_surface ? present_surface->image.size() : Size{};
|
||||
result.dirty_rect = Rect{0, 0, size.width, size.height};
|
||||
result.request_present = true;
|
||||
return result;
|
||||
@@ -161,10 +161,10 @@ Present_Surface_Lease Explicit_Frame_Flow::begin_present(std::uint64_t now_ns, s
|
||||
output->metadata->transition_23_ns = now_ns;
|
||||
output->metadata->present_queue_wait_ns = now_ns > output->metadata->transition_12_ns ? now_ns - output->metadata->transition_12_ns : 0;
|
||||
}
|
||||
return Present_Surface_Lease_Access::from_handle(
|
||||
std::make_unique<Explicit_Present_Surface_Handle>(std::move(output)),
|
||||
return Present_Surface_Lease_Access::from_handle<Explicit_Present_Surface_Handle>(
|
||||
is_new,
|
||||
pending);
|
||||
pending,
|
||||
std::move(output));
|
||||
}
|
||||
|
||||
std::shared_ptr<Frame_Lifecycle_Record> Explicit_Frame_Flow::end_present(Present_Surface_Lease&& surface, std::uint64_t paint_begin_ns, std::uint64_t paint_end_ns) {
|
||||
@@ -185,16 +185,16 @@ std::shared_ptr<Frame_Lifecycle_Record> Explicit_Frame_Flow::end_present(Present
|
||||
}
|
||||
|
||||
void Explicit_Frame_Flow::activate_view(std::uint64_t now_ns) {
|
||||
active.store(true, std::memory_order_release);
|
||||
view_active_state.store(true, std::memory_order_release);
|
||||
evaluate(now_ns);
|
||||
}
|
||||
|
||||
void Explicit_Frame_Flow::deactivate_view() {
|
||||
active.store(false, std::memory_order_release);
|
||||
view_active_state.store(false, std::memory_order_release);
|
||||
}
|
||||
|
||||
bool Explicit_Frame_Flow::view_active() const {
|
||||
return active.load(std::memory_order_acquire);
|
||||
return view_active_state.load(std::memory_order_acquire);
|
||||
}
|
||||
|
||||
void Explicit_Frame_Flow::notify_model_dirty(std::uint64_t now_ns) {
|
||||
@@ -232,7 +232,7 @@ void Explicit_Frame_Flow::drain_frame_update_states(std::pmr::vector<std::shared
|
||||
Explicit_Diagnostics Explicit_Frame_Flow::explicit_diagnostics() const {
|
||||
std::lock_guard<std::mutex> lock(request_mutex);
|
||||
return Explicit_Diagnostics{
|
||||
active.load(std::memory_order_acquire),
|
||||
view_active_state.load(std::memory_order_acquire),
|
||||
static_cast<std::uint64_t>(pending_requests.size())
|
||||
};
|
||||
}
|
||||
@@ -248,7 +248,7 @@ Flow_Diagnostics Explicit_Frame_Flow::diagnostics() const {
|
||||
void Explicit_Frame_Flow::shutdown() {
|
||||
host = nullptr;
|
||||
cancel_all_update_states();
|
||||
active.store(false, std::memory_order_release);
|
||||
view_active_state.store(false, std::memory_order_release);
|
||||
manual_request_pending.store(false, std::memory_order_release);
|
||||
render_job_active.store(false, std::memory_order_release);
|
||||
frame_ready.store(false, std::memory_order_release);
|
||||
|
||||
Reference in New Issue
Block a user