gfx/skia/patches/archive/0005-Bug-777614-Re-apply-bug-687188-Expand-the-gradient-c.patch

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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 From 1ab13a923399aa638388231baca784ba89f2c82b Mon Sep 17 00:00:00 2001
michael@0 2 From: George Wright <gw@gwright.org.uk>
michael@0 3 Date: Wed, 12 Sep 2012 12:30:29 -0400
michael@0 4 Subject: [PATCH 5/9] Bug 777614 - Re-apply bug 687188 - Expand the gradient
michael@0 5 cache by 2 to store 0/1 colour stop values for
michael@0 6 clamping. r=nrc
michael@0 7
michael@0 8 ---
michael@0 9 .../src/effects/gradients/SkGradientShader.cpp | 22 +++++++++++----
michael@0 10 .../src/effects/gradients/SkGradientShaderPriv.h | 5 +++-
michael@0 11 .../src/effects/gradients/SkLinearGradient.cpp | 32 ++++++++++++++++------
michael@0 12 .../gradients/SkTwoPointConicalGradient.cpp | 11 ++++++--
michael@0 13 .../effects/gradients/SkTwoPointRadialGradient.cpp | 11 ++++++--
michael@0 14 5 files changed, 61 insertions(+), 20 deletions(-)
michael@0 15
michael@0 16 diff --git a/gfx/skia/src/effects/gradients/SkGradientShader.cpp b/gfx/skia/src/effects/gradients/SkGradientShader.cpp
michael@0 17 index f0dac4d..79e7202 100644
michael@0 18 --- a/gfx/skia/src/effects/gradients/SkGradientShader.cpp
michael@0 19 +++ b/gfx/skia/src/effects/gradients/SkGradientShader.cpp
michael@0 20 @@ -426,15 +426,15 @@ static void complete_32bit_cache(SkPMColor* cache, int stride) {
michael@0 21
michael@0 22 const SkPMColor* SkGradientShaderBase::getCache32() const {
michael@0 23 if (fCache32 == NULL) {
michael@0 24 - // double the count for dither entries
michael@0 25 - const int entryCount = kCache32Count * 2;
michael@0 26 + // double the count for dither entries, and have an extra two entries for clamp values
michael@0 27 + const int entryCount = kCache32Count * 2 + 2;
michael@0 28 const size_t allocSize = sizeof(SkPMColor) * entryCount;
michael@0 29
michael@0 30 if (NULL == fCache32PixelRef) {
michael@0 31 fCache32PixelRef = SkNEW_ARGS(SkMallocPixelRef,
michael@0 32 (NULL, allocSize, NULL));
michael@0 33 }
michael@0 34 - fCache32 = (SkPMColor*)fCache32PixelRef->getAddr();
michael@0 35 + fCache32 = (SkPMColor*)fCache32PixelRef->getAddr() + 1;
michael@0 36 if (fColorCount == 2) {
michael@0 37 Build32bitCache(fCache32, fOrigColors[0], fOrigColors[1],
michael@0 38 kGradient32Length, fCacheAlpha);
michael@0 39 @@ -458,7 +458,7 @@ const SkPMColor* SkGradientShaderBase::getCache32() const {
michael@0 40 SkMallocPixelRef* newPR = SkNEW_ARGS(SkMallocPixelRef,
michael@0 41 (NULL, allocSize, NULL));
michael@0 42 SkPMColor* linear = fCache32; // just computed linear data
michael@0 43 - SkPMColor* mapped = (SkPMColor*)newPR->getAddr(); // storage for mapped data
michael@0 44 + SkPMColor* mapped = (SkPMColor*)newPR->getAddr() + 1; // storage for mapped data
michael@0 45 SkUnitMapper* map = fMapper;
michael@0 46 for (int i = 0; i < kGradient32Length; i++) {
michael@0 47 int index = map->mapUnit16((i << 8) | i) >> 8;
michael@0 48 @@ -467,10 +467,22 @@ const SkPMColor* SkGradientShaderBase::getCache32() const {
michael@0 49 }
michael@0 50 fCache32PixelRef->unref();
michael@0 51 fCache32PixelRef = newPR;
michael@0 52 - fCache32 = (SkPMColor*)newPR->getAddr();
michael@0 53 + fCache32 = (SkPMColor*)newPR->getAddr() + 1;
michael@0 54 }
michael@0 55 complete_32bit_cache(fCache32, kCache32Count);
michael@0 56 }
michael@0 57 +
michael@0 58 + // Write the clamp colours into the first and last entries of fCache32
michael@0 59 + fCache32[kCache32ClampLower] = SkPackARGB32(fCacheAlpha,
michael@0 60 + SkColorGetR(fOrigColors[0]),
michael@0 61 + SkColorGetG(fOrigColors[0]),
michael@0 62 + SkColorGetB(fOrigColors[0]));
michael@0 63 +
michael@0 64 + fCache32[kCache32ClampUpper] = SkPackARGB32(fCacheAlpha,
michael@0 65 + SkColorGetR(fOrigColors[fColorCount - 1]),
michael@0 66 + SkColorGetG(fOrigColors[fColorCount - 1]),
michael@0 67 + SkColorGetB(fOrigColors[fColorCount - 1]));
michael@0 68 +
michael@0 69 return fCache32;
michael@0 70 }
michael@0 71
michael@0 72 diff --git a/gfx/skia/src/effects/gradients/SkGradientShaderPriv.h b/gfx/skia/src/effects/gradients/SkGradientShaderPriv.h
michael@0 73 index 0e7c2fc..7427935 100644
michael@0 74 --- a/gfx/skia/src/effects/gradients/SkGradientShaderPriv.h
michael@0 75 +++ b/gfx/skia/src/effects/gradients/SkGradientShaderPriv.h
michael@0 76 @@ -133,7 +133,10 @@ public:
michael@0 77 kDitherStride32 = 0,
michael@0 78 #endif
michael@0 79 kDitherStride16 = kCache16Count,
michael@0 80 - kLerpRemainderMask32 = (1 << (16 - kCache32Bits)) - 1
michael@0 81 + kLerpRemainderMask32 = (1 << (16 - kCache32Bits)) - 1,
michael@0 82 +
michael@0 83 + kCache32ClampLower = -1,
michael@0 84 + kCache32ClampUpper = kCache32Count * 2
michael@0 85 };
michael@0 86
michael@0 87
michael@0 88 diff --git a/gfx/skia/src/effects/gradients/SkLinearGradient.cpp b/gfx/skia/src/effects/gradients/SkLinearGradient.cpp
michael@0 89 index bcebc26..d400b4d 100644
michael@0 90 --- a/gfx/skia/src/effects/gradients/SkLinearGradient.cpp
michael@0 91 +++ b/gfx/skia/src/effects/gradients/SkLinearGradient.cpp
michael@0 92 @@ -126,6 +126,17 @@ void shadeSpan_linear_vertical(TileProc proc, SkFixed dx, SkFixed fx,
michael@0 93 SkPMColor* SK_RESTRICT dstC,
michael@0 94 const SkPMColor* SK_RESTRICT cache,
michael@0 95 int toggle, int count) {
michael@0 96 + if (proc == clamp_tileproc) {
michael@0 97 + // No need to lerp or dither for clamp values
michael@0 98 + if (fx < 0) {
michael@0 99 + sk_memset32(dstC, cache[SkGradientShaderBase::kCache32ClampLower], count);
michael@0 100 + return;
michael@0 101 + } else if (fx > 0xffff) {
michael@0 102 + sk_memset32(dstC, cache[SkGradientShaderBase::kCache32ClampUpper], count);
michael@0 103 + return;
michael@0 104 + }
michael@0 105 + }
michael@0 106 +
michael@0 107 // We're a vertical gradient, so no change in a span.
michael@0 108 // If colors change sharply across the gradient, dithering is
michael@0 109 // insufficient (it subsamples the color space) and we need to lerp.
michael@0 110 @@ -144,6 +155,17 @@ void shadeSpan_linear_vertical_lerp(TileProc proc, SkFixed dx, SkFixed fx,
michael@0 111 SkPMColor* SK_RESTRICT dstC,
michael@0 112 const SkPMColor* SK_RESTRICT cache,
michael@0 113 int toggle, int count) {
michael@0 114 + if (proc == clamp_tileproc) {
michael@0 115 + // No need to lerp or dither for clamp values
michael@0 116 + if (fx < 0) {
michael@0 117 + sk_memset32(dstC, cache[SkGradientShaderBase::kCache32ClampLower], count);
michael@0 118 + return;
michael@0 119 + } else if (fx > 0xffff) {
michael@0 120 + sk_memset32(dstC, cache[SkGradientShaderBase::kCache32ClampUpper], count);
michael@0 121 + return;
michael@0 122 + }
michael@0 123 + }
michael@0 124 +
michael@0 125 // We're a vertical gradient, so no change in a span.
michael@0 126 // If colors change sharply across the gradient, dithering is
michael@0 127 // insufficient (it subsamples the color space) and we need to lerp.
michael@0 128 @@ -169,10 +191,7 @@ void shadeSpan_linear_clamp(TileProc proc, SkFixed dx, SkFixed fx,
michael@0 129 range.init(fx, dx, count, 0, SkGradientShaderBase::kGradient32Length);
michael@0 130
michael@0 131 if ((count = range.fCount0) > 0) {
michael@0 132 - sk_memset32_dither(dstC,
michael@0 133 - cache[toggle + range.fV0],
michael@0 134 - cache[(toggle ^ SkGradientShaderBase::kDitherStride32) + range.fV0],
michael@0 135 - count);
michael@0 136 + sk_memset32(dstC, cache[SkGradientShaderBase::kCache32ClampLower], count);
michael@0 137 dstC += count;
michael@0 138 }
michael@0 139 if ((count = range.fCount1) > 0) {
michael@0 140 @@ -191,10 +210,7 @@ void shadeSpan_linear_clamp(TileProc proc, SkFixed dx, SkFixed fx,
michael@0 141 }
michael@0 142 }
michael@0 143 if ((count = range.fCount2) > 0) {
michael@0 144 - sk_memset32_dither(dstC,
michael@0 145 - cache[toggle + range.fV1],
michael@0 146 - cache[(toggle ^ SkGradientShaderBase::kDitherStride32) + range.fV1],
michael@0 147 - count);
michael@0 148 + sk_memset32(dstC, cache[SkGradientShaderBase::kCache32ClampUpper], count);
michael@0 149 }
michael@0 150 }
michael@0 151
michael@0 152 diff --git a/gfx/skia/src/effects/gradients/SkTwoPointConicalGradient.cpp b/gfx/skia/src/effects/gradients/SkTwoPointConicalGradient.cpp
michael@0 153 index 3466d2c..764a444 100644
michael@0 154 --- a/gfx/skia/src/effects/gradients/SkTwoPointConicalGradient.cpp
michael@0 155 +++ b/gfx/skia/src/effects/gradients/SkTwoPointConicalGradient.cpp
michael@0 156 @@ -123,9 +123,14 @@ static void twopoint_clamp(TwoPtRadial* rec, SkPMColor* SK_RESTRICT dstC,
michael@0 157 if (TwoPtRadial::DontDrawT(t)) {
michael@0 158 *dstC++ = 0;
michael@0 159 } else {
michael@0 160 - SkFixed index = SkClampMax(t, 0xFFFF);
michael@0 161 - SkASSERT(index <= 0xFFFF);
michael@0 162 - *dstC++ = cache[index >> SkGradientShaderBase::kCache32Shift];
michael@0 163 + if (t < 0) {
michael@0 164 + *dstC++ = cache[SkGradientShaderBase::kCache32ClampLower];
michael@0 165 + } else if (t > 0xFFFF) {
michael@0 166 + *dstC++ = cache[SkGradientShaderBase::kCache32ClampUpper];
michael@0 167 + } else {
michael@0 168 + SkASSERT(t <= 0xFFFF);
michael@0 169 + *dstC++ = cache[t >> SkGradientShaderBase::kCache32Shift];
michael@0 170 + }
michael@0 171 }
michael@0 172 }
michael@0 173 }
michael@0 174 diff --git a/gfx/skia/src/effects/gradients/SkTwoPointRadialGradient.cpp b/gfx/skia/src/effects/gradients/SkTwoPointRadialGradient.cpp
michael@0 175 index 9362ded..22b028e 100644
michael@0 176 --- a/gfx/skia/src/effects/gradients/SkTwoPointRadialGradient.cpp
michael@0 177 +++ b/gfx/skia/src/effects/gradients/SkTwoPointRadialGradient.cpp
michael@0 178 @@ -120,9 +120,14 @@ void shadeSpan_twopoint_clamp(SkScalar fx, SkScalar dx,
michael@0 179 for (; count > 0; --count) {
michael@0 180 SkFixed t = two_point_radial(b, fx, fy, fSr2D2, foura,
michael@0 181 fOneOverTwoA, posRoot);
michael@0 182 - SkFixed index = SkClampMax(t, 0xFFFF);
michael@0 183 - SkASSERT(index <= 0xFFFF);
michael@0 184 - *dstC++ = cache[index >> SkGradientShaderBase::kCache32Shift];
michael@0 185 + if (t < 0) {
michael@0 186 + *dstC++ = cache[SkGradientShaderBase::kCache32ClampLower];
michael@0 187 + } else if (t > 0xFFFF) {
michael@0 188 + *dstC++ = cache[SkGradientShaderBase::kCache32ClampUpper];
michael@0 189 + } else {
michael@0 190 + SkASSERT(t <= 0xFFFF);
michael@0 191 + *dstC++ = cache[t >> SkGradientShaderBase::kCache32Shift];
michael@0 192 + }
michael@0 193 fx += dx;
michael@0 194 fy += dy;
michael@0 195 b += db;
michael@0 196 --
michael@0 197 1.7.11.4
michael@0 198

mercurial