25 #include "lv_common.h"
26 #include "lv_plugin_registry.h"
36 VisPluginData* plugin;
47 VisMorphPlugin* get_morph_plugin ()
const;
67 VisMorphPlugin* Morph::Impl::get_morph_plugin ()
const
74 return m_impl->plugin;
80 return {
new Morph {name},
false};
82 catch (std::exception& error)
89 Morph::Morph (std::string
const& name)
94 throw std::runtime_error {
"Morph plugin not found"};
98 if (!m_impl->plugin) {
99 throw std::runtime_error {
"Failed to load morph plugin"};
117 return m_impl->get_morph_plugin ()->vidoptions.depth;
120 VisVideoAttrOptions
const* Morph::get_video_attribute_options ()
122 return &m_impl->get_morph_plugin ()->vidoptions;
127 m_impl->dest = video;
132 m_impl->morphtime = time;
137 m_impl->progress = std::min (std::max (progress, 0.0f), 1.0f);
143 return m_impl->morphpal;
148 if (m_impl->progress >= 1.0) {
149 m_impl->timer.stop ();
158 visual_return_val_if_fail (src1, FALSE);
159 visual_return_val_if_fail (src2, FALSE);
161 auto morph_plugin = m_impl->get_morph_plugin ();
164 if (!m_impl->timer.is_active ()) {
165 m_impl->timer.start ();
168 if (morph_plugin->palette) {
169 morph_plugin->palette (m_impl->plugin, m_impl->progress, const_cast<Audio*> (&audio), m_impl->morphpal, src1.
get (), src2.
get ());
176 m_impl->morphpal->blend (src1_pal, src2_pal, m_impl->progress);
180 morph_plugin->apply (m_impl->plugin, m_impl->progress, const_cast<Audio*> (&audio), m_impl->dest.get (), src1.
get (), src2.
get ());
186 double usec_elapsed = m_impl->timer.elapsed ().to_usecs ();
187 double usec_morph = m_impl->morphtime.to_usecs ();
189 m_impl->progress = std::min (std::max (usec_elapsed / usec_morph, 0.0), 1.0);