diff options
author | Russell King <rmk@armlinux.org.uk> | 2018-07-03 12:35:30 +0100 |
---|---|---|
committer | Russell King <rmk@armlinux.org.uk> | 2018-07-13 19:27:23 +0100 |
commit | 29bca2637ee3c6cfe3bf6454e36d0d10e72d7243 (patch) | |
tree | e4c729c9496ec1abe383e26961c0c04abf0ef79f | |
parent | 69ef4cb4abe7f70ea28cda4d62276253eab8796a (diff) |
src: use box_init(), box_width() and box_height()
Use the new helpers to initialise boxes from position + size, get box
widths and heights.
Signed-off-by: Russell King <rmk@armlinux.org.uk>
-rw-r--r-- | etnaviv/etnaviv_accel.c | 26 | ||||
-rw-r--r-- | etnaviv/etnaviv_dri2.c | 6 | ||||
-rw-r--r-- | etnaviv/etnaviv_render.c | 15 | ||||
-rw-r--r-- | etnaviv/etnaviv_xv.c | 24 | ||||
-rw-r--r-- | src/armada_drm_xv.c | 20 | ||||
-rw-r--r-- | src/common_drm.c | 19 | ||||
-rw-r--r-- | vivante/vivante_accel.c | 23 | ||||
-rw-r--r-- | vivante/vivante_dri2.c | 6 |
8 files changed, 44 insertions, 95 deletions
diff --git a/etnaviv/etnaviv_accel.c b/etnaviv/etnaviv_accel.c index 3dd0a54..ed59680 100644 --- a/etnaviv/etnaviv_accel.c +++ b/etnaviv/etnaviv_accel.c @@ -601,17 +601,14 @@ Bool etnaviv_accel_PolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, for (i = 0; i < npt; i++) { x += ppt[i].x; y += ppt[i].y; - pBox[i].x1 = x + pDrawable->x; - pBox[i].y1 = y + pDrawable->y; - pBox[i].x2 = pBox[i].x1 + 1; - pBox[i].y2 = pBox[i].y1 + 1; + box_init(&pBox[i], x + pDrawable->x, y + pDrawable->y, + 1, 1); } } else { for (i = 0; i < npt; i++) { - pBox[i].x1 = ppt[i].x + pDrawable->x; - pBox[i].y1 = ppt[i].y + pDrawable->y; - pBox[i].x2 = pBox[i].x1 + 1; - pBox[i].y2 = pBox[i].y1 + 1; + box_init(&pBox[i], + ppt[i].x + pDrawable->x, + ppt[i].y + pDrawable->y, 1, 1); } } @@ -834,10 +831,10 @@ Bool etnaviv_accel_PolyFillRectSolid(DrawablePtr pDrawable, GCPtr pGC, int n, prefetch (prect + 8); - full_rect.x1 = prect->x + pDrawable->x; - full_rect.y1 = prect->y + pDrawable->y; - full_rect.x2 = full_rect.x1 + prect->width; - full_rect.y2 = full_rect.y1 + prect->height; + box_init(&full_rect, + prect->x + pDrawable->x, + prect->y + pDrawable->y, + prect->width, prect->height); prect++; @@ -937,10 +934,7 @@ Bool etnaviv_accel_PolyFillRectTiled(DrawablePtr pDrawable, GCPtr pGC, int n, w = width; width -= w; - dst.x1 = dst_x; - dst.x2 = dst_x + w; - dst.y1 = dst_y; - dst.y2 = dst_y + h; + box_init(&dst, dst_x, dst_y, w, h); etnaviv_de_op_src_origin(etnaviv, &op, tile_origin, &dst); diff --git a/etnaviv/etnaviv_dri2.c b/etnaviv/etnaviv_dri2.c index 1ecd28b..f329ccb 100644 --- a/etnaviv/etnaviv_dri2.c +++ b/etnaviv/etnaviv_dri2.c @@ -21,6 +21,7 @@ #include <xf86drm.h> #include <armada_bufmgr.h> +#include "boxutil.h" #include "compat-api.h" #include "common_drm.h" #include "common_drm_dri2.h" @@ -126,10 +127,7 @@ static void etnaviv_dri2_blit(ClientPtr client, DrawablePtr draw, RegionRec region; BoxRec box; - box.x1 = 0; - box.y1 = 0; - box.x2 = draw->width; - box.y2 = draw->height; + box_init(&box, 0, 0, draw->width, draw->height); RegionInit(®ion, &box, 0); etnaviv_dri2_CopyRegion(draw, ®ion, front, back); diff --git a/etnaviv/etnaviv_render.c b/etnaviv/etnaviv_render.c index 3c1b65a..4ae7b22 100644 --- a/etnaviv/etnaviv_render.c +++ b/etnaviv/etnaviv_render.c @@ -26,6 +26,7 @@ #include "mipict.h" #include "fbpict.h" +#include "boxutil.h" #include "glyph_assemble.h" #include "glyph_cache.h" #include "glyph_extents.h" @@ -188,10 +189,7 @@ static Bool picture_has_pixels(PicturePtr pPict, xPoint origin, if (pPict->filter == PictFilterConvolution) return FALSE; - b.x1 = origin.x; - b.y1 = origin.y; - b.x2 = origin.x + box->x2; - b.y2 = origin.y + box->y2; + box_init(&b, origin.x, origin.y, box->x2, box->y2); /* transform to the source coordinates if required */ if (pPict->transform) @@ -1224,9 +1222,7 @@ static Bool etnaviv_accel_Glyphs(CARD8 final_op, PicturePtr pSrc, vMask = etnaviv_get_pixmap_priv(pMaskPixmap); /* Clear the mask to transparent */ fmt = etnaviv_set_format(vMask, pMask); - box.x1 = box.y1 = 0; - box.x2 = width; - box.y2 = height; + box_init(&box, 0, 0, width, height); if (!etnaviv_fill_single(etnaviv, vMask, &box, 0)) goto destroy_picture; @@ -1364,10 +1360,7 @@ static void etnaviv_accel_glyph_upload(ScreenPtr pScreen, PicturePtr pDst, src_offset); } - box.x1 = x; - box.y1 = y; - box.x2 = x + width; - box.y2 = y + height; + box_init(&box, x, y, width, height); fmt = etnaviv_set_format(vdst, pDst); diff --git a/etnaviv/etnaviv_xv.c b/etnaviv/etnaviv_xv.c index 475a439..f9bbeda 100644 --- a/etnaviv/etnaviv_xv.c +++ b/etnaviv/etnaviv_xv.c @@ -21,6 +21,7 @@ #include "damage.h" #include <X11/extensions/Xv.h> +#include "boxutil.h" #include "compat-api.h" #include "fourcc.h" #include "pixmaputil.h" @@ -476,10 +477,7 @@ static int etnaviv_PutImage(ScrnInfoPtr pScrn, Bool is_xvbo = id == FOURCC_XVBO; int s_w, s_h, xoff; - dst.x1 = drw_x; - dst.y1 = drw_y; - dst.x2 = drw_x + drw_w; - dst.y2 = drw_y + drw_h; + box_init(&dst, drw_x, drw_y, drw_w, drw_h); x1 = src_x; x2 = src_x + src_w; @@ -554,10 +552,7 @@ static int etnaviv_PutImage(ScrnInfoPtr pScrn, op.src = INIT_BLIT_BO(usr, 0, priv->source_format, ZERO_OFFSET); op.src_pitches = priv->pitches; op.src_offsets = priv->offsets; - op.src_bounds.x1 = xoff >> 16; - op.src_bounds.y1 = 0; - op.src_bounds.x2 = op.src_bounds.x1 + width; - op.src_bounds.y2 = height; + box_init(&op.src_bounds, xoff >> 16, 0, width, height); etna_set_state_multi(etnaviv->ctx, VIVS_DE_FILTER_KERNEL(0), KERNEL_STATE_SZ, xv_filter_kernel); @@ -568,8 +563,8 @@ static int etnaviv_PutImage(ScrnInfoPtr pScrn, */ s_w = x2 - x1; s_h = y2 - y1; - drw_w = dst.x2 - dst.x1; - drw_h = dst.y2 - dst.y1; + drw_w = box_width(&dst); + drw_h = box_height(&dst); /* Check whether we need to scale in the vertical direction first. */ if (s_h != drw_h << 16) { @@ -583,10 +578,7 @@ static int etnaviv_PutImage(ScrnInfoPtr pScrn, !etnaviv_realloc_stage1(pScrn, priv, stage1_size)) goto bad_alloc; - box.x1 = 0; - box.y1 = 0; - box.x2 = width; - box.y2 = drw_h; + box_init(&box, 0, 0, width, drw_h); /* * Perform a vertical filter blit first, converting to @@ -613,9 +605,7 @@ static int etnaviv_PutImage(ScrnInfoPtr pScrn, */ y1 = 0; - op.src_bounds.x1 = 0; - op.src_bounds.x2 = (x2 + 0xffff) >> 16; - op.src_bounds.y2 = drw_h; + box_init(&op.src_bounds, 0, 0, (x2 + 0xffff) >> 16, drw_h); } else { /* No need for the vertical scaling stage. */ x1 += xoff; diff --git a/src/armada_drm_xv.c b/src/armada_drm_xv.c index c08a2e0..656b381 100644 --- a/src/armada_drm_xv.c +++ b/src/armada_drm_xv.c @@ -25,6 +25,7 @@ #include <X11/Xatom.h> #include "armada_ioctl.h" +#include "boxutil.h" #include "fourcc.h" #include "xv_attribute.h" #include "xv_image_format.h" @@ -454,15 +455,6 @@ armada_drm_get_fmt_info(const struct xv_image_format *fmt, return ret; } -static void -armada_drm_coords_to_box(BoxPtr box, short x, short y, short w, short h) -{ - box->x1 = x; - box->y1 = y; - box->x2 = x + w; - box->y2 = y + h; -} - static void armada_drm_bufs_free(struct drm_xv *drmxv) { unsigned i; @@ -953,10 +945,8 @@ armada_drm_plane_Put(ScrnInfoPtr pScrn, struct drm_xv *drmxv, uint32_t fb_id, BoxRec crtcbox; Bool obscured; - crtcbox.x1 = crtc->x; - crtcbox.y1 = crtc->y; - crtcbox.x2 = crtc->x + crtc->mode.HDisplay; - crtcbox.y2 = crtc->y + crtc->mode.VDisplay; + box_init(&crtcbox, crtc->x, crtc->y, + crtc->mode.HDisplay, crtc->mode.VDisplay); obscured = RegionContainsRect(clipBoxes, &crtcbox) == rgnIN; @@ -986,7 +976,7 @@ static int armada_drm_plane_PutImage(ScrnInfoPtr pScrn, uint32_t fb_id; int ret; - armada_drm_coords_to_box(&dst, drw_x, drw_y, drw_w, drw_h); + box_init(&dst, drw_x, drw_y, drw_w, drw_h); ret = armada_drm_plane_fbid(pScrn, drmxv, image, buf, width, height, &fb_id); @@ -1023,7 +1013,7 @@ static int armada_drm_plane_ReputImage(ScrnInfoPtr pScrn, if (drmxv->plane_fb_id == 0) return Success; - armada_drm_coords_to_box(&dst, drw_x, drw_y, drw_w, drw_h); + box_init(&dst, drw_x, drw_y, drw_w, drw_h); ret = armada_drm_plane_Put(pScrn, drmxv, drmxv->plane_fb_id, src_x, src_y, src_w, src_h, diff --git a/src/common_drm.c b/src/common_drm.c index 6fb217b..78060bd 100644 --- a/src/common_drm.c +++ b/src/common_drm.c @@ -545,9 +545,8 @@ void common_drm_flip_pixmap(ScreenPtr pScreen, PixmapPtr front, PixmapPtr b) *common_drm_pixmap(b) = front_c; /* Mark the front pixmap as having changed */ - region.extents.x1 = region.extents.y1 = 0; - region.extents.x2 = front->drawable.width; - region.extents.y2 = front->drawable.height; + box_init(®ion.extents, 0, 0, + front->drawable.width, front->drawable.height); region.data = NULL; DamageRegionAppend(&front->drawable, ®ion); @@ -1037,15 +1036,14 @@ xf86CrtcPtr common_drm_covering_crtc(ScrnInfoPtr pScrn, BoxPtr box, best_crtc = NULL; best_coverage = 0; - box_ret->x1 = box_ret->x2 = box_ret->y1 = box_ret->y2 = 0; + box_init(box_ret, 0, 0, 0, 0); for (c = 0; c < xf86_config->num_crtc; c++) { crtc = xf86_config->crtc[c]; if (!crtc->enabled) continue; - crtc_box.x1 = crtc->x; - crtc_box.x2 = crtc->x + xf86ModeWidth(&crtc->mode, crtc->rotation); - crtc_box.y1 = crtc->y; - crtc_box.y2 = crtc->y + xf86ModeHeight(&crtc->mode, crtc->rotation); + box_init(&crtc_box, crtc->x, crtc->y, + xf86ModeWidth(&crtc->mode, crtc->rotation), + xf86ModeHeight(&crtc->mode, crtc->rotation)); box_intersect(&cover_box, &crtc_box, box); coverage = box_area(&cover_box); if (coverage && crtc == desired) { @@ -1067,10 +1065,7 @@ xf86CrtcPtr common_drm_drawable_covering_crtc(DrawablePtr pDraw) xf86CrtcPtr crtc; BoxRec box, crtcbox; - box.x1 = pDraw->x; - box.y1 = pDraw->y; - box.x2 = box.x1 + pDraw->width; - box.y2 = box.y1 + pDraw->height; + box_init(&box, pDraw->x, pDraw->y, pDraw->width, pDraw->height); crtc = common_drm_covering_crtc(pScrn, &box, NULL, &crtcbox); diff --git a/vivante/vivante_accel.c b/vivante/vivante_accel.c index 58c4b42..64144ec 100644 --- a/vivante/vivante_accel.c +++ b/vivante/vivante_accel.c @@ -494,10 +494,7 @@ static gceSTATUS vivante_blit_srcdst(struct vivante *vivante, op->src.offset.x = src_x - (dst_x + op->dst.offset.x); op->src.offset.y = src_y - (dst_y + op->dst.offset.y); - box.x1 = dst_x; - box.y1 = dst_y; - box.x2 = dst_x + width; - box.y2 = dst_y + height; + box_init(&box, dst_x, dst_y, width, height); err = vivante_blit_start(vivante, op); if (err == gcvSTATUS_OK) { @@ -880,17 +877,13 @@ Bool vivante_accel_PolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, for (i = 0; i < npt; i++) { x += ppt[i].x; y += ppt[i].y; - pBox[i].x1 = x + pDrawable->x; - pBox[i].y1 = y + pDrawable->y; - pBox[i].x2 = pBox[i].x1 + 1; - pBox[i].y2 = pBox[i].y1 + 1; + box_init(&pBox[i], x + pDrawable->x, y + pDrawable->y, + 1, 1); } } else { for (i = 0; i < npt; i++) { - pBox[i].x1 = ppt[i].x + pDrawable->x; - pBox[i].y1 = ppt[i].y + pDrawable->y; - pBox[i].x2 = pBox[i].x1 + 1; - pBox[i].y2 = pBox[i].y1 + 1; + box_init(&pBox[i], ppt[i].x + pDrawable->x, + ppt[i].y + pDrawable->y, 1, 1); } } @@ -945,10 +938,8 @@ Bool vivante_accel_PolyFillRectSolid(DrawablePtr pDrawable, GCPtr pGC, int n, while (n--) { BoxRec full_rect; - full_rect.x1 = prect->x + pDrawable->x; - full_rect.y1 = prect->y + pDrawable->y; - full_rect.x2 = full_rect.x1 + prect->width; - full_rect.y2 = full_rect.y1 + prect->height; + box_init(&full_rect, prect->x + pDrawable->x, + prect->y + pDrawable->y, prect->width, prect->height); prect++; diff --git a/vivante/vivante_dri2.c b/vivante/vivante_dri2.c index 21756a2..a030201 100644 --- a/vivante/vivante_dri2.c +++ b/vivante/vivante_dri2.c @@ -21,6 +21,7 @@ #include <xf86drm.h> #include <armada_bufmgr.h> +#include "boxutil.h" #include "compat-api.h" #include "common_drm.h" #include "common_drm_dri2.h" @@ -167,10 +168,7 @@ vivante_dri2_blit(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front, RegionRec region; BoxRec box; - box.x1 = 0; - box.y1 = 0; - box.x2 = draw->width; - box.y2 = draw->height; + box_init(&box, 0, 0, draw->width, draw->height); RegionInit(®ion, &box, 0); vivante_dri2_CopyRegion(draw, ®ion, front, back); |