#pragma once #include "../Frame_Flow.h" #include "../Render_Ticket.h" #include #include #include namespace renderive { class Explicit_Frame_Flow final : public Frame_Flow { public: Explicit_Frame_Flow(); [[nodiscard]] Render_Ticket request_render(); void attach(Frame_Flow_Host& host) override; [[nodiscard]] std::unique_ptr create_renderable_runtime(Renderable& owner) const override; [[nodiscard]] Frame_Flow_Runtime_Snapshot runtime_snapshot(std::uint64_t now_ns, bool destroying) const override; void advance_edit_version() override; void cancel_all_update_states() override; [[nodiscard]] Render_Frame_Surface begin_render_frame() override; void cancel_render_frame(Render_Frame_Surface&& surface) override; void discard_render_frame(Render_Frame_Surface&& surface) override; [[nodiscard]] Render_Surface_Publish_Result publish_rendered_frame(Render_Frame_Surface&& surface, std::uint64_t now_ns) override; [[nodiscard]] Render_Surface_Publish_Result request_present(std::uint64_t now_ns) override; [[nodiscard]] Present_Surface_Lease begin_present(std::uint64_t now_ns, std::shared_ptr& returned_frame_record) override; [[nodiscard]] std::shared_ptr end_present(Present_Surface_Lease&& surface, std::uint64_t paint_begin_ns, std::uint64_t paint_end_ns) override; void activate_view(std::uint64_t now_ns) override; void deactivate_view() override; [[nodiscard]] bool view_active() const override; void notify_model_dirty(std::uint64_t now_ns) { notify_model_dirty(Dirty_Reason::Core_Data, now_ns); } void notify_model_dirty(Dirty_Reason reason, std::uint64_t now_ns) override; void notify_viewport_changed(Size viewport, std::uint64_t now_ns) override; void notify_render_finished(Frame_Lifecycle_Record& frame, std::uint64_t now_ns) override; void notify_paint_finished(std::uint64_t now_ns) override; void notify_frame_returned(Frame_Lifecycle_Record& frame, std::uint64_t now_ns) override; void notify_timer_fired(std::uint64_t now_ns) override; void drain_frame_update_states(std::pmr::vector>& output) override; [[nodiscard]] Explicit_Diagnostics explicit_diagnostics() const; [[nodiscard]] Flow_Diagnostics diagnostics() const override; void shutdown() override; private: void evaluate(std::uint64_t now_ns); Frame_Flow_Host* host{}; std::atomic_bool view_active_state{false}; std::atomic_bool manual_request_pending{false}; std::atomic_bool render_job_active{false}; std::atomic_bool frame_ready{false}; std::atomic_bool paint_request_pending{false}; mutable std::mutex request_mutex; mutable std::mutex surface_mutex; std::pmr::vector> pending_requests; std::shared_ptr present_surface; std::atomic edit_version{1}; std::uint64_t next_present_request_id{}; }; } // namespace renderive