Exemplo 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;
}
Exemplo n.º 2
0
/**
 * Gives a pointer to the palette within the VisActor. This can be needed to set a palette on the target
 * display when it's in index mode.
 *
 * @see VisPalette
 *
 * @param actor Pointer to a VisActor of which the palette is needed.
 *
 * @return Pointer to the palette structure on succes or NULL on failure. Also it's possible that NULL
 * is returned when the plugin is running in a full color mode or openGL. The returned palette is
 * read only.
 */
VisPalette *visual_actor_get_palette (VisActor *actor)
{
	VisActorPlugin *actplugin;

	visual_log_return_val_if_fail (actor != NULL, NULL);

	actplugin = get_actor_plugin (actor);

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

	if (actor->transform != NULL &&
		actor->video->depth == VISUAL_VIDEO_DEPTH_8BIT) {

		return actor->ditherpal;

	} else {
		return actplugin->palette (visual_actor_get_plugin (actor));
	}

	return NULL;
}
Exemplo n.º 3
0
/** VisActor.actorNew() */
JNIEXPORT jint JNICALL Java_org_libvisual_android_VisActor_actorNew(JNIEnv * env, jobject  obj, jstring name)
{
    LOGI("VisActor.actorNew()");


    /* result */
    VisActor *a = NULL;

    /* get name string */
    jboolean isCopy;  
    const char *actorName = (*env)->GetStringUTFChars(env, name, &isCopy);  

    /* actor valid ? */
    if(!(visual_plugin_registry_has_plugin(VISUAL_PLUGIN_TYPE_ACTOR, actorName)))
    {
            LOGE("Invalid actor-plugin: \"%s\"", actorName);
            goto _van_exit;
    }

    /* create new actor */
    a = visual_actor_new(actorName);

    /* set random seed */
    VisPluginData    *plugin_data = visual_actor_get_plugin(a);
    VisRandomContext *r_context   = visual_plugin_get_random_context (plugin_data);
    visual_random_context_set_seed(r_context, time(NULL));

_van_exit:
    (*env)->ReleaseStringUTFChars(env, name, actorName);
    return (jint) a;
}
Exemplo n.º 4
0
int pipeline_container_propagate_event (LVAVSPipelineContainer *container, VisEvent *event)
{
    VisListEntry *le = NULL;
    VisEventQueue *pluginqueue;
    LVAVSPipelineElement *element;

    while ((element = visual_list_next (container->members, &le)) != NULL) {

        switch (element->type) {
            case LVAVS_PIPELINE_ELEMENT_TYPE_ACTOR:

                pluginqueue = visual_plugin_get_eventqueue (visual_actor_get_plugin (element->data.actor));

                visual_object_ref (VISUAL_OBJECT (event));
                visual_event_queue_add (pluginqueue, event);

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_TRANSFORM:

                pluginqueue = visual_plugin_get_eventqueue (visual_actor_get_plugin (element->data.actor));

                visual_object_ref (VISUAL_OBJECT (event));
                visual_event_queue_add (pluginqueue, event);

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_CONTAINER:

                pipeline_container_propagate_event (LVAVS_PIPELINE_CONTAINER (element), event);

                break;

            default:

                break;
        }
    }


    return VISUAL_OK;
}
Exemplo n.º 5
0
int pipeline_container_realize (LVAVSPipelineContainer *container)
{
    VisListEntry *le = NULL;
    LVAVSPipelineElement *element;

    while ((element = visual_list_next (container->members, &le)) != NULL) {

        switch (element->type) {
            case LVAVS_PIPELINE_ELEMENT_TYPE_NULL:

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_ACTOR:

                visual_actor_realize (element->data.actor);
                visual_param_container_copy_match (visual_plugin_get_params (
                            visual_actor_get_plugin (element->data.actor)), element->params);

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_TRANSFORM:

                visual_transform_realize (element->data.transform);
                visual_param_container_copy_match (visual_plugin_get_params (
                            visual_transform_get_plugin (element->data.transform)), element->params);

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_MORPH:

                visual_morph_realize (element->data.morph);

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_RENDERSTATE:

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_CONTAINER:

                pipeline_container_realize (LVAVS_PIPELINE_CONTAINER (element));

                break;

            default:
                visual_log (VISUAL_LOG_CRITICAL, "Invalid LVAVSPipelineElementType");

                break;
        }
    }
    return 0;
}
Exemplo n.º 6
0
static int button_callback(void * data, int x, int y, int button, int mask)
  {
  VisEventQueue *eventqueue;
  lv_priv_t * priv = (lv_priv_t*)data;
  eventqueue = visual_plugin_get_eventqueue(visual_actor_get_plugin(priv->actor));
  visual_event_queue_add_mousebutton(eventqueue, button, VISUAL_MOUSE_DOWN, x, y);
  if(priv->ov_callbacks && priv->ov_callbacks->button_callback)
    {
    priv->ov_callbacks->button_callback(priv->ov_callbacks->data,
                                        x, y, button, mask);
    }
  return 1;
  }
Exemplo n.º 7
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;
}
Exemplo n.º 8
0
static int key_release_callback(void * data, int key, int mask)
  {
  VisEventQueue *eventqueue;
  int lv_key, lv_mask;
  lv_priv_t * priv = (lv_priv_t*)data;
  
  if(!get_key_code(key, mask, &lv_key, &lv_mask))
    return 0;

  eventqueue = visual_plugin_get_eventqueue(visual_actor_get_plugin(priv->actor));
  
  visual_event_queue_add_keyboard(eventqueue,
                                  lv_key, lv_mask, VISUAL_KEY_UP);
  return 1;
  }
Exemplo n.º 9
0
int main (int argc, char **argv)
{
    // print warm welcome
    std::cerr << argv[0] << " v0.1\n";

    // initialize libvisual once (this is meant to be called only once,
    // visual_init() after visual_quit() results in undefined state)
    visual_log_set_verbosity(VISUAL_LOG_DEBUG);
    visual_init (&argc, &argv);

    try {
        // parse commandline arguments
        if (_parse_args(argc, argv) != EXIT_SUCCESS)
            throw std::runtime_error ("Failed to parse arguments");

        // create new VisBin for video output
        VisBin *bin = visual_bin_new();
        visual_bin_set_supported_depth(bin, VISUAL_VIDEO_DEPTH_ALL);
        visual_bin_switch_set_style(bin, VISUAL_SWITCH_STYLE_MORPH);

        // initialize actor plugin
        std::cerr << "Loading actor '" << actor_name << "'...\n";
        VisActor *actor = visual_actor_new (actor_name.c_str ());
        if (!actor)
            throw std::runtime_error ("Failed to load actor '" + actor_name + "'");

        // Set random seed
        if (have_seed) {
            VisPluginData    *plugin_data = visual_actor_get_plugin(actor);
            VisRandomContext *r_context   = visual_plugin_get_random_context (plugin_data);

            visual_random_context_set_seed (r_context, seed);
            seed++;
        }

        // initialize input plugin
        std::cerr << "Loading input '" << input_name << "'...\n";
        VisInput *input = visual_input_new(input_name.c_str());
        if (!input) {
            throw std::runtime_error ("Failed to load input '" + input_name + "'");
        }

        // Pick the best display depth

        int depthflag = visual_actor_get_supported_depth (actor);

        VisVideoDepth depth;

        if (depthflag == VISUAL_VIDEO_DEPTH_GL) {
            depth = visual_video_depth_get_highest (depthflag);
        }
        else {
            depth = visual_video_depth_get_highest_nogl (depthflag);
        }

        visual_bin_set_depth (bin, depth);

        VisVideoAttributeOptions const* vidoptions =
            visual_actor_get_video_attribute_options(actor);

        // initialize display
        SADisplay display (driver_name);

        // create display
        display.create(depth, vidoptions, width, height, true);

        VisVideo *video = display.get_video();
        if(!video)
            throw std::runtime_error("Failed to get VisVideo from display");

        // put it all together
        visual_bin_connect(bin, actor, input);
        visual_bin_set_video(bin, video);
        visual_bin_realize(bin);
        visual_bin_sync(bin, FALSE);
        visual_bin_depth_changed(bin);

        // get a queue to handle events
        VisEventQueue localqueue;

        // main loop
        bool running = true;
        bool visible = true;

        while (running)
        {
            LV::Event ev;

            // Handle all events
            display.drain_events(localqueue);

            LV::EventQueue* pluginqueue = visual_plugin_get_eventqueue(visual_actor_get_plugin (bin->actor));

            while (localqueue.poll(ev))
            {
                if(ev.type != VISUAL_EVENT_RESIZE)
                    pluginqueue->add (ev);

                switch (ev.type)
                {
                    case VISUAL_EVENT_PARAM:
                    {
                        break;
                    }

                    case VISUAL_EVENT_RESIZE:
                    {
                        display.lock();
                        width = ev.event.resize.width;
                        height = ev.event.resize.height;
                        display.create(depth, vidoptions, width, height, true);
                        video = display.get_video ();

                        visual_bin_set_video (bin, video);
                        visual_actor_video_negotiate (bin->actor, depth, FALSE, FALSE);

                        display.unlock();
                        break;
                    }

                    case VISUAL_EVENT_MOUSEMOTION:
                    {
                        break;
                    }

                    case VISUAL_EVENT_MOUSEBUTTONDOWN:
                    {
                        // switch to next actor
                        v_cycleActor(1);
                        v_cycleMorph();

                        visual_bin_set_morph_by_name(bin, morph_name.c_str());
                        visual_bin_switch_actor_by_name(bin, actor_name.c_str());

                        // get new actor
                        actor = visual_bin_get_actor(bin);

                        // handle depth of new actor
                        depthflag = visual_actor_get_supported_depth(actor);
                        if (depthflag == VISUAL_VIDEO_DEPTH_GL)
                        {
                            visual_bin_set_depth(bin, VISUAL_VIDEO_DEPTH_GL);
                        }
                        else
                        {
                            depth = visual_video_depth_get_highest(depthflag);
                            if ((bin->depthflag & depth) > 0)
                                visual_bin_set_depth(bin, depth);
                            else
                                visual_bin_set_depth(bin, visual_video_depth_get_highest_nogl(bin->depthflag));
                        }
                        bin->depthforcedmain = bin->depth;
                        break;
                    }

                    case VISUAL_EVENT_MOUSEBUTTONUP:
                    {
                        break;
                    }

                    case VISUAL_EVENT_KEYDOWN:
                    {
                        switch(ev.event.keyboard.keysym.sym)
                        {
                            case VKEY_ESCAPE:
                            {
                                running = false;
                                break;
                            }

                            case VKEY_TAB:
                            {
                                break;
                            }

                            default:
                                break;
                        }

                        break;
                    }

                    case VISUAL_EVENT_KEYUP:
                    {
                        break;
                    }

                    case VISUAL_EVENT_QUIT:
                    {
                        running = FALSE;
                        break;
                    }

                    case VISUAL_EVENT_VISIBILITY:
                    {
                        visible = ev.event.visibility.is_visible;
                        break;
                    }

                    default:
                    {
                        break;
                    }
                }
            }

            if (visual_bin_depth_changed(bin))
            {
                display.lock();
                display.create(depth, vidoptions, width, height, true);
                VisVideo *video = display.get_video();
                visual_bin_set_video(bin, video);
                visual_bin_sync(bin, TRUE);
                display.unlock();
            }

            // Do a run cycle
            if (!visible)
                continue;

            display.lock();
            visual_bin_run(bin);
            display.unlock();
            display.update_all();
            display.set_fps_limit(framerate);
        }
    }
    catch (std::exception& error) {
        std::cerr << error.what () << std::endl;
    }

    //printf ("Total frames: %d, average fps: %f\n", display_fps_total (display), display_fps_average (display));

    visual_quit ();

    return EXIT_SUCCESS;
}
Exemplo n.º 10
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;
}
Exemplo n.º 11
0
/** VisActor.actorGetPlugin() */
JNIEXPORT jint JNICALL Java_org_libvisual_android_VisActor_actorGetPlugin(JNIEnv * env, jobject  obj, jint actor)
{
    VisActor *a = (VisActor *) actor;
    return (jint) visual_actor_get_plugin(a);
}
Exemplo n.º 12
0
int main (int argc, char **argv)
{
	SADisplay *display;
	VisVideo *video;

	VisInput *input;
	VisActor *actor;
	VisEventQueue *localqueue;
	VisVideoAttributeOptions *vidoptions;

	int running = TRUE;
	int fullscreen = FALSE;
	int visible = TRUE;

	int depth;

	//visual_mem_alloc_install_vtable (visual_mem_alloc_vtable_profile ());

	visual_init (&argc, &argv);

	display = display_new (sdl_driver_new ());

	/* Libvisual stuff */
	if (argc > 1)
		actor = visual_actor_new (argv[1]);
	else
		actor = visual_actor_new ("projectM");


	if (argc > 3) {
		depth = visual_video_depth_enum_from_value (atoi (argv[3]));
	} else
		depth = visual_video_depth_get_highest (visual_actor_get_supported_depth (actor));

	vidoptions = visual_actor_get_video_attribute_options (actor);

	display_create (display, depth, vidoptions, 480, 360, TRUE);

	visual_actor_realize (actor);

	video = display_get_video (display);

        visual_actor_set_video (actor, video);
	visual_actor_video_negotiate (actor, 0, FALSE, FALSE);

	if (argc > 2)
		input = visual_input_new (argv[2]);
	else
		input = visual_input_new ("alsa");

	visual_input_realize (input);

	localqueue = visual_event_queue_new ();

	while (running) {
		VisEventQueue *pluginqueue;
		VisEvent *ev;

		/* Handle all events */
		display_drain_events (display, localqueue);

		pluginqueue = visual_plugin_get_eventqueue (visual_actor_get_plugin (actor));
		while (visual_event_queue_poll_by_reference (localqueue, &ev)) {

			if (ev->type != VISUAL_EVENT_RESIZE)
				visual_event_queue_add (pluginqueue, ev);

			switch (ev->type) {
				case VISUAL_EVENT_RESIZE:
					video = display_get_video (display);
					visual_actor_set_video (actor, video);

					visual_actor_video_negotiate (actor, depth, FALSE, FALSE);
					break;

				case VISUAL_EVENT_MOUSEMOTION:
					break;

				case VISUAL_EVENT_MOUSEBUTTONDOWN:

					break;

				case VISUAL_EVENT_MOUSEBUTTONUP:
					break;

				case VISUAL_EVENT_KEYDOWN:
					switch (ev->event.keyboard.keysym.sym) {
						case VKEY_ESCAPE:
							running = FALSE;
							break;

						case VKEY_TAB:
							fullscreen = !fullscreen;

							display_set_fullscreen (display, fullscreen, TRUE);

							/* Resync video */
							video = display_get_video (display);
							visual_actor_set_video (actor, video);

							visual_actor_video_negotiate (actor, depth, FALSE, FALSE);

							break;

						default:
							printf ("key: %c\n", ev->event.keyboard.keysym.sym);
							break;
					}

					break;

				case VISUAL_EVENT_KEYUP:
					break;

				case VISUAL_EVENT_QUIT:
					running = FALSE;
					break;

				case VISUAL_EVENT_VISIBILITY:
					visible = ev->event.visibility.is_visible;
					break;

				default:
					break;
			}
		}

		if (visible == FALSE) {
			visual_input_run (input);

			visual_time_usleep (10000);

			continue;
		}

		/* Do a run cycle */
		visual_input_run (input);

		display_lock (display);
		visual_actor_run (actor, input->audio);
		display_unlock (display);

		display_update_all (display);

		display_fps_limit (display, 30);
	}

	/* Termination procedure */
	display_set_fullscreen (display, FALSE, TRUE);
	display_close (display);

	visual_quit ();

	//visual_mem_alloc_profile ();

	printf ("Total frames: %d, average fps: %f\n", display_fps_total (display), display_fps_average (display));

	return 0;
}
Exemplo n.º 13
0
    static bool
    event_handler()
    {
        SDL_Event event;
        VisEventQueue *vevent;

        while( SDL_PollEvent( &event ) )
        {
            vevent = visual_plugin_get_eventqueue( visual_actor_get_plugin( visual_bin_get_actor( Vis::bin ) ) );

            switch( event.type )
            {
            case SDL_KEYUP:
                visual_event_queue_add_keyboard( vevent, (VisKey)event.key.keysym.sym, event.key.keysym.mod, VISUAL_KEY_UP );
                break;

            case SDL_KEYDOWN:
                visual_event_queue_add_keyboard (vevent, (VisKey)event.key.keysym.sym, event.key.keysym.mod, VISUAL_KEY_DOWN);

                switch( event.key.keysym.sym )
                {
                //PLUGIN CONTROLS
                case SDLK_F11:
                case SDLK_TAB:
                    SDL::toggleFullScreen();
                    break;

                case SDLK_ESCAPE:
                    if( SDL::isFullScreen() )
                        SDL::toggleFullScreen();
                    break;

                case SDLK_LEFT:
                    Vis::prevActor();
                    goto morph;

                case SDLK_RIGHT:
                    Vis::nextActor();

                morph:
                    SDL::lock();
                      visual_bin_set_morph_by_name( Vis::bin, (char*)"alphablend" );
                      visual_bin_switch_actor_by_name( Vis::bin, (char*)Vis::plugin );
                    SDL::unlock();

                    SDL_WM_SetCaption( Vis::plugin, 0 );

                    break;

                default:
                    ;
                }
                break;

            case SDL_VIDEORESIZE:
                Vis::resize( event.resize.w, event.resize.h );
                break;

            case SDL_MOUSEMOTION:
                visual_event_queue_add_mousemotion (vevent, event.motion.x, event.motion.y);
                break;

            case SDL_MOUSEBUTTONDOWN:
                if (event.button.button == SDL_BUTTON_RIGHT)
                {
                    SDL::toggleFullScreen();
                    break;
		}
                visual_event_queue_add_mousebutton (vevent, event.button.button, VISUAL_MOUSE_DOWN, 0, 0);
                break;

            case SDL_MOUSEBUTTONUP:
                visual_event_queue_add_mousebutton (vevent, event.button.button, VISUAL_MOUSE_UP, 0, 0);
                break;

            case SDL_QUIT:
                return false;

            default:
                ;
            }
        }

        return true;
    }
Exemplo n.º 14
0
static void set_parameter_lv(void * data, const char * name,
                             const bg_parameter_value_t * val)
  {
  int supported;
  lv_priv_t * priv;
  int index;
  int i_tmp;
  uint8_t r, g, b;
  char * tmp_string;
  VisParamEntry * param;
  VisListEntry * list_entry;

  VisColor * color;
  const bg_parameter_info_t * info;
  
  if(!name)
    return;
  priv = (lv_priv_t*)data;

  info = bg_parameter_find(priv->parameters, name);
  if(!info)
    return;

  /* This would crash if multi_parameters were supported */
  index = info - priv->parameters;

  tmp_string = gavl_strdup(name);
  param = visual_param_entry_new(tmp_string);
  free(tmp_string);
  /* Menus have to be treated specially */
  if(info->type == BG_PARAMETER_STRINGLIST)
    {
    if(!priv->widgets[index])
      return;
    /* Get the selected index */
    supported = 0;
    list_entry = NULL;
    while(visual_list_next(&VISUAL_UI_CHOICE(priv->widgets[index])->choices.choices,
                           &list_entry))
      {
      if(!strcmp(((VisUIChoiceEntry*)(list_entry->data))->name, val->val_str))
        {
        visual_param_entry_set_from_param(param,
                                          ((VisUIChoiceEntry*)(list_entry->data))->value);
        supported = 1;
        break;
        }
      }
    }
  else
    {
    supported = 1;
    switch(priv->params[index]->type)
      {
      case VISUAL_PARAM_ENTRY_TYPE_NULL:     /**< No parameter. */
        supported = 0;
        break;
      case VISUAL_PARAM_ENTRY_TYPE_STRING:   /**< String parameter. */
        if(val->val_str)
          visual_param_entry_set_string(param, val->val_str);
        else
          supported = 0;
        break;
      case VISUAL_PARAM_ENTRY_TYPE_INTEGER:  /**< Integer parameter. */
        visual_param_entry_set_integer(param, val->val_i);
        break;
      case VISUAL_PARAM_ENTRY_TYPE_FLOAT:    /**< Floating point parameter. */
        visual_param_entry_set_float(param, val->val_f);
        break;
      case VISUAL_PARAM_ENTRY_TYPE_DOUBLE:   /**< Double floating point parameter. */
        visual_param_entry_set_double(param, val->val_f);
        break;
      case VISUAL_PARAM_ENTRY_TYPE_COLOR:    /**< VisColor parameter. */
        i_tmp = (int)(val->val_color[0] * 255.0 + 0.5);
        if(i_tmp < 0) i_tmp = 0;
        if(i_tmp > 255) i_tmp = 255;
        r = i_tmp;
        
        i_tmp = (int)(val->val_color[1] * 255.0 + 0.5);
        if(i_tmp < 0) i_tmp = 0;
        if(i_tmp > 255) i_tmp = 255;
        g = i_tmp;

        i_tmp = (int)(val->val_color[2] * 255.0 + 0.5);
        if(i_tmp < 0) i_tmp = 0;
        if(i_tmp > 255) i_tmp = 255;
        b = i_tmp;

        color = visual_color_new();
        visual_color_set(color, r, g, b);
        visual_param_entry_set_color_by_color(param, color);
        visual_object_unref(VISUAL_OBJECT(color));
        break;
      case VISUAL_PARAM_ENTRY_TYPE_PALETTE:  /**< VisPalette parameter. */
      case VISUAL_PARAM_ENTRY_TYPE_OBJECT:   /**< VisObject parameter. */
      case VISUAL_PARAM_ENTRY_TYPE_END:      /**< List end, and used as terminator for VisParamEntry lists. */
        supported = 0;
        break;
      }
    }
  if(supported)
    {
    visual_event_queue_add_param(visual_plugin_get_eventqueue(visual_actor_get_plugin(priv->actor)),
                              param);
    }
  else
    visual_object_unref(VISUAL_OBJECT(param));
  }
Exemplo n.º 15
0
bg_plugin_info_t * bg_lv_get_info(const char * filename)
  {
  int i;
  VisVideoAttributeOptions *vidoptions;
  bg_x11_window_t * win;
  bg_plugin_info_t * ret;
  VisPluginRef * ref;
  VisList * list;
  VisActor * actor;
  VisPluginInfo * info;
  char * tmp_string;
  const char * actor_name = NULL;
  check_init();
  
  list = visual_plugin_get_registry();
  /* Find out if there is a plugin matching the filename */
  while((actor_name = visual_actor_get_next_by_name(actor_name)))
    {
    ref = visual_plugin_find(list, actor_name);
    if(ref && !strcmp(ref->file, filename))
      break;
    }
  if(!actor_name)
    return NULL;
  
  actor = visual_actor_new(actor_name);
  
  if(!actor)
    return NULL;

  ret = calloc(1, sizeof(*ret));

  info = visual_plugin_get_info(visual_actor_get_plugin(actor));
    
  
  ret->name        = bg_sprintf("vis_lv_%s", actor_name);
  ret->long_name   = gavl_strdup(info->name);
  ret->type        = BG_PLUGIN_VISUALIZATION;
  ret->api         = BG_PLUGIN_API_LV;
  ret->description = bg_sprintf(TR("libvisual plugin"));
  ret->module_filename = gavl_strdup(filename);
  /* Optional info */
  if(info->author && *info->author)
    {
    tmp_string = bg_sprintf(TR("\nAuthor: %s"),
                            info->author);
    ret->description = gavl_strcat(ret->description, tmp_string);
    free(tmp_string);
    }
  if(info->version && *info->version)
    {
    tmp_string = bg_sprintf(TR("\nVersion: %s"),
                            info->version);
    ret->description = gavl_strcat(ret->description, tmp_string);
    free(tmp_string);
    }
  if(info->about && *info->about)
    {
    tmp_string = bg_sprintf(TR("\nAbout: %s"),
                            info->about);
    ret->description = gavl_strcat(ret->description, tmp_string);
    free(tmp_string);
    }
  if(info->help && *info->help)
    {
    tmp_string = bg_sprintf(TR("\nHelp: %s"),
                            info->help);
    ret->description = gavl_strcat(ret->description, tmp_string);
    free(tmp_string);
    }
  if(info->license && *info->license)
    {
    tmp_string = bg_sprintf(TR("\nLicense: %s"),
                            info->license);
    ret->description = gavl_strcat(ret->description, tmp_string);
    free(tmp_string);
    }
  
  /* Check out if it's an OpenGL plugin */
  if(visual_actor_get_supported_depth(actor) &
     VISUAL_VIDEO_DEPTH_GL)
    {
    ret->flags |=  BG_PLUGIN_VISUALIZE_GL;
    
    win = bg_x11_window_create(NULL);
    
    /* Create an OpenGL context. For this, we need the OpenGL attributes */
    vidoptions = visual_actor_get_video_attribute_options(actor);
    for(i = 0; i < VISUAL_GL_ATTRIBUTE_LAST; i++)
      {
      if((vidoptions->gl_attributes[i].mutated) && (bg_attributes[i] >= 0))
        {
        bg_x11_window_set_gl_attribute(win, bg_attributes[i],
                                       vidoptions->gl_attributes[i].value);
        }
      }
    /* Set bogus dimensions, will be corrected by the size_callback */
    bg_x11_window_set_size(win, 640, 480);
    
    bg_x11_window_realize(win);
    if(!bg_x11_window_start_gl(win))
      {
      ret->flags |=  BG_PLUGIN_UNSUPPORTED;
      }
    else
      bg_x11_window_set_gl(win);
    }
  else
    {
    ret->flags |=  BG_PLUGIN_VISUALIZE_FRAME;
    win = NULL;
    }
  ret->priority = 1;

  /* Must realize the actor to get the parameters */

  if(!(ret->flags & BG_PLUGIN_UNSUPPORTED))
    {
    visual_actor_realize(actor);
    ret->parameters =
      create_parameters(actor, NULL, NULL);
    visual_object_unref(VISUAL_OBJECT(actor));
    }
  
  
  if(win)
    {
    bg_x11_window_unset_gl(win);
    bg_x11_window_stop_gl(win);
    bg_x11_window_destroy(win);
    }
  
  return ret;
  }
Exemplo n.º 16
0
static bg_parameter_info_t *
create_parameters(VisActor * actor, VisUIWidget *** widgets,
                  VisParamEntry *** params_ret)
  {
  int num_parameters, i, index, supported;
  bg_parameter_info_t * ret;
  VisParamContainer * params;
  //  VisHashmapChainEntry *entry;
  VisParamEntry *param_entry;
  VisListEntry * list_entry;
  VisUIWidget * widget;
  VisUIWidget * param_widget;
  
  params = visual_plugin_get_params(visual_actor_get_plugin(actor));
  
  /* Count parameters */
  num_parameters = 0;
  
  list_entry = NULL;

  while(visual_list_next(&params->entries,
                         &list_entry))
    num_parameters++;

  if(!num_parameters)
    return NULL;
  /* Create parameters */
  ret = calloc(num_parameters+1, sizeof(*ret));

  if(widgets)
    *widgets = calloc(num_parameters, sizeof(**widgets));

  if(params_ret)
    *params_ret = calloc(num_parameters, sizeof(**params_ret));
  
  list_entry = NULL;
  index = 0;

  widget = visual_plugin_get_userinterface(visual_actor_get_plugin(actor));
  
  for(i = 0; i < num_parameters; i++)
    {
    visual_list_next(&params->entries, &list_entry);
    param_entry = list_entry->data;
    //    param_entry = VISUAL_PARAMENTRY(entry->data);
    
    if(params_ret)
      (*params_ret)[index] = param_entry;
    
    supported = 1;
    
    if(widget)
      param_widget = check_widget(widget, param_entry->name, &ret[index]);
    else
      param_widget = NULL;
    
    if(!param_widget)
      {
      switch(param_entry->type)
        {
        case VISUAL_PARAM_ENTRY_TYPE_NULL:     /**< No parameter. */
          supported = 0;
          break;
        case VISUAL_PARAM_ENTRY_TYPE_STRING:   /**< String parameter. */
          ret[index].type = BG_PARAMETER_STRING;
          ret[index].val_default.val_str =
            gavl_strrep(ret[index].val_default.val_str,
                      param_entry->string);
          break;
        case VISUAL_PARAM_ENTRY_TYPE_INTEGER:  /**< Integer parameter. */
          ret[index].type = BG_PARAMETER_INT;
          ret[index].flags |= BG_PARAMETER_SYNC;
          ret[index].val_default.val_i = param_entry->numeric.integer;
          break;
        case VISUAL_PARAM_ENTRY_TYPE_FLOAT:    /**< Floating point parameter. */
          ret[index].type = BG_PARAMETER_FLOAT;
          ret[index].flags |= BG_PARAMETER_SYNC;
          ret[index].val_default.val_f = param_entry->numeric.floating;
          break;
        case VISUAL_PARAM_ENTRY_TYPE_DOUBLE:   /**< Double floating point parameter. */
          ret[index].type = BG_PARAMETER_FLOAT;
          ret[index].flags |= BG_PARAMETER_SYNC;
          ret[index].val_default.val_f = param_entry->numeric.doubleflt;
          break;
        case VISUAL_PARAM_ENTRY_TYPE_COLOR:    /**< VisColor parameter. */
          ret[index].type = BG_PARAMETER_COLOR_RGB;
          ret[index].flags |= BG_PARAMETER_SYNC;
          ret[index].val_default.val_color[0] = (float)param_entry->color.r / 255.0;
          ret[index].val_default.val_color[1] = (float)param_entry->color.g / 255.0;
          ret[index].val_default.val_color[2] = (float)param_entry->color.b / 255.0;
          break;
        case VISUAL_PARAM_ENTRY_TYPE_PALETTE:  /**< VisPalette parameter. */
        case VISUAL_PARAM_ENTRY_TYPE_OBJECT:   /**< VisObject parameter. */
        case VISUAL_PARAM_ENTRY_TYPE_END:      /**< List end, and used as terminator for VisParamEntry lists. */
          supported = 0;
          break;
        }
      }
    
    if(widgets)
      (*widgets)[index] = param_widget;
    
    if(!supported)
      continue;
    
    ret[index].name = gavl_strdup(param_entry->name);
    ret[index].long_name = gavl_strdup(param_entry->name);
    index++;
    }
  return ret;
  }