diff options
Diffstat (limited to 'pixman/pixman/pixman-inlines.h')
-rw-r--r-- | pixman/pixman/pixman-inlines.h | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/pixman/pixman/pixman-inlines.h b/pixman/pixman/pixman-inlines.h index 3532867a4..5517de5a5 100644 --- a/pixman/pixman/pixman-inlines.h +++ b/pixman/pixman/pixman-inlines.h @@ -81,6 +81,13 @@ repeat (pixman_repeat_t repeat, int *c, int size) return TRUE; } +static force_inline int +pixman_fixed_to_bilinear_weight (pixman_fixed_t x) +{ + return (x >> (16 - BILINEAR_INTERPOLATION_BITS)) & + ((1 << BILINEAR_INTERPOLATION_BITS) - 1); +} + #if SIZEOF_LONG > 4 static force_inline uint32_t @@ -92,6 +99,9 @@ bilinear_interpolation (uint32_t tl, uint32_t tr, uint64_t tl64, tr64, bl64, br64; uint64_t f, r; + distx <<= (8 - BILINEAR_INTERPOLATION_BITS); + disty <<= (8 - BILINEAR_INTERPOLATION_BITS); + distxy = distx * disty; distxiy = distx * (256 - disty); distixy = (256 - distx) * disty; @@ -135,6 +145,9 @@ bilinear_interpolation (uint32_t tl, uint32_t tr, int distxy, distxiy, distixy, distixiy; uint32_t f, r; + distx <<= (8 - BILINEAR_INTERPOLATION_BITS); + disty <<= (8 - BILINEAR_INTERPOLATION_BITS); + distxy = distx * disty; distxiy = (distx << 8) - distxy; /* distx * (256 - disty) */ distixy = (disty << 8) - distxy; /* disty * (256 - distx) */ @@ -758,12 +771,14 @@ bilinear_pad_repeat_get_scanline_bounds (int32_t source_image_width, * all source pixels are fetched from zero padding * zone for NONE repeat * - * Note: normally the sum of 'weight_top' and 'weight_bottom' is equal to 256, - * but sometimes it may be less than that for NONE repeat when handling - * fuzzy antialiased top or bottom image edges. Also both top and - * bottom weight variables are guaranteed to have value in 0-255 - * range and can fit into unsigned byte or be used with 8-bit SIMD - * multiplication instructions. + * Note: normally the sum of 'weight_top' and 'weight_bottom' is equal to + * BILINEAR_INTERPOLATION_RANGE, but sometimes it may be less than that + * for NONE repeat when handling fuzzy antialiased top or bottom image + * edges. Also both top and bottom weight variables are guaranteed to + * have value, which is less than BILINEAR_INTERPOLATION_RANGE. + * For example, the weights can fit into unsigned byte or be used + * with 8-bit SIMD multiplication instructions for 8-bit interpolation + * precision. */ #define FAST_BILINEAR_MAINLOOP_INT(scale_func_name, scanline_func, src_type_t, mask_type_t, \ dst_type_t, repeat_mode, flags) \ @@ -877,18 +892,18 @@ fast_composite_scaled_bilinear ## scale_func_name (pixman_implementation_t *imp, } \ \ y1 = pixman_fixed_to_int (vy); \ - weight2 = (vy >> 8) & 0xff; \ + weight2 = pixman_fixed_to_bilinear_weight (vy); \ if (weight2) \ { \ - /* normal case, both row weights are in 0-255 range and fit unsigned byte */ \ + /* both weight1 and weight2 are smaller than BILINEAR_INTERPOLATION_RANGE */ \ y2 = y1 + 1; \ - weight1 = 256 - weight2; \ + weight1 = BILINEAR_INTERPOLATION_RANGE - weight2; \ } \ else \ { \ - /* set both top and bottom row to the same scanline, and weights to 128+128 */ \ + /* set both top and bottom row to the same scanline and tweak weights */ \ y2 = y1; \ - weight1 = weight2 = 128; \ + weight1 = weight2 = BILINEAR_INTERPOLATION_RANGE / 2; \ } \ vy += unit_y; \ if (PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_PAD) \ |