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 | * Copyright 2012 Google Inc. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | * found in the LICENSE file. |
michael@0 | 6 | */ |
michael@0 | 7 | #ifndef SkPathOpsCurve_DEFINE |
michael@0 | 8 | #define SkPathOpsCurve_DEFINE |
michael@0 | 9 | |
michael@0 | 10 | #include "SkPathOpsCubic.h" |
michael@0 | 11 | #include "SkPathOpsLine.h" |
michael@0 | 12 | #include "SkPathOpsQuad.h" |
michael@0 | 13 | |
michael@0 | 14 | static SkDPoint dline_xy_at_t(const SkPoint a[2], double t) { |
michael@0 | 15 | SkDLine line; |
michael@0 | 16 | line.set(a); |
michael@0 | 17 | return line.ptAtT(t); |
michael@0 | 18 | } |
michael@0 | 19 | |
michael@0 | 20 | static SkDPoint dquad_xy_at_t(const SkPoint a[3], double t) { |
michael@0 | 21 | SkDQuad quad; |
michael@0 | 22 | quad.set(a); |
michael@0 | 23 | return quad.ptAtT(t); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | static SkDPoint dcubic_xy_at_t(const SkPoint a[4], double t) { |
michael@0 | 27 | SkDCubic cubic; |
michael@0 | 28 | cubic.set(a); |
michael@0 | 29 | return cubic.ptAtT(t); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | static SkDPoint (* const CurveDPointAtT[])(const SkPoint[], double ) = { |
michael@0 | 33 | NULL, |
michael@0 | 34 | dline_xy_at_t, |
michael@0 | 35 | dquad_xy_at_t, |
michael@0 | 36 | dcubic_xy_at_t |
michael@0 | 37 | }; |
michael@0 | 38 | |
michael@0 | 39 | static SkPoint fline_xy_at_t(const SkPoint a[2], double t) { |
michael@0 | 40 | return dline_xy_at_t(a, t).asSkPoint(); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | static SkPoint fquad_xy_at_t(const SkPoint a[3], double t) { |
michael@0 | 44 | return dquad_xy_at_t(a, t).asSkPoint(); |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | static SkPoint fcubic_xy_at_t(const SkPoint a[4], double t) { |
michael@0 | 48 | return dcubic_xy_at_t(a, t).asSkPoint(); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | static SkPoint (* const CurvePointAtT[])(const SkPoint[], double ) = { |
michael@0 | 52 | NULL, |
michael@0 | 53 | fline_xy_at_t, |
michael@0 | 54 | fquad_xy_at_t, |
michael@0 | 55 | fcubic_xy_at_t |
michael@0 | 56 | }; |
michael@0 | 57 | |
michael@0 | 58 | static SkDVector dline_dxdy_at_t(const SkPoint a[2], double ) { |
michael@0 | 59 | SkDLine line; |
michael@0 | 60 | line.set(a); |
michael@0 | 61 | return line[1] - line[0]; |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | static SkDVector dquad_dxdy_at_t(const SkPoint a[3], double t) { |
michael@0 | 65 | SkDQuad quad; |
michael@0 | 66 | quad.set(a); |
michael@0 | 67 | return quad.dxdyAtT(t); |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | static SkDVector dcubic_dxdy_at_t(const SkPoint a[4], double t) { |
michael@0 | 71 | SkDCubic cubic; |
michael@0 | 72 | cubic.set(a); |
michael@0 | 73 | return cubic.dxdyAtT(t); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | static SkDVector (* const CurveDSlopeAtT[])(const SkPoint[], double ) = { |
michael@0 | 77 | NULL, |
michael@0 | 78 | dline_dxdy_at_t, |
michael@0 | 79 | dquad_dxdy_at_t, |
michael@0 | 80 | dcubic_dxdy_at_t |
michael@0 | 81 | }; |
michael@0 | 82 | |
michael@0 | 83 | static SkVector fline_dxdy_at_t(const SkPoint a[2], double ) { |
michael@0 | 84 | return a[1] - a[0]; |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | static SkVector fquad_dxdy_at_t(const SkPoint a[3], double t) { |
michael@0 | 88 | return dquad_dxdy_at_t(a, t).asSkVector(); |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | static SkVector fcubic_dxdy_at_t(const SkPoint a[4], double t) { |
michael@0 | 92 | return dcubic_dxdy_at_t(a, t).asSkVector(); |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | static SkVector (* const CurveSlopeAtT[])(const SkPoint[], double ) = { |
michael@0 | 96 | NULL, |
michael@0 | 97 | fline_dxdy_at_t, |
michael@0 | 98 | fquad_dxdy_at_t, |
michael@0 | 99 | fcubic_dxdy_at_t |
michael@0 | 100 | }; |
michael@0 | 101 | |
michael@0 | 102 | static SkPoint quad_top(const SkPoint a[3], double startT, double endT) { |
michael@0 | 103 | SkDQuad quad; |
michael@0 | 104 | quad.set(a); |
michael@0 | 105 | SkDPoint topPt = quad.top(startT, endT); |
michael@0 | 106 | return topPt.asSkPoint(); |
michael@0 | 107 | } |
michael@0 | 108 | |
michael@0 | 109 | static SkPoint cubic_top(const SkPoint a[4], double startT, double endT) { |
michael@0 | 110 | SkDCubic cubic; |
michael@0 | 111 | cubic.set(a); |
michael@0 | 112 | SkDPoint topPt = cubic.top(startT, endT); |
michael@0 | 113 | return topPt.asSkPoint(); |
michael@0 | 114 | } |
michael@0 | 115 | |
michael@0 | 116 | static SkPoint (* const CurveTop[])(const SkPoint[], double , double ) = { |
michael@0 | 117 | NULL, |
michael@0 | 118 | NULL, |
michael@0 | 119 | quad_top, |
michael@0 | 120 | cubic_top |
michael@0 | 121 | }; |
michael@0 | 122 | |
michael@0 | 123 | static bool line_is_vertical(const SkPoint a[2], double startT, double endT) { |
michael@0 | 124 | SkDLine line; |
michael@0 | 125 | line.set(a); |
michael@0 | 126 | SkDPoint dst[2] = { line.ptAtT(startT), line.ptAtT(endT) }; |
michael@0 | 127 | return AlmostEqualUlps(dst[0].fX, dst[1].fX); |
michael@0 | 128 | } |
michael@0 | 129 | |
michael@0 | 130 | static bool quad_is_vertical(const SkPoint a[3], double startT, double endT) { |
michael@0 | 131 | SkDQuad quad; |
michael@0 | 132 | quad.set(a); |
michael@0 | 133 | SkDQuad dst = quad.subDivide(startT, endT); |
michael@0 | 134 | return AlmostEqualUlps(dst[0].fX, dst[1].fX) && AlmostEqualUlps(dst[1].fX, dst[2].fX); |
michael@0 | 135 | } |
michael@0 | 136 | |
michael@0 | 137 | static bool cubic_is_vertical(const SkPoint a[4], double startT, double endT) { |
michael@0 | 138 | SkDCubic cubic; |
michael@0 | 139 | cubic.set(a); |
michael@0 | 140 | SkDCubic dst = cubic.subDivide(startT, endT); |
michael@0 | 141 | return AlmostEqualUlps(dst[0].fX, dst[1].fX) && AlmostEqualUlps(dst[1].fX, dst[2].fX) |
michael@0 | 142 | && AlmostEqualUlps(dst[2].fX, dst[3].fX); |
michael@0 | 143 | } |
michael@0 | 144 | |
michael@0 | 145 | static bool (* const CurveIsVertical[])(const SkPoint[], double , double) = { |
michael@0 | 146 | NULL, |
michael@0 | 147 | line_is_vertical, |
michael@0 | 148 | quad_is_vertical, |
michael@0 | 149 | cubic_is_vertical |
michael@0 | 150 | }; |
michael@0 | 151 | |
michael@0 | 152 | #endif |