Esempio n. 1
0
static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
                         igt_plane_t *plane, drmModeModeInfo *mode, enum igt_commit_style s)
{
    igt_display_t *display = &data->display;

    igt_output_set_pipe(output, pipe);

    /* create the pipe_crc object for this pipe */
    igt_pipe_crc_free(data->pipe_crc);
    data->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO);

    /* before allocating, free if any older fb */
    if (data->fb_id1) {
        igt_remove_fb(data->drm_fd, &data->fb1);
        data->fb_id1 = 0;
    }

    /* allocate fb for plane 1 */
    data->fb_id1 = igt_create_fb(data->drm_fd,
                                 mode->hdisplay, mode->vdisplay,
                                 DRM_FORMAT_XRGB8888,
                                 LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */
                                 &data->fb1);
    igt_assert(data->fb_id1);

    paint_color(data, &data->fb1, mode->hdisplay, mode->vdisplay);

    /*
     * We always set the primary plane to actually enable the pipe as
     * there's no way (that works) to light up a pipe with only a sprite
     * plane enabled at the moment.
     */
    if (!plane->is_primary) {
        igt_plane_t *primary;

        primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
        igt_plane_set_fb(primary, &data->fb1);
    }

    igt_plane_set_fb(plane, &data->fb1);
    if (s == COMMIT_LEGACY) {
        int ret;
        ret = drmModeSetCrtc(data->drm_fd,
                             output->config.crtc->crtc_id,
                             data->fb_id1,
                             plane->pan_x, plane->pan_y,
                             &output->id,
                             1,
                             mode);
        igt_assert_eq(ret, 0);
    } else {
        igt_display_commit2(display, s);
    }
}
Esempio n. 2
0
static void test_plane_scaling(data_t *d)
{
    igt_display_t *display = &d->display;
    igt_output_t *output;
    cairo_surface_t *image;
    enum pipe pipe;
    int valid_tests = 0;
    int primary_plane_scaling = 0; /* For now */

    igt_require(d->display.has_universal_planes);
    igt_require(d->num_scalers);

    for_each_connected_output(display, output) {
        drmModeModeInfo *mode;

        pipe = output->config.pipe;
        igt_output_set_pipe(output, pipe);

        mode = igt_output_get_mode(output);

        /* allocate fb2 with image size */
        image = cairo_image_surface_create_from_png(FILE_NAME);
        igt_assert(cairo_surface_status(image) == CAIRO_STATUS_SUCCESS);
        d->image_w = cairo_image_surface_get_width(image);
        d->image_h = cairo_image_surface_get_height(image);
        cairo_surface_destroy(image);

        d->fb_id2 = igt_create_fb(d->drm_fd,
                                  d->image_w, d->image_h,
                                  DRM_FORMAT_XRGB8888,
                                  LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */
                                  &d->fb2);
        igt_assert(d->fb_id2);
        paint_image(d, &d->fb2, d->fb2.width, d->fb2.height);

        d->fb_id3 = igt_create_fb(d->drm_fd,
                                  mode->hdisplay, mode->vdisplay,
                                  DRM_FORMAT_XRGB8888,
                                  LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */
                                  &d->fb3);
        igt_assert(d->fb_id3);
        paint_color(d, &d->fb3, mode->hdisplay, mode->vdisplay);

        /* Set up display with plane 1 */
        d->plane1 = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
        prepare_crtc(d, output, pipe, d->plane1, mode, COMMIT_UNIVERSAL);

        if (primary_plane_scaling) {
            /* Primary plane upscaling */
            igt_fb_set_position(&d->fb1, d->plane1, 100, 100);
            igt_fb_set_size(&d->fb1, d->plane1, 500, 500);
            igt_plane_set_position(d->plane1, 0, 0);
            igt_plane_set_size(d->plane1, mode->hdisplay, mode->vdisplay);
            igt_display_commit2(display, COMMIT_UNIVERSAL);

            /* Primary plane 1:1 no scaling */
            igt_fb_set_position(&d->fb1, d->plane1, 0, 0);
            igt_fb_set_size(&d->fb1, d->plane1, d->fb1.width, d->fb1.height);
            igt_plane_set_position(d->plane1, 0, 0);
            igt_plane_set_size(d->plane1, mode->hdisplay, mode->vdisplay);
            igt_display_commit2(display, COMMIT_UNIVERSAL);
        }

        /* Set up fb2->plane2 mapping. */
        d->plane2 = igt_output_get_plane(output, IGT_PLANE_2);
        igt_plane_set_fb(d->plane2, &d->fb2);

        /* 2nd plane windowed */
        igt_fb_set_position(&d->fb2, d->plane2, 100, 100);
        igt_fb_set_size(&d->fb2, d->plane2, d->fb2.width-200, d->fb2.height-200);
        igt_plane_set_position(d->plane2, 100, 100);
        igt_plane_set_size(d->plane2, mode->hdisplay-200, mode->vdisplay-200);
        igt_display_commit2(display, COMMIT_UNIVERSAL);

        iterate_plane_scaling(d, mode);

        /* 2nd plane up scaling */
        igt_fb_set_position(&d->fb2, d->plane2, 100, 100);
        igt_fb_set_size(&d->fb2, d->plane2, 500, 500);
        igt_plane_set_position(d->plane2, 10, 10);
        igt_plane_set_size(d->plane2, mode->hdisplay-20, mode->vdisplay-20);
        igt_display_commit2(display, COMMIT_UNIVERSAL);

        /* 2nd plane downscaling */
        igt_fb_set_position(&d->fb2, d->plane2, 0, 0);
        igt_fb_set_size(&d->fb2, d->plane2, d->fb2.width, d->fb2.height);
        igt_plane_set_position(d->plane2, 10, 10);
        igt_plane_set_size(d->plane2, 500, 500 * d->fb2.height/d->fb2.width);
        igt_display_commit2(display, COMMIT_UNIVERSAL);

        if (primary_plane_scaling) {
            /* Primary plane up scaling */
            igt_fb_set_position(&d->fb1, d->plane1, 100, 100);
            igt_fb_set_size(&d->fb1, d->plane1, 500, 500);
            igt_plane_set_position(d->plane1, 0, 0);
            igt_plane_set_size(d->plane1, mode->hdisplay, mode->vdisplay);
            igt_display_commit2(display, COMMIT_UNIVERSAL);
        }

        /* Set up fb3->plane3 mapping. */
        d->plane3 = igt_output_get_plane(output, IGT_PLANE_3);
        igt_plane_set_fb(d->plane3, &d->fb3);

        /* 3rd plane windowed - no scaling */
        igt_fb_set_position(&d->fb3, d->plane3, 100, 100);
        igt_fb_set_size(&d->fb3, d->plane3, d->fb3.width-300, d->fb3.height-300);
        igt_plane_set_position(d->plane3, 100, 100);
        igt_plane_set_size(d->plane3, mode->hdisplay-300, mode->vdisplay-300);
        igt_display_commit2(display, COMMIT_UNIVERSAL);

        /* Switch scaler from plane 2 to plane 3 */
        igt_fb_set_position(&d->fb2, d->plane2, 100, 100);
        igt_fb_set_size(&d->fb2, d->plane2, d->fb2.width-200, d->fb2.height-200);
        igt_plane_set_position(d->plane2, 100, 100);
        igt_plane_set_size(d->plane2, d->fb2.width-200, d->fb2.height-200);

        igt_fb_set_position(&d->fb3, d->plane3, 100, 100);
        igt_fb_set_size(&d->fb3, d->plane3, d->fb3.width-400, d->fb3.height-400);
        igt_plane_set_position(d->plane3, 10, 10);
        igt_plane_set_size(d->plane3, mode->hdisplay-300, mode->vdisplay-300);
        igt_display_commit2(display, COMMIT_UNIVERSAL);

        if (primary_plane_scaling) {
            /* Switch scaler from plane 1 to plane 2 */
            igt_fb_set_position(&d->fb1, d->plane1, 0, 0);
            igt_fb_set_size(&d->fb1, d->plane1, d->fb1.width, d->fb1.height);
            igt_plane_set_position(d->plane1, 0, 0);
            igt_plane_set_size(d->plane1, mode->hdisplay, mode->vdisplay);

            igt_fb_set_position(&d->fb2, d->plane2, 100, 100);
            igt_fb_set_size(&d->fb2, d->plane2, d->fb2.width-500,d->fb2.height-500);
            igt_plane_set_position(d->plane2, 100, 100);
            igt_plane_set_size(d->plane2, mode->hdisplay-200, mode->vdisplay-200);
            igt_display_commit2(display, COMMIT_UNIVERSAL);
        }

        /* back to single plane mode */
        igt_plane_set_fb(d->plane2, NULL);
        igt_plane_set_fb(d->plane3, NULL);
        igt_display_commit2(display, COMMIT_UNIVERSAL);

        valid_tests++;
        cleanup_crtc(d, output, d->plane1);
    }
Esempio n. 3
0
File: dict.c Progetto: Uyouii/dict
void put_list( )//输出储存在list中的检索列表里面的内容
				//where 储存第一个单词在count中的序号 ,order是光标在列表中的位置 
{
	char p[25][20];
	char t1[10],t2[10];
	char t3[]="of";
	int i=0,t=0; 
	int x=10,y=30;
	
	clear_list();
	paint_color(order);
	if(count>=25)
	{
		for(i=0;i<25;i++)
		{
			strcpy(p[i],list[where+i]);
		}
		y=30;
		for(i=0;i<25;i++)
		{
			outtextxy(x,y,p[i]);
			y+=21;
		}
	}
	else
	{
		for(i=0;i<count;i++)
		{
			strcpy(p[i],list[where+i]);
		}
		y=30;
		for(i=0;i<count;i++)
		{
			outtextxy(x,y,p[i]);
			y+=21;
		}
	}
	while(t!=ESC)
	{
		if((order==1&&where>=0)||(order==25&&(where+order)<=count)||(t==PgUp&&where>0)||t==PgDn&&where+25<count||t==Home||t==End||t==Del||t==Ins)
		{
			clear_list();
			paint_color(order);
			if(count>=25)
			{
				for(i=0;i<25;i++)
				{
					strcpy(p[i],list[where+i]);
				}
				y=30;
				for(i=0;i<25;i++)
				{
					outtextxy(x,y,p[i]);
					y+=21;
				}
			}
			else
			{
				for(i=0;i<count;i++)
				{
					strcpy(p[i],list[where+i]);
				}
				y=30;
				for(i=0;i<count;i++)
				{
					outtextxy(x,y,p[i]);
					y+=21;
				}
			}
		}
		else
		{
			if(t==UP) 
			{
				setfillstyle(SOLID_FILL,BLACK);
				bar(5,30+order*21,185,51+order*21);
				outtextxy(10,order*21+30,p[order]);
				setfillstyle(SOLID_FILL,BLUE);
				bar(5,30+(order-1)*21,185,51+(order-1)*21);
				outtextxy(10,30+(order-1)*21,p[order-1]);
			}
			if(t==DOWN)
			{
				setfillstyle(SOLID_FILL,BLACK);
				bar(5,30+(order-2)*21,185,51+(order-2)*21);
				outtextxy(10,(order-2)*21+30,p[order-2]);
				setfillstyle(SOLID_FILL,BLUE);
				bar(5,30+(order-1)*21,185,51+(order-1)*21);
				outtextxy(10,30+(order-1)*21,p[order-1]);
			}
		}
		setfillstyle(SOLID_FILL,BLACK);
		bar(70,12,200,26);
		sprintf(t1,"%d",where+order);
		sprintf(t2,"%d",count);
		outtextxy(70,12,t1);
		outtextxy(70+strlen(t1)*8+4,12,t3);
		outtextxy(70+strlen(t1)*8+strlen(t3)*8+8,12,t2);
		
		t=bioskey(0);
		
		switch(t)
		{
			case DOWN:
				{
					if(order<25&&(where+order)<count) order++;
					else if(order==25&&(where+order)<count)
						{
							where++;
						}
					else ;
				}break;
			case UP:
				{
					if(order>1) order--;
					else if(order==1&&where>0) where--;
					else ;
				}break;
			case PgDn:
				{
					if(count<=25) ;
					else
					{
						if((where+50)>count) where+=count-where-25;
						else if(where+25>=count) ;
						else where+=25;
					}
				}break;
			case PgUp:
				{
					if((where-25)<0&&where>=-24) where=0;
					else if(where-25>=0) where-=25;
					else ;
				}break;
			case Home:
				{
					where=0;
				}break;
			case End:
				{
					if(count<=25) ;
					else  where=count-25;
				}break;
			case Enter:
				{
					clear_translation();
					strcpy(str,list[where+order-1]);
					show_translation(str);
					if(record>0) total=2;
					else total=1;
					show_page();
					if(record>0)
					{
						t=bioskey(0);
						while(t==LEFT||t==RIGHT)
						{
							if(page==1&&t==RIGHT)
							{
								clear_translation();
								page++;
				 				copy_example( example, example2, record);
				 				put_translation2(example2);
				 				show_page();
							}
							if(page==2&&t==LEFT)
							{
								clear_translation();
								page--;
								show_translation(str);
								show_page();
							}
							t=bioskey(0);
						}
					}
					for(i=0;i<2000;i++)
					{
						translation[i]=0;
						example[i]=0;
						example2[i]=0;
					}
					page=1;
					record=0;
				}break;
			case Ins:
				{
					order=1;
				}break;
			case Del:
				{
					if(count<25) order=count;
					else order=25;
				}break;
				
		}
	}
		
	clear_list();
	count=0;where=0;order=1;
	free(list);
	
}