diff options
author | Søren Sandmann Pedersen <soren.sandmann@gmail.com> | 2016-04-15 04:08:41 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <soren.sandmann@gmail.com> | 2016-09-06 15:41:40 -0400 |
commit | 89e51000e56e91003b294f739b8e0d9db2002037 (patch) | |
tree | b8fb9ff33643f85c923dbd3a7a66c39525c7795d | |
parent | 9a51d191232e47fc164fb666a441207dbe98823f (diff) |
sample points for fast path
-rw-r--r-- | pixman/pixman-bits-image.c | 7 | ||||
-rw-r--r-- | pixman/pixman-fast-path.c | 7 | ||||
-rw-r--r-- | pixman/pixman-filter.c | 24 |
3 files changed, 20 insertions, 18 deletions
diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c index dcdcc699..e23b2299 100644 --- a/pixman/pixman-bits-image.c +++ b/pixman/pixman-bits-image.c @@ -234,14 +234,17 @@ bits_image_fetch_pixel_separable_convolution (bits_image_t *image, int32_t x1, x2, y1, y2; int32_t px, py; int i, j; + uint32_t x_mask, y_mask; /* Round x and y to the middle of the closest phase before continuing. This * ensures that the convolution matrix is aligned right, since it was * positioned relative to a particular phase (and not relative to whatever * exact fraction we happen to get here). */ - x = ((x >> x_phase_shift) << x_phase_shift) + ((1 << x_phase_shift) >> 1); - y = ((y >> y_phase_shift) << y_phase_shift) + ((1 << y_phase_shift) >> 1); + x_mask = (1 << x_phase_shift) - 1; + y_mask = (1 << y_phase_shift) - 1; + x = ((x - 0x8000 + ((1 << x_phase_shift) >> 1)) & ~x_mask) + 0x8000; + y = ((y - 0x8000 + ((1 << y_phase_shift) >> 1)) & ~y_mask) + 0x8000; px = (x & 0xffff) >> x_phase_shift; py = (y & 0xffff) >> y_phase_shift; diff --git a/pixman/pixman-fast-path.c b/pixman/pixman-fast-path.c index b4daa265..db2f30be 100644 --- a/pixman/pixman-fast-path.c +++ b/pixman/pixman-fast-path.c @@ -2748,6 +2748,7 @@ bits_image_fetch_separable_convolution_affine (pixman_image_t * image, pixman_fixed_t x, y; int32_t x1, x2, y1, y2; int32_t px, py; + uint32_t x_mask, y_mask; int i, j; if (mask && !mask[k]) @@ -2758,8 +2759,10 @@ bits_image_fetch_separable_convolution_affine (pixman_image_t * image, * positioned relative to a particular phase (and not relative to whatever * exact fraction we happen to get here). */ - x = ((vx >> x_phase_shift) << x_phase_shift) + ((1 << x_phase_shift) >> 1); - y = ((vy >> y_phase_shift) << y_phase_shift) + ((1 << y_phase_shift) >> 1); + x_mask = (1 << x_phase_shift) - 1; + y_mask = (1 << y_phase_shift) - 1; + x = ((vx - 0x8000 + ((1 << x_phase_shift) >> 1)) & ~x_mask) + 0x8000; + y = ((vy - 0x8000 + ((1 << y_phase_shift) >> 1)) & ~y_mask) + 0x8000; px = (x & 0xffff) >> x_phase_shift; py = (y & 0xffff) >> y_phase_shift; diff --git a/pixman/pixman-filter.c b/pixman/pixman-filter.c index 5f3b752f..17668234 100644 --- a/pixman/pixman-filter.c +++ b/pixman/pixman-filter.c @@ -239,14 +239,11 @@ create_1d_filter (int width, int n_phases, pixman_fixed_t *p) { - double step; int i; - step = 1.0 / n_phases; - for (i = 0; i < n_phases; ++i) { - double frac = step / 2.0 + i * step; + double frac = (n_phases == 1)? 0.5 : (i / (double)n_phases); pixman_fixed_t new_total; int x, x1, x2; double total, e; @@ -334,12 +331,9 @@ filter_width (pixman_kernel_t reconstruct, pixman_kernel_t sample, double size) static void gnuplot_filter (int width, int n_phases, const pixman_fixed_t* p) { - double step; int i, j; int first; - step = 1.0 / n_phases; - printf ("set style line 1 lc rgb '#0060ad' lt 1 lw 0.5 pt 7 pi 1 ps 0.5\n"); printf ("plot [x=%g:%g] '-' with linespoints ls 1\n", -width*0.5, width*0.5); /* Print a point at the origin so that y==0 line is included: */ @@ -356,7 +350,8 @@ gnuplot_filter (int width, int n_phases, const pixman_fixed_t* p) * * ceil (frac - width / 2.0 - 0.5) + 0.5 - frac * = ceil (frac) + K - frac - * = 1 + K - frac + * = 1 + K - frac for frac > 0 + * K for frac = 0 * * for some K, so this is minimized when frac is maximized and * strictly growing with frac. So for odd widths, we can simply @@ -388,21 +383,22 @@ gnuplot_filter (int width, int n_phases, const pixman_fixed_t* p) * * Which phase is as close as possible 0.5? The locations of the * sampling point corresponding to the kth phase is given by - * 1/(2 * n_phases) + k / n_phases: + * k / n_phases: * - * 1/(2 * n_phases) + k / n_phases = 0.5 + * k / n_phases = 0.5 * * from which it follows that * - * k = (n_phases - 1) / 2 + * k = n_phases / 2 * * rounded down is the phase in question. */ if (width & 1) - first = n_phases - 1; + first = 0; else - first = (n_phases - 1) / 2; + first = n_phases / 2; + printf ("# width: %d n_phases: %d \n", width, n_phases); for (j = 0; j < width; ++j) { for (i = 0; i < n_phases; ++i) @@ -413,7 +409,7 @@ gnuplot_filter (int width, int n_phases, const pixman_fixed_t* p) if (phase < 0) phase = n_phases + phase; - frac = step / 2.0 + phase * step; + frac = (n_phases == 1)? 0.5 : (phase / (double)n_phases); pos = ceil (frac - width / 2.0 - 0.5) + 0.5 - frac + j; printf ("%g %g\n", |