所有权添加完成
This commit is contained in:
@@ -14,7 +14,7 @@ void advance_revision(std::atomic<std::uint64_t>& revision) noexcept {
|
||||
}
|
||||
}
|
||||
Renderable_Base::Renderable_Base(Scene_Base& scene, Renderable_Configuration configuration)
|
||||
: memory_domain_(scene.memory_domain_), real_time_data_state_(std::allocate_shared<Real_Time_Data_State>(Scene_Memory_Allocator<Real_Time_Data_State>{memory_domain_}, scene.scene_lifetime_)), discard_stale_frame_on_latest_data_update(real_time_data_state_->discard_stale_frame_on_latest_data_update), layer_node_(this, memory_domain_->resource()), dependency_node_(this, memory_domain_->resource()), renderable_id_(scene.allocate_renderable_id()), composite_node_id_(scene.allocate_node_id()), configuration_(configuration) {}
|
||||
: memory_domain_(scene.memory_domain_), real_time_data_state_(std::allocate_shared<Real_Time_Data_State>(Scene_Memory_Allocator<Real_Time_Data_State>{memory_domain_}, scene.scene_lifetime_)), discard_stale_frame_on_latest_data_update(real_time_data_state_->discard_stale_frame_on_latest_data_update), renderable_id_(scene.allocate_renderable_id()), composite_node_id_(scene.allocate_node_id()), configuration_(configuration) {}
|
||||
Renderable_Base::~Renderable_Base() {
|
||||
real_time_data_state_->renderable_alive.store(false, std::memory_order_release);
|
||||
}
|
||||
@@ -51,13 +51,13 @@ bool Renderable_Base::paint_cache_valid() const noexcept {
|
||||
void Renderable_Base::rebuild_render_graph() noexcept {
|
||||
{
|
||||
std::lock_guard lock(render_graph_mutex_);
|
||||
render_graph_dirty_ = true;
|
||||
render_graph_.reset();
|
||||
}
|
||||
invalidate_prepare();
|
||||
}
|
||||
std::shared_ptr<const Renderable_Graph> Renderable_Base::render_graph() {
|
||||
std::lock_guard lock(render_graph_mutex_);
|
||||
if (render_graph_dirty_) {
|
||||
if (!render_graph_) {
|
||||
std::unordered_map<std::string, Render_Node_Id> next_identities;
|
||||
Renderable_Graph_Builder builder(renderable_id_, [this, &next_identities](
|
||||
std::string_view key) {
|
||||
@@ -76,11 +76,10 @@ std::shared_ptr<const Renderable_Graph> Renderable_Base::render_graph() {
|
||||
auto graph = std::make_shared<Renderable_Graph>(std::move(builder).finish());
|
||||
node_identities_ = std::move(next_identities);
|
||||
render_graph_ = std::move(graph);
|
||||
render_graph_dirty_ = false;
|
||||
}
|
||||
return render_graph_;
|
||||
}
|
||||
std::uint64_t Renderable_Base::renderable_id() const noexcept {
|
||||
Renderable_Id Renderable_Base::renderable_id() const noexcept {
|
||||
return renderable_id_;
|
||||
}
|
||||
std::pmr::memory_resource& Renderable_Base::memory_resource() const noexcept {
|
||||
@@ -97,26 +96,34 @@ Renderable_Configuration Renderable_Base::configuration() const noexcept {
|
||||
std::lock_guard lock(configuration_mutex_);
|
||||
return configuration_;
|
||||
}
|
||||
bool Renderable_Base::is_visible() const noexcept {
|
||||
std::lock_guard lock(configuration_mutex_);
|
||||
return visible_;
|
||||
}
|
||||
void Renderable_Base::set_visible(bool visible) {
|
||||
{
|
||||
std::lock_guard lock(configuration_mutex_);
|
||||
if (visible_ == visible)
|
||||
return;
|
||||
visible_ = visible;
|
||||
invalidate_prepare();
|
||||
}
|
||||
scene().notify_model_dirty();
|
||||
}
|
||||
void Renderable_Base::build_prepare_graph(Renderable_Graph_Builder& builder) {
|
||||
builder.emplace("prepare", "Prepare", Render_Node_Kind::prepare,
|
||||
[this](const Scene_Render_Context& context) {
|
||||
builder.emplace("prepare", "Prepare",
|
||||
[this](const Prepare_Render_Context& context) {
|
||||
prepare(context);
|
||||
});
|
||||
}
|
||||
void Renderable_Base::build_paint_graph(Renderable_Graph_Builder&) {}
|
||||
void Renderable_Base::prepare(const Scene_Render_Context&) {}
|
||||
void Renderable_Base::prepare(const Prepare_Render_Context&) {}
|
||||
Render_State_View Renderable_Base::render_state_view() noexcept {
|
||||
return {};
|
||||
}
|
||||
Real_Time_Data_Binding Renderable_Base::bind_real_time_data(Real_Time_Data_Base& data) {
|
||||
return data.bind_renderable(*this);
|
||||
}
|
||||
bool Renderable_Base::requires_prepare() const noexcept {
|
||||
return !prepare_cache_valid();
|
||||
}
|
||||
bool Renderable_Base::requires_paint() const noexcept {
|
||||
return !paint_cache_valid();
|
||||
}
|
||||
void Renderable_Base::mark_prepared(std::uint64_t revision) noexcept {
|
||||
prepared_revision_.store(revision, std::memory_order_release);
|
||||
}
|
||||
@@ -125,10 +132,6 @@ void Renderable_Base::mark_painted(std::uint64_t paint_revision,
|
||||
painted_prepare_revision_.store(prepare_revision, std::memory_order_release);
|
||||
painted_revision_.store(paint_revision, std::memory_order_release);
|
||||
}
|
||||
void Renderable_Base::set_configuration(Renderable_Configuration configuration) noexcept {
|
||||
std::lock_guard lock(configuration_mutex_);
|
||||
configuration_ = configuration;
|
||||
}
|
||||
void Renderable_Base::register_real_time_data(Real_Time_Data_Base& data) {
|
||||
std::lock_guard lock(real_time_data_mutex_);
|
||||
if (std::find(real_time_data_.begin(), real_time_data_.end(), &data) == real_time_data_.end()) {
|
||||
|
||||
Reference in New Issue
Block a user