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