Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* NEON optimized code (C) COPYRIGHT 2009 Motorola |
michael@0 | 2 | * |
michael@0 | 3 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | * found in the LICENSE file. |
michael@0 | 5 | */ |
michael@0 | 6 | |
michael@0 | 7 | #include "SkBitmapProcState.h" |
michael@0 | 8 | #include "SkPerspIter.h" |
michael@0 | 9 | #include "SkShader.h" |
michael@0 | 10 | #include "SkUtilsArm.h" |
michael@0 | 11 | #include "SkBitmapProcState_utils.h" |
michael@0 | 12 | |
michael@0 | 13 | #include <arm_neon.h> |
michael@0 | 14 | |
michael@0 | 15 | extern const SkBitmapProcState::MatrixProc ClampX_ClampY_Procs_neon[]; |
michael@0 | 16 | extern const SkBitmapProcState::MatrixProc RepeatX_RepeatY_Procs_neon[]; |
michael@0 | 17 | |
michael@0 | 18 | static void decal_nofilter_scale_neon(uint32_t dst[], SkFixed fx, SkFixed dx, int count); |
michael@0 | 19 | static void decal_filter_scale_neon(uint32_t dst[], SkFixed fx, SkFixed dx, int count); |
michael@0 | 20 | |
michael@0 | 21 | // TILEX_PROCF(fx, max) SkClampMax((fx) >> 16, max) |
michael@0 | 22 | static inline int16x8_t sbpsm_clamp_tile8(int32x4_t low, int32x4_t high, unsigned max) { |
michael@0 | 23 | int16x8_t res; |
michael@0 | 24 | |
michael@0 | 25 | // get the hi 16s of all those 32s |
michael@0 | 26 | res = vuzpq_s16(vreinterpretq_s16_s32(low), vreinterpretq_s16_s32(high)).val[1]; |
michael@0 | 27 | |
michael@0 | 28 | // clamp |
michael@0 | 29 | res = vmaxq_s16(res, vdupq_n_s16(0)); |
michael@0 | 30 | res = vminq_s16(res, vdupq_n_s16(max)); |
michael@0 | 31 | |
michael@0 | 32 | return res; |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | // TILEX_PROCF(fx, max) SkClampMax((fx) >> 16, max) |
michael@0 | 36 | static inline int32x4_t sbpsm_clamp_tile4(int32x4_t f, unsigned max) { |
michael@0 | 37 | int32x4_t res; |
michael@0 | 38 | |
michael@0 | 39 | // get the hi 16s of all those 32s |
michael@0 | 40 | res = vshrq_n_s32(f, 16); |
michael@0 | 41 | |
michael@0 | 42 | // clamp |
michael@0 | 43 | res = vmaxq_s32(res, vdupq_n_s32(0)); |
michael@0 | 44 | res = vminq_s32(res, vdupq_n_s32(max)); |
michael@0 | 45 | |
michael@0 | 46 | return res; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | // TILEY_LOW_BITS(fy, max) (((fy) >> 12) & 0xF) |
michael@0 | 50 | static inline int32x4_t sbpsm_clamp_tile4_low_bits(int32x4_t fx) { |
michael@0 | 51 | int32x4_t ret; |
michael@0 | 52 | |
michael@0 | 53 | ret = vshrq_n_s32(fx, 12); |
michael@0 | 54 | |
michael@0 | 55 | /* We don't need the mask below because the caller will |
michael@0 | 56 | * overwrite the non-masked bits |
michael@0 | 57 | */ |
michael@0 | 58 | //ret = vandq_s32(ret, vdupq_n_s32(0xF)); |
michael@0 | 59 | |
michael@0 | 60 | return ret; |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | // TILEX_PROCF(fx, max) (((fx)&0xFFFF)*((max)+1)>> 16) |
michael@0 | 64 | static inline int16x8_t sbpsm_repeat_tile8(int32x4_t low, int32x4_t high, unsigned max) { |
michael@0 | 65 | uint16x8_t res; |
michael@0 | 66 | uint32x4_t tmpl, tmph; |
michael@0 | 67 | |
michael@0 | 68 | // get the lower 16 bits |
michael@0 | 69 | res = vuzpq_u16(vreinterpretq_u16_s32(low), vreinterpretq_u16_s32(high)).val[0]; |
michael@0 | 70 | |
michael@0 | 71 | // bare multiplication, not SkFixedMul |
michael@0 | 72 | tmpl = vmull_u16(vget_low_u16(res), vdup_n_u16(max+1)); |
michael@0 | 73 | tmph = vmull_u16(vget_high_u16(res), vdup_n_u16(max+1)); |
michael@0 | 74 | |
michael@0 | 75 | // extraction of the 16 upper bits |
michael@0 | 76 | res = vuzpq_u16(vreinterpretq_u16_u32(tmpl), vreinterpretq_u16_u32(tmph)).val[1]; |
michael@0 | 77 | |
michael@0 | 78 | return vreinterpretq_s16_u16(res); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | // TILEX_PROCF(fx, max) (((fx)&0xFFFF)*((max)+1)>> 16) |
michael@0 | 82 | static inline int32x4_t sbpsm_repeat_tile4(int32x4_t f, unsigned max) { |
michael@0 | 83 | uint16x4_t res; |
michael@0 | 84 | uint32x4_t tmp; |
michael@0 | 85 | |
michael@0 | 86 | // get the lower 16 bits |
michael@0 | 87 | res = vmovn_u32(vreinterpretq_u32_s32(f)); |
michael@0 | 88 | |
michael@0 | 89 | // bare multiplication, not SkFixedMul |
michael@0 | 90 | tmp = vmull_u16(res, vdup_n_u16(max+1)); |
michael@0 | 91 | |
michael@0 | 92 | // extraction of the 16 upper bits |
michael@0 | 93 | tmp = vshrq_n_u32(tmp, 16); |
michael@0 | 94 | |
michael@0 | 95 | return vreinterpretq_s32_u32(tmp); |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | // TILEX_LOW_BITS(fx, max) ((((fx) & 0xFFFF) * ((max) + 1) >> 12) & 0xF) |
michael@0 | 99 | static inline int32x4_t sbpsm_repeat_tile4_low_bits(int32x4_t fx, unsigned max) { |
michael@0 | 100 | uint16x4_t res; |
michael@0 | 101 | uint32x4_t tmp; |
michael@0 | 102 | int32x4_t ret; |
michael@0 | 103 | |
michael@0 | 104 | // get the lower 16 bits |
michael@0 | 105 | res = vmovn_u32(vreinterpretq_u32_s32(fx)); |
michael@0 | 106 | |
michael@0 | 107 | // bare multiplication, not SkFixedMul |
michael@0 | 108 | tmp = vmull_u16(res, vdup_n_u16(max + 1)); |
michael@0 | 109 | |
michael@0 | 110 | // shift and mask |
michael@0 | 111 | ret = vshrq_n_s32(vreinterpretq_s32_u32(tmp), 12); |
michael@0 | 112 | |
michael@0 | 113 | /* We don't need the mask below because the caller will |
michael@0 | 114 | * overwrite the non-masked bits |
michael@0 | 115 | */ |
michael@0 | 116 | //ret = vandq_s32(ret, vdupq_n_s32(0xF)); |
michael@0 | 117 | |
michael@0 | 118 | return ret; |
michael@0 | 119 | } |
michael@0 | 120 | |
michael@0 | 121 | #define MAKENAME(suffix) ClampX_ClampY ## suffix ## _neon |
michael@0 | 122 | #define TILEX_PROCF(fx, max) SkClampMax((fx) >> 16, max) |
michael@0 | 123 | #define TILEY_PROCF(fy, max) SkClampMax((fy) >> 16, max) |
michael@0 | 124 | #define TILEX_PROCF_NEON8(l, h, max) sbpsm_clamp_tile8(l, h, max) |
michael@0 | 125 | #define TILEY_PROCF_NEON8(l, h, max) sbpsm_clamp_tile8(l, h, max) |
michael@0 | 126 | #define TILEX_PROCF_NEON4(fx, max) sbpsm_clamp_tile4(fx, max) |
michael@0 | 127 | #define TILEY_PROCF_NEON4(fy, max) sbpsm_clamp_tile4(fy, max) |
michael@0 | 128 | #define TILEX_LOW_BITS(fx, max) (((fx) >> 12) & 0xF) |
michael@0 | 129 | #define TILEY_LOW_BITS(fy, max) (((fy) >> 12) & 0xF) |
michael@0 | 130 | #define TILEX_LOW_BITS_NEON4(fx, max) sbpsm_clamp_tile4_low_bits(fx) |
michael@0 | 131 | #define TILEY_LOW_BITS_NEON4(fy, max) sbpsm_clamp_tile4_low_bits(fy) |
michael@0 | 132 | #define CHECK_FOR_DECAL |
michael@0 | 133 | #include "SkBitmapProcState_matrix_neon.h" |
michael@0 | 134 | |
michael@0 | 135 | #define MAKENAME(suffix) RepeatX_RepeatY ## suffix ## _neon |
michael@0 | 136 | #define TILEX_PROCF(fx, max) SK_USHIFT16(((fx) & 0xFFFF) * ((max) + 1)) |
michael@0 | 137 | #define TILEY_PROCF(fy, max) SK_USHIFT16(((fy) & 0xFFFF) * ((max) + 1)) |
michael@0 | 138 | #define TILEX_PROCF_NEON8(l, h, max) sbpsm_repeat_tile8(l, h, max) |
michael@0 | 139 | #define TILEY_PROCF_NEON8(l, h, max) sbpsm_repeat_tile8(l, h, max) |
michael@0 | 140 | #define TILEX_PROCF_NEON4(fx, max) sbpsm_repeat_tile4(fx, max) |
michael@0 | 141 | #define TILEY_PROCF_NEON4(fy, max) sbpsm_repeat_tile4(fy, max) |
michael@0 | 142 | #define TILEX_LOW_BITS(fx, max) ((((fx) & 0xFFFF) * ((max) + 1) >> 12) & 0xF) |
michael@0 | 143 | #define TILEY_LOW_BITS(fy, max) ((((fy) & 0xFFFF) * ((max) + 1) >> 12) & 0xF) |
michael@0 | 144 | #define TILEX_LOW_BITS_NEON4(fx, max) sbpsm_repeat_tile4_low_bits(fx, max) |
michael@0 | 145 | #define TILEY_LOW_BITS_NEON4(fy, max) sbpsm_repeat_tile4_low_bits(fy, max) |
michael@0 | 146 | #include "SkBitmapProcState_matrix_neon.h" |
michael@0 | 147 | |
michael@0 | 148 | |
michael@0 | 149 | |
michael@0 | 150 | void decal_nofilter_scale_neon(uint32_t dst[], SkFixed fx, SkFixed dx, int count) { |
michael@0 | 151 | if (count >= 8) { |
michael@0 | 152 | // SkFixed is 16.16 fixed point |
michael@0 | 153 | SkFixed dx8 = dx * 8; |
michael@0 | 154 | int32x4_t vdx8 = vdupq_n_s32(dx8); |
michael@0 | 155 | |
michael@0 | 156 | // setup lbase and hbase |
michael@0 | 157 | int32x4_t lbase, hbase; |
michael@0 | 158 | lbase = vdupq_n_s32(fx); |
michael@0 | 159 | lbase = vsetq_lane_s32(fx + dx, lbase, 1); |
michael@0 | 160 | lbase = vsetq_lane_s32(fx + dx + dx, lbase, 2); |
michael@0 | 161 | lbase = vsetq_lane_s32(fx + dx + dx + dx, lbase, 3); |
michael@0 | 162 | hbase = lbase + vdupq_n_s32(4 * dx); |
michael@0 | 163 | |
michael@0 | 164 | do { |
michael@0 | 165 | // store the upper 16 bits |
michael@0 | 166 | vst1q_u32(dst, vreinterpretq_u32_s16( |
michael@0 | 167 | vuzpq_s16(vreinterpretq_s16_s32(lbase), vreinterpretq_s16_s32(hbase)).val[1] |
michael@0 | 168 | )); |
michael@0 | 169 | |
michael@0 | 170 | // on to the next group of 8 |
michael@0 | 171 | lbase += vdx8; |
michael@0 | 172 | hbase += vdx8; |
michael@0 | 173 | dst += 4; // we did 8 elements but the result is twice smaller |
michael@0 | 174 | count -= 8; |
michael@0 | 175 | fx += dx8; |
michael@0 | 176 | } while (count >= 8); |
michael@0 | 177 | } |
michael@0 | 178 | |
michael@0 | 179 | uint16_t* xx = (uint16_t*)dst; |
michael@0 | 180 | for (int i = count; i > 0; --i) { |
michael@0 | 181 | *xx++ = SkToU16(fx >> 16); fx += dx; |
michael@0 | 182 | } |
michael@0 | 183 | } |
michael@0 | 184 | |
michael@0 | 185 | void decal_filter_scale_neon(uint32_t dst[], SkFixed fx, SkFixed dx, int count) { |
michael@0 | 186 | if (count >= 8) { |
michael@0 | 187 | SkFixed dx8 = dx * 8; |
michael@0 | 188 | int32x4_t vdx8 = vdupq_n_s32(dx8); |
michael@0 | 189 | |
michael@0 | 190 | int32x4_t wide_fx, wide_fx2; |
michael@0 | 191 | wide_fx = vdupq_n_s32(fx); |
michael@0 | 192 | wide_fx = vsetq_lane_s32(fx + dx, wide_fx, 1); |
michael@0 | 193 | wide_fx = vsetq_lane_s32(fx + dx + dx, wide_fx, 2); |
michael@0 | 194 | wide_fx = vsetq_lane_s32(fx + dx + dx + dx, wide_fx, 3); |
michael@0 | 195 | |
michael@0 | 196 | wide_fx2 = vaddq_s32(wide_fx, vdupq_n_s32(4 * dx)); |
michael@0 | 197 | |
michael@0 | 198 | while (count >= 8) { |
michael@0 | 199 | int32x4_t wide_out; |
michael@0 | 200 | int32x4_t wide_out2; |
michael@0 | 201 | |
michael@0 | 202 | wide_out = vshlq_n_s32(vshrq_n_s32(wide_fx, 12), 14); |
michael@0 | 203 | wide_out = wide_out | (vshrq_n_s32(wide_fx,16) + vdupq_n_s32(1)); |
michael@0 | 204 | |
michael@0 | 205 | wide_out2 = vshlq_n_s32(vshrq_n_s32(wide_fx2, 12), 14); |
michael@0 | 206 | wide_out2 = wide_out2 | (vshrq_n_s32(wide_fx2,16) + vdupq_n_s32(1)); |
michael@0 | 207 | |
michael@0 | 208 | vst1q_u32(dst, vreinterpretq_u32_s32(wide_out)); |
michael@0 | 209 | vst1q_u32(dst+4, vreinterpretq_u32_s32(wide_out2)); |
michael@0 | 210 | |
michael@0 | 211 | dst += 8; |
michael@0 | 212 | fx += dx8; |
michael@0 | 213 | wide_fx += vdx8; |
michael@0 | 214 | wide_fx2 += vdx8; |
michael@0 | 215 | count -= 8; |
michael@0 | 216 | } |
michael@0 | 217 | } |
michael@0 | 218 | |
michael@0 | 219 | if (count & 1) |
michael@0 | 220 | { |
michael@0 | 221 | SkASSERT((fx >> (16 + 14)) == 0); |
michael@0 | 222 | *dst++ = (fx >> 12 << 14) | ((fx >> 16) + 1); |
michael@0 | 223 | fx += dx; |
michael@0 | 224 | } |
michael@0 | 225 | while ((count -= 2) >= 0) |
michael@0 | 226 | { |
michael@0 | 227 | SkASSERT((fx >> (16 + 14)) == 0); |
michael@0 | 228 | *dst++ = (fx >> 12 << 14) | ((fx >> 16) + 1); |
michael@0 | 229 | fx += dx; |
michael@0 | 230 | |
michael@0 | 231 | *dst++ = (fx >> 12 << 14) | ((fx >> 16) + 1); |
michael@0 | 232 | fx += dx; |
michael@0 | 233 | } |
michael@0 | 234 | } |