gfx/cairo/pixman-bilinear-fastpath.patch

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/cairo/pixman-bilinear-fastpath.patch	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,287 @@
     1.4 +changeset:   94061:73a9b24d863a
     1.5 +tag:         bilin
     1.6 +tag:         qbase
     1.7 +tag:         qtip
     1.8 +tag:         tip
     1.9 +user:        Jeff Muizelaar <jmuizelaar@mozilla.com>
    1.10 +date:        Tue May 15 18:26:16 2012 -0400
    1.11 +summary:     Bug 754364. Add bilinear non-repeat and repeat fast paths. r=joe
    1.12 +
    1.13 +diff --git a/gfx/cairo/libpixman/src/pixman-fast-path.c b/gfx/cairo/libpixman/src/pixman-fast-path.c
    1.14 +--- a/gfx/cairo/libpixman/src/pixman-fast-path.c
    1.15 ++++ b/gfx/cairo/libpixman/src/pixman-fast-path.c
    1.16 +@@ -1186,16 +1186,228 @@ FAST_NEAREST (8888_565_none, 8888, 0565,
    1.17 + FAST_NEAREST (8888_565_pad, 8888, 0565, uint32_t, uint16_t, SRC, PAD)
    1.18 + FAST_NEAREST (8888_565_normal, 8888, 0565, uint32_t, uint16_t, SRC, NORMAL)
    1.19 + FAST_NEAREST (565_565_normal, 0565, 0565, uint16_t, uint16_t, SRC, NORMAL)
    1.20 + FAST_NEAREST (8888_565_cover, 8888, 0565, uint32_t, uint16_t, OVER, COVER)
    1.21 + FAST_NEAREST (8888_565_none, 8888, 0565, uint32_t, uint16_t, OVER, NONE)
    1.22 + FAST_NEAREST (8888_565_pad, 8888, 0565, uint32_t, uint16_t, OVER, PAD)
    1.23 + FAST_NEAREST (8888_565_normal, 8888, 0565, uint32_t, uint16_t, OVER, NORMAL)
    1.24 + 
    1.25 ++static force_inline void
    1.26 ++scaled_bilinear_scanline_8888_565_OVER (uint16_t *       dst,
    1.27 ++                                        const uint32_t * mask,
    1.28 ++                                        const uint32_t * src_top,
    1.29 ++                                        const uint32_t * src_bottom,
    1.30 ++                                        int32_t          w,
    1.31 ++                                        int              wt,
    1.32 ++                                        int              wb,
    1.33 ++                                        pixman_fixed_t   vx,
    1.34 ++                                        pixman_fixed_t   unit_x,
    1.35 ++                                        pixman_fixed_t   max_vx,
    1.36 ++                                        pixman_bool_t    zero_src)
    1.37 ++{
    1.38 ++    while ((w -= 1) >= 0)
    1.39 ++    {
    1.40 ++	uint32_t tl = src_top [pixman_fixed_to_int (vx)];
    1.41 ++	uint32_t tr = src_top [pixman_fixed_to_int (vx) + 1];
    1.42 ++	uint32_t bl = src_bottom [pixman_fixed_to_int (vx)];
    1.43 ++	uint32_t br = src_bottom [pixman_fixed_to_int (vx) + 1];
    1.44 ++	uint32_t src, result;
    1.45 ++	uint16_t d;
    1.46 ++	d = *dst;
    1.47 ++	src = bilinear_interpolation (tl, tr,
    1.48 ++				      bl, br,
    1.49 ++				      interpolation_coord(vx),
    1.50 ++				      wb >> (8 - INTERPOLATION_PRECISION_BITS));
    1.51 ++	vx += unit_x;
    1.52 ++	result = over (src, CONVERT_0565_TO_0888 (d));
    1.53 ++	*dst++ = CONVERT_8888_TO_0565(result);
    1.54 ++    }
    1.55 ++}
    1.56 ++
    1.57 ++static force_inline void
    1.58 ++scaled_bilinear_scanline_8888_8888_OVER (uint32_t *       dst,
    1.59 ++                                         const uint32_t * mask,
    1.60 ++                                         const uint32_t * src_top,
    1.61 ++                                         const uint32_t * src_bottom,
    1.62 ++                                         int32_t          w,
    1.63 ++                                         int              wt,
    1.64 ++                                         int              wb,
    1.65 ++                                         pixman_fixed_t   vx,
    1.66 ++                                         pixman_fixed_t   unit_x,
    1.67 ++                                         pixman_fixed_t   max_vx,
    1.68 ++                                         pixman_bool_t    zero_src)
    1.69 ++{
    1.70 ++    while ((w -= 1) >= 0)
    1.71 ++    {
    1.72 ++	uint32_t tl = src_top [pixman_fixed_to_int (vx)];
    1.73 ++	uint32_t tr = src_top [pixman_fixed_to_int (vx) + 1];
    1.74 ++	uint32_t bl = src_bottom [pixman_fixed_to_int (vx)];
    1.75 ++	uint32_t br = src_bottom [pixman_fixed_to_int (vx) + 1];
    1.76 ++	uint32_t src;
    1.77 ++	uint32_t d;
    1.78 ++	uint32_t result;
    1.79 ++	d = *dst;
    1.80 ++	src = bilinear_interpolation (tl, tr,
    1.81 ++				      bl, br,
    1.82 ++				      interpolation_coord(vx),
    1.83 ++				      wb >> (8 - INTERPOLATION_PRECISION_BITS));
    1.84 ++	vx += unit_x;
    1.85 ++	*dst++ = over (src, d);
    1.86 ++    }
    1.87 ++}
    1.88 ++
    1.89 ++#if 1
    1.90 ++
    1.91 ++static force_inline void
    1.92 ++scaled_bilinear_scanline_565_565_SRC (uint16_t *       dst,
    1.93 ++				      const uint32_t * mask,
    1.94 ++				      const uint16_t * src_top,
    1.95 ++				      const uint16_t * src_bottom,
    1.96 ++				      int32_t          w,
    1.97 ++				      int              wt,
    1.98 ++				      int              wb,
    1.99 ++				      pixman_fixed_t   vx,
   1.100 ++				      pixman_fixed_t   unit_x,
   1.101 ++				      pixman_fixed_t   max_vx,
   1.102 ++				      pixman_bool_t    zero_src)
   1.103 ++{
   1.104 ++    while ((w -= 1) >= 0)
   1.105 ++    {
   1.106 ++	uint16_t tl = src_top [pixman_fixed_to_int (vx)];
   1.107 ++	uint16_t tr = src_top [pixman_fixed_to_int (vx) + 1];
   1.108 ++	uint16_t bl = src_bottom [pixman_fixed_to_int (vx)];
   1.109 ++	uint16_t br = src_bottom [pixman_fixed_to_int (vx) + 1];
   1.110 ++	uint32_t d;
   1.111 ++	d = bilinear_interpolation(CONVERT_0565_TO_8888(tl),
   1.112 ++				   CONVERT_0565_TO_8888(tr),
   1.113 ++				   CONVERT_0565_TO_8888(bl),
   1.114 ++				   CONVERT_0565_TO_8888(br),
   1.115 ++				   interpolation_coord(vx),
   1.116 ++				   wb >> (8 - INTERPOLATION_PRECISION_BITS));
   1.117 ++	vx += unit_x;
   1.118 ++	*dst++ = CONVERT_8888_TO_0565(d);
   1.119 ++    }
   1.120 ++}
   1.121 ++
   1.122 ++#else
   1.123 ++
   1.124 ++#define SK_G16_MASK_IN_PLACE 0xfc0
   1.125 ++
   1.126 ++static inline uint32_t SkExpand_rgb_16(uint16_t c) {
   1.127 ++
   1.128 ++    return ((c & SK_G16_MASK_IN_PLACE) << 16) | (c & ~SK_G16_MASK_IN_PLACE);
   1.129 ++}
   1.130 ++
   1.131 ++/** Compress an expanded value (from SkExpand_rgb_16) back down to a 16bit
   1.132 ++    color value. The computation yields only 16bits of valid data, but we claim
   1.133 ++    to return 32bits, so that the compiler won't generate extra instructions to
   1.134 ++    "clean" the top 16bits. However, the top 16 can contain garbage, so it is
   1.135 ++    up to the caller to safely ignore them.
   1.136 ++*/
   1.137 ++static inline uint16_t SkCompact_rgb_16(uint32_t c) {
   1.138 ++    return ((c >> 16) & SK_G16_MASK_IN_PLACE) | (c & ~SK_G16_MASK_IN_PLACE);
   1.139 ++}
   1.140 ++// returns expanded * 5bits
   1.141 ++static inline uint32_t Filter_565_Expanded(unsigned x, unsigned y,
   1.142 ++                                           uint32_t a00, uint32_t a01,
   1.143 ++                                           uint32_t a10, uint32_t a11) {
   1.144 ++    a00 = SkExpand_rgb_16(a00);
   1.145 ++    a01 = SkExpand_rgb_16(a01);
   1.146 ++    a10 = SkExpand_rgb_16(a10);
   1.147 ++    a11 = SkExpand_rgb_16(a11);
   1.148 ++    
   1.149 ++    int xy = x * y >> 3;
   1.150 ++    return  a00 * (32 - 2*y - 2*x + xy) +
   1.151 ++            a01 * (2*x - xy) +
   1.152 ++            a10 * (2*y - xy) +
   1.153 ++            a11 * xy;
   1.154 ++}
   1.155 ++
   1.156 ++
   1.157 ++
   1.158 ++static force_inline void
   1.159 ++scaled_bilinear_scanline_565_565_SRC (uint16_t *       dst,
   1.160 ++				      const uint32_t * mask,
   1.161 ++				      const uint16_t * src_top,
   1.162 ++				      const uint16_t * src_bottom,
   1.163 ++				      int32_t          w,
   1.164 ++				      int              wt,
   1.165 ++				      int              wb,
   1.166 ++				      pixman_fixed_t   vx,
   1.167 ++				      pixman_fixed_t   unit_x,
   1.168 ++				      pixman_fixed_t   max_vx,
   1.169 ++				      pixman_bool_t    zero_src)
   1.170 ++{
   1.171 ++    while ((w -= 1) >= 0)
   1.172 ++    {
   1.173 ++	uint16_t tl = src_top [pixman_fixed_to_int (vx)];
   1.174 ++	uint16_t tr = src_top [pixman_fixed_to_int (vx) + 1];
   1.175 ++	uint16_t bl = src_bottom [pixman_fixed_to_int (vx)];
   1.176 ++	uint16_t br = src_bottom [pixman_fixed_to_int (vx) + 1];
   1.177 ++
   1.178 ++        uint32_t tmp = Filter_565_Expanded((vx>>12)&0xf, wb>>4, tl, tr, bl, br);
   1.179 ++        vx += unit_x;
   1.180 ++        *dst++ = SkCompact_rgb_16((tmp) >> 5);
   1.181 ++    }
   1.182 ++}
   1.183 ++
   1.184 ++
   1.185 ++#endif
   1.186 ++FAST_BILINEAR_MAINLOOP_COMMON (565_565_cover_SRC,
   1.187 ++			       scaled_bilinear_scanline_565_565_SRC,
   1.188 ++			       uint16_t, uint32_t, uint16_t,
   1.189 ++			       COVER, FLAG_NONE)
   1.190 ++FAST_BILINEAR_MAINLOOP_COMMON (565_565_pad_SRC,
   1.191 ++			       scaled_bilinear_scanline_565_565_SRC,
   1.192 ++			       uint16_t, uint32_t, uint16_t,
   1.193 ++			       PAD, FLAG_NONE)
   1.194 ++FAST_BILINEAR_MAINLOOP_COMMON (565_565_none_SRC,
   1.195 ++			       scaled_bilinear_scanline_565_565_SRC,
   1.196 ++			       uint16_t, uint32_t, uint16_t,
   1.197 ++			       NONE, FLAG_NONE)
   1.198 ++FAST_BILINEAR_MAINLOOP_COMMON (565_565_normal_SRC,
   1.199 ++			       scaled_bilinear_scanline_565_565_SRC,
   1.200 ++			       uint16_t, uint32_t, uint16_t,
   1.201 ++			       NORMAL, FLAG_NONE)
   1.202 ++
   1.203 ++FAST_BILINEAR_MAINLOOP_COMMON (8888_565_cover_OVER,
   1.204 ++			       scaled_bilinear_scanline_8888_565_OVER,
   1.205 ++			       uint32_t, uint32_t, uint16_t,
   1.206 ++			       COVER, FLAG_NONE)
   1.207 ++FAST_BILINEAR_MAINLOOP_COMMON (8888_565_pad_OVER,
   1.208 ++			       scaled_bilinear_scanline_8888_565_OVER,
   1.209 ++			       uint32_t, uint32_t, uint16_t,
   1.210 ++			       PAD, FLAG_NONE)
   1.211 ++FAST_BILINEAR_MAINLOOP_COMMON (8888_565_none_OVER,
   1.212 ++			       scaled_bilinear_scanline_8888_565_OVER,
   1.213 ++			       uint32_t, uint32_t, uint16_t,
   1.214 ++			       NONE, FLAG_NONE)
   1.215 ++FAST_BILINEAR_MAINLOOP_COMMON (8888_565_normal_OVER,
   1.216 ++			       scaled_bilinear_scanline_8888_565_OVER,
   1.217 ++			       uint32_t, uint32_t, uint16_t,
   1.218 ++			       NORMAL, FLAG_NONE)
   1.219 ++
   1.220 ++FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_cover_OVER,
   1.221 ++			       scaled_bilinear_scanline_8888_8888_OVER,
   1.222 ++			       uint32_t, uint32_t, uint32_t,
   1.223 ++			       COVER, FLAG_NONE)
   1.224 ++FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_pad_OVER,
   1.225 ++			       scaled_bilinear_scanline_8888_8888_OVER,
   1.226 ++			       uint32_t, uint32_t, uint32_t,
   1.227 ++			       PAD, FLAG_NONE)
   1.228 ++FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_none_OVER,
   1.229 ++			       scaled_bilinear_scanline_8888_8888_OVER,
   1.230 ++			       uint32_t, uint32_t, uint32_t,
   1.231 ++			       NONE, FLAG_NONE)
   1.232 ++FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_normal_OVER,
   1.233 ++			       scaled_bilinear_scanline_8888_8888_OVER,
   1.234 ++			       uint32_t, uint32_t, uint32_t,
   1.235 ++			       NORMAL, FLAG_NONE)
   1.236 ++
   1.237 + #define REPEAT_MIN_WIDTH    32
   1.238 + 
   1.239 + static void
   1.240 + fast_composite_tiled_repeat (pixman_implementation_t *imp,
   1.241 + 			     pixman_composite_info_t *info)
   1.242 + {
   1.243 +     PIXMAN_COMPOSITE_ARGS (info);
   1.244 +     pixman_composite_func_t func;
   1.245 +@@ -1960,16 +2172,20 @@ static const pixman_fast_path_t c_fast_p
   1.246 + 	PIXMAN_any,
   1.247 + 	(FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM | FAST_PATH_BITS_IMAGE |
   1.248 + 	 FAST_PATH_NORMAL_REPEAT),
   1.249 + 	PIXMAN_any, 0,
   1.250 + 	PIXMAN_any, FAST_PATH_STD_DEST_FLAGS,
   1.251 + 	fast_composite_tiled_repeat
   1.252 +     },
   1.253 + 
   1.254 ++    SIMPLE_BILINEAR_FAST_PATH (SRC, r5g6b5, r5g6b5, 565_565),
   1.255 ++    SIMPLE_BILINEAR_FAST_PATH (OVER, a8r8g8b8, r5g6b5, 8888_565),
   1.256 ++    SIMPLE_BILINEAR_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, 8888_8888),
   1.257 ++
   1.258 +     {   PIXMAN_OP_NONE	},
   1.259 + };
   1.260 + 
   1.261 + #ifdef WORDS_BIGENDIAN
   1.262 + #define A1_FILL_MASK(n, offs) (((1U << (n)) - 1) << (32 - (offs) - (n)))
   1.263 + #else
   1.264 + #define A1_FILL_MASK(n, offs) (((1U << (n)) - 1) << (offs))
   1.265 + #endif
   1.266 +diff --git a/gfx/cairo/libpixman/src/pixman-inlines.h b/gfx/cairo/libpixman/src/pixman-inlines.h
   1.267 +--- a/gfx/cairo/libpixman/src/pixman-inlines.h
   1.268 ++++ b/gfx/cairo/libpixman/src/pixman-inlines.h
   1.269 +@@ -80,16 +80,21 @@ repeat (pixman_repeat_t repeat, int *c, 
   1.270 +     }
   1.271 +     return TRUE;
   1.272 + }
   1.273 + 
   1.274 + #ifdef MOZ_GFX_OPTIMIZE_MOBILE
   1.275 + #define LOW_QUALITY_INTERPOLATION
   1.276 + #endif
   1.277 + 
   1.278 ++#ifdef LOW_QUALITY_INTERPOLATION
   1.279 ++#define INTERPOLATION_PRECISION_BITS 4
   1.280 ++#else
   1.281 ++#define INTERPOLATION_PRECISION_BITS 8
   1.282 ++#endif
   1.283 + static force_inline int32_t
   1.284 + interpolation_coord(pixman_fixed_t t)
   1.285 + {
   1.286 + #ifdef LOW_QUALITY_INTERPOLATION
   1.287 +     return (t >> 12) & 0xf;
   1.288 + #else
   1.289 +     return (t >> 8) & 0xff;
   1.290 + #endif

mercurial