示例#1
0
int main (int argc, char **argv)
{
	VisVideo *dest, *src;
	int i;

	visual_init (&argc, &argv);

	dest = visual_video_new ();
	visual_video_set_depth (dest, DEPTH);
	visual_video_set_dimension (dest, 640, 400);
	visual_video_allocate_buffer (dest);

	src = visual_video_new ();
	visual_video_set_depth (src, DEPTH);
	visual_video_set_dimension (src, 320, 200);
	visual_video_allocate_buffer (src);

	for (i = 0; i < TIMES; i++)
		visual_video_scale (dest, src, INTERPOL);

	printf ("Scale bench overlay %d times, depth %d, interpol %d\n", TIMES,
			DEPTH, INTERPOL);

	return EXIT_SUCCESS;
}
示例#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;
}
示例#3
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;
}
示例#4
0
文件: bglv.c 项目: Jheengut/gmerlin
static void size_changed(void * data, int width, int height)
  {
  lv_priv_t * priv;
  priv = (lv_priv_t*)data;
  visual_video_set_dimension(priv->video, width, height);
  visual_actor_set_video(priv->actor, priv->video);
  visual_actor_video_negotiate(priv->actor, 0, FALSE, FALSE);
  }
示例#5
0
    static void
    resize( int width, int height )
    {
        visual_video_set_dimension( video, width, height );

        SDL::create( width, height );

        visual_bin_sync( bin, false );
    }
extern "C" int lv_projectm_dimension (VisPluginData *plugin, VisVideo *video, int width, int height)
{
	ProjectmPrivate *priv = (ProjectmPrivate*)visual_object_get_private (VISUAL_OBJECT (plugin));

	visual_video_set_dimension (video, width, height);

	priv->PM->projectM_resetGL( width, height );

	return 0;
}
static gboolean
gst_visual_setup (GstAudioVisualizer * bscope)
{
  GstVisual *visual = GST_VISUAL (bscope);
  gint depth;

  gst_visual_clear_actors (visual);

  /* FIXME: we need to know how many bits we actually have in memory */
  depth = bscope->vinfo.finfo->pixel_stride[0];
  if (bscope->vinfo.finfo->bits >= 8) {
    depth *= 8;
  }

  visual->actor =
      visual_actor_new (GST_VISUAL_GET_CLASS (visual)->plugin->info->plugname);
  visual->video = visual_video_new ();
  visual->audio = visual_audio_new ();
  /* can't have a play without actors */
  if (!visual->actor || !visual->video)
    goto no_actors;

  if (visual_actor_realize (visual->actor) != 0)
    goto no_realize;

  visual_actor_set_video (visual->actor, visual->video);

  visual_video_set_depth (visual->video,
      visual_video_depth_enum_from_value (depth));
  visual_video_set_dimension (visual->video,
      GST_VIDEO_INFO_WIDTH (&bscope->vinfo),
      GST_VIDEO_INFO_HEIGHT (&bscope->vinfo));
  visual_actor_video_negotiate (visual->actor, 0, FALSE, FALSE);

  GST_DEBUG_OBJECT (visual, "WxH: %dx%d, bpp: %d, depth: %d",
      GST_VIDEO_INFO_WIDTH (&bscope->vinfo),
      GST_VIDEO_INFO_HEIGHT (&bscope->vinfo), visual->video->bpp, depth);

  return TRUE;
  /* ERRORS */
no_actors:
  {
    GST_ELEMENT_ERROR (visual, LIBRARY, INIT, (NULL),
        ("could not create actors"));
    gst_visual_clear_actors (visual);
    return FALSE;
  }
no_realize:
  {
    GST_ELEMENT_ERROR (visual, LIBRARY, INIT, (NULL),
        ("could not realize actor"));
    gst_visual_clear_actors (visual);
    return FALSE;
  }
}
示例#8
0
int visual_video_copy_attrs (VisVideo *dest, VisVideo *src)
{
	visual_return_val_if_fail (dest != NULL, -VISUAL_ERROR_VIDEO_NULL);
	visual_return_val_if_fail (src != NULL, -VISUAL_ERROR_VIDEO_NULL);

	visual_video_set_depth (dest, src->depth);
	visual_video_set_dimension (dest, src->width, src->height);
	visual_video_set_pitch (dest, src->pitch);

	return VISUAL_OK;
}
示例#9
0
    static void
    init( int &argc, char **&argv )
    {
        VisVideoDepth depth;

        visual_init( &argc, &argv );

        bin    = visual_bin_new ();
        depth  = visual_video_depth_enum_from_value( 24 );

        if( !plugin ) plugin = visual_actor_get_next_by_name( 0 );
        if( !plugin ) exit( "Actor plugin not found!" );

        visual_bin_set_supported_depth( bin, VISUAL_VIDEO_DEPTH_ALL );

        if( NULL == (video = visual_video_new()) )       exit( "Cannot create a video surface" );
        if( visual_video_set_depth( video, depth ) < 0 ) exit( "Cannot set video depth" );

        visual_video_set_dimension( video, 320, 200 );

        if( visual_bin_set_video( bin, video ) ) exit( "Cannot set video" );

        visual_bin_connect_by_names( bin, (char*)plugin, 0 );

        if( visual_bin_get_depth( bin ) == VISUAL_VIDEO_DEPTH_GL )
        {
            visual_video_set_depth( video, VISUAL_VIDEO_DEPTH_GL );
            pluginIsGL = true;
        }

        SDL::create( 320, 200 );

        SDL_WM_SetCaption( plugin, 0 );

        /* Called so the flag is set to false, seen we create the initial environment here */
        visual_bin_depth_changed( bin );

        VisInput *input = visual_bin_get_input( bin );
        if( visual_input_set_callback( input, upload_callback, NULL ) < 0 ) exit( "Cannot set input plugin callback" );

        visual_bin_switch_set_style( bin, VISUAL_SWITCH_STYLE_MORPH );
        visual_bin_switch_set_automatic( bin, true );
        visual_bin_switch_set_steps( bin, 100 );

        visual_bin_realize( bin );
        visual_bin_sync( bin, false );

        std::cout << "[PANA] Libvisual version " << visual_get_version() << '\n';
        std::cout << "[PANA] bpp: " << video->bpp << std::endl;
        std::cout << "[PANA]  GL: "  << (pluginIsGL ? "true\n" : "false\n");
    }
示例#10
0
int main (int argc, char **argv)
{
	char *d1, *d2;
	VisVideo *dest, *src;
	VisVideoDepth depth1, depth2;
	int i;

	visual_init (&argc, &argv);

	if (argc > 2) {
		d1 = argv[1];
		d2 = argv[2];
	} else {
		d1 = strdup("32");
		d2 = strdup("16");
	}

	depth1 = visual_video_depth_enum_from_value(atoi(d1));
	depth2 = visual_video_depth_enum_from_value(atoi(d2));

	dest = visual_video_new ();
	visual_video_set_depth (dest, depth1);
	visual_video_set_dimension (dest, 640, 400);
	visual_video_set_palette (dest, visual_palette_new (256));
	visual_video_allocate_buffer (dest);

	src = visual_video_new ();
	visual_video_set_depth (src, depth2);
	visual_video_set_dimension (src, 640, 400);
	visual_video_set_palette (src, visual_palette_new (256));
	visual_video_allocate_buffer (src);

	for (i = 0; i < TIMES; i++)
		visual_video_depth_transform (dest, src);

	printf ("Depth transformed %d times from %s to %s\n", TIMES, d1, d2);
}
int main (int argc, char **argv)
{
	float rate = 0.0;
	VisMorph *morph;
	VisAudio audio;
	VisVideo *dest, *src1, *src2;
	int i;

	visual_init (&argc, &argv);

	if (argc < 2)
		morph = visual_morph_new ("alphablend");
	else
		morph = visual_morph_new (argv[1]);

	visual_morph_realize (morph);

	dest = visual_video_new ();

	visual_video_set_depth (dest, DEPTH);
	visual_video_set_dimension (dest, 640, 400);
	visual_video_allocate_buffer (dest);

	src1 = visual_video_new ();
	src2 = visual_video_new ();

	visual_video_copy_attrs (src1, dest);
	visual_video_copy_attrs (src2, dest);

	visual_video_allocate_buffer (src1);
	visual_video_allocate_buffer (src2);

	visual_morph_set_video (morph, dest);
	for (i = 0; i < TIMES; i++) {
		visual_morph_set_rate (morph, rate);
		visual_morph_run (morph, &audio, src1, src2);

		rate += 0.1;

		if (rate > 1.0)
			rate = 0.0;
	}

	printf ("Morph throughput bench %d times depthBPP %d morph: %s\n", TIMES, dest->bpp,
			(visual_plugin_get_info (visual_morph_get_plugin (morph)))->plugname);

	return EXIT_SUCCESS;
}
示例#12
0
static int native_getvideo (SADisplay *display, VisVideo *screen)
{
        SDLNative *native = SDL_NATIVE (display->native);
        SDL_Surface *sdlscreen = native->screen;

        if (native->requested_depth == VISUAL_VIDEO_DEPTH_GL)
                visual_video_set_depth (screen, VISUAL_VIDEO_DEPTH_GL);
        else
                visual_video_set_depth (screen, visual_video_depth_enum_from_value (sdlscreen->format->BitsPerPixel));

        visual_video_set_dimension (screen, sdlscreen->w, sdlscreen->h);
        visual_video_set_pitch (screen, sdlscreen->pitch);
        visual_video_set_buffer (screen, sdlscreen->pixels);

        return 0;
}
示例#13
0
static gboolean
gst_visual_src_setcaps (GstPad * pad, GstCaps * caps)
{
  GstVisual *visual = GST_VISUAL (gst_pad_get_parent (pad));
  GstStructure *structure;
  gint depth, pitch;

  structure = gst_caps_get_structure (caps, 0);

  GST_DEBUG_OBJECT (visual, "src pad got caps %" GST_PTR_FORMAT, caps);

  if (!gst_structure_get_int (structure, "width", &visual->width))
    goto error;
  if (!gst_structure_get_int (structure, "height", &visual->height))
    goto error;
  if (!gst_structure_get_int (structure, "bpp", &depth))
    goto error;
  if (!gst_structure_get_fraction (structure, "framerate", &visual->fps_n,
          &visual->fps_d))
    goto error;

  visual_video_set_depth (visual->video,
      visual_video_depth_enum_from_value (depth));
  visual_video_set_dimension (visual->video, visual->width, visual->height);
  pitch = GST_ROUND_UP_4 (visual->width * visual->video->bpp);
  visual_video_set_pitch (visual->video, pitch);
  visual_actor_video_negotiate (visual->actor, 0, FALSE, FALSE);

  /* precalc some values */
  visual->outsize = visual->video->height * pitch;
  visual->spf =
      gst_util_uint64_scale_int (visual->rate, visual->fps_d, visual->fps_n);
  visual->duration =
      gst_util_uint64_scale_int (GST_SECOND, visual->fps_d, visual->fps_n);

  gst_object_unref (visual);
  return TRUE;

  /* ERRORS */
error:
  {
    GST_DEBUG_OBJECT (visual, "error parsing caps");
    gst_object_unref (visual);
    return FALSE;
  }
}
示例#14
0
文件: bglv.c 项目: Jheengut/gmerlin
static int
open_ov_lv(void * data, gavl_audio_format_t * audio_format,
           gavl_video_format_t * video_format)
  {
  int depths, depth;
  lv_priv_t * priv;
  priv = (lv_priv_t*)data;
  adjust_audio_format(audio_format);
  
  /* Get the depth */
  depths = visual_actor_get_supported_depth(priv->actor);

  if(depths & VISUAL_VIDEO_DEPTH_32BIT)    /**< 32 bits surface flag. */
    {
    video_format->pixelformat = GAVL_BGR_32;
    depth = VISUAL_VIDEO_DEPTH_32BIT;
    }
  else if(depths & VISUAL_VIDEO_DEPTH_24BIT)    /**< 24 bits surface flag. */
    {
    video_format->pixelformat = GAVL_BGR_24;
    depth = VISUAL_VIDEO_DEPTH_24BIT;
    }
  else if(depths & VISUAL_VIDEO_DEPTH_16BIT)    /**< 16 bits 5-6-5 surface flag. */
    {
    video_format->pixelformat = GAVL_RGB_16;
    depth = VISUAL_VIDEO_DEPTH_16BIT;
    }
  else if(depths & VISUAL_VIDEO_DEPTH_8BIT)    /**< 8 bits indexed surface flag. */
    {
    video_format->pixelformat = GAVL_BGR_24;
    depth = VISUAL_VIDEO_DEPTH_24BIT;
    }
  else
    return 0;
  
  visual_video_set_depth(priv->video, depth);
  visual_video_set_dimension(priv->video,
                             video_format->image_width,
                             video_format->image_height);
  
  visual_actor_set_video(priv->actor, priv->video);
  visual_actor_video_negotiate(priv->actor,
                               0, FALSE, FALSE);
  return 1;
  }
示例#15
0
static void
actor_negotiate (GstGLDisplay * display, GstVisualGL * visual)
{
  gint err = VISUAL_OK;

  err = visual_video_set_depth (visual->video, VISUAL_VIDEO_DEPTH_GL);
  if (err != VISUAL_OK)
    g_warning ("failed to visual_video_set_depth\n");

  err =
      visual_video_set_dimension (visual->video, visual->width, visual->height);
  if (err != VISUAL_OK)
    g_warning ("failed to visual_video_set_dimension\n");

  err = visual_actor_video_negotiate (visual->actor, 0, FALSE, FALSE);
  if (err != VISUAL_OK)
    g_warning ("failed to visual_actor_video_negotiate\n");
}
示例#16
0
VisVideo *visual_video_new_with_buffer (int width, int height, VisVideoDepth depth)
{
	VisVideo *video;
	int ret;

	video = visual_video_new ();

	visual_video_set_depth (video, depth);
	visual_video_set_dimension (video, width, height);

	ret = visual_video_allocate_buffer (video);

	if (ret < 0) {
		visual_object_unref (VISUAL_OBJECT (video));

		return NULL;
	}

	return video;
}
示例#17
0
int main (int argc, char **argv)
{
	VisVideo *dest, *src;
	int i;
	
	visual_init (&argc, &argv);

	dest = visual_video_new ();
	visual_video_set_depth (dest, VISUAL_VIDEO_DEPTH_32BIT);
	visual_video_set_dimension (dest, 640, 400);
	visual_video_allocate_buffer (dest);

	src = visual_video_new ();
	visual_video_clone (src, dest);
	visual_video_allocate_buffer (src);

	for (i = 0; i < TIMES; i++)
		visual_video_blit_overlay (dest, src, 0, 0, TRUE);

	printf ("Blit overlay %d times\n", TIMES);
}
示例#18
0
文件: bglv.c 项目: Jheengut/gmerlin
static int
open_gl_lv(void * data, gavl_audio_format_t * audio_format,
           const char * window_id)
  {
  int width, height;
  
  lv_priv_t * priv;
  priv = (lv_priv_t*)data;

  visual_video_set_depth(priv->video, VISUAL_VIDEO_DEPTH_GL);
  
  adjust_audio_format(audio_format);

    
  gavl_audio_format_copy(&priv->audio_format, audio_format);
  
  bg_x11_window_set_gl(priv->win);
  visual_actor_set_video(priv->actor, priv->video);
  bg_x11_window_unset_gl(priv->win);
  
  /* Set the size changed callback after initializing the libvisual stuff */
  bg_x11_window_set_callbacks(priv->win, &priv->window_callbacks);
  bg_x11_window_show(priv->win, 1);

  
  bg_x11_window_set_gl(priv->win);
  
  bg_x11_window_get_size(priv->win, &width, &height);
  
  /* We cannot use the size callback above since it's called before the
     actor is realized */
  visual_video_set_dimension(priv->video, width, height);
  visual_actor_video_negotiate(priv->actor, 0, FALSE, FALSE);
  
  bg_x11_window_unset_gl(priv->win);
  return 1;
  }
示例#19
0
/* Main stuff */
int main (int argc, char *argv[])
{
	int width = 1000, height = 600;
	int i, j;
	int freeze = 0;
	int depthflag = 0;
	int alpha = 190;
	int xoff = 0, yoff = -90;
	int sxsize = 1000;
	int sysize = 700;
	int interpol = VISUAL_VIDEO_SCALE_NEAREST;
        int frames = 0;
	VisTime start, end;
		
	bpp = 4;
	sdl_init (width, height);

	scrbuf = malloc (screen->pitch * screen->h);
	memset (scrbuf, 0, screen->pitch * screen->h);

	SDL_Event event;

	visual_init (&argc, &argv);
	
	if (argc > 1)
		actor = visual_actor_new (argv[1]);
	else
		actor = visual_actor_new ("corona");

	visual_actor_realize (actor);

	video = visual_video_new ();

	if (argc > 2)
		video = visual_bitmap_load_new_video (argv[2]);
	else
		video = visual_bitmap_load_new_video ("bg.bmp");

	actvid = visual_video_new ();
	visual_actor_set_video (actor, actvid);
	visual_video_set_depth (actvid, visual_video_depth_get_highest (visual_actor_get_supported_depth (actor)));
	visual_video_set_dimension (actvid, width, height);
	visual_video_allocate_buffer (actvid);

	visual_actor_video_negotiate (actor, 0, FALSE, FALSE);

	video32 = visual_video_new ();
	visual_video_set_depth (video32, VISUAL_VIDEO_DEPTH_32BIT);
	visual_video_set_dimension (video32, video->width, video->height);
	visual_video_allocate_buffer (video32);
	
	scalevid = visual_video_new ();
	visual_video_set_depth (scalevid, VISUAL_VIDEO_DEPTH_32BIT);
	visual_video_set_dimension (scalevid, sxsize, sysize);
	visual_video_allocate_buffer (scalevid);

	sdlvid = visual_video_new ();
	visual_video_set_depth (sdlvid, VISUAL_VIDEO_DEPTH_32BIT);
	visual_video_set_dimension (sdlvid, screen->w, screen->h);
	visual_video_set_pitch (sdlvid, screen->pitch);
	visual_video_set_buffer (sdlvid, scrbuf);
	
	input = visual_input_new ("xmms2");
	visual_input_realize (input);

	SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
        
	visual_time_get (&start);
	
	while (1) {
		visual_input_run (input);
		visual_actor_run (actor, input->audio);
	
		/* place on screen */
//		visual_video_blit_overlay (sdlvid, video, 0, 0, FALSE);
	
		if (sxsize < 0)
			sxsize = 0;

		if (sysize < 0)
			sysize = 0;
		
		if (sxsize != scalevid->width || sysize != scalevid->height) {
			visual_video_set_dimension (scalevid, sxsize, sysize);
			visual_video_allocate_buffer (scalevid);
		}

		visual_video_depth_transform (video32, video);


//		visual_video_alpha_fill (sdlvid, 0);
		
//		visual_video_alpha_fill (video32, alpha);
//		visual_video_alpha_color (video32, 0, 0, 0, 255);
	

		do_alpha (video32, alpha);
		visual_video_scale (scalevid, video32, interpol);

		
		visual_video_blit_overlay (sdlvid, actvid, 0, 0, FALSE);
		visual_video_blit_overlay (sdlvid, scalevid, xoff, yoff, TRUE);

		sdl_draw_buf ();
		frames++;
		
		while (SDL_PollEvent (&event)) {
			switch (event.type) {
				case SDL_KEYDOWN:
					switch (event.key.keysym.sym) {
						case SDLK_F11:
							SDL_WM_ToggleFullScreen (screen);
							break;

						case SDLK_UP:
							yoff -= 10;

							break;

						case SDLK_DOWN:
							yoff += 10;

							break;
						
						case SDLK_LEFT:
							xoff -= 10;

							break;

						case SDLK_RIGHT:
							xoff += 10;

							break;
						
						case SDLK_q:
							sysize -= 10;

							break;

						case SDLK_a:
							sysize += 10;

							break;
						
						case SDLK_z:
							sxsize -= 10;

							break;

						case SDLK_x:
							sxsize += 10;

							break;

						case SDLK_i:
							if (interpol == VISUAL_VIDEO_SCALE_NEAREST)
								interpol = VISUAL_VIDEO_SCALE_BILINEAR;
							else
								interpol = VISUAL_VIDEO_SCALE_NEAREST;
							
							break;

						case SDLK_o:
							alpha -= 8;
							if (alpha < 0)
								alpha = 0;

							break;

						case SDLK_p:
							alpha += 8;
							if (alpha > 255)
								alpha = 255;

							break;
							
						case SDLK_ESCAPE:
							goto out;
							break;
					}
					break;

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

				case SDL_QUIT:
					goto out;
					break;
			}
		}
	}
out:
	visual_time_get (&end);
	
	VisTime diff;

	visual_time_difference (&diff, &start, &end);


	printf ("Ran: %d:%d, drawn %d frames\n",
			diff.tv_sec, diff.tv_usec, frames);

	SDL_Quit ();
}
示例#20
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;
}
示例#21
0
/* Main stuff */
int main (int argc, char *argv[])
{
	int width = 1000, height = 600;
	int i, j;
	int freeze = 0;
	int depthflag = 0;
	int alpha = 128;

	bpp = 4;
	sdl_init (width, height);

	scrbuf = malloc (screen->pitch * screen->h);
	memset (scrbuf, 0, screen->pitch * screen->h);

	SDL_Event event;

	visual_init (&argc, &argv);
	
	if (argc > 1)
		actor = visual_actor_new (argv[1]);
	else
		actor = visual_actor_new ("G-Force");

	visual_actor_realize (actor);

	video = visual_video_new ();
	
	visual_actor_set_video (actor, video);
	visual_video_set_depth (video, VISUAL_VIDEO_DEPTH_32BIT);
	visual_video_set_dimension (video, 256, 256);
	visual_video_allocate_buffer (video);

	visual_actor_video_negotiate (actor, 0, FALSE, FALSE);

	scalevid = visual_video_new ();
	visual_video_set_depth (scalevid, VISUAL_VIDEO_DEPTH_32BIT);
	visual_video_set_dimension (scalevid, 300, 400);
	visual_video_allocate_buffer (scalevid);

	sdlvid = visual_video_new ();
	visual_video_set_depth (sdlvid, VISUAL_VIDEO_DEPTH_32BIT);
	visual_video_set_dimension (sdlvid, screen->w, screen->h);
	visual_video_set_pitch (sdlvid, screen->pitch);
	visual_video_set_buffer (sdlvid, scrbuf);
	
	input = visual_input_new ("alsa");
	visual_input_realize (input);
	
	while (1) {
		visual_input_run (input);
		visual_actor_run (actor, input->audio);
		
		/* place on screen */
		visual_video_blit_overlay (sdlvid, video, 0, 0, FALSE);

		visual_video_set_palette (scalevid, visual_actor_get_palette (actor));	

		visual_video_scale (scalevid, video, VISUAL_VIDEO_SCALE_BILINEAR);

		visual_video_blit_overlay (sdlvid, scalevid, 256, 0, FALSE);

		sdl_draw_buf ();
		
		usleep (5000);
		
		while (SDL_PollEvent (&event)) {
			switch (event.type) {
				case SDL_KEYDOWN:
					switch (event.key.keysym.sym) {
						case SDLK_F11:
							sdl_fullscreen_toggle ();
							break;

						case SDLK_q:
							alpha -= 8;
							if (alpha < 0)
								alpha = 0;

							break;

						case SDLK_a:
							alpha += 8;
							if (alpha > 255)
								alpha = 255;

							break;
						
						case SDLK_ESCAPE:
							goto out;
							break;
					}
					break;

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

				case SDL_QUIT:
					goto out;
					break;
			}
		}
	}
out:
	SDL_Quit ();
}