xf86-video-intel: src/sna/fb src/sna/sna_display.c src/sna/sna.h src/uxa/intel_video.c
Chris Wilson
ickle at kemper.freedesktop.org
Thu Aug 8 01:28:42 PDT 2013
src/sna/fb/fbclip.h | 7 ++++++-
src/sna/sna.h | 7 ++++++-
src/sna/sna_display.c | 8 +++++++-
src/uxa/intel_video.c | 7 ++++++-
4 files changed, 25 insertions(+), 4 deletions(-)
New commits:
commit c6add09791a44d9b3af79d50f52e6913c46341a8
Author: Raul Fernandes <rgfernandes at gmail.com>
Date: Thu Aug 8 09:26:59 2013 +0100
Micro-optimise box intersections
We can shave a few instructions off the routine by incrementally
performing the "is-empty" check as soon as we compute the intersection
in each dimension.
diff --git a/src/sna/fb/fbclip.h b/src/sna/fb/fbclip.h
index f07e63c..554aeb3 100644
--- a/src/sna/fb/fbclip.h
+++ b/src/sna/fb/fbclip.h
@@ -38,12 +38,17 @@ box_intersect(BoxPtr a, const BoxRec *b)
a->x1 = b->x1;
if (a->x2 > b->x2)
a->x2 = b->x2;
+ if (a->x1 >= a->x2)
+ return false;
+
if (a->y1 < b->y1)
a->y1 = b->y1;
if (a->y2 > b->y2)
a->y2 = b->y2;
+ if (a->y1 >= a->y2)
+ return false;
- return a->x1 < a->x2 && a->y1 < a->y2;
+ return true;
}
#define run_box(b, c) \
diff --git a/src/sna/sna.h b/src/sna/sna.h
index abc8c5b..caf671f 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -895,12 +895,17 @@ box_intersect(BoxPtr a, const BoxRec *b)
a->x1 = b->x1;
if (a->x2 > b->x2)
a->x2 = b->x2;
+ if (a->x1 >= a->x2)
+ return false;
+
if (a->y1 < b->y1)
a->y1 = b->y1;
if (a->y2 > b->y2)
a->y2 = b->y2;
+ if (a->y1 >= a->y2)
+ return false;
- return a->x1 < a->x2 && a->y1 < a->y2;
+ return true;
}
unsigned sna_cpu_detect(void);
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index f13b423..5dcf47f 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -3213,6 +3213,9 @@ static bool sna_box_intersect(BoxPtr r, const BoxRec *a, const BoxRec *b)
{
r->x1 = a->x1 > b->x1 ? a->x1 : b->x1;
r->x2 = a->x2 < b->x2 ? a->x2 : b->x2;
+ if (r->x1 >= r->x2)
+ return false;
+
r->y1 = a->y1 > b->y1 ? a->y1 : b->y1;
r->y2 = a->y2 < b->y2 ? a->y2 : b->y2;
DBG(("%s: (%d, %d), (%d, %d) intersect (%d, %d), (%d, %d) = (%d, %d), (%d, %d)\n",
@@ -3220,7 +3223,10 @@ static bool sna_box_intersect(BoxPtr r, const BoxRec *a, const BoxRec *b)
a->x1, a->y1, a->x2, a->y2,
b->x1, b->y1, b->x2, b->y2,
r->x1, r->y1, r->x2, r->y2));
- return r->x2 > r->x1 && r->y2 > r->y1;
+ if (r->y1 >= r->y2)
+ return false;
+
+ return true;
}
static int sna_box_area(const BoxRec *box)
diff --git a/src/uxa/intel_video.c b/src/uxa/intel_video.c
index c74b793..d6906bf 100644
--- a/src/uxa/intel_video.c
+++ b/src/uxa/intel_video.c
@@ -1017,9 +1017,14 @@ static void intel_box_intersect(BoxPtr dest, BoxPtr a, BoxPtr b)
{
dest->x1 = a->x1 > b->x1 ? a->x1 : b->x1;
dest->x2 = a->x2 < b->x2 ? a->x2 : b->x2;
+ if (dest->x1 >= dest->x2) {
+ dest->x1 = dest->x2 = dest->y1 = dest->y2 = 0;
+ return;
+ }
+
dest->y1 = a->y1 > b->y1 ? a->y1 : b->y1;
dest->y2 = a->y2 < b->y2 ? a->y2 : b->y2;
- if (dest->x1 >= dest->x2 || dest->y1 >= dest->y2)
+ if (dest->y1 >= dest->y2)
dest->x1 = dest->x2 = dest->y1 = dest->y2 = 0;
}
More information about the xorg-commit
mailing list