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.
2 /*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8 #include "SkUnitMappers.h"
9 #include "SkReadBuffer.h"
10 #include "SkWriteBuffer.h"
13 SkDiscreteMapper::SkDiscreteMapper(int segments) {
14 if (segments < 2) {
15 fSegments = 0;
16 fScale = 0;
17 } else {
18 if (segments > 0xFFFF) {
19 segments = 0xFFFF;
20 }
21 fSegments = segments;
22 fScale = (1 << 30) / (segments - 1);
23 }
24 }
26 uint16_t SkDiscreteMapper::mapUnit16(uint16_t input) {
27 SkFixed x = input * fSegments >> 16;
28 x = x * fScale >> 14;
29 x += x << 15 >> 31; // map 0x10000 to 0xFFFF
30 return SkToU16(x);
31 }
33 SkDiscreteMapper::SkDiscreteMapper(SkReadBuffer& rb)
34 : SkUnitMapper(rb) {
35 fSegments = rb.readInt();
36 fScale = rb.read32();
37 }
39 void SkDiscreteMapper::flatten(SkWriteBuffer& wb) const {
40 this->INHERITED::flatten(wb);
42 wb.writeInt(fSegments);
43 wb.write32(fScale);
44 }
46 ///////////////////////////////////////////////////////////////////////////////
48 uint16_t SkCosineMapper::mapUnit16(uint16_t input)
49 {
50 /* we want to call cosine(input * pi/2) treating input as [0...1)
51 however, the straight multitply would overflow 32bits since input is
52 16bits and pi/2 is 17bits, so we shift down our pi const before we mul
53 */
54 SkFixed rads = (unsigned)(input * (SK_FixedPI >> 2)) >> 15;
55 SkFixed x = SkFixedCos(rads);
56 x += x << 15 >> 31; // map 0x10000 to 0xFFFF
57 return SkToU16(x);
58 }
60 SkCosineMapper::SkCosineMapper(SkReadBuffer& rb)
61 : SkUnitMapper(rb) {}