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 2010 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 | |
michael@0 | 8 | #ifndef SkRasterClip_DEFINED |
michael@0 | 9 | #define SkRasterClip_DEFINED |
michael@0 | 10 | |
michael@0 | 11 | #include "SkRegion.h" |
michael@0 | 12 | #include "SkAAClip.h" |
michael@0 | 13 | |
michael@0 | 14 | class SkRasterClip { |
michael@0 | 15 | public: |
michael@0 | 16 | SkRasterClip(); |
michael@0 | 17 | SkRasterClip(const SkIRect&); |
michael@0 | 18 | SkRasterClip(const SkRasterClip&); |
michael@0 | 19 | ~SkRasterClip(); |
michael@0 | 20 | |
michael@0 | 21 | bool isBW() const { return fIsBW; } |
michael@0 | 22 | bool isAA() const { return !fIsBW; } |
michael@0 | 23 | const SkRegion& bwRgn() const { SkASSERT(fIsBW); return fBW; } |
michael@0 | 24 | const SkAAClip& aaRgn() const { SkASSERT(!fIsBW); return fAA; } |
michael@0 | 25 | |
michael@0 | 26 | bool isEmpty() const { |
michael@0 | 27 | SkASSERT(this->computeIsEmpty() == fIsEmpty); |
michael@0 | 28 | return fIsEmpty; |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | bool isRect() const { |
michael@0 | 32 | SkASSERT(this->computeIsRect() == fIsRect); |
michael@0 | 33 | return fIsRect; |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | bool isComplex() const; |
michael@0 | 37 | const SkIRect& getBounds() const; |
michael@0 | 38 | |
michael@0 | 39 | bool setEmpty(); |
michael@0 | 40 | bool setRect(const SkIRect&); |
michael@0 | 41 | |
michael@0 | 42 | bool setPath(const SkPath& path, const SkRegion& clip, bool doAA); |
michael@0 | 43 | bool setPath(const SkPath& path, const SkIRect& clip, bool doAA); |
michael@0 | 44 | |
michael@0 | 45 | bool op(const SkIRect&, SkRegion::Op); |
michael@0 | 46 | bool op(const SkRegion&, SkRegion::Op); |
michael@0 | 47 | bool op(const SkRasterClip&, SkRegion::Op); |
michael@0 | 48 | bool op(const SkRect&, SkRegion::Op, bool doAA); |
michael@0 | 49 | |
michael@0 | 50 | void translate(int dx, int dy, SkRasterClip* dst) const; |
michael@0 | 51 | void translate(int dx, int dy) { |
michael@0 | 52 | this->translate(dx, dy, this); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | bool quickContains(const SkIRect& rect) const; |
michael@0 | 56 | bool quickContains(int left, int top, int right, int bottom) const { |
michael@0 | 57 | return quickContains(SkIRect::MakeLTRB(left, top, right, bottom)); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | /** |
michael@0 | 61 | * Return true if this region is empty, or if the specified rectangle does |
michael@0 | 62 | * not intersect the region. Returning false is not a guarantee that they |
michael@0 | 63 | * intersect, but returning true is a guarantee that they do not. |
michael@0 | 64 | */ |
michael@0 | 65 | bool quickReject(const SkIRect& rect) const { |
michael@0 | 66 | return this->isEmpty() || rect.isEmpty() || |
michael@0 | 67 | !SkIRect::Intersects(this->getBounds(), rect); |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | // hack for SkCanvas::getTotalClip |
michael@0 | 71 | const SkRegion& forceGetBW(); |
michael@0 | 72 | |
michael@0 | 73 | #ifdef SK_DEBUG |
michael@0 | 74 | void validate() const; |
michael@0 | 75 | #else |
michael@0 | 76 | void validate() const {} |
michael@0 | 77 | #endif |
michael@0 | 78 | |
michael@0 | 79 | private: |
michael@0 | 80 | SkRegion fBW; |
michael@0 | 81 | SkAAClip fAA; |
michael@0 | 82 | bool fIsBW; |
michael@0 | 83 | // these 2 are caches based on querying the right obj based on fIsBW |
michael@0 | 84 | bool fIsEmpty; |
michael@0 | 85 | bool fIsRect; |
michael@0 | 86 | |
michael@0 | 87 | bool computeIsEmpty() const { |
michael@0 | 88 | return fIsBW ? fBW.isEmpty() : fAA.isEmpty(); |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | bool computeIsRect() const { |
michael@0 | 92 | return fIsBW ? fBW.isRect() : false; |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | bool updateCacheAndReturnNonEmpty() { |
michael@0 | 96 | fIsEmpty = this->computeIsEmpty(); |
michael@0 | 97 | fIsRect = this->computeIsRect(); |
michael@0 | 98 | return !fIsEmpty; |
michael@0 | 99 | } |
michael@0 | 100 | |
michael@0 | 101 | void convertToAA(); |
michael@0 | 102 | }; |
michael@0 | 103 | |
michael@0 | 104 | class SkAutoRasterClipValidate : SkNoncopyable { |
michael@0 | 105 | public: |
michael@0 | 106 | SkAutoRasterClipValidate(const SkRasterClip& rc) : fRC(rc) { |
michael@0 | 107 | fRC.validate(); |
michael@0 | 108 | } |
michael@0 | 109 | ~SkAutoRasterClipValidate() { |
michael@0 | 110 | fRC.validate(); |
michael@0 | 111 | } |
michael@0 | 112 | private: |
michael@0 | 113 | const SkRasterClip& fRC; |
michael@0 | 114 | }; |
michael@0 | 115 | #define SkAutoRasterClipValidate(...) SK_REQUIRE_LOCAL_VAR(SkAutoRasterClipValidate) |
michael@0 | 116 | |
michael@0 | 117 | #ifdef SK_DEBUG |
michael@0 | 118 | #define AUTO_RASTERCLIP_VALIDATE(rc) SkAutoRasterClipValidate arcv(rc) |
michael@0 | 119 | #else |
michael@0 | 120 | #define AUTO_RASTERCLIP_VALIDATE(rc) |
michael@0 | 121 | #endif |
michael@0 | 122 | |
michael@0 | 123 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 124 | |
michael@0 | 125 | /** |
michael@0 | 126 | * Encapsulates the logic of deciding if we need to change/wrap the blitter |
michael@0 | 127 | * for aaclipping. If so, getRgn and getBlitter return modified values. If |
michael@0 | 128 | * not, they return the raw blitter and (bw) clip region. |
michael@0 | 129 | * |
michael@0 | 130 | * We need to keep the constructor/destructor cost as small as possible, so we |
michael@0 | 131 | * can freely put this guy on the stack, and not pay too much for the case when |
michael@0 | 132 | * we're really BW anyways. |
michael@0 | 133 | */ |
michael@0 | 134 | class SkAAClipBlitterWrapper { |
michael@0 | 135 | public: |
michael@0 | 136 | SkAAClipBlitterWrapper(); |
michael@0 | 137 | SkAAClipBlitterWrapper(const SkRasterClip&, SkBlitter*); |
michael@0 | 138 | SkAAClipBlitterWrapper(const SkAAClip*, SkBlitter*); |
michael@0 | 139 | |
michael@0 | 140 | void init(const SkRasterClip&, SkBlitter*); |
michael@0 | 141 | |
michael@0 | 142 | const SkIRect& getBounds() const { |
michael@0 | 143 | SkASSERT(fClipRgn); |
michael@0 | 144 | return fClipRgn->getBounds(); |
michael@0 | 145 | } |
michael@0 | 146 | const SkRegion& getRgn() const { |
michael@0 | 147 | SkASSERT(fClipRgn); |
michael@0 | 148 | return *fClipRgn; |
michael@0 | 149 | } |
michael@0 | 150 | SkBlitter* getBlitter() { |
michael@0 | 151 | SkASSERT(fBlitter); |
michael@0 | 152 | return fBlitter; |
michael@0 | 153 | } |
michael@0 | 154 | |
michael@0 | 155 | private: |
michael@0 | 156 | SkRegion fBWRgn; |
michael@0 | 157 | SkAAClipBlitter fAABlitter; |
michael@0 | 158 | // what we return |
michael@0 | 159 | const SkRegion* fClipRgn; |
michael@0 | 160 | SkBlitter* fBlitter; |
michael@0 | 161 | }; |
michael@0 | 162 | |
michael@0 | 163 | #endif |