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
static int native_drainevents (SADisplay *display, VisEventQueue *eventqueue)
{
        SDLNative *native = SDL_NATIVE (display->native);
        SDL_Event event;

        /* Visible or not */
        if (((SDL_GetAppState () & SDL_APPACTIVE) == 0) && (native->active == TRUE)) {
                native->active = FALSE;
                visual_event_queue_add_visibility (eventqueue, FALSE);
        } else if (((SDL_GetAppState () & SDL_APPACTIVE) != 0) && (native->active == FALSE)) {
                native->active = TRUE;
                visual_event_queue_add_visibility (eventqueue, TRUE);
        }

        /* Events */
        while (SDL_PollEvent (&event)) {

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

                        case SDL_KEYDOWN:
                                visual_event_queue_add_keyboard (eventqueue, event.key.keysym.sym, event.key.keysym.mod,
                                                                 VISUAL_KEY_DOWN);
                                break;

                        case SDL_VIDEORESIZE:
                                visual_event_queue_add_resize (eventqueue, display->screen, event.resize.w, event.resize.h);

                                native_create (display, display->screen->depth, NULL, event.resize.w, event.resize.h, native->resizable);
                                break;

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

                        case SDL_MOUSEBUTTONDOWN:
                                visual_event_queue_add_mousebutton (eventqueue, event.button.button, VISUAL_MOUSE_DOWN,
                                                                    event.button.x, event.button.y);
                                break;

                        case SDL_MOUSEBUTTONUP:
                                visual_event_queue_add_mousebutton (eventqueue, event.button.button, VISUAL_MOUSE_UP,
                                                                    event.button.x, event.button.y);
                                break;

                        case SDL_QUIT:
                                visual_event_queue_add_quit (eventqueue, FALSE);
                                break;

                        default:
                                break;
                }
        }

        return 0;
}
Exemplo n.º 3
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.º 4
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;
}