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