예제 #1
0
/* called from raster_realize() */
static int realize_canvas(raster_t *raster)
{
    video_canvas_t *new_canvas;

    raster->intialized = 1;

    if (!video_disabled_mode) {
        new_canvas = video_canvas_create(raster->canvas,
                                         &raster->canvas->draw_buffer->canvas_width,
                                         &raster->canvas->draw_buffer->canvas_height, 1);

        if (new_canvas == NULL) {
            return -1;
        }

        raster->canvas = new_canvas;

#if defined(USE_SDLUI) || defined(USE_SDLUI2)
        /* A hack to allow raster_force_repaint() calls for SDL UI & vkbd */
        raster->canvas->parent_raster = raster;
#endif

        video_canvas_create_set(raster->canvas);
    }

    if (raster_realize_frame_buffer(raster) < 0) {
        return -1;
    }

    /* The canvas might give us something different from what we
       requested. FIXME: Only do this if really something changed. */
    video_viewport_resize(raster->canvas, 1);
    return 0;
}
예제 #2
0
static int set_double_size_enabled(int val, void *param)
{
    cap_render_t *cap_render;
    video_canvas_t *canvas = (video_canvas_t *)param;
    int old_doublesizex, old_doublesizey;
    video_chip_cap_t *video_chip_cap = canvas->videoconfig->cap;

    if (val) {
        cap_render = &video_chip_cap->double_mode;
    } else {
        cap_render = &video_chip_cap->single_mode;
    }

    canvas->videoconfig->rendermode = cap_render->rmode;

    old_doublesizex = canvas->videoconfig->doublesizex;
    old_doublesizey = canvas->videoconfig->doublesizey;

    if (cap_render->sizex > 1
        && (video_chip_cap->dsize_limit_width == 0
        || (canvas->draw_buffer->canvas_width > 0
        && canvas->draw_buffer->canvas_width
        <= video_chip_cap->dsize_limit_width)))
        canvas->videoconfig->doublesizex = 1;
    else
        canvas->videoconfig->doublesizex = 0;

    if (cap_render->sizey > 1
        && (video_chip_cap->dsize_limit_height == 0
        || (canvas->draw_buffer->canvas_height > 0
        && canvas->draw_buffer->canvas_height
        <= video_chip_cap->dsize_limit_height)))
        canvas->videoconfig->doublesizey = 1;
    else
        canvas->videoconfig->doublesizey = 0;

    /* FIXME: Kludge needed until kind of render and dimensions are
       separated from `rendermode' (which is overloaded currently). */
    if (canvas->videoconfig->rendermode == VIDEO_RENDER_RGB_2X2) {
        if (canvas->videoconfig->doublesizex == 0)
            canvas->videoconfig->rendermode = VIDEO_RENDER_RGB_1X2;
        if (canvas->videoconfig->doublesizex == 0
            && canvas->videoconfig->doublesizey == 0)
            canvas->videoconfig->rendermode = VIDEO_RENDER_RGB_1X1;
    }

    if ((canvas->videoconfig->double_size_enabled != val
        || old_doublesizex != canvas->videoconfig->doublesizex
        || old_doublesizey != canvas->videoconfig->doublesizey)
        && canvas->initialized
        && canvas->viewport->update_canvas > 0) {
        video_viewport_resize(canvas);
    }

    canvas->videoconfig->double_size_enabled = val;

    video_resources_update_ui(canvas);

    return 0;
}
예제 #3
0
static int set_double_size_enabled(int val, void *param)
{
    cap_render_t *cap_render;
    video_canvas_t *canvas = (video_canvas_t *)param;
    int old_doublesizex, old_doublesizey;
    video_chip_cap_t *video_chip_cap = canvas->videoconfig->cap;

    if (val) {
        cap_render = &video_chip_cap->double_mode;
    } else {
        cap_render = &video_chip_cap->single_mode;
    }

    canvas->videoconfig->rendermode = cap_render->rmode;

    old_doublesizex = canvas->videoconfig->doublesizex;
    old_doublesizey = canvas->videoconfig->doublesizey;

    if (cap_render->sizex > 1
        && (video_chip_cap->dsize_limit_width == 0
            || (canvas->draw_buffer->canvas_width
                   <= video_chip_cap->dsize_limit_width))
        ) {
        canvas->videoconfig->doublesizex = (cap_render->sizex - 1);
    } else {
        canvas->videoconfig->doublesizex = 0;
    }

    if (cap_render->sizey > 1
        && (video_chip_cap->dsize_limit_height == 0
            || (canvas->draw_buffer->canvas_height
                   <= video_chip_cap->dsize_limit_height))
        ) {
        canvas->videoconfig->doublesizey = (cap_render->sizey - 1);
    } else {
        canvas->videoconfig->doublesizey = 0;
    }


    DBG(("set_double_size_enabled sizex:%d sizey:%d doublesizex:%d doublesizey:%d rendermode:%d", cap_render->sizex, cap_render->sizey, canvas->videoconfig->doublesizex, canvas->videoconfig->doublesizey, canvas->videoconfig->rendermode));

    if ((canvas->videoconfig->double_size_enabled != val
         || old_doublesizex != canvas->videoconfig->doublesizex
         || old_doublesizey != canvas->videoconfig->doublesizey)
        && canvas->initialized
        && canvas->viewport->update_canvas > 0) {
        video_viewport_resize(canvas, 1);
    }

    canvas->videoconfig->double_size_enabled = val;

    video_resources_update_ui(canvas);

    return 0;
}
예제 #4
0
int vidmode_enable(struct video_canvas_s *canvas, int enable)
{
#ifdef HAVE_FULLSCREEN
    Display *vm_display;
    Window shellwin;

    if (vm_available == 0) {
        return 0;
    }

    vm_display = x11ui_get_display_ptr();

    if (enable) {
        vm_is_enabled = 0;
        log_message(vidmode_log, "Enabling Vidmode with%s", vm_bestmodes[vidmode_selected_mode].name);
        vm = vm_modes[vm_bestmodes[vidmode_selected_mode].modeindex];

        saved_w = canvas->draw_buffer->canvas_width;
        saved_h = canvas->draw_buffer->canvas_height;

        vidmode_resize_canvas(canvas, canvas->fullscreenconfig->ui_border_top > 0);
        XF86VidModeSwitchToMode(vm_display, screen, vm);
        vidmode_center_canvas(canvas);
        XWarpPointer(vm_display, None, DefaultRootWindow(vm_display), 0, 0, vm->hdisplay, vm->vdisplay, x + vm->hdisplay / 2, y + vm->vdisplay / 2);

        /* grab the pointer */
        shellwin = x11ui_get_X11_window();
        XGrabPointer(vm_display, shellwin, 1, PointerMotionMask | ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, shellwin, None, CurrentTime);

        active_canvas = canvas;
        vm_is_enabled = 1;
        vm_is_suspended = 0;
    } else {
        if (!vm_is_enabled) {
            return 0;
        }
        log_message(vidmode_log, "Disabling Vidmode");

        /* FIXME: don't ungrab if either mouse or lightpen emulation is enabled */
        XUngrabPointer(vm_display, CurrentTime);
        XUngrabKeyboard(vm_display, CurrentTime);

        XF86VidModeSwitchToMode(vm_display, screen, vm_modes[0]);

        /* restore canvas size for windowed mode */
        canvas->draw_buffer->canvas_width = saved_w;
        canvas->draw_buffer->canvas_height = saved_h;
        video_viewport_resize(canvas);
        vm_is_enabled = 0;
    }
#endif
    return 0;
}
예제 #5
0
static int perform_mode_change(raster_t *raster)
{
    if (!video_disabled_mode
        && raster->canvas && raster->canvas->palette != NULL) {
        if (video_canvas_set_palette(raster->canvas, raster->canvas->palette) < 0) {
            return -1;
        }
    }
    raster_force_repaint(raster);

    video_viewport_resize(raster->canvas, 1);

    return 0;
}
예제 #6
0
void video_canvas_redraw_size(video_canvas_t *canvas, unsigned int width, unsigned int height)
{
	if (canvas->videoconfig->doublesizex)
		width /= 2;
	if (canvas->videoconfig->doublesizey)
		height /= 2;

	if (width != canvas->draw_buffer->canvas_width || height != canvas->draw_buffer->canvas_height)
	{
		canvas->draw_buffer->canvas_width = width;
		canvas->draw_buffer->canvas_height = height;
		video_viewport_resize(canvas);
	}
	video_canvas_refresh_all(canvas);
}
예제 #7
0
파일: crtc.c 프로젝트: SMTDDR/droidsound
void crtc_set_screen_options(int num_cols, int rasterlines)
{
    crtc.screen_width = (num_cols + CRTC_EXTRA_COLS) * 8 + 2 * CRTC_SCREEN_BORDERWIDTH;
    crtc.screen_height = rasterlines + CRTC_EXTRA_RASTERLINES + 2 * CRTC_SCREEN_BORDERHEIGHT;

    DBG(("crtc_set_screen_options: cols=%d, rl=%d -> w=%d, h=%d",
              num_cols, rasterlines, crtc.screen_width, crtc.screen_height));

    crtc_update_window();
    resources_touch("CrtcDoubleSize");

    if (crtc.raster.canvas != NULL) {
        video_viewport_resize(crtc.raster.canvas, 1);
    }
}
예제 #8
0
static void vidmode_resize_canvas(struct video_canvas_s *canvas, int uienable)
{
        int status_h = 0;
        int fs_h, fs_w;
        Display *vm_display;

    if (vm_available == 0) {
        return;
    }

    vm_display = x11ui_get_display_ptr();

#ifdef HAVE_FULLSCREEN
    if (uienable) {
        status_h = canvas->fullscreenconfig->ui_border_top + canvas->fullscreenconfig->ui_border_bottom;
    }
#endif

    /* fs_w = ((float)vm->hdisplay * get_aspect(canvas)); */
    fs_h = vm->vdisplay;
    fs_w = vm->hdisplay;

    if (canvas->videoconfig->doublesizex) {
        xoffs = ((fs_w) - (vm->hdisplay));
        fs_w /= 2;
    } else {
        xoffs = (fs_w / 2) - (vm->hdisplay / 2);
    }

    if (canvas->videoconfig->doublesizey) {
        yoffs = ((fs_h) - (vm->vdisplay));
        fs_h -= status_h;
        fs_h /= 2;
    } else {
        yoffs = (fs_h / 2) - (vm->vdisplay / 2);
        fs_h -= status_h;
    }

    fs_w += (EXTRA_BORDER * 2);
    fs_h += (EXTRA_BORDER * 2);
    xoffs += EXTRA_BORDER;
    yoffs += EXTRA_BORDER;

    canvas->draw_buffer->canvas_width = fs_w;
    canvas->draw_buffer->canvas_height = fs_h;
    video_viewport_resize(canvas);
    ui_dispatch_events();
}
예제 #9
0
static int set_hwscale_enabled(int val, void *param)
{
    video_canvas_t *canvas = (video_canvas_t *)param;

    if (val
        && !canvas->videoconfig->hwscale
        && !hwscale_possible) {
        log_message(LOG_DEFAULT, "HW scale not available, forcing to disabled");
        return 0;
    }

    canvas->videoconfig->hwscale = val;
    canvas->videoconfig->color_tables.updated = 0;

    if (canvas->initialized) {
        video_viewport_resize(canvas, 1);
    }
    return 0;
}
예제 #10
0
static int perform_mode_change(raster_t *raster)
{
    if (!video_disabled_mode
        && raster->canvas && raster->canvas->palette != NULL) {
        if (video_canvas_set_palette(raster->canvas,
            raster->canvas->palette) < 0)
            return -1;
    }
    raster_force_repaint(raster);

    /* FIXME: `video_viewport_resize()' already calls
       `video_canvas_resize()'. */
    video_canvas_resize(raster->canvas,
                        raster->canvas->draw_buffer->canvas_width,
                        raster->canvas->draw_buffer->canvas_height);
    video_viewport_resize(raster->canvas);

    return 0;
}
예제 #11
0
static int set_hwscale_enabled(int val, void *param)
{
    video_canvas_t *canvas = (video_canvas_t *)param;

    if (val && !canvas->videoconfig->hwscale && !hwscale_possible)
    {
    	#ifdef CELL_DEBUG
        printf("INFO - HW scale not available, forcing to disabled\n");
	#endif
        return 0;
    }

    canvas->videoconfig->hwscale = val;

    if (canvas->initialized) {
        video_viewport_resize(canvas);
        video_color_update_palette(canvas);
    }

    video_resources_update_ui(canvas);

    return 0;
}
예제 #12
0
static int fullscreen_enable(struct video_canvas_s *canvas, int enable)
{
    SDL_Event e;
    int count;

    DBG(("%s: %i", __func__, enable));

    if (!canvas->fullscreenconfig->device_set) {
        return 0;
    }

    canvas->fullscreenconfig->enable = enable;

    ui_check_mouse_cursor();

    if (canvas->initialized) {
        /* resize window back to normal when leaving fullscreen */
        video_viewport_resize(canvas, 1);
        /* HACK: when switching from/to fullscreen using hotkey (alt+d), some
                 spurious keyup/keydown events fire for the keys being held
                 down while switching modes. the following tries to get rid
                 of these events, so "alt-d" doesnt end up in the emulated machine.
        */
        count = 10; while (count--) {
            while (SDL_PollEvent(&e)) {
                switch (e.type) {
                    case SDL_KEYDOWN:
                    case SDL_KEYUP:
                        sdlkbd_release(SDL2x_to_SDL1x_Keys(e.key.keysym.sym), e.key.keysym.mod);
                        break;
                }
            }
            SDL_Delay(20);
        }
    }
    return 0;
}