示例#1
0
文件: video.c 项目: martinpiper/VICE
video_canvas_t *video_canvas_create(video_canvas_t *canvas, 
		unsigned int *width, unsigned int *height, int mapped)
{
	static int vicii_setup=0;

	display_width=320;

	canvas->depth=8;
	canvas->width=320;
	canvas->height=240;

	video_canvas_set_palette(canvas, canvas->palette);

	if (vicii_setup_delay==1)
	{
		if (!vicii_setup) canvas->width=0;
		vicii_setup=1;
	}

	tvout_pal=1;
	if(gp2x_memregs[0x2800>>1]&0x100) {
		tvout=1;
		hwscaling=1;
		if(gp2x_memregs[0x2818>>1]==239) tvout_pal=0;
		printf("\n0x2818=%d\n", gp2x_memregs[0x2818>>1]);
		display_set();
	}

	current_canvas=canvas;
	return canvas;
}
示例#2
0
video_canvas_t video_canvas_create(const char *title, UINT *width,
                             UINT *height, int mapped,
                             canvas_redraw_t exposure_handler,
                             const palette_t *palette,
                             struct video_frame_buffer_s *fb)
{
    video_canvas_t canvas_new;

    DEBUG(("Creating canvas width=%d height=%d", *width, *height));

    if (palette->num_entries > 255) {
       log_error(video_log, "Too many colors requested.");
       return (video_canvas_t) NULL;
    }

    vidlog("canvas alloc",1);
    canvas_new = lib_calloc(1,sizeof(struct _canvas));
    if (!canvas_new) return (video_canvas_t) NULL;

    canvas_new->init_ready       =  FALSE;  // canvas_new not yet initialized
    canvas_new->width            = *width;
    canvas_new->height           = *height;
    canvas_new->pbmi_initialized =  FALSE;  // pbmi not yet initialized

    rc=DosCreateMutexSem("\\SEM32\\GFX", &hmtx, 0, FALSE); // gfx init begin
    vidlog("Create: ",rc);
    _beginthread(PM_mainloop,NULL,0x4000,&canvas_new);

    while (!canvas_new->pbmi_initialized) DosSleep(1);
    video_canvas_set_palette(canvas_new, palette);

    canvas_new->exposure_handler = exposure_handler;
    return canvas_new;
}
示例#3
0
static void init_xv_settings(video_canvas_t *canvas)
{
    /* Find XVideo color setting limits. */
    if (canvas->videoconfig->hwscale && canvas->xv_image) {
        int i, j;
        int numattr = 0;
        Display *dpy = x11ui_get_display_ptr();
        XvAttribute *attr = XvQueryPortAttributes(dpy, canvas->xv_port, &numattr);
        for (i = 0; i < (int)(sizeof(xv_settings)/sizeof(xv_settings[0])); i++) {
            xv_settings[i].atom = 0;

            for (j = 0; j < numattr; j++) {
                if (strcmp(xv_settings[i].name, attr[j].name) == 0) {
                    xv_settings[i].atom = XInternAtom(dpy, xv_settings[i].name, False);
                    xv_settings[i].min = attr[j].min_value;
                    xv_settings[i].max = attr[j].max_value;
                    break;
                }
            }
        }

        if (attr) {
            XFree(attr);
        }

        /* Apply color settings to XVideo. */
        video_canvas_set_palette(canvas, canvas->palette);
    }
}
示例#4
0
int video_canvas_palette_set(struct video_canvas_s *canvas, struct palette_s *palette)
{
	struct palette_s *old_palette;

	if (palette == NULL)
		return 0;

	old_palette = canvas->palette;

	if (canvas->created)
	{
		if (video_canvas_set_palette(canvas, palette) < 0)
			return -1;
	}
	else
		canvas->palette = palette;

	if (old_palette != NULL)
		video_color_palette_free(old_palette);

	if (canvas->created)
		video_canvas_refresh_all(canvas);

	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
static void init_xv_settings(video_canvas_t *canvas)
{
    /* Find XVideo color setting limits. */
    if (canvas->videoconfig->hwscale && canvas->xv_image) {
        int i, j;
        int numattr = 0;
        Display *dpy = x11ui_get_display_ptr();
        XvAttribute *attr = XvQueryPortAttributes(dpy, canvas->xv_port, &numattr);

        xv_settings[0].value = &(canvas->videoconfig->video_resources.color_saturation);
        xv_settings[1].value = &(canvas->videoconfig->video_resources.color_contrast);
        xv_settings[2].value = &(canvas->videoconfig->video_resources.color_brightness);
        xv_settings[3].value = &(canvas->videoconfig->video_resources.color_gamma);

        for (i = 0; i < (int)util_arraysize(xv_settings); i++) {
            xv_settings[i].atom = 0;

            for (j = 0; j < numattr; j++) {
                if (!(attr[j].flags & XvSettable)) {
                    continue; /* useless, can't be set */
                }
                if (strcmp(xv_settings[i].name, attr[j].name) == 0) {
                    xv_settings[i].atom = XInternAtom(dpy, xv_settings[i].name, False);
                    xv_settings[i].min = attr[j].min_value;
                    xv_settings[i].max = attr[j].max_value;
                    if ((attr[j].flags & XvGettable) && !xv_settings[i].restore) {
                        xv_settings[i].restore = (XvGetPortAttribute(dpy, canvas->xv_port,
                                xv_settings[i].atom, &xv_settings[i].xv_default) == Success);
                        if (!xv_settings[i].restore) {
                            xv_settings[i].restore = 2;
                        }
                    }
                    break;
                }
            }
        }

        if (attr) {
            XFree(attr);
        }

        /* Apply color settings to XVideo. */
        video_canvas_set_palette(canvas, canvas->palette);
    }
}
示例#7
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;
}
示例#8
0
/* Change the size of the canvas. */
void video_canvas_resize(video_canvas_t *canvas, char resize_canvas)
{
    if (console_mode || video_disabled_mode) {
        return;
    }
    canvas->videoconfig->readable = 1; /* it's not direct rendering */

    if (canvas->gdk_image != NULL) {
        g_object_unref(canvas->gdk_image);
    }
    canvas->gdk_image = gdk_image_new(GDK_IMAGE_FASTEST, gtk_widget_get_visual(canvas->emuwindow), canvas->draw_buffer->canvas_physical_width, canvas->draw_buffer->canvas_physical_height);

#ifdef HAVE_HWSCALE
    lib_free(canvas->hwscale_image);
    canvas->hwscale_image = lib_malloc(canvas->gdk_image->width * canvas->gdk_image->height * 4);
#endif

    if (video_canvas_set_palette(canvas, canvas->palette) < 0) {
        log_debug("Setting palette for this mode failed. (Try 16/24/32 bpp.)");
        exit(-1);
    }

    ui_resize_canvas_window(canvas);
}