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 "SkBoundaryPatch.h"
10 SkBoundaryPatch::SkBoundaryPatch() : fBoundary(NULL) {}
12 SkBoundaryPatch::~SkBoundaryPatch() {
13 SkSafeUnref(fBoundary);
14 }
16 SkBoundary* SkBoundaryPatch::setBoundary(SkBoundary* b) {
17 SkRefCnt_SafeAssign(fBoundary, b);
18 return b;
19 }
21 static SkPoint SkMakePoint(SkScalar x, SkScalar y) {
22 SkPoint pt;
23 pt.set(x, y);
24 return pt;
25 }
27 static SkPoint SkPointInterp(const SkPoint& a, const SkPoint& b, SkScalar t) {
28 return SkMakePoint(SkScalarInterp(a.fX, b.fX, t),
29 SkScalarInterp(a.fY, b.fY, t));
30 }
32 SkPoint SkBoundaryPatch::eval(SkScalar unitU, SkScalar unitV) {
33 SkBoundary* b = fBoundary;
34 SkPoint u = SkPointInterp(b->eval(SkBoundary::kLeft, SK_Scalar1 - unitV),
35 b->eval(SkBoundary::kRight, unitV),
36 unitU);
37 SkPoint v = SkPointInterp(b->eval(SkBoundary::kTop, unitU),
38 b->eval(SkBoundary::kBottom, SK_Scalar1 - unitU),
39 unitV);
40 return SkMakePoint(SkScalarAve(u.fX, v.fX),
41 SkScalarAve(u.fY, v.fY));
42 }
44 bool SkBoundaryPatch::evalPatch(SkPoint verts[], int rows, int cols) {
45 if (rows < 2 || cols < 2) {
46 return false;
47 }
49 const SkScalar invR = SkScalarInvert(SkIntToScalar(rows - 1));
50 const SkScalar invC = SkScalarInvert(SkIntToScalar(cols - 1));
52 for (int y = 0; y < cols; y++) {
53 SkScalar yy = y * invC;
54 for (int x = 0; x < rows; x++) {
55 *verts++ = this->eval(x * invR, yy);
56 }
57 }
58 return true;
59 }
61 ////////////////////////////////////////////////////////////////////////
63 #include "SkGeometry.h"
65 SkPoint SkLineBoundary::eval(Edge e, SkScalar t) {
66 SkASSERT((unsigned)e < 4);
67 return SkPointInterp(fPts[e], fPts[(e + 1) & 3], t);
68 }
70 SkPoint SkCubicBoundary::eval(Edge e, SkScalar t) {
71 SkASSERT((unsigned)e < 4);
73 // ensure our 4th cubic wraps to the start of the first
74 fPts[12] = fPts[0];
76 SkPoint loc;
77 SkEvalCubicAt(&fPts[e * 3], t, &loc, NULL, NULL);
78 return loc;
79 }