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 | diff --git a/gfx/skia/src/effects/SkGradientShader.cpp b/gfx/skia/src/effects/SkGradientShader.cpp |
michael@0 | 2 | --- a/gfx/skia/src/effects/SkGradientShader.cpp |
michael@0 | 3 | +++ b/gfx/skia/src/effects/SkGradientShader.cpp |
michael@0 | 4 | @@ -1184,116 +1184,17 @@ public: |
michael@0 | 5 | { |
michael@0 | 6 | // make sure our table is insync with our current #define for kSQRT_TABLE_SIZE |
michael@0 | 7 | SkASSERT(sizeof(gSqrt8Table) == kSQRT_TABLE_SIZE); |
michael@0 | 8 | |
michael@0 | 9 | rad_to_unit_matrix(center, radius, &fPtsToUnit); |
michael@0 | 10 | } |
michael@0 | 11 | |
michael@0 | 12 | virtual void shadeSpan(int x, int y, SkPMColor* dstC, int count) SK_OVERRIDE; |
michael@0 | 13 | - virtual void shadeSpan16(int x, int y, uint16_t* SK_RESTRICT dstC, int count) SK_OVERRIDE { |
michael@0 | 14 | - SkASSERT(count > 0); |
michael@0 | 15 | - |
michael@0 | 16 | - SkPoint srcPt; |
michael@0 | 17 | - SkMatrix::MapXYProc dstProc = fDstToIndexProc; |
michael@0 | 18 | - TileProc proc = fTileProc; |
michael@0 | 19 | - const uint16_t* SK_RESTRICT cache = this->getCache16(); |
michael@0 | 20 | - int toggle = ((x ^ y) & 1) << kCache16Bits; |
michael@0 | 21 | - |
michael@0 | 22 | - if (fDstToIndexClass != kPerspective_MatrixClass) { |
michael@0 | 23 | - dstProc(fDstToIndex, SkIntToScalar(x) + SK_ScalarHalf, |
michael@0 | 24 | - SkIntToScalar(y) + SK_ScalarHalf, &srcPt); |
michael@0 | 25 | - SkFixed dx, fx = SkScalarToFixed(srcPt.fX); |
michael@0 | 26 | - SkFixed dy, fy = SkScalarToFixed(srcPt.fY); |
michael@0 | 27 | - |
michael@0 | 28 | - if (fDstToIndexClass == kFixedStepInX_MatrixClass) { |
michael@0 | 29 | - SkFixed storage[2]; |
michael@0 | 30 | - (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), &storage[0], &storage[1]); |
michael@0 | 31 | - dx = storage[0]; |
michael@0 | 32 | - dy = storage[1]; |
michael@0 | 33 | - } else { |
michael@0 | 34 | - SkASSERT(fDstToIndexClass == kLinear_MatrixClass); |
michael@0 | 35 | - dx = SkScalarToFixed(fDstToIndex.getScaleX()); |
michael@0 | 36 | - dy = SkScalarToFixed(fDstToIndex.getSkewY()); |
michael@0 | 37 | - } |
michael@0 | 38 | - |
michael@0 | 39 | - if (proc == clamp_tileproc) { |
michael@0 | 40 | - const uint8_t* SK_RESTRICT sqrt_table = gSqrt8Table; |
michael@0 | 41 | - |
michael@0 | 42 | - /* knock these down so we can pin against +- 0x7FFF, which is an immediate load, |
michael@0 | 43 | - rather than 0xFFFF which is slower. This is a compromise, since it reduces our |
michael@0 | 44 | - precision, but that appears to be visually OK. If we decide this is OK for |
michael@0 | 45 | - all of our cases, we could (it seems) put this scale-down into fDstToIndex, |
michael@0 | 46 | - to avoid having to do these extra shifts each time. |
michael@0 | 47 | - */ |
michael@0 | 48 | - fx >>= 1; |
michael@0 | 49 | - dx >>= 1; |
michael@0 | 50 | - fy >>= 1; |
michael@0 | 51 | - dy >>= 1; |
michael@0 | 52 | - if (dy == 0) { // might perform this check for the other modes, but the win will be a smaller % of the total |
michael@0 | 53 | - fy = SkPin32(fy, -0xFFFF >> 1, 0xFFFF >> 1); |
michael@0 | 54 | - fy *= fy; |
michael@0 | 55 | - do { |
michael@0 | 56 | - unsigned xx = SkPin32(fx, -0xFFFF >> 1, 0xFFFF >> 1); |
michael@0 | 57 | - unsigned fi = (xx * xx + fy) >> (14 + 16 - kSQRT_TABLE_BITS); |
michael@0 | 58 | - fi = SkFastMin32(fi, 0xFFFF >> (16 - kSQRT_TABLE_BITS)); |
michael@0 | 59 | - fx += dx; |
michael@0 | 60 | - *dstC++ = cache[toggle + (sqrt_table[fi] >> (8 - kCache16Bits))]; |
michael@0 | 61 | - toggle ^= (1 << kCache16Bits); |
michael@0 | 62 | - } while (--count != 0); |
michael@0 | 63 | - } else { |
michael@0 | 64 | - do { |
michael@0 | 65 | - unsigned xx = SkPin32(fx, -0xFFFF >> 1, 0xFFFF >> 1); |
michael@0 | 66 | - unsigned fi = SkPin32(fy, -0xFFFF >> 1, 0xFFFF >> 1); |
michael@0 | 67 | - fi = (xx * xx + fi * fi) >> (14 + 16 - kSQRT_TABLE_BITS); |
michael@0 | 68 | - fi = SkFastMin32(fi, 0xFFFF >> (16 - kSQRT_TABLE_BITS)); |
michael@0 | 69 | - fx += dx; |
michael@0 | 70 | - fy += dy; |
michael@0 | 71 | - *dstC++ = cache[toggle + (sqrt_table[fi] >> (8 - kCache16Bits))]; |
michael@0 | 72 | - toggle ^= (1 << kCache16Bits); |
michael@0 | 73 | - } while (--count != 0); |
michael@0 | 74 | - } |
michael@0 | 75 | - } else if (proc == mirror_tileproc) { |
michael@0 | 76 | - do { |
michael@0 | 77 | - SkFixed dist = SkFixedSqrt(SkFixedSquare(fx) + SkFixedSquare(fy)); |
michael@0 | 78 | - unsigned fi = mirror_tileproc(dist); |
michael@0 | 79 | - SkASSERT(fi <= 0xFFFF); |
michael@0 | 80 | - fx += dx; |
michael@0 | 81 | - fy += dy; |
michael@0 | 82 | - *dstC++ = cache[toggle + (fi >> (16 - kCache16Bits))]; |
michael@0 | 83 | - toggle ^= (1 << kCache16Bits); |
michael@0 | 84 | - } while (--count != 0); |
michael@0 | 85 | - } else { |
michael@0 | 86 | - SkASSERT(proc == repeat_tileproc); |
michael@0 | 87 | - do { |
michael@0 | 88 | - SkFixed dist = SkFixedSqrt(SkFixedSquare(fx) + SkFixedSquare(fy)); |
michael@0 | 89 | - unsigned fi = repeat_tileproc(dist); |
michael@0 | 90 | - SkASSERT(fi <= 0xFFFF); |
michael@0 | 91 | - fx += dx; |
michael@0 | 92 | - fy += dy; |
michael@0 | 93 | - *dstC++ = cache[toggle + (fi >> (16 - kCache16Bits))]; |
michael@0 | 94 | - toggle ^= (1 << kCache16Bits); |
michael@0 | 95 | - } while (--count != 0); |
michael@0 | 96 | - } |
michael@0 | 97 | - } else { // perspective case |
michael@0 | 98 | - SkScalar dstX = SkIntToScalar(x); |
michael@0 | 99 | - SkScalar dstY = SkIntToScalar(y); |
michael@0 | 100 | - do { |
michael@0 | 101 | - dstProc(fDstToIndex, dstX, dstY, &srcPt); |
michael@0 | 102 | - unsigned fi = proc(SkScalarToFixed(srcPt.length())); |
michael@0 | 103 | - SkASSERT(fi <= 0xFFFF); |
michael@0 | 104 | - |
michael@0 | 105 | - int index = fi >> (16 - kCache16Bits); |
michael@0 | 106 | - *dstC++ = cache[toggle + index]; |
michael@0 | 107 | - toggle ^= (1 << kCache16Bits); |
michael@0 | 108 | - |
michael@0 | 109 | - dstX += SK_Scalar1; |
michael@0 | 110 | - } while (--count != 0); |
michael@0 | 111 | - } |
michael@0 | 112 | - } |
michael@0 | 113 | + virtual void shadeSpan16(int x, int y, uint16_t* dstC, int count) SK_OVERRIDE; |
michael@0 | 114 | |
michael@0 | 115 | virtual BitmapType asABitmap(SkBitmap* bitmap, |
michael@0 | 116 | SkMatrix* matrix, |
michael@0 | 117 | TileMode* xy, |
michael@0 | 118 | SkScalar* twoPointRadialParams) const SK_OVERRIDE { |
michael@0 | 119 | if (bitmap) { |
michael@0 | 120 | this->commonAsABitmap(bitmap); |
michael@0 | 121 | } |
michael@0 | 122 | @@ -1507,16 +1408,117 @@ void Radial_Gradient::shadeSpan(int x, i |
michael@0 | 123 | unsigned fi = proc(SkScalarToFixed(srcPt.length())); |
michael@0 | 124 | SkASSERT(fi <= 0xFFFF); |
michael@0 | 125 | *dstC++ = cache[fi >> (16 - kCache32Bits)]; |
michael@0 | 126 | dstX += SK_Scalar1; |
michael@0 | 127 | } while (--count != 0); |
michael@0 | 128 | } |
michael@0 | 129 | } |
michael@0 | 130 | |
michael@0 | 131 | +void Radial_Gradient::shadeSpan16(int x, int y, uint16_t* SK_RESTRICT dstC, int count) { |
michael@0 | 132 | + SkASSERT(count > 0); |
michael@0 | 133 | + |
michael@0 | 134 | + SkPoint srcPt; |
michael@0 | 135 | + SkMatrix::MapXYProc dstProc = fDstToIndexProc; |
michael@0 | 136 | + TileProc proc = fTileProc; |
michael@0 | 137 | + const uint16_t* SK_RESTRICT cache = this->getCache16(); |
michael@0 | 138 | + int toggle = ((x ^ y) & 1) << kCache16Bits; |
michael@0 | 139 | + |
michael@0 | 140 | + if (fDstToIndexClass != kPerspective_MatrixClass) { |
michael@0 | 141 | + dstProc(fDstToIndex, SkIntToScalar(x) + SK_ScalarHalf, |
michael@0 | 142 | + SkIntToScalar(y) + SK_ScalarHalf, &srcPt); |
michael@0 | 143 | + SkFixed dx, fx = SkScalarToFixed(srcPt.fX); |
michael@0 | 144 | + SkFixed dy, fy = SkScalarToFixed(srcPt.fY); |
michael@0 | 145 | + |
michael@0 | 146 | + if (fDstToIndexClass == kFixedStepInX_MatrixClass) { |
michael@0 | 147 | + SkFixed storage[2]; |
michael@0 | 148 | + (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), &storage[0], &storage[1]); |
michael@0 | 149 | + dx = storage[0]; |
michael@0 | 150 | + dy = storage[1]; |
michael@0 | 151 | + } else { |
michael@0 | 152 | + SkASSERT(fDstToIndexClass == kLinear_MatrixClass); |
michael@0 | 153 | + dx = SkScalarToFixed(fDstToIndex.getScaleX()); |
michael@0 | 154 | + dy = SkScalarToFixed(fDstToIndex.getSkewY()); |
michael@0 | 155 | + } |
michael@0 | 156 | + |
michael@0 | 157 | + if (proc == clamp_tileproc) { |
michael@0 | 158 | + const uint8_t* SK_RESTRICT sqrt_table = gSqrt8Table; |
michael@0 | 159 | + |
michael@0 | 160 | + /* knock these down so we can pin against +- 0x7FFF, which is an immediate load, |
michael@0 | 161 | + rather than 0xFFFF which is slower. This is a compromise, since it reduces our |
michael@0 | 162 | + precision, but that appears to be visually OK. If we decide this is OK for |
michael@0 | 163 | + all of our cases, we could (it seems) put this scale-down into fDstToIndex, |
michael@0 | 164 | + to avoid having to do these extra shifts each time. |
michael@0 | 165 | + */ |
michael@0 | 166 | + fx >>= 1; |
michael@0 | 167 | + dx >>= 1; |
michael@0 | 168 | + fy >>= 1; |
michael@0 | 169 | + dy >>= 1; |
michael@0 | 170 | + if (dy == 0) { // might perform this check for the other modes, but the win will be a smaller % of the total |
michael@0 | 171 | + fy = SkPin32(fy, -0xFFFF >> 1, 0xFFFF >> 1); |
michael@0 | 172 | + fy *= fy; |
michael@0 | 173 | + do { |
michael@0 | 174 | + unsigned xx = SkPin32(fx, -0xFFFF >> 1, 0xFFFF >> 1); |
michael@0 | 175 | + unsigned fi = (xx * xx + fy) >> (14 + 16 - kSQRT_TABLE_BITS); |
michael@0 | 176 | + fi = SkFastMin32(fi, 0xFFFF >> (16 - kSQRT_TABLE_BITS)); |
michael@0 | 177 | + fx += dx; |
michael@0 | 178 | + *dstC++ = cache[toggle + (sqrt_table[fi] >> (8 - kCache16Bits))]; |
michael@0 | 179 | + toggle ^= (1 << kCache16Bits); |
michael@0 | 180 | + } while (--count != 0); |
michael@0 | 181 | + } else { |
michael@0 | 182 | + do { |
michael@0 | 183 | + unsigned xx = SkPin32(fx, -0xFFFF >> 1, 0xFFFF >> 1); |
michael@0 | 184 | + unsigned fi = SkPin32(fy, -0xFFFF >> 1, 0xFFFF >> 1); |
michael@0 | 185 | + fi = (xx * xx + fi * fi) >> (14 + 16 - kSQRT_TABLE_BITS); |
michael@0 | 186 | + fi = SkFastMin32(fi, 0xFFFF >> (16 - kSQRT_TABLE_BITS)); |
michael@0 | 187 | + fx += dx; |
michael@0 | 188 | + fy += dy; |
michael@0 | 189 | + *dstC++ = cache[toggle + (sqrt_table[fi] >> (8 - kCache16Bits))]; |
michael@0 | 190 | + toggle ^= (1 << kCache16Bits); |
michael@0 | 191 | + } while (--count != 0); |
michael@0 | 192 | + } |
michael@0 | 193 | + } else if (proc == mirror_tileproc) { |
michael@0 | 194 | + do { |
michael@0 | 195 | + SkFixed dist = SkFixedSqrt(SkFixedSquare(fx) + SkFixedSquare(fy)); |
michael@0 | 196 | + unsigned fi = mirror_tileproc(dist); |
michael@0 | 197 | + SkASSERT(fi <= 0xFFFF); |
michael@0 | 198 | + fx += dx; |
michael@0 | 199 | + fy += dy; |
michael@0 | 200 | + *dstC++ = cache[toggle + (fi >> (16 - kCache16Bits))]; |
michael@0 | 201 | + toggle ^= (1 << kCache16Bits); |
michael@0 | 202 | + } while (--count != 0); |
michael@0 | 203 | + } else { |
michael@0 | 204 | + SkASSERT(proc == repeat_tileproc); |
michael@0 | 205 | + do { |
michael@0 | 206 | + SkFixed dist = SkFixedSqrt(SkFixedSquare(fx) + SkFixedSquare(fy)); |
michael@0 | 207 | + unsigned fi = repeat_tileproc(dist); |
michael@0 | 208 | + SkASSERT(fi <= 0xFFFF); |
michael@0 | 209 | + fx += dx; |
michael@0 | 210 | + fy += dy; |
michael@0 | 211 | + *dstC++ = cache[toggle + (fi >> (16 - kCache16Bits))]; |
michael@0 | 212 | + toggle ^= (1 << kCache16Bits); |
michael@0 | 213 | + } while (--count != 0); |
michael@0 | 214 | + } |
michael@0 | 215 | + } else { // perspective case |
michael@0 | 216 | + SkScalar dstX = SkIntToScalar(x); |
michael@0 | 217 | + SkScalar dstY = SkIntToScalar(y); |
michael@0 | 218 | + do { |
michael@0 | 219 | + dstProc(fDstToIndex, dstX, dstY, &srcPt); |
michael@0 | 220 | + unsigned fi = proc(SkScalarToFixed(srcPt.length())); |
michael@0 | 221 | + SkASSERT(fi <= 0xFFFF); |
michael@0 | 222 | + |
michael@0 | 223 | + int index = fi >> (16 - kCache16Bits); |
michael@0 | 224 | + *dstC++ = cache[toggle + index]; |
michael@0 | 225 | + toggle ^= (1 << kCache16Bits); |
michael@0 | 226 | + |
michael@0 | 227 | + dstX += SK_Scalar1; |
michael@0 | 228 | + } while (--count != 0); |
michael@0 | 229 | + } |
michael@0 | 230 | +} |
michael@0 | 231 | + |
michael@0 | 232 | /* Two-point radial gradients are specified by two circles, each with a center |
michael@0 | 233 | point and radius. The gradient can be considered to be a series of |
michael@0 | 234 | concentric circles, with the color interpolated from the start circle |
michael@0 | 235 | (at t=0) to the end circle (at t=1). |
michael@0 | 236 | |
michael@0 | 237 | For each point (x, y) in the span, we want to find the |
michael@0 | 238 | interpolated circle that intersects that point. The center |
michael@0 | 239 | of the desired circle (Cx, Cy) falls at some distance t |
michael@0 | 240 | @@ -1661,109 +1663,17 @@ public: |
michael@0 | 241 | info->fPoint[0] = fCenter1; |
michael@0 | 242 | info->fPoint[1] = fCenter2; |
michael@0 | 243 | info->fRadius[0] = fRadius1; |
michael@0 | 244 | info->fRadius[1] = fRadius2; |
michael@0 | 245 | } |
michael@0 | 246 | return kRadial2_GradientType; |
michael@0 | 247 | } |
michael@0 | 248 | |
michael@0 | 249 | - virtual void shadeSpan(int x, int y, SkPMColor* SK_RESTRICT dstC, int count) SK_OVERRIDE { |
michael@0 | 250 | - SkASSERT(count > 0); |
michael@0 | 251 | - |
michael@0 | 252 | - // Zero difference between radii: fill with transparent black. |
michael@0 | 253 | - // TODO: Is removing this actually correct? Two circles with the |
michael@0 | 254 | - // same radius, but different centers doesn't sound like it |
michael@0 | 255 | - // should be cleared |
michael@0 | 256 | - if (fDiffRadius == 0 && fCenter1 == fCenter2) { |
michael@0 | 257 | - sk_bzero(dstC, count * sizeof(*dstC)); |
michael@0 | 258 | - return; |
michael@0 | 259 | - } |
michael@0 | 260 | - SkMatrix::MapXYProc dstProc = fDstToIndexProc; |
michael@0 | 261 | - TileProc proc = fTileProc; |
michael@0 | 262 | - const SkPMColor* SK_RESTRICT cache = this->getCache32(); |
michael@0 | 263 | - |
michael@0 | 264 | - SkScalar foura = fA * 4; |
michael@0 | 265 | - bool posRoot = fDiffRadius < 0; |
michael@0 | 266 | - if (fDstToIndexClass != kPerspective_MatrixClass) { |
michael@0 | 267 | - SkPoint srcPt; |
michael@0 | 268 | - dstProc(fDstToIndex, SkIntToScalar(x) + SK_ScalarHalf, |
michael@0 | 269 | - SkIntToScalar(y) + SK_ScalarHalf, &srcPt); |
michael@0 | 270 | - SkScalar dx, fx = srcPt.fX; |
michael@0 | 271 | - SkScalar dy, fy = srcPt.fY; |
michael@0 | 272 | - |
michael@0 | 273 | - if (fDstToIndexClass == kFixedStepInX_MatrixClass) { |
michael@0 | 274 | - SkFixed fixedX, fixedY; |
michael@0 | 275 | - (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), &fixedX, &fixedY); |
michael@0 | 276 | - dx = SkFixedToScalar(fixedX); |
michael@0 | 277 | - dy = SkFixedToScalar(fixedY); |
michael@0 | 278 | - } else { |
michael@0 | 279 | - SkASSERT(fDstToIndexClass == kLinear_MatrixClass); |
michael@0 | 280 | - dx = fDstToIndex.getScaleX(); |
michael@0 | 281 | - dy = fDstToIndex.getSkewY(); |
michael@0 | 282 | - } |
michael@0 | 283 | - SkScalar b = (SkScalarMul(fDiff.fX, fx) + |
michael@0 | 284 | - SkScalarMul(fDiff.fY, fy) - fStartRadius) * 2; |
michael@0 | 285 | - SkScalar db = (SkScalarMul(fDiff.fX, dx) + |
michael@0 | 286 | - SkScalarMul(fDiff.fY, dy)) * 2; |
michael@0 | 287 | - if (proc == clamp_tileproc) { |
michael@0 | 288 | - for (; count > 0; --count) { |
michael@0 | 289 | - SkFixed t = two_point_radial(b, fx, fy, fSr2D2, foura, fOneOverTwoA, posRoot); |
michael@0 | 290 | - if (t < 0) { |
michael@0 | 291 | - *dstC++ = cache[-1]; |
michael@0 | 292 | - } else if (t > 0xFFFF) { |
michael@0 | 293 | - *dstC++ = cache[kCache32Count * 2]; |
michael@0 | 294 | - } else { |
michael@0 | 295 | - SkASSERT(t <= 0xFFFF); |
michael@0 | 296 | - *dstC++ = cache[t >> (16 - kCache32Bits)]; |
michael@0 | 297 | - } |
michael@0 | 298 | - fx += dx; |
michael@0 | 299 | - fy += dy; |
michael@0 | 300 | - b += db; |
michael@0 | 301 | - } |
michael@0 | 302 | - } else if (proc == mirror_tileproc) { |
michael@0 | 303 | - for (; count > 0; --count) { |
michael@0 | 304 | - SkFixed t = two_point_radial(b, fx, fy, fSr2D2, foura, fOneOverTwoA, posRoot); |
michael@0 | 305 | - SkFixed index = mirror_tileproc(t); |
michael@0 | 306 | - SkASSERT(index <= 0xFFFF); |
michael@0 | 307 | - *dstC++ = cache[index >> (16 - kCache32Bits)]; |
michael@0 | 308 | - fx += dx; |
michael@0 | 309 | - fy += dy; |
michael@0 | 310 | - b += db; |
michael@0 | 311 | - } |
michael@0 | 312 | - } else { |
michael@0 | 313 | - SkASSERT(proc == repeat_tileproc); |
michael@0 | 314 | - for (; count > 0; --count) { |
michael@0 | 315 | - SkFixed t = two_point_radial(b, fx, fy, fSr2D2, foura, fOneOverTwoA, posRoot); |
michael@0 | 316 | - SkFixed index = repeat_tileproc(t); |
michael@0 | 317 | - SkASSERT(index <= 0xFFFF); |
michael@0 | 318 | - *dstC++ = cache[index >> (16 - kCache32Bits)]; |
michael@0 | 319 | - fx += dx; |
michael@0 | 320 | - fy += dy; |
michael@0 | 321 | - b += db; |
michael@0 | 322 | - } |
michael@0 | 323 | - } |
michael@0 | 324 | - } else { // perspective case |
michael@0 | 325 | - SkScalar dstX = SkIntToScalar(x); |
michael@0 | 326 | - SkScalar dstY = SkIntToScalar(y); |
michael@0 | 327 | - for (; count > 0; --count) { |
michael@0 | 328 | - SkPoint srcPt; |
michael@0 | 329 | - dstProc(fDstToIndex, dstX, dstY, &srcPt); |
michael@0 | 330 | - SkScalar fx = srcPt.fX; |
michael@0 | 331 | - SkScalar fy = srcPt.fY; |
michael@0 | 332 | - SkScalar b = (SkScalarMul(fDiff.fX, fx) + |
michael@0 | 333 | - SkScalarMul(fDiff.fY, fy) - fStartRadius) * 2; |
michael@0 | 334 | - SkFixed t = two_point_radial(b, fx, fy, fSr2D2, foura, fOneOverTwoA, posRoot); |
michael@0 | 335 | - SkFixed index = proc(t); |
michael@0 | 336 | - SkASSERT(index <= 0xFFFF); |
michael@0 | 337 | - *dstC++ = cache[index >> (16 - kCache32Bits)]; |
michael@0 | 338 | - dstX += SK_Scalar1; |
michael@0 | 339 | - } |
michael@0 | 340 | - } |
michael@0 | 341 | - } |
michael@0 | 342 | + virtual void shadeSpan(int x, int y, SkPMColor* dstC, int count) SK_OVERRIDE; |
michael@0 | 343 | |
michael@0 | 344 | virtual bool setContext(const SkBitmap& device, |
michael@0 | 345 | const SkPaint& paint, |
michael@0 | 346 | const SkMatrix& matrix) SK_OVERRIDE { |
michael@0 | 347 | if (!this->INHERITED::setContext(device, paint, matrix)) { |
michael@0 | 348 | return false; |
michael@0 | 349 | } |
michael@0 | 350 | |
michael@0 | 351 | @@ -1817,16 +1727,110 @@ private: |
michael@0 | 352 | fA = SkScalarSquare(fDiff.fX) + SkScalarSquare(fDiff.fY) - SK_Scalar1; |
michael@0 | 353 | fOneOverTwoA = fA ? SkScalarInvert(fA * 2) : 0; |
michael@0 | 354 | |
michael@0 | 355 | fPtsToUnit.setTranslate(-fCenter1.fX, -fCenter1.fY); |
michael@0 | 356 | fPtsToUnit.postScale(inv, inv); |
michael@0 | 357 | } |
michael@0 | 358 | }; |
michael@0 | 359 | |
michael@0 | 360 | +void Two_Point_Radial_Gradient::shadeSpan(int x, int y, SkPMColor* SK_RESTRICT dstC, int count) { |
michael@0 | 361 | + SkASSERT(count > 0); |
michael@0 | 362 | + |
michael@0 | 363 | + // Zero difference between radii: fill with transparent black. |
michael@0 | 364 | + // TODO: Is removing this actually correct? Two circles with the |
michael@0 | 365 | + // same radius, but different centers doesn't sound like it |
michael@0 | 366 | + // should be cleared |
michael@0 | 367 | + if (fDiffRadius == 0 && fCenter1 == fCenter2) { |
michael@0 | 368 | + sk_bzero(dstC, count * sizeof(*dstC)); |
michael@0 | 369 | + return; |
michael@0 | 370 | + } |
michael@0 | 371 | + SkMatrix::MapXYProc dstProc = fDstToIndexProc; |
michael@0 | 372 | + TileProc proc = fTileProc; |
michael@0 | 373 | + const SkPMColor* SK_RESTRICT cache = this->getCache32(); |
michael@0 | 374 | + |
michael@0 | 375 | + SkScalar foura = fA * 4; |
michael@0 | 376 | + bool posRoot = fDiffRadius < 0; |
michael@0 | 377 | + if (fDstToIndexClass != kPerspective_MatrixClass) { |
michael@0 | 378 | + SkPoint srcPt; |
michael@0 | 379 | + dstProc(fDstToIndex, SkIntToScalar(x) + SK_ScalarHalf, |
michael@0 | 380 | + SkIntToScalar(y) + SK_ScalarHalf, &srcPt); |
michael@0 | 381 | + SkScalar dx, fx = srcPt.fX; |
michael@0 | 382 | + SkScalar dy, fy = srcPt.fY; |
michael@0 | 383 | + |
michael@0 | 384 | + if (fDstToIndexClass == kFixedStepInX_MatrixClass) { |
michael@0 | 385 | + SkFixed fixedX, fixedY; |
michael@0 | 386 | + (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), &fixedX, &fixedY); |
michael@0 | 387 | + dx = SkFixedToScalar(fixedX); |
michael@0 | 388 | + dy = SkFixedToScalar(fixedY); |
michael@0 | 389 | + } else { |
michael@0 | 390 | + SkASSERT(fDstToIndexClass == kLinear_MatrixClass); |
michael@0 | 391 | + dx = fDstToIndex.getScaleX(); |
michael@0 | 392 | + dy = fDstToIndex.getSkewY(); |
michael@0 | 393 | + } |
michael@0 | 394 | + SkScalar b = (SkScalarMul(fDiff.fX, fx) + |
michael@0 | 395 | + SkScalarMul(fDiff.fY, fy) - fStartRadius) * 2; |
michael@0 | 396 | + SkScalar db = (SkScalarMul(fDiff.fX, dx) + |
michael@0 | 397 | + SkScalarMul(fDiff.fY, dy)) * 2; |
michael@0 | 398 | + if (proc == clamp_tileproc) { |
michael@0 | 399 | + for (; count > 0; --count) { |
michael@0 | 400 | + SkFixed t = two_point_radial(b, fx, fy, fSr2D2, foura, fOneOverTwoA, posRoot); |
michael@0 | 401 | + if (t < 0) { |
michael@0 | 402 | + *dstC++ = cache[-1]; |
michael@0 | 403 | + } else if (t > 0xFFFF) { |
michael@0 | 404 | + *dstC++ = cache[kCache32Count * 2]; |
michael@0 | 405 | + } else { |
michael@0 | 406 | + SkASSERT(t <= 0xFFFF); |
michael@0 | 407 | + *dstC++ = cache[t >> (16 - kCache32Bits)]; |
michael@0 | 408 | + } |
michael@0 | 409 | + fx += dx; |
michael@0 | 410 | + fy += dy; |
michael@0 | 411 | + b += db; |
michael@0 | 412 | + } |
michael@0 | 413 | + } else if (proc == mirror_tileproc) { |
michael@0 | 414 | + for (; count > 0; --count) { |
michael@0 | 415 | + SkFixed t = two_point_radial(b, fx, fy, fSr2D2, foura, fOneOverTwoA, posRoot); |
michael@0 | 416 | + SkFixed index = mirror_tileproc(t); |
michael@0 | 417 | + SkASSERT(index <= 0xFFFF); |
michael@0 | 418 | + *dstC++ = cache[index >> (16 - kCache32Bits)]; |
michael@0 | 419 | + fx += dx; |
michael@0 | 420 | + fy += dy; |
michael@0 | 421 | + b += db; |
michael@0 | 422 | + } |
michael@0 | 423 | + } else { |
michael@0 | 424 | + SkASSERT(proc == repeat_tileproc); |
michael@0 | 425 | + for (; count > 0; --count) { |
michael@0 | 426 | + SkFixed t = two_point_radial(b, fx, fy, fSr2D2, foura, fOneOverTwoA, posRoot); |
michael@0 | 427 | + SkFixed index = repeat_tileproc(t); |
michael@0 | 428 | + SkASSERT(index <= 0xFFFF); |
michael@0 | 429 | + *dstC++ = cache[index >> (16 - kCache32Bits)]; |
michael@0 | 430 | + fx += dx; |
michael@0 | 431 | + fy += dy; |
michael@0 | 432 | + b += db; |
michael@0 | 433 | + } |
michael@0 | 434 | + } |
michael@0 | 435 | + } else { // perspective case |
michael@0 | 436 | + SkScalar dstX = SkIntToScalar(x); |
michael@0 | 437 | + SkScalar dstY = SkIntToScalar(y); |
michael@0 | 438 | + for (; count > 0; --count) { |
michael@0 | 439 | + SkPoint srcPt; |
michael@0 | 440 | + dstProc(fDstToIndex, dstX, dstY, &srcPt); |
michael@0 | 441 | + SkScalar fx = srcPt.fX; |
michael@0 | 442 | + SkScalar fy = srcPt.fY; |
michael@0 | 443 | + SkScalar b = (SkScalarMul(fDiff.fX, fx) + |
michael@0 | 444 | + SkScalarMul(fDiff.fY, fy) - fStartRadius) * 2; |
michael@0 | 445 | + SkFixed t = two_point_radial(b, fx, fy, fSr2D2, foura, fOneOverTwoA, posRoot); |
michael@0 | 446 | + SkFixed index = proc(t); |
michael@0 | 447 | + SkASSERT(index <= 0xFFFF); |
michael@0 | 448 | + *dstC++ = cache[index >> (16 - kCache32Bits)]; |
michael@0 | 449 | + dstX += SK_Scalar1; |
michael@0 | 450 | + } |
michael@0 | 451 | + } |
michael@0 | 452 | +} |
michael@0 | 453 | + |
michael@0 | 454 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 455 | |
michael@0 | 456 | class Sweep_Gradient : public Gradient_Shader { |
michael@0 | 457 | public: |
michael@0 | 458 | Sweep_Gradient(SkScalar cx, SkScalar cy, const SkColor colors[], |
michael@0 | 459 | const SkScalar pos[], int count, SkUnitMapper* mapper) |
michael@0 | 460 | : Gradient_Shader(colors, pos, count, SkShader::kClamp_TileMode, mapper), |
michael@0 | 461 | fCenter(SkPoint::Make(cx, cy)) |