summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-10-08 09:40:34 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-10-08 09:40:34 +0100
commit082c08789cf9a8c0cc2bf44d0fee579b96c0798f (patch)
tree85e06a4aeacef4cc54dd8dccad088d910d8be3c7 /src
parent06a8ad9690590a605b1564012d062b98c60546a6 (diff)
sna: Rework the num_threads refinement to avoid the division
We can replace the division by a multiplication. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/sna/sna_threads.c2
-rw-r--r--src/sna/sna_trapezoids.c2
-rw-r--r--src/sna/sna_trapezoids_imprecise.c6
-rw-r--r--src/sna/sna_trapezoids_mono.c2
-rw-r--r--src/sna/sna_trapezoids_precise.c10
5 files changed, 11 insertions, 11 deletions
diff --git a/src/sna/sna_threads.c b/src/sna/sna_threads.c
index 3e10e5a4..333b7ebd 100644
--- a/src/sna/sna_threads.c
+++ b/src/sna/sna_threads.c
@@ -274,7 +274,7 @@ void sna_image_composite(pixman_op_t op,
y = dst_y;
dy = (height + num_threads - 1) / num_threads;
- num_threads = (height + dy - 1) / dy;
+ num_threads -= (num_threads-1) * dy >= height;
data[0].op = op;
data[0].src = src;
diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c
index 8827b9c6..f14a67c9 100644
--- a/src/sna/sna_trapezoids.c
+++ b/src/sna/sna_trapezoids.c
@@ -390,7 +390,7 @@ trapezoids_fallback(struct sna *sna,
y = bounds.y1;
dy = (height + num_threads - 1) / num_threads;
- num_threads = (bounds.y2 - bounds.y1 + dy - 1) / dy;
+ num_threads -= (num_threads-1) * dy >= bounds.y2 - bounds.y1;
for (n = 1; n < num_threads; n++) {
threads[n] = threads[0];
diff --git a/src/sna/sna_trapezoids_imprecise.c b/src/sna/sna_trapezoids_imprecise.c
index 4809e9cc..3624dd63 100644
--- a/src/sna/sna_trapezoids_imprecise.c
+++ b/src/sna/sna_trapezoids_imprecise.c
@@ -1982,7 +1982,7 @@ imprecise_trapezoid_span_converter(struct sna *sna,
y = clip.extents.y1;
h = clip.extents.y2 - clip.extents.y1;
h = (h + num_threads - 1) / num_threads;
- num_threads = (clip.extents.y2 - clip.extents.y1 + h - 1) / h;
+ num_threads -= (num_threads-1) * h >= clip.extents.y2 - clip.extents.y1;
for (n = 1; n < num_threads; n++) {
threads[n] = threads[0];
@@ -2841,7 +2841,7 @@ trapezoid_span_inplace__x8r8g8b8(CARD8 op,
y = region.extents.y1;
h = region.extents.y2 - region.extents.y1;
h = (h + num_threads - 1) / num_threads;
- num_threads = (region.extents.y2 - region.extents.y1 + h - 1) / h;
+ num_threads -= (num_threads-1) * h >= region.extents.y2 - region.extents.y1;
for (n = 1; n < num_threads; n++) {
threads[n] = threads[0];
@@ -3112,7 +3112,7 @@ imprecise_trapezoid_span_inplace(struct sna *sna,
y = region.extents.y1;
h = region.extents.y2 - region.extents.y1;
h = (h + num_threads - 1) / num_threads;
- num_threads = (region.extents.y2 - region.extents.y1 + h - 1) / h;
+ num_threads -= (num_threads-1) * h >= region.extents.y2 - region.extents.y1;
for (n = 1; n < num_threads; n++) {
threads[n] = threads[0];
diff --git a/src/sna/sna_trapezoids_mono.c b/src/sna/sna_trapezoids_mono.c
index 790863e8..2f7a2bb8 100644
--- a/src/sna/sna_trapezoids_mono.c
+++ b/src/sna/sna_trapezoids_mono.c
@@ -843,7 +843,7 @@ mono_trapezoids_span_converter(struct sna *sna,
y = extents.y1;
h = extents.y2 - extents.y1;
h = (h + num_threads - 1) / num_threads;
- num_threads = (extents.y2 - extents.y1 + h - 1) / h;
+ num_threads -= (num_threads-1) * h >= extents.y2 - extents.y1;
for (n = 1; n < num_threads; n++) {
threads[n] = threads[0];
diff --git a/src/sna/sna_trapezoids_precise.c b/src/sna/sna_trapezoids_precise.c
index 3720d8ba..7e685471 100644
--- a/src/sna/sna_trapezoids_precise.c
+++ b/src/sna/sna_trapezoids_precise.c
@@ -1907,7 +1907,7 @@ precise_trapezoid_span_converter(struct sna *sna,
y = clip.extents.y1;
h = clip.extents.y2 - clip.extents.y1;
h = (h + num_threads - 1) / num_threads;
- num_threads = (clip.extents.y2 - clip.extents.y1 + h - 1) / h;
+ num_threads -= (num_threads-1) * h >= clip.extents.y2 - clip.extents.y1;
for (n = 1; n < num_threads; n++) {
threads[n] = threads[0];
@@ -2133,7 +2133,7 @@ precise_trapezoid_mask_converter(CARD8 op, PicturePtr src, PicturePtr dst,
y = extents.y1;
h = extents.y2 - extents.y1;
h = (h + num_threads - 1) / num_threads;
- num_threads = (extents.y2 - extents.y1 + h - 1) / h;
+ num_threads -= (num_threads-1) * h >= extents.y2 - extents.y1;
for (n = 1; n < num_threads; n++) {
threads[n] = threads[0];
@@ -2839,7 +2839,7 @@ trapezoid_span_inplace__x8r8g8b8(CARD8 op,
y = region.extents.y1;
h = region.extents.y2 - region.extents.y1;
h = (h + num_threads - 1) / num_threads;
- num_threads = (region.extents.y2 - region.extents.y1 + h - 1) / h;
+ num_threads -= (num_threads-1) * h >= region.extents.y2 - region.extents.y1;
for (n = 1; n < num_threads; n++) {
threads[n] = threads[0];
@@ -3111,7 +3111,7 @@ precise_trapezoid_span_inplace(struct sna *sna,
y = region.extents.y1;
h = region.extents.y2 - region.extents.y1;
h = (h + num_threads - 1) / num_threads;
- num_threads = (region.extents.y2 - region.extents.y1 + h - 1) / h;
+ num_threads -= (num_threads-1) * h >= region.extents.y2 - region.extents.y1;
for (n = 1; n < num_threads; n++) {
threads[n] = threads[0];
@@ -3255,7 +3255,7 @@ precise_trapezoid_span_fallback(CARD8 op, PicturePtr src, PicturePtr dst,
y = extents.y1;
h = extents.y2 - extents.y1;
h = (h + num_threads - 1) / num_threads;
- num_threads = (extents.y2 - extents.y1 + h - 1) / h;
+ num_threads -= (num_threads-1) * h >= extents.y2 - extents.y1;
for (n = 1; n < num_threads; n++) {
threads[n] = threads[0];