26 #include "lv_common.h"
38 VideoPtr actmorphvideo;
48 VisBinDepth depthpreferred;
63 void set_actor (ActorPtr
const& actor);
64 void set_input (InputPtr
const& input);
71 switch (depthpreferred) {
72 case VISUAL_BIN_DEPTH_LOWEST:
76 case VISUAL_BIN_DEPTH_HIGHEST:
82 if (depthflag & depth)
94 , depthpreferred (VISUAL_BIN_DEPTH_HIGHEST)
98 , depthchanged (false)
111 void Bin::Impl::set_actor (ActorPtr
const& new_actor)
116 void Bin::Impl::set_input (InputPtr
const& new_input)
135 m_impl->actor->realize ();
138 m_impl->input->realize ();
141 m_impl->morph->realize ();
144 ActorPtr
const& Bin::get_actor ()
const
146 return m_impl->actor;
149 InputPtr
const& Bin::get_input ()
const
151 return m_impl->input;
154 void Bin::set_morph (std::string
const& morph_name)
157 visual_return_if_fail (m_impl->morph);
159 VisVideoDepth depthflag = m_impl->morph->get_supported_depths ();
162 m_impl->morph.reset ();
167 MorphPtr
const& Bin::get_morph ()
const
169 return m_impl->morph;
172 bool Bin::connect (ActorPtr
const& actor, InputPtr
const& input)
174 visual_return_val_if_fail (actor,
false);
175 visual_return_val_if_fail (input,
false);
177 m_impl->set_actor (actor);
178 m_impl->set_input (input);
180 auto depthflag = actor->get_supported_depths ();
185 set_depth (m_impl->get_suitable_depth (depthflag));
188 m_impl->depthforcedmain = m_impl->depth;
193 bool Bin::connect (std::string
const& actor_name, std::string
const& input_name)
197 visual_return_val_if_fail (actor,
false);
201 visual_return_val_if_fail (input,
false);
204 if (!connect (actor, input)) {
211 void Bin::sync (
bool noevent)
218 if (m_impl->morphing && m_impl->use_morph &&
221 m_impl->morph->set_video (m_impl->actvideo);
223 video = m_impl->privvid;
229 video->free_buffer ();
230 video->copy_attrs (m_impl->actvideo);
233 m_impl->actvideo->get_pitch (), video->get_pitch ());
237 video = m_impl->actvideo;
239 video->allocate_buffer ();
243 video = m_impl->actvideo;
250 video->get_depth (), video->get_bpp ());
255 m_impl->actor->set_video (video);
258 video->get_pitch (), m_impl->depthold,
259 m_impl->depthforcedmain, noevent);
262 m_impl->actor->video_negotiate (m_impl->depthforcedmain,
false,
true);
265 m_impl->actor->video_negotiate (m_impl->depthforcedmain, noevent,
true);
272 if (m_impl->morphing && m_impl->use_morph) {
274 auto actvideo = m_impl->actmorphvideo;
280 actvideo->free_buffer ();
282 actvideo->copy_attrs (video);
285 actvideo->allocate_buffer ();
287 m_impl->actmorph->realize ();
290 m_impl->actvideo->get_pitch ());
292 m_impl->actmorph->video_negotiate (m_impl->depthforced,
false,
true);
298 void Bin::set_video (VideoPtr
const& video)
300 m_impl->actvideo = video;
305 m_impl->depthflag = depthflag;
310 return m_impl->depthflag;
313 void Bin::set_preferred_depth (VisBinDepth depthpreferred)
315 m_impl->depthpreferred = depthpreferred;
320 m_impl->depthold = m_impl->depth;
327 if (m_impl->depth != depth)
328 m_impl->depthchanged =
true;
331 m_impl->depthfromGL =
true;
333 m_impl->depthfromGL =
false;
335 m_impl->depth = depth;
337 if (m_impl->actvideo) {
338 m_impl->actvideo->set_depth (depth);
344 return m_impl->depth;
347 bool Bin::depth_changed ()
349 if (!m_impl->depthchanged)
352 m_impl->depthchanged =
false;
357 Palette
const& Bin::get_palette ()
const
359 if (m_impl->morphing)
360 return *m_impl->morph->get_palette ();
362 return *m_impl->actor->get_palette ();
365 void Bin::switch_actor (std::string
const& actor_name)
370 if (m_impl->actmorph) {
371 m_impl->actmorph.reset ();
372 m_impl->actmorphvideo.reset ();
377 visual_return_if_fail (actor);
380 video->copy_attrs(m_impl->actvideo);
382 auto depthflag = actor->get_supported_depths ();
390 m_impl->depthforced = depth;
391 m_impl->depthforcedmain = depth;
393 video->set_depth(depth);
397 m_impl->depthchanged =
true;
402 depth = m_impl->get_suitable_depth (depthflag);
403 video->set_depth(depth);
414 m_impl->depthforcedmain, m_impl->actvideo->get_depth ());
417 if (m_impl->depthforcedmain != m_impl->actvideo->get_depth ()) {
418 m_impl->actor->video_negotiate (m_impl->depthforcedmain,
true,
true);
422 if (m_impl->actvideo->get_depth () > video->get_depth ()
424 && m_impl->use_morph) {
427 video->get_depth (), m_impl->depth);
429 m_impl->depthforced = depth;;
430 m_impl->depthforcedmain = m_impl->depth;
432 set_depth (m_impl->actvideo->get_depth ());
433 video->set_depth (m_impl->actvideo->get_depth ());
438 video->get_depth (), depth, m_impl->depth);
441 m_impl->actvideo->get_depth (), m_impl->depth, m_impl->depthold);
443 m_impl->depthforced = video->get_depth ();
444 m_impl->depthforcedmain = m_impl->depth;
448 set_depth (video->get_depth ());
453 m_impl->depthforced = video->get_depth ();
454 m_impl->depthforcedmain = video->get_depth ();
457 video->get_depth ());
464 video->allocate_buffer();
469 video->get_pitch ());
471 actor->set_video (video);
473 m_impl->actmorphvideo = video;
476 switch_actor (actor);
481 void Bin::switch_actor (ActorPtr
const& actor)
483 visual_return_if_fail (actor);
486 m_impl->actmorph = actor;
491 m_impl->privvid.reset ();
494 m_impl->actor->get_video ()->get_depth ());
497 if (m_impl->use_morph &&
500 !m_impl->depthfromGL) {
503 m_impl->morph->set_progress (0.0f);
504 m_impl->morph->set_video (m_impl->actvideo);
505 m_impl->morph->set_time (m_impl->morphtime);
514 m_impl->actvideo->get_depth (),
515 m_impl->actmorph->get_video ()->get_depth ());
518 privvid->copy_attrs (m_impl->actvideo);
521 privvid->get_pitch (), m_impl->actvideo->get_pitch ());
523 privvid->allocate_buffer ();
529 m_impl->actmorph->get_video ()->get_depth (),
530 m_impl->actvideo->get_pixels ());
532 if (m_impl->actvideo->get_pixels () && privvid->get_pixels ())
533 visual_mem_copy (privvid->get_pixels (), m_impl->actvideo->get_pixels (),
534 privvid->get_size ());
535 else if (privvid->get_pixels ())
536 visual_mem_set (privvid->get_pixels (), 0, privvid->get_size ());
538 m_impl->actor->set_video (privvid);
539 m_impl->privvid = privvid;
543 m_impl->actvideo->get_pixels ()) {
544 visual_mem_set (m_impl->actvideo->get_pixels (), 0, m_impl->actvideo->get_size ());
549 m_impl->actor->get_video ()->get_depth (),
550 m_impl->actmorph->get_video ()->get_depth ());
552 m_impl->morphing =
true;
555 void Bin::switch_finalize ()
562 m_impl->actmorphvideo.reset ();
563 m_impl->privvid.reset ();
565 m_impl->actor = m_impl->actmorph;
566 m_impl->actmorph.reset ();
568 m_impl->actor->set_video (m_impl->actvideo);
570 m_impl->morphing =
false;
571 m_impl->morph.reset ();
574 m_impl->actvideo->get_depth (),
575 m_impl->actvideo->get_bpp ());
577 VisVideoDepth depthflag = m_impl->actor->get_supported_depths ();
578 m_impl->actvideo->set_depth (m_impl->get_suitable_depth (depthflag));
579 set_depth (m_impl->actvideo->get_depth ());
581 m_impl->depthforcedmain = m_impl->actvideo->get_depth ();
585 if (m_impl->depthchanged) {
587 m_impl->actor->video_negotiate (m_impl->depthforcedmain,
true,
true);
595 void Bin::use_morph (
bool use)
597 m_impl->use_morph = use;
600 void Bin::switch_set_time (Time
const& time)
602 m_impl->morphtime = time;
607 visual_return_if_fail (m_impl->actor);
608 visual_return_if_fail (m_impl->input);
610 m_impl->input->run ();
615 if (m_impl->morphing) {
617 m_impl->actmorph->realize ();
619 m_impl->actmorph->video_negotiate (m_impl->depthforced,
false,
true);
625 m_impl->actor->realize ();
627 m_impl->actor->video_negotiate (m_impl->depthforced,
false,
true);
642 m_impl->actor->realize ();
644 auto const& audio = m_impl->input->get_audio ();
646 m_impl->actor->run (audio);
648 if (m_impl->morphing) {
649 if (m_impl->use_morph &&
653 m_impl->actmorph->run (audio);
655 if (!m_impl->morph) {
662 m_impl->morph->realize ();
663 m_impl->morph->run (audio,
664 m_impl->actor->get_video (),
665 m_impl->actmorph->get_video ());
667 if (m_impl->morph->is_done ()) {