gfx/cairo/pixman-bilinear-fastpath.patch

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 changeset: 94061:73a9b24d863a
michael@0 2 tag: bilin
michael@0 3 tag: qbase
michael@0 4 tag: qtip
michael@0 5 tag: tip
michael@0 6 user: Jeff Muizelaar <jmuizelaar@mozilla.com>
michael@0 7 date: Tue May 15 18:26:16 2012 -0400
michael@0 8 summary: Bug 754364. Add bilinear non-repeat and repeat fast paths. r=joe
michael@0 9
michael@0 10 diff --git a/gfx/cairo/libpixman/src/pixman-fast-path.c b/gfx/cairo/libpixman/src/pixman-fast-path.c
michael@0 11 --- a/gfx/cairo/libpixman/src/pixman-fast-path.c
michael@0 12 +++ b/gfx/cairo/libpixman/src/pixman-fast-path.c
michael@0 13 @@ -1186,16 +1186,228 @@ FAST_NEAREST (8888_565_none, 8888, 0565,
michael@0 14 FAST_NEAREST (8888_565_pad, 8888, 0565, uint32_t, uint16_t, SRC, PAD)
michael@0 15 FAST_NEAREST (8888_565_normal, 8888, 0565, uint32_t, uint16_t, SRC, NORMAL)
michael@0 16 FAST_NEAREST (565_565_normal, 0565, 0565, uint16_t, uint16_t, SRC, NORMAL)
michael@0 17 FAST_NEAREST (8888_565_cover, 8888, 0565, uint32_t, uint16_t, OVER, COVER)
michael@0 18 FAST_NEAREST (8888_565_none, 8888, 0565, uint32_t, uint16_t, OVER, NONE)
michael@0 19 FAST_NEAREST (8888_565_pad, 8888, 0565, uint32_t, uint16_t, OVER, PAD)
michael@0 20 FAST_NEAREST (8888_565_normal, 8888, 0565, uint32_t, uint16_t, OVER, NORMAL)
michael@0 21
michael@0 22 +static force_inline void
michael@0 23 +scaled_bilinear_scanline_8888_565_OVER (uint16_t * dst,
michael@0 24 + const uint32_t * mask,
michael@0 25 + const uint32_t * src_top,
michael@0 26 + const uint32_t * src_bottom,
michael@0 27 + int32_t w,
michael@0 28 + int wt,
michael@0 29 + int wb,
michael@0 30 + pixman_fixed_t vx,
michael@0 31 + pixman_fixed_t unit_x,
michael@0 32 + pixman_fixed_t max_vx,
michael@0 33 + pixman_bool_t zero_src)
michael@0 34 +{
michael@0 35 + while ((w -= 1) >= 0)
michael@0 36 + {
michael@0 37 + uint32_t tl = src_top [pixman_fixed_to_int (vx)];
michael@0 38 + uint32_t tr = src_top [pixman_fixed_to_int (vx) + 1];
michael@0 39 + uint32_t bl = src_bottom [pixman_fixed_to_int (vx)];
michael@0 40 + uint32_t br = src_bottom [pixman_fixed_to_int (vx) + 1];
michael@0 41 + uint32_t src, result;
michael@0 42 + uint16_t d;
michael@0 43 + d = *dst;
michael@0 44 + src = bilinear_interpolation (tl, tr,
michael@0 45 + bl, br,
michael@0 46 + interpolation_coord(vx),
michael@0 47 + wb >> (8 - INTERPOLATION_PRECISION_BITS));
michael@0 48 + vx += unit_x;
michael@0 49 + result = over (src, CONVERT_0565_TO_0888 (d));
michael@0 50 + *dst++ = CONVERT_8888_TO_0565(result);
michael@0 51 + }
michael@0 52 +}
michael@0 53 +
michael@0 54 +static force_inline void
michael@0 55 +scaled_bilinear_scanline_8888_8888_OVER (uint32_t * dst,
michael@0 56 + const uint32_t * mask,
michael@0 57 + const uint32_t * src_top,
michael@0 58 + const uint32_t * src_bottom,
michael@0 59 + int32_t w,
michael@0 60 + int wt,
michael@0 61 + int wb,
michael@0 62 + pixman_fixed_t vx,
michael@0 63 + pixman_fixed_t unit_x,
michael@0 64 + pixman_fixed_t max_vx,
michael@0 65 + pixman_bool_t zero_src)
michael@0 66 +{
michael@0 67 + while ((w -= 1) >= 0)
michael@0 68 + {
michael@0 69 + uint32_t tl = src_top [pixman_fixed_to_int (vx)];
michael@0 70 + uint32_t tr = src_top [pixman_fixed_to_int (vx) + 1];
michael@0 71 + uint32_t bl = src_bottom [pixman_fixed_to_int (vx)];
michael@0 72 + uint32_t br = src_bottom [pixman_fixed_to_int (vx) + 1];
michael@0 73 + uint32_t src;
michael@0 74 + uint32_t d;
michael@0 75 + uint32_t result;
michael@0 76 + d = *dst;
michael@0 77 + src = bilinear_interpolation (tl, tr,
michael@0 78 + bl, br,
michael@0 79 + interpolation_coord(vx),
michael@0 80 + wb >> (8 - INTERPOLATION_PRECISION_BITS));
michael@0 81 + vx += unit_x;
michael@0 82 + *dst++ = over (src, d);
michael@0 83 + }
michael@0 84 +}
michael@0 85 +
michael@0 86 +#if 1
michael@0 87 +
michael@0 88 +static force_inline void
michael@0 89 +scaled_bilinear_scanline_565_565_SRC (uint16_t * dst,
michael@0 90 + const uint32_t * mask,
michael@0 91 + const uint16_t * src_top,
michael@0 92 + const uint16_t * src_bottom,
michael@0 93 + int32_t w,
michael@0 94 + int wt,
michael@0 95 + int wb,
michael@0 96 + pixman_fixed_t vx,
michael@0 97 + pixman_fixed_t unit_x,
michael@0 98 + pixman_fixed_t max_vx,
michael@0 99 + pixman_bool_t zero_src)
michael@0 100 +{
michael@0 101 + while ((w -= 1) >= 0)
michael@0 102 + {
michael@0 103 + uint16_t tl = src_top [pixman_fixed_to_int (vx)];
michael@0 104 + uint16_t tr = src_top [pixman_fixed_to_int (vx) + 1];
michael@0 105 + uint16_t bl = src_bottom [pixman_fixed_to_int (vx)];
michael@0 106 + uint16_t br = src_bottom [pixman_fixed_to_int (vx) + 1];
michael@0 107 + uint32_t d;
michael@0 108 + d = bilinear_interpolation(CONVERT_0565_TO_8888(tl),
michael@0 109 + CONVERT_0565_TO_8888(tr),
michael@0 110 + CONVERT_0565_TO_8888(bl),
michael@0 111 + CONVERT_0565_TO_8888(br),
michael@0 112 + interpolation_coord(vx),
michael@0 113 + wb >> (8 - INTERPOLATION_PRECISION_BITS));
michael@0 114 + vx += unit_x;
michael@0 115 + *dst++ = CONVERT_8888_TO_0565(d);
michael@0 116 + }
michael@0 117 +}
michael@0 118 +
michael@0 119 +#else
michael@0 120 +
michael@0 121 +#define SK_G16_MASK_IN_PLACE 0xfc0
michael@0 122 +
michael@0 123 +static inline uint32_t SkExpand_rgb_16(uint16_t c) {
michael@0 124 +
michael@0 125 + return ((c & SK_G16_MASK_IN_PLACE) << 16) | (c & ~SK_G16_MASK_IN_PLACE);
michael@0 126 +}
michael@0 127 +
michael@0 128 +/** Compress an expanded value (from SkExpand_rgb_16) back down to a 16bit
michael@0 129 + color value. The computation yields only 16bits of valid data, but we claim
michael@0 130 + to return 32bits, so that the compiler won't generate extra instructions to
michael@0 131 + "clean" the top 16bits. However, the top 16 can contain garbage, so it is
michael@0 132 + up to the caller to safely ignore them.
michael@0 133 +*/
michael@0 134 +static inline uint16_t SkCompact_rgb_16(uint32_t c) {
michael@0 135 + return ((c >> 16) & SK_G16_MASK_IN_PLACE) | (c & ~SK_G16_MASK_IN_PLACE);
michael@0 136 +}
michael@0 137 +// returns expanded * 5bits
michael@0 138 +static inline uint32_t Filter_565_Expanded(unsigned x, unsigned y,
michael@0 139 + uint32_t a00, uint32_t a01,
michael@0 140 + uint32_t a10, uint32_t a11) {
michael@0 141 + a00 = SkExpand_rgb_16(a00);
michael@0 142 + a01 = SkExpand_rgb_16(a01);
michael@0 143 + a10 = SkExpand_rgb_16(a10);
michael@0 144 + a11 = SkExpand_rgb_16(a11);
michael@0 145 +
michael@0 146 + int xy = x * y >> 3;
michael@0 147 + return a00 * (32 - 2*y - 2*x + xy) +
michael@0 148 + a01 * (2*x - xy) +
michael@0 149 + a10 * (2*y - xy) +
michael@0 150 + a11 * xy;
michael@0 151 +}
michael@0 152 +
michael@0 153 +
michael@0 154 +
michael@0 155 +static force_inline void
michael@0 156 +scaled_bilinear_scanline_565_565_SRC (uint16_t * dst,
michael@0 157 + const uint32_t * mask,
michael@0 158 + const uint16_t * src_top,
michael@0 159 + const uint16_t * src_bottom,
michael@0 160 + int32_t w,
michael@0 161 + int wt,
michael@0 162 + int wb,
michael@0 163 + pixman_fixed_t vx,
michael@0 164 + pixman_fixed_t unit_x,
michael@0 165 + pixman_fixed_t max_vx,
michael@0 166 + pixman_bool_t zero_src)
michael@0 167 +{
michael@0 168 + while ((w -= 1) >= 0)
michael@0 169 + {
michael@0 170 + uint16_t tl = src_top [pixman_fixed_to_int (vx)];
michael@0 171 + uint16_t tr = src_top [pixman_fixed_to_int (vx) + 1];
michael@0 172 + uint16_t bl = src_bottom [pixman_fixed_to_int (vx)];
michael@0 173 + uint16_t br = src_bottom [pixman_fixed_to_int (vx) + 1];
michael@0 174 +
michael@0 175 + uint32_t tmp = Filter_565_Expanded((vx>>12)&0xf, wb>>4, tl, tr, bl, br);
michael@0 176 + vx += unit_x;
michael@0 177 + *dst++ = SkCompact_rgb_16((tmp) >> 5);
michael@0 178 + }
michael@0 179 +}
michael@0 180 +
michael@0 181 +
michael@0 182 +#endif
michael@0 183 +FAST_BILINEAR_MAINLOOP_COMMON (565_565_cover_SRC,
michael@0 184 + scaled_bilinear_scanline_565_565_SRC,
michael@0 185 + uint16_t, uint32_t, uint16_t,
michael@0 186 + COVER, FLAG_NONE)
michael@0 187 +FAST_BILINEAR_MAINLOOP_COMMON (565_565_pad_SRC,
michael@0 188 + scaled_bilinear_scanline_565_565_SRC,
michael@0 189 + uint16_t, uint32_t, uint16_t,
michael@0 190 + PAD, FLAG_NONE)
michael@0 191 +FAST_BILINEAR_MAINLOOP_COMMON (565_565_none_SRC,
michael@0 192 + scaled_bilinear_scanline_565_565_SRC,
michael@0 193 + uint16_t, uint32_t, uint16_t,
michael@0 194 + NONE, FLAG_NONE)
michael@0 195 +FAST_BILINEAR_MAINLOOP_COMMON (565_565_normal_SRC,
michael@0 196 + scaled_bilinear_scanline_565_565_SRC,
michael@0 197 + uint16_t, uint32_t, uint16_t,
michael@0 198 + NORMAL, FLAG_NONE)
michael@0 199 +
michael@0 200 +FAST_BILINEAR_MAINLOOP_COMMON (8888_565_cover_OVER,
michael@0 201 + scaled_bilinear_scanline_8888_565_OVER,
michael@0 202 + uint32_t, uint32_t, uint16_t,
michael@0 203 + COVER, FLAG_NONE)
michael@0 204 +FAST_BILINEAR_MAINLOOP_COMMON (8888_565_pad_OVER,
michael@0 205 + scaled_bilinear_scanline_8888_565_OVER,
michael@0 206 + uint32_t, uint32_t, uint16_t,
michael@0 207 + PAD, FLAG_NONE)
michael@0 208 +FAST_BILINEAR_MAINLOOP_COMMON (8888_565_none_OVER,
michael@0 209 + scaled_bilinear_scanline_8888_565_OVER,
michael@0 210 + uint32_t, uint32_t, uint16_t,
michael@0 211 + NONE, FLAG_NONE)
michael@0 212 +FAST_BILINEAR_MAINLOOP_COMMON (8888_565_normal_OVER,
michael@0 213 + scaled_bilinear_scanline_8888_565_OVER,
michael@0 214 + uint32_t, uint32_t, uint16_t,
michael@0 215 + NORMAL, FLAG_NONE)
michael@0 216 +
michael@0 217 +FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_cover_OVER,
michael@0 218 + scaled_bilinear_scanline_8888_8888_OVER,
michael@0 219 + uint32_t, uint32_t, uint32_t,
michael@0 220 + COVER, FLAG_NONE)
michael@0 221 +FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_pad_OVER,
michael@0 222 + scaled_bilinear_scanline_8888_8888_OVER,
michael@0 223 + uint32_t, uint32_t, uint32_t,
michael@0 224 + PAD, FLAG_NONE)
michael@0 225 +FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_none_OVER,
michael@0 226 + scaled_bilinear_scanline_8888_8888_OVER,
michael@0 227 + uint32_t, uint32_t, uint32_t,
michael@0 228 + NONE, FLAG_NONE)
michael@0 229 +FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_normal_OVER,
michael@0 230 + scaled_bilinear_scanline_8888_8888_OVER,
michael@0 231 + uint32_t, uint32_t, uint32_t,
michael@0 232 + NORMAL, FLAG_NONE)
michael@0 233 +
michael@0 234 #define REPEAT_MIN_WIDTH 32
michael@0 235
michael@0 236 static void
michael@0 237 fast_composite_tiled_repeat (pixman_implementation_t *imp,
michael@0 238 pixman_composite_info_t *info)
michael@0 239 {
michael@0 240 PIXMAN_COMPOSITE_ARGS (info);
michael@0 241 pixman_composite_func_t func;
michael@0 242 @@ -1960,16 +2172,20 @@ static const pixman_fast_path_t c_fast_p
michael@0 243 PIXMAN_any,
michael@0 244 (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM | FAST_PATH_BITS_IMAGE |
michael@0 245 FAST_PATH_NORMAL_REPEAT),
michael@0 246 PIXMAN_any, 0,
michael@0 247 PIXMAN_any, FAST_PATH_STD_DEST_FLAGS,
michael@0 248 fast_composite_tiled_repeat
michael@0 249 },
michael@0 250
michael@0 251 + SIMPLE_BILINEAR_FAST_PATH (SRC, r5g6b5, r5g6b5, 565_565),
michael@0 252 + SIMPLE_BILINEAR_FAST_PATH (OVER, a8r8g8b8, r5g6b5, 8888_565),
michael@0 253 + SIMPLE_BILINEAR_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, 8888_8888),
michael@0 254 +
michael@0 255 { PIXMAN_OP_NONE },
michael@0 256 };
michael@0 257
michael@0 258 #ifdef WORDS_BIGENDIAN
michael@0 259 #define A1_FILL_MASK(n, offs) (((1U << (n)) - 1) << (32 - (offs) - (n)))
michael@0 260 #else
michael@0 261 #define A1_FILL_MASK(n, offs) (((1U << (n)) - 1) << (offs))
michael@0 262 #endif
michael@0 263 diff --git a/gfx/cairo/libpixman/src/pixman-inlines.h b/gfx/cairo/libpixman/src/pixman-inlines.h
michael@0 264 --- a/gfx/cairo/libpixman/src/pixman-inlines.h
michael@0 265 +++ b/gfx/cairo/libpixman/src/pixman-inlines.h
michael@0 266 @@ -80,16 +80,21 @@ repeat (pixman_repeat_t repeat, int *c,
michael@0 267 }
michael@0 268 return TRUE;
michael@0 269 }
michael@0 270
michael@0 271 #ifdef MOZ_GFX_OPTIMIZE_MOBILE
michael@0 272 #define LOW_QUALITY_INTERPOLATION
michael@0 273 #endif
michael@0 274
michael@0 275 +#ifdef LOW_QUALITY_INTERPOLATION
michael@0 276 +#define INTERPOLATION_PRECISION_BITS 4
michael@0 277 +#else
michael@0 278 +#define INTERPOLATION_PRECISION_BITS 8
michael@0 279 +#endif
michael@0 280 static force_inline int32_t
michael@0 281 interpolation_coord(pixman_fixed_t t)
michael@0 282 {
michael@0 283 #ifdef LOW_QUALITY_INTERPOLATION
michael@0 284 return (t >> 12) & 0xf;
michael@0 285 #else
michael@0 286 return (t >> 8) & 0xff;
michael@0 287 #endif

mercurial