Ejemplo n.º 1
0
static void
gth_image_rotator_draw (GthImageViewerTool *base,
			cairo_t            *cr)
{
	GthImageRotator *self = GTH_IMAGE_ROTATOR (base);
	GtkAllocation    allocation;

	cairo_save (cr);

  	/* background */

	/*
	GtkStyleContext *style_context;
	GdkRGBA          color;
	style_context = gtk_widget_get_style_context (GTK_WIDGET (self->priv->viewer));
	gtk_style_context_get_background_color (style_context,
						gtk_widget_get_state (GTK_WIDGET (self->priv->viewer)),
						&color);
	gdk_cairo_set_source_rgba (cr, &color);
	*/

	gtk_widget_get_allocation (GTK_WIDGET (self->priv->viewer), &allocation);
	cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);

  	cairo_set_source_rgba (cr,
  			       self->priv->background_color.red,
  			       self->priv->background_color.green,
  			       self->priv->background_color.blue,
  			       self->priv->background_color.alpha);
	cairo_fill (cr);
	cairo_restore (cr);

	if (self->priv->preview_image == NULL)
		return;

	paint_image (self, cr);
	paint_darker_background (self, cr);
	paint_grid (self, cr);

	if (self->priv->dragging) {
		GdkPoint center;

		cairo_save (cr);
		cairo_set_antialias (cr, CAIRO_ANTIALIAS_DEFAULT);
		cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
		cairo_restore (cr);

		center.x = self->priv->center.x * self->priv->preview_zoom + self->priv->preview_image_area.x;
		center.y = self->priv->center.y * self->priv->preview_zoom + self->priv->preview_image_area.y;
		paint_point (self, cr, &center);

		/* used for debugging purposes
		paint_point (self, cr, &self->priv->drag_p1);
		paint_point (self, cr, &self->priv->drag_p2);
		*/
	}
}
Ejemplo n.º 2
0
static void paint_output_info(struct connector *c, struct igt_fb *fb)
{
	cairo_t *cr = igt_get_cairo_ctx(drm_fd, fb);
	int l_width = fb->width;
	int l_height = fb->height;
	double str_width;
	double x, y, top_y;
	double max_width;
	int i;

	cairo_move_to(cr, l_width / 2, l_height / 2);

	/* Print connector and mode name */
	cairo_set_font_size(cr, 48);
	igt_cairo_printf_line(cr, align_hcenter, 10, "%s",
		 kmstest_connector_type_str(c->connector->connector_type));

	cairo_set_font_size(cr, 36);
	str_width = igt_cairo_printf_line(cr, align_hcenter, 10,
		"%s @ %dHz on %s encoder", c->mode.name, c->mode.vrefresh,
		kmstest_encoder_type_str(c->encoder->encoder_type));

	cairo_rel_move_to(cr, -str_width / 2, 0);

	/* List available modes */
	cairo_set_font_size(cr, 18);
	str_width = igt_cairo_printf_line(cr, align_left, 10,
					      "Available modes:");
	cairo_rel_move_to(cr, str_width, 0);
	cairo_get_current_point(cr, &x, &top_y);

	max_width = 0;
	for (i = 0; i < c->connector->count_modes; i++) {
		cairo_get_current_point(cr, &x, &y);
		if (y >= l_height) {
			x += max_width + 10;
			max_width = 0;
			cairo_move_to(cr, x, top_y);
		}
		str_width = igt_cairo_printf_line(cr, align_right, 10,
			"%s @ %dHz", c->connector->modes[i].name,
			 c->connector->modes[i].vrefresh);
		if (str_width > max_width)
			max_width = str_width;
	}

	if (qr_code)
		paint_image(cr, "pass.png");

	igt_assert(!cairo_status(cr));

	cairo_destroy(cr);
}
Ejemplo n.º 3
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);
    }