On Wed, Sep 05, 2018 at 05:18:16PM -0700, Deepak Rawat wrote: > The plane property FB_DAMAGE_CLIPS provides a way mark damaged regions > on the plane in framebuffer coordinates of the framebuffer attached to > the plane. > > This patch adds a new member "damage" to compositor version of > drm_plane_state and set FB_DAMAGE_CLIPS property whenever damage is > available. > > Signed-off-by: Deepak Rawat <drawat@xxxxxxxxxx> > Cc: dri-devel@xxxxxxxxxxxxxxxxxxxxx Note that weston has switched over to gitlab based merge requests: https://gitlab.freedesktop.org/wayland/weston/blob/master/CONTRIBUTING.md Cheers, Daniel > --- > libweston/compositor-drm.c | 35 +++++++++++++++++++++++++++++++++++ > 1 file changed, 35 insertions(+) > > diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c > index 6a87a296..30f6fce9 100644 > --- a/libweston/compositor-drm.c > +++ b/libweston/compositor-drm.c > @@ -129,6 +129,7 @@ enum wdrm_plane_property { > WDRM_PLANE_FB_ID, > WDRM_PLANE_CRTC_ID, > WDRM_PLANE_IN_FORMATS, > + WDRM_PLANE_FB_DAMAGE_CLIPS, > WDRM_PLANE__COUNT > }; > > @@ -171,6 +172,7 @@ static const struct drm_property_info plane_props[] = { > [WDRM_PLANE_FB_ID] = { .name = "FB_ID", }, > [WDRM_PLANE_CRTC_ID] = { .name = "CRTC_ID", }, > [WDRM_PLANE_IN_FORMATS] = { .name = "IN_FORMATS" }, > + [WDRM_PLANE_FB_DAMAGE_CLIPS] = { .name = "FB_DAMAGE_CLIPS" }, > }; > > /** > @@ -403,6 +405,8 @@ struct drm_plane_state { > > bool complete; > > + pixman_region32_t damage; /* damage sent to kernel */ > + > struct wl_list link; /* drm_output_state::plane_list */ > }; > > @@ -1306,6 +1310,7 @@ drm_plane_state_alloc(struct drm_output_state *state_output, > assert(state); > state->output_state = state_output; > state->plane = plane; > + pixman_region32_init(&state->damage); > > /* Here we only add the plane state to the desired link, and not > * set the member. Having an output pointer set means that the > @@ -1336,6 +1341,7 @@ drm_plane_state_free(struct drm_plane_state *state, bool force) > wl_list_remove(&state->link); > wl_list_init(&state->link); > state->output_state = NULL; > + pixman_region32_fini(&state->damage); > > if (force || state != state->plane->state_cur) { > drm_fb_unref(state->fb); > @@ -1373,6 +1379,7 @@ drm_plane_state_duplicate(struct drm_output_state *state_output, > if (src->fb) > dst->fb = drm_fb_ref(src->fb); > dst->output_state = state_output; > + pixman_region32_init(&dst->damage); > dst->complete = false; > > return dst; > @@ -2409,6 +2416,33 @@ drm_mode_ensure_blob(struct drm_backend *backend, struct drm_mode *mode) > return ret; > } > > +static int > +plane_add_damage(drmModeAtomicReq *req, struct drm_backend *backend, > + struct drm_plane_state *plane_state) > +{ > + struct drm_plane *plane = plane_state->plane; > + pixman_box32_t *rects; > + uint32_t blob_id; > + int n_rects; > + int ret; > + > + if (!pixman_region32_not_empty(&plane_state->damage)) > + return 0; > + > + rects = pixman_region32_rectangles(&plane_state->damage, &n_rects); > + > + ret = drmModeCreatePropertyBlob(backend->drm.fd, rects, > + sizeof(*rects) * n_rects, &blob_id); > + if (ret != 0) > + return ret; > + > + ret = plane_add_prop(req, plane, WDRM_PLANE_FB_DAMAGE_CLIPS, blob_id); > + if (ret != 0) > + return ret; > + > + return 0; > +} > + > static int > drm_output_apply_state_atomic(struct drm_output_state *state, > drmModeAtomicReq *req, > @@ -2477,6 +2511,7 @@ drm_output_apply_state_atomic(struct drm_output_state *state, > plane_state->dest_w); > ret |= plane_add_prop(req, plane, WDRM_PLANE_CRTC_H, > plane_state->dest_h); > + ret |= plane_add_damage(req, backend, plane_state); > > if (ret != 0) { > weston_log("couldn't set plane state\n"); > -- > 2.17.1 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel