xf86-video-intel: 10 commits - src/sna/kgem.c src/sna/sna_accel.c src/sna/sna_display.c src/sna/sna_driver.c src/sna/sna.h

Chris Wilson ickle at kemper.freedesktop.org
Fri Jun 17 01:29:31 PDT 2011


 src/sna/kgem.c        |   10 ++-
 src/sna/sna.h         |    2 
 src/sna/sna_accel.c   |  163 ++++++++++++++++++++++++++++++--------------------
 src/sna/sna_display.c |   92 ++++++++++++++++++++++++++--
 src/sna/sna_driver.c  |    2 
 5 files changed, 199 insertions(+), 70 deletions(-)

New commits:
commit 39f0b0ae17d00402971bb62555d3807bdf39ee93
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jun 16 23:49:06 2011 +0100

    sna: Copy the fbcon contents onto the front buffer upon X startup
    
    This patch has been carried by the distributions every since they
    started doing graphical boot splashes. Time to integrate it and give it
    some TLC.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna.h b/src/sna/sna.h
index d186f2c..897fe74 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -501,6 +501,8 @@ void sna_accel_close(struct sna *sna);
 void sna_accel_free(struct sna *sna);
 
 Bool sna_accel_create(struct sna *sna);
+void sna_copy_fbcon(struct sna *sna);
+
 void sna_composite(CARD8 op,
 		   PicturePtr src,
 		   PicturePtr mask,
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index e3f0e98..bab64ea 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -466,6 +466,82 @@ sna_crtc_dpms(xf86CrtcPtr crtc, int mode)
 		sna_crtc_restore(sna_crtc->sna);
 }
 
+static struct kgem_bo *sna_create_bo_for_fbcon(struct sna *sna,
+					       drmModeFBPtr fbcon)
+{
+	struct drm_gem_flink flink;
+	struct kgem_bo *bo;
+	int ret;
+
+	/* Create a new reference for the fbcon so that we can track it
+	 * using a normal bo and so that when we call gem_close on it we
+	 * delete our reference and not fbcon's!
+	 */
+	memset(&flink, 0, sizeof(flink));
+	flink.handle = fbcon->handle;
+	ret = drmIoctl(sna->kgem.fd, DRM_IOCTL_GEM_FLINK, &flink);
+	if (ret)
+		return NULL;
+
+	bo = kgem_create_for_name(&sna->kgem, flink.name);
+	if (bo == NULL)
+		return NULL;
+
+	bo->pitch = fbcon->pitch;
+	return bo;
+}
+
+/* Copy the current framebuffer contents into the front-buffer for a seamless
+ * transition from e.g. plymouth.
+ */
+void sna_copy_fbcon(struct sna *sna)
+{
+	xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(sna->scrn);
+	drmModeFBPtr fbcon;
+	struct kgem_bo *fbcon_bo;
+	BoxRec box;
+	int i;
+
+	/* Scan the connectors for a framebuffer and assume that is the fbcon */
+	fbcon = NULL;
+	for (i = 0; fbcon == NULL && i < xf86_config->num_crtc; i++) {
+		struct sna_crtc *crtc = xf86_config->crtc[i]->driver_private;
+		drmModeCrtcPtr mode_crtc;
+
+		mode_crtc = drmModeGetCrtc(sna->kgem.fd,
+					   sna->mode.mode_res->crtcs[crtc->num]);
+		if (mode_crtc->buffer_id)
+			fbcon = drmModeGetFB(sna->kgem.fd,
+					     mode_crtc->buffer_id);
+		drmModeFreeCrtc(mode_crtc);
+	}
+	if (fbcon == NULL)
+		return;
+
+	if (fbcon->depth != sna->front->drawable.depth)
+		goto cleanup_fbcon;
+
+	box.x1 = box.y1 = 0;
+	box.x2 = fbcon->width;
+	box.y2 = fbcon->height;
+
+	fbcon_bo = sna_create_bo_for_fbcon(sna, fbcon);
+	if (fbcon_bo == NULL)
+		goto cleanup_fbcon;
+
+	sna->render.copy_boxes(sna, GXcopy,
+			       sna->front, fbcon_bo, 0, 0,
+			       sna->front, sna_pixmap_get_bo(sna->front),
+			       (sna->front->drawable.width - fbcon->width)/2,
+			       (sna->front->drawable.height - fbcon->height)/2,
+			       &box, 1);
+
+	kgem_bo_destroy(&sna->kgem, fbcon_bo);
+
+cleanup_fbcon:
+	drmModeFreeFB(fbcon);
+}
+
 static Bool
 sna_crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 			Rotation rotation, int x, int y)
diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c
index 9970177..ee7a8ae 100644
--- a/src/sna/sna_driver.c
+++ b/src/sna/sna_driver.c
@@ -200,6 +200,8 @@ static Bool sna_create_screen_resources(ScreenPtr screen)
 	if (!sna_accel_create(sna))
 		goto cleanup_front;
 
+	sna_copy_fbcon(sna);
+
 	if (!sna_enter_vt(screen->myNum, 0))
 		goto cleanup_front;
 
commit 37ba33f502af0878f6cb75f890c9fe288d0f7e41
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Jun 17 07:03:25 2011 +0100

    sna: Fix kgem_create_from_name error paths and to mark the bo as non-reusable
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index f5f87d4..f039735 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -1068,6 +1068,7 @@ next_bo:
 struct kgem_bo *kgem_create_for_name(struct kgem *kgem, uint32_t name)
 {
 	struct drm_gem_open open_arg;
+	struct kgem_bo *bo;
 
 	DBG(("%s(name=%d)\n", __FUNCTION__, name));
 
@@ -1077,7 +1078,14 @@ struct kgem_bo *kgem_create_for_name(struct kgem *kgem, uint32_t name)
 		return NULL;
 
 	DBG(("%s: new handle=%d\n", __FUNCTION__, open_arg.handle));
-	return __kgem_bo_alloc(open_arg.handle, 0);
+	bo = __kgem_bo_alloc(open_arg.handle, 0);
+	if (bo == NULL) {
+		gem_close(kgem->fd, open_arg.handle);
+		return NULL;
+	}
+
+	bo->reusable = false;
+	return bo;
 }
 
 struct kgem_bo *kgem_create_linear(struct kgem *kgem, int size)
commit 665bc1735748f266fad5255f82c40edc59ef98e5
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Jun 17 07:00:54 2011 +0100

    sna/display: Remove the caching of the drmModeCrtc
    
    We only use it for the id. Everything else stored on it, like the
    buffer_id, is not permanent and we need to query the current status as
    required.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 8587922..e3f0e98 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -51,11 +51,12 @@
 struct sna_crtc {
 	struct sna *sna;
 	drmModeModeInfo kmode;
-	drmModeCrtcPtr mode_crtc;
 	PixmapPtr shadow;
 	uint32_t shadow_fb_id;
 	uint32_t cursor;
 	xf86CrtcPtr crtc;
+	int num;
+	int id;
 	int pipe;
 	int active;
 	struct list link;
@@ -121,7 +122,7 @@ static const char *backlight_interfaces[] = {
 static inline int
 crtc_id(struct sna_crtc *crtc)
 {
-	return crtc->mode_crtc->crtc_id;
+	return crtc->id;
 }
 
 int sna_crtc_id(xf86CrtcPtr crtc)
@@ -687,6 +688,7 @@ static void
 sna_crtc_init(ScrnInfoPtr scrn, struct sna_mode *mode, int num)
 {
 	struct sna *sna = to_sna(scrn);
+	drmModeCrtcPtr mode_crtc;
 	xf86CrtcPtr crtc;
 	struct sna_crtc *sna_crtc;
 	struct drm_i915_get_pipe_from_crtc_id get_pipe;
@@ -695,10 +697,14 @@ sna_crtc_init(ScrnInfoPtr scrn, struct sna_mode *mode, int num)
 	if (sna_crtc == NULL)
 		return;
 
-	sna_crtc->mode_crtc = drmModeGetCrtc(sna->kgem.fd,
-					     mode->mode_res->crtcs[num]);
+	sna_crtc->num = num;
+
+	mode_crtc = drmModeGetCrtc(sna->kgem.fd, mode->mode_res->crtcs[num]);
+	sna_crtc->id = mode_crtc->crtc_id;
+	drmModeFreeCrtc(mode_crtc);
+
 	get_pipe.pipe = 0;
-	get_pipe.crtc_id = sna_crtc->mode_crtc->crtc_id;
+	get_pipe.crtc_id = sna_crtc->id;
 	drmIoctl(sna->kgem.fd,
 		 DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID,
 		 &get_pipe);
commit ad6235cfb11a5dfdd27106ac45106aaacba73bde
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jun 16 19:02:36 2011 +0100

    sna/accel: convert BOX_ADD_RECT to an inline function
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 5e60592..23f2cb2 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -861,12 +861,19 @@ static inline void box_add_pt(BoxPtr box, int16_t x, int16_t y)
 	else if (box->y2 < y)
 		box->y2 = y;
 }
-#define BOX_ADD_RECT(box, x, y, w, h) do { \
-	if (box.x1 > x) box.x1 = x; \
-	else if (box.x2 < x + w) box.x2 = x + w; \
-	if (box.y1 > y) box.y1 = y; \
-	else if (box.y2 < y + h) box.y2 = y + h; \
-} while (0)
+
+static inline void box_add_rect(BoxPtr box, const xRectangle *r)
+{
+	if (box->x1 > r->x)
+		box->x1 = r->x;
+	if (box->x2 < r->x + r->width)
+		box->x2 = r->x + r->width;
+
+	if (box->y1 > r->y)
+		box->y1 = r->y;
+	if (box->y2 < r->y + r->height)
+		box->y2 = r->y + r->height;
+}
 
 static inline bool box_empty(const BoxRec *box)
 {
@@ -2672,7 +2679,7 @@ sna_poly_fill_rect_extents(DrawablePtr drawable, GCPtr gc,
 
 	while (--n) {
 		rect++;
-		BOX_ADD_RECT(box, rect->x, rect->y, rect->width, rect->height);
+		box_add_rect(&box, rect);
 	}
 
 	trim_and_translate_box(&box, drawable, gc);
commit a86f43988c4ded10cc3b1b964668300c9aa3af59
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jun 16 19:00:09 2011 +0100

    sna/accel: convert BOX_ADD_PT to an inline function
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 4b15b88..5e60592 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -849,13 +849,18 @@ static inline void trim_and_translate_box(BoxPtr box, DrawablePtr d, GCPtr gc)
 	clip_box(box, gc);
 }
 
-#define BOX_ADD_PT(box, x, y) do { \
-	if (box.x1 > x) box.x1 = x; \
-	else if (box.x2 < x) box.x2 = x; \
-	if (box.y1 > y) box.y1 = y; \
-	else if (box.y2 < y) box.y2 = y; \
-} while (0)
+static inline void box_add_pt(BoxPtr box, int16_t x, int16_t y)
+{
+	if (box->x1 > x)
+		box->x1 = x;
+	else if (box->x2 < x)
+		box->x2 = x;
 
+	if (box->y1 > y)
+		box->y1 = y;
+	else if (box->y2 < y)
+		box->y2 = y;
+}
 #define BOX_ADD_RECT(box, x, y, w, h) do { \
 	if (box.x1 > x) box.x1 = x; \
 	else if (box.x2 < x + w) box.x2 = x + w; \
@@ -1750,7 +1755,7 @@ sna_poly_point_extents(DrawablePtr drawable, GCPtr gc,
 	box.y2 = box.y1 = pt->y;
 	while (--n) {
 		pt++;
-		BOX_ADD_PT(box, pt->x, pt->y);
+		box_add_pt(&box, pt->x, pt->y);
 	}
 	box.x2++;
 	box.y2++;
@@ -1956,12 +1961,12 @@ sna_poly_line_extents(DrawablePtr drawable, GCPtr gc,
 			pt++;
 			x += pt->x;
 			y += pt->y;
-			BOX_ADD_PT(box, x, y);
+			box_add_pt(&box, x, y);
 		}
 	} else {
 		while (--n) {
 			pt++;
-			BOX_ADD_PT(box, pt->x, pt->y);
+			box_add_pt(&box, pt->x, pt->y);
 		}
 	}
 	box.x2++;
commit f67a26590aadac8b9b9870ae3b03d23eb7eda1a2
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jun 16 18:58:38 2011 +0100

    sna/accel: convert TRIM_AND_TRANSLATE_BOX to an inline function
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index e3adf01..4b15b88 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -842,11 +842,12 @@ static inline void translate_box(BoxPtr box, DrawablePtr d)
 	box->y2 += d->y;
 }
 
-#define TRIM_AND_TRANSLATE_BOX(box, d, gc) do { \
-	trim_box(&box, d); \
-	translate_box(&box, d); \
-	clip_box(&box, gc); \
-} while (0)
+static inline void trim_and_translate_box(BoxPtr box, DrawablePtr d, GCPtr gc)
+{
+	trim_box(box, d);
+	translate_box(box, d);
+	clip_box(box, gc);
+}
 
 #define BOX_ADD_PT(box, x, y) do { \
 	if (box.x1 > x) box.x1 = x; \
@@ -1754,7 +1755,7 @@ sna_poly_point_extents(DrawablePtr drawable, GCPtr gc,
 	box.x2++;
 	box.y2++;
 
-	TRIM_AND_TRANSLATE_BOX(box, drawable, gc);
+	trim_and_translate_box(&box, drawable, gc);
 	*out = box;
 	return box_empty(&box);
 }
@@ -1973,7 +1974,7 @@ sna_poly_line_extents(DrawablePtr drawable, GCPtr gc,
 		box.y2 += extra;
 	}
 
-	TRIM_AND_TRANSLATE_BOX(box, drawable, gc);
+	trim_and_translate_box(&box, drawable, gc);
 	*out = box;
 	return box_empty(&box);
 }
@@ -2187,7 +2188,7 @@ sna_poly_segment_extents(DrawablePtr drawable, GCPtr gc,
 		box.y2 += extra;
 	}
 
-	TRIM_AND_TRANSLATE_BOX(box, drawable, gc);
+	trim_and_translate_box(&box, drawable, gc);
 	*out = box;
 	return box_empty(&box);
 }
@@ -2291,7 +2292,7 @@ sna_poly_arc_extents(DrawablePtr drawable, GCPtr gc,
 	box.x2++;
 	box.y2++;
 
-	TRIM_AND_TRANSLATE_BOX(box, drawable, gc);
+	trim_and_translate_box(&box, drawable, gc);
 	*out = box;
 	return box_empty(&box);
 }
@@ -2669,7 +2670,7 @@ sna_poly_fill_rect_extents(DrawablePtr drawable, GCPtr gc,
 		BOX_ADD_RECT(box, rect->x, rect->y, rect->width, rect->height);
 	}
 
-	TRIM_AND_TRANSLATE_BOX(box, drawable, gc);
+	trim_and_translate_box(&box, drawable, gc);
 	*out = box;
 	return box_empty(&box);
 }
commit df1b117dedfdda425fbc3e4ee394169902df4716
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jun 16 18:57:38 2011 +0100

    sna/accel: convert TRANSLATE_BOX to an inline function
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 7b3bef9..e3adf01 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -833,16 +833,18 @@ static inline void clip_box(BoxPtr box, GCPtr gc)
 		box->y2 = clip->y2;
 }
 
-#define TRANSLATE_BOX(box, d) do { \
-	box.x1 += d->x; \
-	box.x2 += d->x; \
-	box.y1 += d->y; \
-	box.y2 += d->y; \
-} while (0)
+static inline void translate_box(BoxPtr box, DrawablePtr d)
+{
+	box->x1 += d->x;
+	box->x2 += d->x;
+
+	box->y1 += d->y;
+	box->y2 += d->y;
+}
 
 #define TRIM_AND_TRANSLATE_BOX(box, d, gc) do { \
 	trim_box(&box, d); \
-	TRANSLATE_BOX(box, d); \
+	translate_box(&box, d); \
 	clip_box(&box, gc); \
 } while (0)
 
@@ -1555,7 +1557,7 @@ sna_spans_extents(DrawablePtr drawable, GCPtr gc,
 
 	if (gc) {
 		if (!gc->miTranslate)
-			TRANSLATE_BOX(box, drawable);
+			translate_box(&box, drawable);
 		clip_box(&box, gc);
 	}
 	*out = box;
@@ -2780,7 +2782,7 @@ sna_image_glyph(DrawablePtr drawable, GCPtr gc,
 	trim_box(&box, drawable);
 	if (box_empty(&box))
 		return;
-	TRANSLATE_BOX(box, drawable);
+	translate_box(&box, drawable);
 
 	DBG(("%s: extents(%d, %d), (%d, %d)\n",
 	     __FUNCTION__, box.x1, box.y1, box.x2, box.y2));
@@ -2819,7 +2821,7 @@ sna_poly_glyph(DrawablePtr drawable, GCPtr gc,
 	trim_box(&box, drawable);
 	if (box_empty(&box))
 		return;
-	TRANSLATE_BOX(box, drawable);
+	translate_box(&box, drawable);
 
 	DBG(("%s: extents(%d, %d), (%d, %d)\n",
 	     __FUNCTION__, box.x1, box.y1, box.x2, box.y2));
commit 76ff3c715cf6059316d08217e7e7783ca0388393
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jun 16 18:56:24 2011 +0100

    sna/accel: convert TRIM_BOX to an inline
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 370a368..7b3bef9 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -800,12 +800,18 @@ static void sna_gc_move_to_cpu(GCPtr gc)
 		sna_drawable_move_to_cpu(&gc->tile.pixmap->drawable, false);
 }
 
-#define TRIM_BOX(box, d) do { \
-	if (box.x1 < 0) box.x1 = 0; \
-	if (box.x2 > d->width) box.x2 = d->width; \
-	if (box.y1 < 0) box.y1 = 0; \
-	if (box.y2 > d->height) box.y2 = d->height; \
-} while (0)
+static inline void trim_box(BoxPtr box, DrawablePtr d)
+{
+	if (box->x1 < 0)
+		box->x1 = 0;
+	if (box->x2 > d->width)
+		box->x2 = d->width;
+
+	if (box->y1 < 0)
+		box->y1 = 0;
+	if (box->y2 > d->height)
+		box->y2 = d->height;
+}
 
 static inline void clip_box(BoxPtr box, GCPtr gc)
 {
@@ -835,7 +841,7 @@ static inline void clip_box(BoxPtr box, GCPtr gc)
 } while (0)
 
 #define TRIM_AND_TRANSLATE_BOX(box, d, gc) do { \
-	TRIM_BOX(box, d); \
+	trim_box(&box, d); \
 	TRANSLATE_BOX(box, d); \
 	clip_box(&box, gc); \
 } while (0)
@@ -2771,7 +2777,7 @@ sna_image_glyph(DrawablePtr drawable, GCPtr gc,
 	}
 	box.y1 = y - FONTASCENT(gc->font);
 	box.y2 = y + FONTDESCENT(gc->font);
-	TRIM_BOX(box, drawable);
+	trim_box(&box, drawable);
 	if (box_empty(&box))
 		return;
 	TRANSLATE_BOX(box, drawable);
@@ -2810,7 +2816,7 @@ sna_poly_glyph(DrawablePtr drawable, GCPtr gc,
 	box.x2 = x + extents.overallRight;
 	box.y2 = y + extents.overallDescent;
 
-	TRIM_BOX(box, drawable);
+	trim_box(&box, drawable);
 	if (box_empty(&box))
 		return;
 	TRANSLATE_BOX(box, drawable);
commit e4a66368e71df288323fce66b27237f1d9f93c3a
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jun 16 18:55:03 2011 +0100

    sna/accel: convert CLIP_BOX to an inline function
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 8d73868..370a368 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -807,14 +807,25 @@ static void sna_gc_move_to_cpu(GCPtr gc)
 	if (box.y2 > d->height) box.y2 = d->height; \
 } while (0)
 
-#define CLIP_BOX(box, gc) \
-	if (gc->pCompositeClip) { \
-		BoxPtr extents = &gc->pCompositeClip->extents;\
-		if (box.x1 < extents->x1) box.x1 = extents->x1; \
-		if (box.x2 > extents->x2) box.x2 = extents->x2; \
-		if (box.y1 < extents->y1) box.y1 = extents->y1; \
-		if (box.y2 > extents->y2) box.y2 = extents->y2; \
-	}
+static inline void clip_box(BoxPtr box, GCPtr gc)
+{
+	const BoxRec *clip;
+
+	if (!gc->pCompositeClip)
+		return;
+
+	clip = &gc->pCompositeClip->extents;
+
+	if (box->x1 < clip->x1)
+		box->x1 = clip->x1;
+	if (box->x2 > clip->x2)
+		box->x2 = clip->x2;
+
+	if (box->y1 < clip->y1)
+		box->y1 = clip->y1;
+	if (box->y2 > clip->y2)
+		box->y2 = clip->y2;
+}
 
 #define TRANSLATE_BOX(box, d) do { \
 	box.x1 += d->x; \
@@ -826,7 +837,7 @@ static void sna_gc_move_to_cpu(GCPtr gc)
 #define TRIM_AND_TRANSLATE_BOX(box, d, gc) do { \
 	TRIM_BOX(box, d); \
 	TRANSLATE_BOX(box, d); \
-	CLIP_BOX(box, gc); \
+	clip_box(&box, gc); \
 } while (0)
 
 #define BOX_ADD_PT(box, x, y) do { \
@@ -1539,7 +1550,7 @@ sna_spans_extents(DrawablePtr drawable, GCPtr gc,
 	if (gc) {
 		if (!gc->miTranslate)
 			TRANSLATE_BOX(box, drawable);
-		CLIP_BOX(box, gc);
+		clip_box(&box, gc);
 	}
 	*out = box;
 	return box_empty(&box);
@@ -2842,7 +2853,7 @@ sna_push_pixels(GCPtr gc, PixmapPtr bitmap, DrawablePtr drawable,
 	box.x2 = box.x1 + w;
 	box.y2 = box.y1 + h;
 
-	CLIP_BOX(box, gc);
+	clip_box(&box, gc);
 	if (box_empty(&box))
 		return;
 
commit d7b51cc5d6e624a72b2f2fb92b4488e49a1c749c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jun 16 18:52:56 2011 +0100

    sna/accel: convert BOX_EMPTY macro to an inline function
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index b959e44..8d73868 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -843,7 +843,10 @@ static void sna_gc_move_to_cpu(GCPtr gc)
 	else if (box.y2 < y + h) box.y2 = y + h; \
 } while (0)
 
-#define BOX_EMPTY(box) (box.x2 <= box.x1 || box.y2 <= box.y1)
+static inline bool box_empty(const BoxRec *box)
+{
+	return box->x2 <= box->x1 || box->y2 <= box->y1;
+}
 
 static Bool
 sna_put_image_upload_blt(DrawablePtr drawable, GCPtr gc, RegionPtr region,
@@ -1014,7 +1017,7 @@ sna_put_image(DrawablePtr drawable, GCPtr gc, int depth,
 		box.x2 = pixmap->drawable.width;
 	if (box.y2 > pixmap->drawable.height)
 		box.y2 = pixmap->drawable.height;
-	if (BOX_EMPTY(box))
+	if (box_empty(&box))
 		return;
 
 	RegionInit(&region, &box, 1);
@@ -1539,7 +1542,7 @@ sna_spans_extents(DrawablePtr drawable, GCPtr gc,
 		CLIP_BOX(box, gc);
 	}
 	*out = box;
-	return BOX_EMPTY(box);
+	return box_empty(&box);
 }
 
 static void
@@ -1734,7 +1737,7 @@ sna_poly_point_extents(DrawablePtr drawable, GCPtr gc,
 
 	TRIM_AND_TRANSLATE_BOX(box, drawable, gc);
 	*out = box;
-	return BOX_EMPTY(box);
+	return box_empty(&box);
 }
 
 static void
@@ -1953,7 +1956,7 @@ sna_poly_line_extents(DrawablePtr drawable, GCPtr gc,
 
 	TRIM_AND_TRANSLATE_BOX(box, drawable, gc);
 	*out = box;
-	return BOX_EMPTY(box);
+	return box_empty(&box);
 }
 
 static void
@@ -2167,7 +2170,7 @@ sna_poly_segment_extents(DrawablePtr drawable, GCPtr gc,
 
 	TRIM_AND_TRANSLATE_BOX(box, drawable, gc);
 	*out = box;
-	return BOX_EMPTY(box);
+	return box_empty(&box);
 }
 
 static void
@@ -2271,7 +2274,7 @@ sna_poly_arc_extents(DrawablePtr drawable, GCPtr gc,
 
 	TRIM_AND_TRANSLATE_BOX(box, drawable, gc);
 	*out = box;
-	return BOX_EMPTY(box);
+	return box_empty(&box);
 }
 
 static void
@@ -2649,7 +2652,7 @@ sna_poly_fill_rect_extents(DrawablePtr drawable, GCPtr gc,
 
 	TRIM_AND_TRANSLATE_BOX(box, drawable, gc);
 	*out = box;
-	return BOX_EMPTY(box);
+	return box_empty(&box);
 }
 
 static void
@@ -2758,7 +2761,7 @@ sna_image_glyph(DrawablePtr drawable, GCPtr gc,
 	box.y1 = y - FONTASCENT(gc->font);
 	box.y2 = y + FONTDESCENT(gc->font);
 	TRIM_BOX(box, drawable);
-	if (BOX_EMPTY(box))
+	if (box_empty(&box))
 		return;
 	TRANSLATE_BOX(box, drawable);
 
@@ -2797,7 +2800,7 @@ sna_poly_glyph(DrawablePtr drawable, GCPtr gc,
 	box.y2 = y + extents.overallDescent;
 
 	TRIM_BOX(box, drawable);
-	if (BOX_EMPTY(box))
+	if (box_empty(&box))
 		return;
 	TRANSLATE_BOX(box, drawable);
 
@@ -2840,7 +2843,7 @@ sna_push_pixels(GCPtr gc, PixmapPtr bitmap, DrawablePtr drawable,
 	box.y2 = box.y1 + h;
 
 	CLIP_BOX(box, gc);
-	if (BOX_EMPTY(box))
+	if (box_empty(&box))
 		return;
 
 	DBG(("%s: extents(%d, %d), (%d, %d)\n",


More information about the xorg-commit mailing list