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 | #ifndef SkDeviceProperties_DEFINED |
michael@0 | 2 | #define SkDeviceProperties_DEFINED |
michael@0 | 3 | |
michael@0 | 4 | #ifndef SK_GAMMA_EXPONENT |
michael@0 | 5 | #define SK_GAMMA_EXPONENT (2.2f) |
michael@0 | 6 | #endif |
michael@0 | 7 | |
michael@0 | 8 | #ifdef SK_GAMMA_SRGB |
michael@0 | 9 | #undef SK_GAMMA_EXPONENT |
michael@0 | 10 | #define SK_GAMMA_EXPONENT (0.0f) |
michael@0 | 11 | #endif |
michael@0 | 12 | |
michael@0 | 13 | //TODO: get everyone to stop using SkFontLCDConfig::SetSubpixel* and remove this import. |
michael@0 | 14 | #include "SkFontLCDConfig.h" |
michael@0 | 15 | |
michael@0 | 16 | struct SkDeviceProperties { |
michael@0 | 17 | struct Geometry { |
michael@0 | 18 | /** The orientation of the pixel specifies the interpretation of the |
michael@0 | 19 | * layout. If the orientation is horizontal, the layout is interpreted as |
michael@0 | 20 | * left to right. It the orientation is vertical, the layout is |
michael@0 | 21 | * interpreted top to bottom (rotated 90deg cw from horizontal). |
michael@0 | 22 | */ |
michael@0 | 23 | enum Orientation { |
michael@0 | 24 | kUnknown_Orientation = 0x0, |
michael@0 | 25 | kKnown_Orientation = 0x2, |
michael@0 | 26 | |
michael@0 | 27 | kHorizontal_Orientation = 0x2, //!< this is the default |
michael@0 | 28 | kVertical_Orientation = 0x3, |
michael@0 | 29 | |
michael@0 | 30 | kOrientationMask = 0x3, |
michael@0 | 31 | }; |
michael@0 | 32 | |
michael@0 | 33 | /** The layout of the pixel specifies its subpixel geometry. |
michael@0 | 34 | * |
michael@0 | 35 | * kUnknown_Layout means that the subpixel elements are not spatially |
michael@0 | 36 | * separated in any known or usable fashion. |
michael@0 | 37 | */ |
michael@0 | 38 | enum Layout { |
michael@0 | 39 | kUnknown_Layout = 0x0, |
michael@0 | 40 | kKnown_Layout = 0x8, |
michael@0 | 41 | |
michael@0 | 42 | kRGB_Layout = 0x8, //!< this is the default |
michael@0 | 43 | kBGR_Layout = 0xC, |
michael@0 | 44 | |
michael@0 | 45 | kLayoutMask = 0xC, |
michael@0 | 46 | }; |
michael@0 | 47 | |
michael@0 | 48 | Orientation getOrientation() { |
michael@0 | 49 | return static_cast<Orientation>(fGeometry & kOrientationMask); |
michael@0 | 50 | } |
michael@0 | 51 | Layout getLayout() { |
michael@0 | 52 | return static_cast<Layout>(fGeometry & kLayoutMask); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | bool isOrientationKnown() { |
michael@0 | 56 | return SkToBool(fGeometry & kKnown_Orientation); |
michael@0 | 57 | } |
michael@0 | 58 | bool isLayoutKnown() { |
michael@0 | 59 | return SkToBool(fGeometry & kKnown_Layout); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | private: |
michael@0 | 63 | //TODO: get everyone to stop using SkFontLCDConfig::SetSubpixel* and replace these calls with constants. |
michael@0 | 64 | static Orientation fromOldOrientation(SkFontLCDConfig::LCDOrientation orientation) { |
michael@0 | 65 | switch (orientation) { |
michael@0 | 66 | case SkFontLCDConfig::kHorizontal_LCDOrientation: return kHorizontal_Orientation; |
michael@0 | 67 | case SkFontLCDConfig::kVertical_LCDOrientation: return kVertical_Orientation; |
michael@0 | 68 | default: return kUnknown_Orientation; |
michael@0 | 69 | } |
michael@0 | 70 | } |
michael@0 | 71 | static Layout fromOldLayout(SkFontLCDConfig::LCDOrder order) { |
michael@0 | 72 | switch (order) { |
michael@0 | 73 | case SkFontLCDConfig::kRGB_LCDOrder: return kRGB_Layout; |
michael@0 | 74 | case SkFontLCDConfig::kBGR_LCDOrder: return kBGR_Layout; |
michael@0 | 75 | default: return kUnknown_Layout; |
michael@0 | 76 | } |
michael@0 | 77 | } |
michael@0 | 78 | public: |
michael@0 | 79 | static Geometry MakeDefault() { |
michael@0 | 80 | Orientation orientation = fromOldOrientation(SkFontLCDConfig::GetSubpixelOrientation()); //kHorizontal_Orientation |
michael@0 | 81 | Layout layout = fromOldLayout(SkFontLCDConfig::GetSubpixelOrder()); //kRGB_Layout |
michael@0 | 82 | Geometry ret = { SkToU8(orientation | layout) }; |
michael@0 | 83 | return ret; |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | static Geometry Make(Orientation orientation, Layout layout) { |
michael@0 | 87 | Geometry ret = { SkToU8(orientation | layout) }; |
michael@0 | 88 | return ret; |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | uint8_t fGeometry; |
michael@0 | 92 | }; |
michael@0 | 93 | |
michael@0 | 94 | static SkDeviceProperties MakeDefault() { |
michael@0 | 95 | SkDeviceProperties ret = { Geometry::MakeDefault(), SK_GAMMA_EXPONENT }; |
michael@0 | 96 | return ret; |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | static SkDeviceProperties Make(Geometry geometry, SkScalar gamma) { |
michael@0 | 100 | SkDeviceProperties ret = { geometry, gamma }; |
michael@0 | 101 | return ret; |
michael@0 | 102 | } |
michael@0 | 103 | |
michael@0 | 104 | /** Each pixel of an image will have some number of channels. |
michael@0 | 105 | * Can the layout of those channels be exploited? */ |
michael@0 | 106 | Geometry fGeometry; |
michael@0 | 107 | |
michael@0 | 108 | /** Represents the color space of the image. This is a woefully inadequate beginning. */ |
michael@0 | 109 | SkScalar fGamma; |
michael@0 | 110 | }; |
michael@0 | 111 | |
michael@0 | 112 | #endif |