删减文件
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
#include "Renderable.h"
|
||||
|
||||
#include "../plot/Plot_Core.h"
|
||||
#include "../render/Blend2D_Cache.h"
|
||||
|
||||
#include <renderive/scene/base/Scene_Render_Context.hpp>
|
||||
|
||||
namespace renderive {
|
||||
|
||||
Renderable::Renderable(Plot_Core& plot, bool cache_enabled)
|
||||
: ::Renderable_Base(plot.kernel_scene(), {.cache_enabled = cache_enabled}), plot_(plot) {}
|
||||
|
||||
Renderable::~Renderable() = default;
|
||||
|
||||
Renderable_Cache_Mode Renderable::get_cache_mode() const noexcept {
|
||||
return configuration().cache_enabled
|
||||
? Renderable_Cache_Mode::Local_Pixel
|
||||
: Renderable_Cache_Mode::Direct;
|
||||
}
|
||||
|
||||
void Renderable::set_cache_mode(Renderable_Cache_Mode mode) {
|
||||
plot_.set_renderable_cache(*this, mode);
|
||||
}
|
||||
|
||||
std::string Renderable::object_name() const {
|
||||
std::lock_guard lock(metadata_mutex_);
|
||||
return object_name_;
|
||||
}
|
||||
|
||||
void Renderable::set_object_name(std::string name) {
|
||||
std::lock_guard lock(metadata_mutex_);
|
||||
object_name_ = std::move(name);
|
||||
}
|
||||
|
||||
bool Renderable::is_visible() const noexcept {
|
||||
return visible_.load(std::memory_order_acquire);
|
||||
}
|
||||
|
||||
void Renderable::set_visible(bool visible) {
|
||||
if (visible_.exchange(visible, std::memory_order_acq_rel) != visible)
|
||||
changed();
|
||||
}
|
||||
|
||||
void Renderable::render(const ::Scene_Render_Context& context) {
|
||||
if (!is_visible() || context.color_cache == nullptr)
|
||||
return;
|
||||
auto* cache = dynamic_cast<detail::Blend2D_Color_Cache*>(context.color_cache);
|
||||
if (!cache)
|
||||
return;
|
||||
detail::Painter painter(*cache, viewport_size());
|
||||
if (painter)
|
||||
paint(painter);
|
||||
}
|
||||
|
||||
void Renderable::changed() noexcept {
|
||||
invalidate_cache();
|
||||
plot_.notify_model_dirty();
|
||||
}
|
||||
|
||||
Size Renderable::viewport_size() const noexcept {
|
||||
return plot_.viewport_size();
|
||||
}
|
||||
|
||||
} // namespace renderive
|
||||
Reference in New Issue
Block a user