[cairo-commit] 2 commits - perf/cairo-stats.c src/win32

Chris Wilson ickle at kemper.freedesktop.org
Tue Apr 2 00:39:22 PDT 2013


 perf/cairo-stats.c                     |   41 ++++++++++++++++++---------------
 src/win32/cairo-win32-gdi-compositor.c |    3 +-
 2 files changed, 25 insertions(+), 19 deletions(-)

New commits:
commit e66e9ac12e3e11af76f14e8de3cfee72d4299864
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Tue Apr 2 00:32:56 2013 +0200

    win32: fix corrupted drawing
    
    Fix src bitmap coordinates, which origin is bottom-left. This is
    apparently a bug in StretchDIBits(), according to some comments on
    MSDN API documentation.
    
    The backend used to have this coordinate change in the past:
    
                if (!StretchDIBits (dst->dc,
                                    /* dst x,y,w,h */
                                    dst_r.x, dst_r.y + dst_r.height - 1,
                                    dst_r.width, - (int) dst_r.height,
                                    /* src x,y,w,h */
                                    src_r.x, src_extents.height - src_r.y + 1,
                                    src_r.width, - (int) src_r.height,
                                    src_image->data,
                                    &bi,
                                    DIB_RGB_COLORS,
                                    SRCCOPY))
    
    https://bugs.freedesktop.org/show_bug.cgi?id=61876

diff --git a/src/win32/cairo-win32-gdi-compositor.c b/src/win32/cairo-win32-gdi-compositor.c
index c70b0f9..073e889 100644
--- a/src/win32/cairo-win32-gdi-compositor.c
+++ b/src/win32/cairo-win32-gdi-compositor.c
@@ -151,10 +151,11 @@ static cairo_bool_t upload_box (cairo_box_t *box, void *closure)
     int y = _cairo_fixed_integer_part (box->p1.y);
     int width  = _cairo_fixed_integer_part (box->p2.x - box->p1.x);
     int height = _cairo_fixed_integer_part (box->p2.y - box->p1.y);
+    int src_height = -cb->bi.bmiHeader.biHeight;
 
     TRACE ((stderr, "%s\n", __FUNCTION__));
     return StretchDIBits (cb->dst, x, y + height - 1, width, -height,
-			  x + cb->tx,  height - (y + cb->ty - 1),
+			  x + cb->tx,  src_height - (y + cb->ty - 1),
 			  width, -height,
 			  cb->data, &cb->bi,
 			  DIB_RGB_COLORS, SRCCOPY);
commit 0446fae26d35dc4e31aadc498f0f9b48b21d2c45
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Mar 23 11:19:14 2013 +0000

    perf: Iteratively prune outliers
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/perf/cairo-stats.c b/perf/cairo-stats.c
index 44ed038..7a36a13 100644
--- a/perf/cairo-stats.c
+++ b/perf/cairo-stats.c
@@ -56,37 +56,42 @@ _cairo_stats_compute (cairo_stats_t *stats,
      * and third quartiles and IQR is the inter-quartile range (Q3 -
      * Q1).
      */
-    qsort (values, num_values, sizeof (cairo_time_t), _cairo_time_cmp);
+    num_valid = num_values;
+    do {
+	num_values = num_valid;
+	qsort (values, num_values, sizeof (cairo_time_t), _cairo_time_cmp);
 
-    q1 = values[1*num_values/4];
-    q3 = values[3*num_values/4];
+	q1 = values[1*num_values/4];
+	q3 = values[3*num_values/4];
 
-    /* XXX assumes we have native uint64_t */
-    iqr = q3 - q1;
-    outlier_min = q1 - 3 * iqr / 2;
-    outlier_max = q3 + 3 * iqr / 2;
+	/* XXX assumes we have native uint64_t */
+	iqr = q3 - q1;
+	outlier_min = q1 - 3 * iqr / 2;
+	outlier_max = q3 + 3 * iqr / 2;
 
-    for (i = 0; i < num_values && values[i] < outlier_min; i++)
-	;
-    min_valid = i;
+	for (i = 0; i < num_values && values[i] < outlier_min; i++)
+	    ;
+	min_valid = i;
 
-    for (i = 0; i < num_values && values[i] <= outlier_max; i++)
-	;
-    num_valid = i - min_valid;
-    assert(num_valid);
+	for (i = 0; i < num_values && values[i] <= outlier_max; i++)
+	    ;
+	num_valid = i - min_valid;
+	assert(num_valid);
+	values += min_valid;
+    } while (num_valid != num_values);
 
     stats->iterations = num_valid;
-    stats->min_ticks = values[min_valid];
-    stats->median_ticks = values[min_valid + num_valid / 2];
+    stats->min_ticks = values[0];
+    stats->median_ticks = values[num_valid / 2];
 
     sum = 0;
-    for (i = min_valid; i < min_valid + num_valid; i++)
+    for (i = 0; i < num_valid; i++)
 	sum = _cairo_time_add (sum, values[i]);
     mean = sum / num_valid;
 
     /* Let's use a normalized std. deviation for easier comparison. */
     s = 0;
-    for (i = min_valid; i < min_valid + num_valid; i++) {
+    for (i = 0; i < num_valid; i++) {
 	double delta = (values[i] - mean) / (double)mean;
 	s += delta * delta;
     }


More information about the cairo-commit mailing list