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 2006 The Android Open Source Project |
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 | |
michael@0 | 9 | |
michael@0 | 10 | #include "Sk2DPathEffect.h" |
michael@0 | 11 | #include "SkReadBuffer.h" |
michael@0 | 12 | #include "SkWriteBuffer.h" |
michael@0 | 13 | #include "SkPath.h" |
michael@0 | 14 | #include "SkRegion.h" |
michael@0 | 15 | |
michael@0 | 16 | Sk2DPathEffect::Sk2DPathEffect(const SkMatrix& mat) : fMatrix(mat) { |
michael@0 | 17 | fMatrixIsInvertible = mat.invert(&fInverse); |
michael@0 | 18 | } |
michael@0 | 19 | |
michael@0 | 20 | bool Sk2DPathEffect::filterPath(SkPath* dst, const SkPath& src, |
michael@0 | 21 | SkStrokeRec*, const SkRect*) const { |
michael@0 | 22 | if (!fMatrixIsInvertible) { |
michael@0 | 23 | return false; |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | SkPath tmp; |
michael@0 | 27 | SkIRect ir; |
michael@0 | 28 | |
michael@0 | 29 | src.transform(fInverse, &tmp); |
michael@0 | 30 | tmp.getBounds().round(&ir); |
michael@0 | 31 | if (!ir.isEmpty()) { |
michael@0 | 32 | this->begin(ir, dst); |
michael@0 | 33 | |
michael@0 | 34 | SkRegion rgn; |
michael@0 | 35 | rgn.setPath(tmp, SkRegion(ir)); |
michael@0 | 36 | SkRegion::Iterator iter(rgn); |
michael@0 | 37 | for (; !iter.done(); iter.next()) { |
michael@0 | 38 | const SkIRect& rect = iter.rect(); |
michael@0 | 39 | for (int y = rect.fTop; y < rect.fBottom; ++y) { |
michael@0 | 40 | this->nextSpan(rect.fLeft, y, rect.width(), dst); |
michael@0 | 41 | } |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | this->end(dst); |
michael@0 | 45 | } |
michael@0 | 46 | return true; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | void Sk2DPathEffect::nextSpan(int x, int y, int count, SkPath* path) const { |
michael@0 | 50 | if (!fMatrixIsInvertible) { |
michael@0 | 51 | return; |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | const SkMatrix& mat = this->getMatrix(); |
michael@0 | 55 | SkPoint src, dst; |
michael@0 | 56 | |
michael@0 | 57 | src.set(SkIntToScalar(x) + SK_ScalarHalf, SkIntToScalar(y) + SK_ScalarHalf); |
michael@0 | 58 | do { |
michael@0 | 59 | mat.mapPoints(&dst, &src, 1); |
michael@0 | 60 | this->next(dst, x++, y, path); |
michael@0 | 61 | src.fX += SK_Scalar1; |
michael@0 | 62 | } while (--count > 0); |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | void Sk2DPathEffect::begin(const SkIRect& uvBounds, SkPath* dst) const {} |
michael@0 | 66 | void Sk2DPathEffect::next(const SkPoint& loc, int u, int v, SkPath* dst) const {} |
michael@0 | 67 | void Sk2DPathEffect::end(SkPath* dst) const {} |
michael@0 | 68 | |
michael@0 | 69 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 70 | |
michael@0 | 71 | void Sk2DPathEffect::flatten(SkWriteBuffer& buffer) const { |
michael@0 | 72 | this->INHERITED::flatten(buffer); |
michael@0 | 73 | buffer.writeMatrix(fMatrix); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | Sk2DPathEffect::Sk2DPathEffect(SkReadBuffer& buffer) { |
michael@0 | 77 | buffer.readMatrix(&fMatrix); |
michael@0 | 78 | fMatrixIsInvertible = fMatrix.invert(&fInverse); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 82 | |
michael@0 | 83 | bool SkLine2DPathEffect::filterPath(SkPath* dst, const SkPath& src, |
michael@0 | 84 | SkStrokeRec* rec, const SkRect* cullRect) const { |
michael@0 | 85 | if (this->INHERITED::filterPath(dst, src, rec, cullRect)) { |
michael@0 | 86 | rec->setStrokeStyle(fWidth); |
michael@0 | 87 | return true; |
michael@0 | 88 | } |
michael@0 | 89 | return false; |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | void SkLine2DPathEffect::nextSpan(int u, int v, int ucount, SkPath* dst) const { |
michael@0 | 93 | if (ucount > 1) { |
michael@0 | 94 | SkPoint src[2], dstP[2]; |
michael@0 | 95 | |
michael@0 | 96 | src[0].set(SkIntToScalar(u) + SK_ScalarHalf, SkIntToScalar(v) + SK_ScalarHalf); |
michael@0 | 97 | src[1].set(SkIntToScalar(u+ucount) + SK_ScalarHalf, SkIntToScalar(v) + SK_ScalarHalf); |
michael@0 | 98 | this->getMatrix().mapPoints(dstP, src, 2); |
michael@0 | 99 | |
michael@0 | 100 | dst->moveTo(dstP[0]); |
michael@0 | 101 | dst->lineTo(dstP[1]); |
michael@0 | 102 | } |
michael@0 | 103 | } |
michael@0 | 104 | |
michael@0 | 105 | SkLine2DPathEffect::SkLine2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) { |
michael@0 | 106 | fWidth = buffer.readScalar(); |
michael@0 | 107 | } |
michael@0 | 108 | |
michael@0 | 109 | void SkLine2DPathEffect::flatten(SkWriteBuffer &buffer) const { |
michael@0 | 110 | this->INHERITED::flatten(buffer); |
michael@0 | 111 | buffer.writeScalar(fWidth); |
michael@0 | 112 | } |
michael@0 | 113 | |
michael@0 | 114 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 115 | |
michael@0 | 116 | SkPath2DPathEffect::SkPath2DPathEffect(const SkMatrix& m, const SkPath& p) |
michael@0 | 117 | : INHERITED(m), fPath(p) { |
michael@0 | 118 | } |
michael@0 | 119 | |
michael@0 | 120 | SkPath2DPathEffect::SkPath2DPathEffect(SkReadBuffer& buffer) |
michael@0 | 121 | : INHERITED(buffer) { |
michael@0 | 122 | buffer.readPath(&fPath); |
michael@0 | 123 | } |
michael@0 | 124 | |
michael@0 | 125 | void SkPath2DPathEffect::flatten(SkWriteBuffer& buffer) const { |
michael@0 | 126 | this->INHERITED::flatten(buffer); |
michael@0 | 127 | buffer.writePath(fPath); |
michael@0 | 128 | } |
michael@0 | 129 | |
michael@0 | 130 | void SkPath2DPathEffect::next(const SkPoint& loc, int u, int v, |
michael@0 | 131 | SkPath* dst) const { |
michael@0 | 132 | dst->addPath(fPath, loc.fX, loc.fY); |
michael@0 | 133 | } |