int visual_bin_set_morph_by_name (VisBin *bin, char *morphname) { VisMorph *morph; int depthflag; visual_log_return_val_if_fail (bin != NULL, -1); if (bin->morph != NULL) visual_object_unref (VISUAL_OBJECT (bin->morph)); morph = visual_morph_new (morphname); bin->morph = morph; bin->morphmanaged = TRUE; visual_log_return_val_if_fail (morph->plugin != NULL, -1); depthflag = visual_morph_get_supported_depth (morph); if (visual_video_depth_is_supported (depthflag, bin->actvideo->depth) <= 0) { visual_object_unref (VISUAL_OBJECT (morph)); bin->morph = NULL; return -2; } return 0; }
bool Actor::video_negotiate (VisVideoDepth run_depth, bool noevent, bool forced) { auto output_width = m_impl->video->get_width (); auto output_height = m_impl->video->get_height (); auto output_depth = m_impl->video->get_depth (); // Ask actor for preferred rendering dimensions int run_width = output_width; int run_height = output_height; m_impl->get_actor_plugin ()->requisition (m_impl->plugin, &run_width, &run_height); // Check to make sure requested run depth is supported. If not, pick the highest. auto supported_depths = get_supported_depths (); m_impl->run_depth = forced ? run_depth : visual_video_depth_get_highest_nogl (supported_depths); if (!visual_video_depth_is_supported (supported_depths, m_impl->run_depth)) { m_impl->run_depth = visual_video_depth_get_highest_nogl (supported_depths); } // Configure proxy videos to convert rendering m_impl->to_scale.reset (); m_impl->to_convert.reset (); visual_log (VISUAL_LOG_DEBUG, "Setting up any necessary video conversions.."); if (output_depth != VISUAL_VIDEO_DEPTH_GL) { // Configure any necessary depth conversion if (m_impl->run_depth != output_depth) { visual_log (VISUAL_LOG_DEBUG, "Setting up depth conversion: %s -> %s", visual_video_depth_name (m_impl->run_depth), visual_video_depth_name (output_depth)); m_impl->to_convert = Video::create (output_width, output_height, m_impl->run_depth); } // Configure any necessary scaling if (run_width != output_width || run_height != output_height) { visual_log (VISUAL_LOG_DEBUG, "Setting up scaling: (%dx%d) -> (%dx%d)", run_width, run_height, output_width, output_height); m_impl->to_scale = Video::create (run_width, run_height, output_depth); } } else { visual_log (VISUAL_LOG_DEBUG, "Conversions skipped in OpenGL rendering mode"); } // FIXME: This should be moved into the if block above. It's out // here because plugins depend on this to receive information // about initial dimensions if (!noevent) { visual_event_queue_add (visual_plugin_get_event_queue (m_impl->plugin), visual_event_new_resize (run_width, run_height)); } return true; }
/** * This function negotiates the VisActor with it's target video that is set by visual_actor_set_video. * When needed it also sets up size fitting environment and depth transformation environment. * * The function has a few extra arguments that are mainly to be used from within internal code. * * This function needs to be called everytime there is a change within either the size or depth of * the target video. * * The main method of calling this function is: "visual_actor_video_negotiate (actor, 0, FALSE, FALSE)" * * @see visual_actor_set_video * * @param actor Pointer to a VisActor that needs negotiation. * @param rundepth An depth in the form of the VISUAL_VIDEO_DEPTH_* style when a depth is forced. * This could be needed when for example a plugin has both a 8 bits and a 32 bits display method * but while the target video is in 32 bits you still want to run the plugin in 8 bits. If this * is desired the "forced" argument also needs to be set on TRUE. * @param noevent When set on TRUE this does only renegotiate depth transformation environments. For example * when the target display was running in 32 bits and switched to 8 bits while the plugin was already * in 8 bits it doesn't need an events, which possibly reinitializes the plugin. * @param forced This should be set if the rundepth argument is set, so it forces the plugin in a certain * depth. * * @return VISUAL_OK on succes, -VISUAL_ERROR_ACTOR_NULL, -VISUAL_ERROR_PLUGIN_NULL, -VISUAL_ERROR_PLUGIN_REF_NULL, * -VISUAL_ERROR_ACTOR_VIDEO_NULL or -VISUAL_ERROR_ACTOR_GL_NEGOTIATE on failure. */ int visual_actor_video_negotiate (VisActor *actor, int rundepth, int noevent, int forced) { int depthflag; visual_log_return_val_if_fail (actor != NULL, -VISUAL_ERROR_ACTOR_NULL); visual_log_return_val_if_fail (actor->plugin != NULL, -VISUAL_ERROR_PLUGIN_NULL); visual_log_return_val_if_fail (actor->plugin->ref != NULL, -VISUAL_ERROR_PLUGIN_REF_NULL); visual_log_return_val_if_fail (actor->video != NULL, -VISUAL_ERROR_ACTOR_VIDEO_NULL); if (actor->transform != NULL) { visual_object_unref (VISUAL_OBJECT (actor->transform)); actor->transform = NULL; } if (actor->fitting != NULL) { visual_object_unref (VISUAL_OBJECT (actor->fitting)); actor->fitting = NULL; } if (actor->ditherpal != NULL) { visual_object_unref (VISUAL_OBJECT (actor->ditherpal)); actor->ditherpal = NULL; } depthflag = visual_actor_get_supported_depth (actor); visual_log (VISUAL_LOG_INFO, "negotiating plugin %s", actor->plugin->info->name); /* Set up depth transformation enviroment */ if (visual_video_depth_is_supported (depthflag, actor->video->depth) != TRUE || (forced == TRUE && actor->video->depth != rundepth)) /* When the depth is not supported, or if we only switch the depth and not * the size */ return negotiate_video_with_unsupported_depth (actor, rundepth, noevent, forced); else return negotiate_video (actor, noevent); return -VISUAL_ERROR_IMPOSSIBLE; }
/** * This function negotiates the VisTransform with it's target video that is set by visual_transform_set_video. * When needed it also sets up size fitting environment and depth transformation environment. * * @param transform Pointer to a VisTransform that needs negotiation. * * @return VISUAL_OK on succes, -VISUAL_ERROR_TRANSFORM_NULL, -VISUAL_ERROR_PLUGIN_NULL, -VISUAL_ERROR_PLUGIN_REF_NULL * or -VISUAL_ERROR_TRANSFORM_NEGOTIATE on failure. */ int visual_transform_video_negotiate (VisTransform *transform) { int depthflag; visual_log_return_val_if_fail (transform != NULL, -VISUAL_ERROR_TRANSFORM_NULL); visual_log_return_val_if_fail (transform->plugin != NULL, -VISUAL_ERROR_PLUGIN_NULL); visual_log_return_val_if_fail (transform->plugin->ref != NULL, -VISUAL_ERROR_PLUGIN_REF_NULL); depthflag = visual_transform_get_supported_depth (transform); if (visual_video_depth_is_supported (depthflag, transform->video->depth) == FALSE) return -VISUAL_ERROR_TRANSFORM_NEGOTIATE; visual_event_queue_add_resize (&transform->plugin->eventqueue, transform->video, transform->video->width, transform->video->height); visual_plugin_events_pump (transform->plugin); return -VISUAL_OK; }
int visual_bin_set_depth (VisBin *bin, int depth) { visual_log_return_val_if_fail (bin != NULL, -1); bin->depthold = bin->depth; if (visual_video_depth_is_supported (bin->depthflag, depth) != TRUE) return -2; visual_log (VISUAL_LOG_DEBUG, "old: %d new: %d", bin->depth, depth); if (bin->depth != depth) bin->depthchanged = TRUE; if (bin->depth == VISUAL_VIDEO_DEPTH_GL && bin->depthchanged == TRUE) bin->depthfromGL = TRUE; else bin->depthfromGL = FALSE; bin->depth = depth; visual_video_set_depth (bin->actvideo, depth); return 0; }
int visual_bin_switch_actor_by_name (VisBin *bin, char *actname) { VisActor *actor; VisVideo *video; int depthflag; int depth; visual_log_return_val_if_fail (bin != NULL, -1); visual_log_return_val_if_fail (actname != NULL, -1); visual_log (VISUAL_LOG_DEBUG, "switching to a new actor: %s, old actor: %s", actname, bin->actor->plugin->info->name); /* Destroy if there already is a managed one */ if (bin->actmorphmanaged == TRUE) { if (bin->actmorph != NULL) { visual_object_unref (VISUAL_OBJECT (bin->actmorph)); if (bin->actmorphvideo != NULL) visual_object_unref (VISUAL_OBJECT (bin->actmorphvideo)); } } /* Create a new managed actor */ actor = visual_actor_new (actname); visual_log_return_val_if_fail (actor != NULL, -1); video = visual_video_new (); visual_video_clone (video, bin->actvideo); depthflag = visual_actor_get_supported_depth (actor); if (visual_video_depth_is_supported (depthflag, VISUAL_VIDEO_DEPTH_GL) == TRUE) { visual_log (VISUAL_LOG_INFO, _("Switching to Gl mode")); bin->depthforced = VISUAL_VIDEO_DEPTH_GL; bin->depthforcedmain = VISUAL_VIDEO_DEPTH_GL; visual_video_set_depth (video, VISUAL_VIDEO_DEPTH_GL); visual_bin_set_depth (bin, VISUAL_VIDEO_DEPTH_GL); bin->depthchanged = TRUE; } else { visual_log (VISUAL_LOG_INFO, _("Switching away from Gl mode -- or non Gl switch")); /* Switching from GL */ depth = bin_get_depth_using_preferred (bin, depthflag); fix_depth_with_bin (bin, video, depth); visual_log (VISUAL_LOG_DEBUG, "after depth fixating"); /* After a depth change, the pitch value needs an update from the client * if it's different from width * bpp, after a visual_bin_sync * the issues are fixed again */ visual_log (VISUAL_LOG_INFO, _("video depth (from fixate): %d"), video->depth); /* FIXME check if there are any unneeded depth transform environments and drop these */ visual_log (VISUAL_LOG_DEBUG, "checking if we need to drop something: depthforcedmain: %d actvideo->depth %d", bin->depthforcedmain, bin->actvideo->depth); /* Drop a transformation environment when not needed */ if (bin->depthforcedmain != bin->actvideo->depth) { visual_actor_video_negotiate (bin->actor, bin->depthforcedmain, TRUE, TRUE); visual_log (VISUAL_LOG_DEBUG, "[[[[optionally a bogus transform environment, dropping]]]]\n"); } if (bin->actvideo->depth > video->depth && bin->actvideo->depth != VISUAL_VIDEO_DEPTH_GL && bin->morphstyle == VISUAL_SWITCH_STYLE_MORPH) { visual_log (VISUAL_LOG_INFO, _("old depth is higher, video depth %d, depth %d, bin depth %d"), video->depth, depth, bin->depth); bin->depthforced = depth; bin->depthforcedmain = bin->depth; visual_bin_set_depth (bin, bin->actvideo->depth); visual_video_set_depth (video, bin->actvideo->depth); } else if (bin->actvideo->depth != VISUAL_VIDEO_DEPTH_GL) { visual_log (VISUAL_LOG_INFO, _("new depth is higher, or equal: video depth %d, depth %d bin depth %d"), video->depth, depth, bin->depth); visual_log (VISUAL_LOG_DEBUG, "depths i can locate: actvideo: %d bin: %d bin-old: %d", bin->actvideo->depth, bin->depth, bin->depthold); bin->depthforced = video->depth; bin->depthforcedmain = bin->depth; visual_log (VISUAL_LOG_DEBUG, "depthforcedmain in switch by name: %d", bin->depthforcedmain); visual_log (VISUAL_LOG_DEBUG, "visual_bin_set_depth %d", video->depth); visual_bin_set_depth (bin, video->depth); } else { /* Don't force ourself into a GL depth, seen we do a direct * switch in the run */ bin->depthforced = video->depth; bin->depthforcedmain = video->depth; visual_log (VISUAL_LOG_INFO, _("Switching from Gl TO framebuffer for real, framebuffer depth: %d"), video->depth); } visual_log (VISUAL_LOG_INFO, _("Target depth selected: %d"), depth); visual_video_set_dimension (video, video->width, video->height); visual_log (VISUAL_LOG_INFO, _("Switch to new pitch: %d"), bin->actvideo->pitch); if (bin->actvideo->depth != VISUAL_VIDEO_DEPTH_GL) visual_video_set_pitch (video, bin->actvideo->pitch); visual_log (VISUAL_LOG_DEBUG, "before allocating buffer"); visual_video_allocate_buffer (video); visual_log (VISUAL_LOG_DEBUG, "after allocating buffer"); } visual_log (VISUAL_LOG_INFO, _("video pitch of that what connects to the new actor %d"), video->pitch); visual_actor_set_video (actor, video); bin->actmorphvideo = video; bin->actmorphmanaged = TRUE; visual_log (VISUAL_LOG_INFO, _("switching... ******************************************")); visual_bin_switch_actor (bin, actor); visual_log (VISUAL_LOG_INFO, _("end switch actor by name function ******************")); return 0; }