Re: [igt-dev] [RESEND,v3 5/5] kms_plane: Add clipping subtests

Imre Deak
2018-09-10T14:06:47Z

On Fri, Sep 07, 2018 at 06:18:43PM +0300, Mun, Gwan-gyeong wrote:
> > > [...]
> > > +static void
> > > +create_fb_for_mode__clipping_display(data_t *data, drmModeModeInfo
> > > *mode,
> > > + square_t *clip_squares,
> > > + int clip_squares_cnt,
> > > + struct igt_fb *fb /* out */)
> > > +{
> > > + int plane;
> > > + struct igt_fb plane_fbs[4];
> > > + unsigned int fb_id;
> > > + cairo_t *cr;
> > > + cairo_surface_t *srcs[4];
> > > +
> > > + fb_id = igt_create_fb(data->drm_fd,
> > > + mode->hdisplay, mode->vdisplay,
> > > + DRM_FORMAT_XRGB8888,
> > > + LOCAL_DRM_FORMAT_MOD_NONE,
> > > + fb);
> > > + igt_assert(fb_id);
> > > +
> > > + cr = igt_get_cairo_ctx(data->drm_fd, fb);
> > > + igt_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay,
> > > + 0, 0, 0);
> > > +
> > > + for (plane = 0; plane < clip_squares_cnt; plane++) {
> > > + create_fb_for_mode__clipping_plane(data, IGT_ROTATION_0,
> > > + LOCAL_DRM_FORMAT_MOD_NONE,
> > > + DRM_FORMAT_XRGB8888,
> > > + clip_squares[plane].size,
> > > + &plane_fbs[plane]);
> > > +
> > > + srcs[plane] = igt_get_cairo_surface(data->drm_fd,
> > > + &plane_fbs[plane]);
> > > + cairo_set_source_surface(cr, srcs[plane],
> > > + clip_squares[plane].x,
> > > + clip_squares[plane].y);
> > > + cairo_rectangle(cr,
> > > + clip_squares[plane].x,
> > > + clip_squares[plane].y,
> > > + clip_squares[plane].size,
> > > + clip_squares[plane].size);
> > > + cairo_fill(cr);
> >
> > Could remove the FB, cairo surface already here, so we don't need the
> > array and a second loop below?
> >
> if we remove the FB and cairo surface here, we will receive SIGABRT
> like this,
>
> kms_plane: cairo-surface.c:955: cairo_surface_destroy: Assertion
> `CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)' failed.
> Received signal SIGABRT.
>
> And when we call cairo_destroy(), a cairo image surface of igt calls
> blit.

Oops, that's true, I forgot about this oddity in the Cairo API. So your
version is fine.

--Imre