Ejemplo n.º 1
0
static int negotiate_video (VisActor *actor, int noevent)
{
	VisActorPlugin *actplugin = get_actor_plugin (actor);
	int tmpwidth, tmpheight, tmppitch;

	tmpwidth = actor->video->width;
	tmpheight = actor->video->height;
	tmppitch = actor->video->pitch;

	/* Pump the resize events and handle all the pending events */
	actplugin->requisition (visual_actor_get_plugin (actor), &actor->video->width, &actor->video->height);

	if (noevent == FALSE) {
		visual_event_queue_add_resize (&actor->plugin->eventqueue, actor->video,
				actor->video->width, actor->video->height);

		visual_plugin_events_pump (actor->plugin);
	}

	/* Size fitting enviroment */
	if (tmpwidth != actor->video->width || tmpheight != actor->video->height) {
		if (actor->video->depth != VISUAL_VIDEO_DEPTH_GL) {
			actor->fitting = visual_video_new_with_buffer (actor->video->width,
					actor->video->height, actor->video->depth);
		}

		visual_video_set_dimension (actor->video, tmpwidth, tmpheight);
	}

	/* Set the pitch seen this is the framebuffer context */
	visual_video_set_pitch (actor->video, tmppitch);

	return VISUAL_OK;
}
Ejemplo n.º 2
0
static int negotiate_video_with_unsupported_depth (VisActor *actor, int rundepth, int noevent, int forced)
{
	VisActorPlugin *actplugin = get_actor_plugin (actor);
	int depthflag = visual_actor_get_supported_depth (actor);
	
	/* Depth transform enviroment, it automaticly
	 * fits size because it can use the pitch from
	 * the dest video context */
	actor->transform = visual_video_new ();

	visual_log (VISUAL_LOG_INFO, _("run depth %d forced %d\n"), rundepth, forced);

	if (forced == TRUE)
		visual_video_set_depth (actor->transform, rundepth);
	else
		visual_video_set_depth (actor->transform,
				visual_video_depth_get_highest_nogl (depthflag));

	visual_log (VISUAL_LOG_INFO, _("transpitch1 %d depth %d bpp %d"), actor->transform->pitch, actor->transform->depth,
			actor->transform->bpp);
	/* If there is only GL (which gets returned by highest nogl if
	 * nothing else is there, stop here */
	if (actor->transform->depth == VISUAL_VIDEO_DEPTH_GL)
		return -VISUAL_ERROR_ACTOR_GL_NEGOTIATE;

	visual_video_set_dimension (actor->transform, actor->video->width, actor->video->height);
	visual_log (VISUAL_LOG_INFO, _("transpitch2 %d %d"), actor->transform->width, actor->transform->pitch);

	actplugin->requisition (visual_actor_get_plugin (actor), &actor->transform->width, &actor->transform->height);
	visual_log (VISUAL_LOG_INFO, _("transpitch3 %d"), actor->transform->pitch);

	if (noevent == FALSE) {
		visual_event_queue_add_resize (&actor->plugin->eventqueue, actor->transform,
				actor->transform->width, actor->transform->height);
		visual_plugin_events_pump (actor->plugin);
	} else {
		/* Normally a visual_video_set_dimension get's called within the
		 * event handler, but we won't come there right now so we've
		 * got to set the pitch ourself */
		visual_video_set_dimension (actor->transform,
				actor->transform->width, actor->transform->height);
	}

	visual_log (VISUAL_LOG_INFO, _("rundepth: %d transpitch %d\n"), rundepth, actor->transform->pitch);
	visual_video_allocate_buffer (actor->transform);

	if (actor->video->depth == VISUAL_VIDEO_DEPTH_8BIT)
		actor->ditherpal = visual_palette_new (256);

	return VISUAL_OK;
}
Ejemplo n.º 3
0
/**
 * 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;
}
Ejemplo n.º 4
0
/**
 * This is called to run the palette part of a VisTransform.
 *
 * @see visual_transform_run
 *
 * @param transform Pointer to a VisTransform that needs to be runned.
 * @param audio Pointer to a VisAudio that contains all the audio data.
 *
 * @return VISUAL_OK on succes, -VISUAL_ERROR_TRANSFORM_NULL, -VISUAL_ERROR_TRANSFORM_PALETTE_NULL
 *	or -VISUAL_ERROR_TRANSFORM_PLUGIN_NULL on failure.
 */
int visual_transform_run_palette (VisTransform *transform, VisAudio *audio)
{
	VisTransformPlugin *transplugin;
	VisPluginData *plugin;

	visual_log_return_val_if_fail (transform != NULL, -VISUAL_ERROR_TRANSFORM_NULL);
	visual_log_return_val_if_fail (transform->pal != NULL, -VISUAL_ERROR_TRANSFORM_PALETTE_NULL);

	transplugin = get_transform_plugin (transform);
	plugin = visual_transform_get_plugin (transform);

	if (transplugin == NULL) {
		visual_log (VISUAL_LOG_CRITICAL,
			_("The given transform does not reference any transform plugin"));

		return -VISUAL_ERROR_TRANSFORM_PLUGIN_NULL;
	}

	visual_plugin_events_pump (plugin);

	transplugin->palette (plugin, transform->pal, audio);

	return VISUAL_OK;
}
Ejemplo n.º 5
0
/**
 * This is called to run a VisActor. It also pump it's events when needed, checks for new song events and also does the fitting 
 * and depth transformation actions when needed.
 *
 * Every run cycle one frame is created, so this function needs to be used in the main draw loop of the application.
 *
 * @param actor Pointer to a VisActor that needs to be runned.
 * @param audio Pointer to a VisAudio that contains all the audio data.
 *
 * return VISUAL_OK on succes, -VISUAL_ERROR_ACTOR_NULL, -VISUAL_ERROR_ACTOR_VIDEO_NULL, -VISUAL_ERROR_NULL or
 * 	-VISUAL_ERROR_ACTOR_PLUGIN_NULL on failure.
 */
int visual_actor_run (VisActor *actor, VisAudio *audio)
{
	VisActorPlugin *actplugin;
	VisPluginData *plugin;
	VisVideo *video;
	VisVideo *transform;
	VisVideo *fitting;

	/* We don't check for video, because we don't always need a video */
	/*
	 * Really? take a look at visual_video_set_palette bellow
	 */
	visual_log_return_val_if_fail (actor != NULL, -VISUAL_ERROR_ACTOR_NULL);
	visual_log_return_val_if_fail (actor->video != NULL, -VISUAL_ERROR_ACTOR_VIDEO_NULL);
	visual_log_return_val_if_fail (audio != NULL, -VISUAL_ERROR_NULL);

	actplugin = get_actor_plugin (actor);
	plugin = visual_actor_get_plugin (actor);

	if (actplugin == NULL) {
		visual_log (VISUAL_LOG_CRITICAL,
			_("The given actor does not reference any actor plugin"));

		return -VISUAL_ERROR_ACTOR_PLUGIN_NULL;
	}

	/* Songinfo handling */
	if(0) /*FIXME*/if (visual_songinfo_compare (&actor->songcompare, &actplugin->songinfo) == FALSE ||
        actor->songcompare.elapsed != actplugin->songinfo.elapsed) {
		visual_songinfo_mark (&actplugin->songinfo);

		visual_event_queue_add_newsong (
			visual_plugin_get_eventqueue (plugin),
			&actplugin->songinfo);

		visual_songinfo_free_strings (&actor->songcompare);
		visual_songinfo_copy (&actor->songcompare, &actplugin->songinfo);
	}

	video = actor->video;
	transform = actor->transform;
	fitting = actor->fitting;

	/*
	 * This needs to happen before palette, render stuff, always, period.
	 * Also internal vars can be initialized when params have been set in init on the param
	 * events in the event loop.
	 */
	visual_plugin_events_pump (actor->plugin);

	visual_video_set_palette (video, visual_actor_get_palette (actor));

	/* Set the palette to the target video */
	video->pal = visual_actor_get_palette (actor);

	/* Yeah some transformation magic is going on here when needed */
	if (transform != NULL && (transform->depth != video->depth)) {
		actplugin->render (plugin, transform, audio);

		if (transform->depth == VISUAL_VIDEO_DEPTH_8BIT) {
			visual_video_set_palette (transform, visual_actor_get_palette (actor));
			visual_video_depth_transform (video, transform);
		} else {
			visual_video_set_palette (transform, actor->ditherpal);
			visual_video_depth_transform (video, transform);
		}
	} else {
		if (fitting != NULL && (fitting->width != video->width || fitting->height != video->height)) {
			actplugin->render (plugin, fitting, audio);
			visual_video_blit_overlay (video, fitting, 0, 0, FALSE);
		} else {
			actplugin->render (plugin, video, audio);
		}
	}

	return VISUAL_OK;
}
Ejemplo n.º 6
0
  void Actor::run (Audio const& audio)
  {
      visual_return_if_fail (m_impl->video);

      auto actor_plugin = m_impl->get_actor_plugin ();
      if (!actor_plugin) {
          visual_log (VISUAL_LOG_ERROR, "The given actor does not reference any actor plugin");
          return;
      }

      auto plugin = get_plugin ();

      /* Songinfo handling */
      if (!visual_songinfo_compare (&m_impl->songcompare, actor_plugin->songinfo) ||
          m_impl->songcompare.get_elapsed () != actor_plugin->songinfo->get_elapsed ()) {

          actor_plugin->songinfo->mark ();

          visual_event_queue_add (visual_plugin_get_event_queue (plugin),
                                  visual_event_new_newsong (actor_plugin->songinfo));

          visual_songinfo_copy (&m_impl->songcompare, actor_plugin->songinfo);
      }

      // Get plugin to process all events
      visual_plugin_events_pump (m_impl->plugin);

      auto const& video      = m_impl->video;
      auto const& to_convert = m_impl->to_convert;
      auto const& to_scale   = m_impl->to_scale;

      if (video->get_depth () != VISUAL_VIDEO_DEPTH_GL) {
          auto palette = get_palette ();

          if (to_convert) {
              // Have depth conversion

              // Setup any palette
              if (palette) {
                  to_convert->set_palette (*palette);
              }

              // Render first
              actor_plugin->render (m_impl->plugin, to_convert.get (), const_cast<Audio*> (&audio));

              if (to_scale) {
                  // Convert depth, then scale
                  to_scale->convert_depth (to_convert);
                  video->scale (to_scale, VISUAL_VIDEO_SCALE_NEAREST);
              }
              else {
                  // Convert depth only
                  video->convert_depth (to_convert);
              }
          } else {
              // No depth conversion

              if (to_scale) {
                  // Setup any palette
                  if (palette) {
                      to_scale->set_palette (*palette);
                  }

                  // Render, then scale
                  actor_plugin->render (m_impl->plugin, to_scale.get (), const_cast<Audio*> (&audio));
                  video->scale (to_scale, VISUAL_VIDEO_SCALE_NEAREST);
              } else {
                  // Setup any palette
                  if (palette) {
                      video->set_palette (*palette);
                  }

                  // Render directly to video target
                  actor_plugin->render (m_impl->plugin, video.get (), const_cast<Audio*> (&audio));
              }
          }
      } else {
          // Render directly to video target (OpenGL)
          actor_plugin->render (m_impl->plugin, video.get (), const_cast<Audio*> (&audio));
      }
  }