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 2011 Google Inc. |
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 | #ifndef SkClipStack_DEFINED |
michael@0 | 9 | #define SkClipStack_DEFINED |
michael@0 | 10 | |
michael@0 | 11 | #include "SkDeque.h" |
michael@0 | 12 | #include "SkPath.h" |
michael@0 | 13 | #include "SkRect.h" |
michael@0 | 14 | #include "SkRRect.h" |
michael@0 | 15 | #include "SkRegion.h" |
michael@0 | 16 | #include "SkTDArray.h" |
michael@0 | 17 | #include "SkTLazy.h" |
michael@0 | 18 | |
michael@0 | 19 | |
michael@0 | 20 | // Because a single save/restore state can have multiple clips, this class |
michael@0 | 21 | // stores the stack depth (fSaveCount) and clips (fDeque) separately. |
michael@0 | 22 | // Each clip in fDeque stores the stack state to which it belongs |
michael@0 | 23 | // (i.e., the fSaveCount in force when it was added). Restores are thus |
michael@0 | 24 | // implemented by removing clips from fDeque that have an fSaveCount larger |
michael@0 | 25 | // then the freshly decremented count. |
michael@0 | 26 | class SK_API SkClipStack { |
michael@0 | 27 | public: |
michael@0 | 28 | enum BoundsType { |
michael@0 | 29 | // The bounding box contains all the pixels that can be written to |
michael@0 | 30 | kNormal_BoundsType, |
michael@0 | 31 | // The bounding box contains all the pixels that cannot be written to. |
michael@0 | 32 | // The real bound extends out to infinity and all the pixels outside |
michael@0 | 33 | // of the bound can be written to. Note that some of the pixels inside |
michael@0 | 34 | // the bound may also be writeable but all pixels that cannot be |
michael@0 | 35 | // written to are guaranteed to be inside. |
michael@0 | 36 | kInsideOut_BoundsType |
michael@0 | 37 | }; |
michael@0 | 38 | |
michael@0 | 39 | class Element { |
michael@0 | 40 | public: |
michael@0 | 41 | enum Type { |
michael@0 | 42 | //!< This element makes the clip empty (regardless of previous elements). |
michael@0 | 43 | kEmpty_Type, |
michael@0 | 44 | //!< This element combines a rect with the current clip using a set operation |
michael@0 | 45 | kRect_Type, |
michael@0 | 46 | //!< This element combines a round-rect with the current clip using a set operation |
michael@0 | 47 | kRRect_Type, |
michael@0 | 48 | //!< This element combines a path with the current clip using a set operation |
michael@0 | 49 | kPath_Type, |
michael@0 | 50 | }; |
michael@0 | 51 | |
michael@0 | 52 | Element() { |
michael@0 | 53 | this->initCommon(0, SkRegion::kReplace_Op, false); |
michael@0 | 54 | this->setEmpty(); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | Element(const Element&); |
michael@0 | 58 | |
michael@0 | 59 | Element(const SkRect& rect, SkRegion::Op op, bool doAA) { |
michael@0 | 60 | this->initRect(0, rect, op, doAA); |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | Element(const SkRRect& rrect, SkRegion::Op op, bool doAA) { |
michael@0 | 64 | this->initRRect(0, rrect, op, doAA); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | Element(const SkPath& path, SkRegion::Op op, bool doAA) { |
michael@0 | 68 | this->initPath(0, path, op, doAA); |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | bool operator== (const Element& element) const; |
michael@0 | 72 | bool operator!= (const Element& element) const { return !(*this == element); } |
michael@0 | 73 | |
michael@0 | 74 | //!< Call to get the type of the clip element. |
michael@0 | 75 | Type getType() const { return fType; } |
michael@0 | 76 | |
michael@0 | 77 | //!< Call if getType() is kPath to get the path. |
michael@0 | 78 | const SkPath& getPath() const { SkASSERT(kPath_Type == fType); return *fPath.get(); } |
michael@0 | 79 | |
michael@0 | 80 | //!< Call if getType() is kRRect to get the round-rect. |
michael@0 | 81 | const SkRRect& getRRect() const { SkASSERT(kRRect_Type == fType); return fRRect; } |
michael@0 | 82 | |
michael@0 | 83 | //!< Call if getType() is kRect to get the rect. |
michael@0 | 84 | const SkRect& getRect() const { |
michael@0 | 85 | SkASSERT(kRect_Type == fType && (fRRect.isRect() || fRRect.isEmpty())); |
michael@0 | 86 | return fRRect.getBounds(); |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | //!< Call if getType() is not kEmpty to get the set operation used to combine this element. |
michael@0 | 90 | SkRegion::Op getOp() const { return fOp; } |
michael@0 | 91 | |
michael@0 | 92 | //!< Call to get the element as a path, regardless of its type. |
michael@0 | 93 | void asPath(SkPath* path) const; |
michael@0 | 94 | |
michael@0 | 95 | /** If getType() is not kEmpty this indicates whether the clip shape should be anti-aliased |
michael@0 | 96 | when it is rasterized. */ |
michael@0 | 97 | bool isAA() const { return fDoAA; } |
michael@0 | 98 | |
michael@0 | 99 | //!< Inverts the fill of the clip shape. Note that a kEmpty element remains kEmpty. |
michael@0 | 100 | void invertShapeFillType(); |
michael@0 | 101 | |
michael@0 | 102 | //!< Sets the set operation represented by the element. |
michael@0 | 103 | void setOp(SkRegion::Op op) { fOp = op; } |
michael@0 | 104 | |
michael@0 | 105 | /** The GenID can be used by clip stack clients to cache representations of the clip. The |
michael@0 | 106 | ID corresponds to the set of clip elements up to and including this element within the |
michael@0 | 107 | stack not to the element itself. That is the same clip path in different stacks will |
michael@0 | 108 | have a different ID since the elements produce different clip result in the context of |
michael@0 | 109 | their stacks. */ |
michael@0 | 110 | int32_t getGenID() const { SkASSERT(kInvalidGenID != fGenID); return fGenID; } |
michael@0 | 111 | |
michael@0 | 112 | /** |
michael@0 | 113 | * Gets the bounds of the clip element, either the rect or path bounds. (Whether the shape |
michael@0 | 114 | * is inverse filled is not considered.) |
michael@0 | 115 | */ |
michael@0 | 116 | const SkRect& getBounds() const { |
michael@0 | 117 | static const SkRect kEmpty = { 0, 0, 0, 0 }; |
michael@0 | 118 | switch (fType) { |
michael@0 | 119 | case kRect_Type: // fallthrough |
michael@0 | 120 | case kRRect_Type: |
michael@0 | 121 | return fRRect.getBounds(); |
michael@0 | 122 | case kPath_Type: |
michael@0 | 123 | return fPath.get()->getBounds(); |
michael@0 | 124 | case kEmpty_Type: |
michael@0 | 125 | return kEmpty; |
michael@0 | 126 | default: |
michael@0 | 127 | SkDEBUGFAIL("Unexpected type."); |
michael@0 | 128 | return kEmpty; |
michael@0 | 129 | } |
michael@0 | 130 | } |
michael@0 | 131 | |
michael@0 | 132 | /** |
michael@0 | 133 | * Conservatively checks whether the clip shape contains the rect param. (Whether the shape |
michael@0 | 134 | * is inverse filled is not considered.) |
michael@0 | 135 | */ |
michael@0 | 136 | bool contains(const SkRect& rect) const { |
michael@0 | 137 | switch (fType) { |
michael@0 | 138 | case kRect_Type: |
michael@0 | 139 | return this->getRect().contains(rect); |
michael@0 | 140 | case kRRect_Type: |
michael@0 | 141 | return fRRect.contains(rect); |
michael@0 | 142 | case kPath_Type: |
michael@0 | 143 | return fPath.get()->conservativelyContainsRect(rect); |
michael@0 | 144 | case kEmpty_Type: |
michael@0 | 145 | return false; |
michael@0 | 146 | default: |
michael@0 | 147 | SkDEBUGFAIL("Unexpected type."); |
michael@0 | 148 | return false; |
michael@0 | 149 | } |
michael@0 | 150 | } |
michael@0 | 151 | |
michael@0 | 152 | /** |
michael@0 | 153 | * Is the clip shape inverse filled. |
michael@0 | 154 | */ |
michael@0 | 155 | bool isInverseFilled() const { |
michael@0 | 156 | return kPath_Type == fType && fPath.get()->isInverseFillType(); |
michael@0 | 157 | } |
michael@0 | 158 | |
michael@0 | 159 | private: |
michael@0 | 160 | friend class SkClipStack; |
michael@0 | 161 | |
michael@0 | 162 | SkTLazy<SkPath> fPath; |
michael@0 | 163 | SkRRect fRRect; |
michael@0 | 164 | int fSaveCount; // save count of stack when this element was added. |
michael@0 | 165 | SkRegion::Op fOp; |
michael@0 | 166 | Type fType; |
michael@0 | 167 | bool fDoAA; |
michael@0 | 168 | |
michael@0 | 169 | /* fFiniteBoundType and fFiniteBound are used to incrementally update the clip stack's |
michael@0 | 170 | bound. When fFiniteBoundType is kNormal_BoundsType, fFiniteBound represents the |
michael@0 | 171 | conservative bounding box of the pixels that aren't clipped (i.e., any pixels that can be |
michael@0 | 172 | drawn to are inside the bound). When fFiniteBoundType is kInsideOut_BoundsType (which |
michael@0 | 173 | occurs when a clip is inverse filled), fFiniteBound represents the conservative bounding |
michael@0 | 174 | box of the pixels that _are_ clipped (i.e., any pixels that cannot be drawn to are inside |
michael@0 | 175 | the bound). When fFiniteBoundType is kInsideOut_BoundsType the actual bound is the |
michael@0 | 176 | infinite plane. This behavior of fFiniteBoundType and fFiniteBound is required so that we |
michael@0 | 177 | can capture the cancelling out of the extensions to infinity when two inverse filled |
michael@0 | 178 | clips are Booleaned together. */ |
michael@0 | 179 | SkClipStack::BoundsType fFiniteBoundType; |
michael@0 | 180 | SkRect fFiniteBound; |
michael@0 | 181 | |
michael@0 | 182 | // When element is applied to the previous elements in the stack is the result known to be |
michael@0 | 183 | // equivalent to a single rect intersection? IIOW, is the clip effectively a rectangle. |
michael@0 | 184 | bool fIsIntersectionOfRects; |
michael@0 | 185 | |
michael@0 | 186 | int fGenID; |
michael@0 | 187 | |
michael@0 | 188 | Element(int saveCount) { |
michael@0 | 189 | this->initCommon(saveCount, SkRegion::kReplace_Op, false); |
michael@0 | 190 | this->setEmpty(); |
michael@0 | 191 | } |
michael@0 | 192 | |
michael@0 | 193 | Element(int saveCount, const SkRRect& rrect, SkRegion::Op op, bool doAA) { |
michael@0 | 194 | this->initRRect(saveCount, rrect, op, doAA); |
michael@0 | 195 | } |
michael@0 | 196 | |
michael@0 | 197 | Element(int saveCount, const SkRect& rect, SkRegion::Op op, bool doAA) { |
michael@0 | 198 | this->initRect(saveCount, rect, op, doAA); |
michael@0 | 199 | } |
michael@0 | 200 | |
michael@0 | 201 | Element(int saveCount, const SkPath& path, SkRegion::Op op, bool doAA) { |
michael@0 | 202 | this->initPath(saveCount, path, op, doAA); |
michael@0 | 203 | } |
michael@0 | 204 | |
michael@0 | 205 | void initCommon(int saveCount, SkRegion::Op op, bool doAA) { |
michael@0 | 206 | fSaveCount = saveCount; |
michael@0 | 207 | fOp = op; |
michael@0 | 208 | fDoAA = doAA; |
michael@0 | 209 | // A default of inside-out and empty bounds means the bounds are effectively void as it |
michael@0 | 210 | // indicates that nothing is known to be outside the clip. |
michael@0 | 211 | fFiniteBoundType = kInsideOut_BoundsType; |
michael@0 | 212 | fFiniteBound.setEmpty(); |
michael@0 | 213 | fIsIntersectionOfRects = false; |
michael@0 | 214 | fGenID = kInvalidGenID; |
michael@0 | 215 | } |
michael@0 | 216 | |
michael@0 | 217 | void initRect(int saveCount, const SkRect& rect, SkRegion::Op op, bool doAA) { |
michael@0 | 218 | fRRect.setRect(rect); |
michael@0 | 219 | fType = kRect_Type; |
michael@0 | 220 | this->initCommon(saveCount, op, doAA); |
michael@0 | 221 | } |
michael@0 | 222 | |
michael@0 | 223 | void initRRect(int saveCount, const SkRRect& rrect, SkRegion::Op op, bool doAA) { |
michael@0 | 224 | SkRRect::Type type = rrect.getType(); |
michael@0 | 225 | fRRect = rrect; |
michael@0 | 226 | if (SkRRect::kRect_Type == type || SkRRect::kEmpty_Type == type) { |
michael@0 | 227 | fType = kRect_Type; |
michael@0 | 228 | } else { |
michael@0 | 229 | fType = kRRect_Type; |
michael@0 | 230 | } |
michael@0 | 231 | this->initCommon(saveCount, op, doAA); |
michael@0 | 232 | } |
michael@0 | 233 | |
michael@0 | 234 | void initPath(int saveCount, const SkPath& path, SkRegion::Op op, bool doAA); |
michael@0 | 235 | |
michael@0 | 236 | void setEmpty(); |
michael@0 | 237 | |
michael@0 | 238 | // All Element methods below are only used within SkClipStack.cpp |
michael@0 | 239 | inline void checkEmpty() const; |
michael@0 | 240 | inline bool canBeIntersectedInPlace(int saveCount, SkRegion::Op op) const; |
michael@0 | 241 | /* This method checks to see if two rect clips can be safely merged into one. The issue here |
michael@0 | 242 | is that to be strictly correct all the edges of the resulting rect must have the same |
michael@0 | 243 | anti-aliasing. */ |
michael@0 | 244 | bool rectRectIntersectAllowed(const SkRect& newR, bool newAA) const; |
michael@0 | 245 | /** Determines possible finite bounds for the Element given the previous element of the |
michael@0 | 246 | stack */ |
michael@0 | 247 | void updateBoundAndGenID(const Element* prior); |
michael@0 | 248 | // The different combination of fill & inverse fill when combining bounding boxes |
michael@0 | 249 | enum FillCombo { |
michael@0 | 250 | kPrev_Cur_FillCombo, |
michael@0 | 251 | kPrev_InvCur_FillCombo, |
michael@0 | 252 | kInvPrev_Cur_FillCombo, |
michael@0 | 253 | kInvPrev_InvCur_FillCombo |
michael@0 | 254 | }; |
michael@0 | 255 | // per-set operation functions used by updateBoundAndGenID(). |
michael@0 | 256 | inline void combineBoundsDiff(FillCombo combination, const SkRect& prevFinite); |
michael@0 | 257 | inline void combineBoundsXOR(int combination, const SkRect& prevFinite); |
michael@0 | 258 | inline void combineBoundsUnion(int combination, const SkRect& prevFinite); |
michael@0 | 259 | inline void combineBoundsIntersection(int combination, const SkRect& prevFinite); |
michael@0 | 260 | inline void combineBoundsRevDiff(int combination, const SkRect& prevFinite); |
michael@0 | 261 | }; |
michael@0 | 262 | |
michael@0 | 263 | SkClipStack(); |
michael@0 | 264 | SkClipStack(const SkClipStack& b); |
michael@0 | 265 | explicit SkClipStack(const SkRect& r); |
michael@0 | 266 | explicit SkClipStack(const SkIRect& r); |
michael@0 | 267 | ~SkClipStack(); |
michael@0 | 268 | |
michael@0 | 269 | SkClipStack& operator=(const SkClipStack& b); |
michael@0 | 270 | bool operator==(const SkClipStack& b) const; |
michael@0 | 271 | bool operator!=(const SkClipStack& b) const { return !(*this == b); } |
michael@0 | 272 | |
michael@0 | 273 | void reset(); |
michael@0 | 274 | |
michael@0 | 275 | int getSaveCount() const { return fSaveCount; } |
michael@0 | 276 | void save(); |
michael@0 | 277 | void restore(); |
michael@0 | 278 | |
michael@0 | 279 | /** |
michael@0 | 280 | * getBounds places the current finite bound in its first parameter. In its |
michael@0 | 281 | * second, it indicates which kind of bound is being returned. If |
michael@0 | 282 | * 'canvFiniteBound' is a normal bounding box then it encloses all writeable |
michael@0 | 283 | * pixels. If 'canvFiniteBound' is an inside out bounding box then it |
michael@0 | 284 | * encloses all the un-writeable pixels and the true/normal bound is the |
michael@0 | 285 | * infinite plane. isIntersectionOfRects is an optional parameter |
michael@0 | 286 | * that is true if 'canvFiniteBound' resulted from an intersection of rects. |
michael@0 | 287 | */ |
michael@0 | 288 | void getBounds(SkRect* canvFiniteBound, |
michael@0 | 289 | BoundsType* boundType, |
michael@0 | 290 | bool* isIntersectionOfRects = NULL) const; |
michael@0 | 291 | |
michael@0 | 292 | /** |
michael@0 | 293 | * Takes an input rect in device space and conservatively clips it to the |
michael@0 | 294 | * clip-stack. If false is returned then the rect does not intersect the |
michael@0 | 295 | * clip and is unmodified. |
michael@0 | 296 | */ |
michael@0 | 297 | bool intersectRectWithClip(SkRect* devRect) const; |
michael@0 | 298 | |
michael@0 | 299 | /** |
michael@0 | 300 | * Returns true if the input rect in device space is entirely contained |
michael@0 | 301 | * by the clip. A return value of false does not guarantee that the rect |
michael@0 | 302 | * is not contained by the clip. |
michael@0 | 303 | */ |
michael@0 | 304 | bool quickContains(const SkRect& devRect) const; |
michael@0 | 305 | |
michael@0 | 306 | void clipDevRect(const SkIRect& ir, SkRegion::Op op) { |
michael@0 | 307 | SkRect r; |
michael@0 | 308 | r.set(ir); |
michael@0 | 309 | this->clipDevRect(r, op, false); |
michael@0 | 310 | } |
michael@0 | 311 | void clipDevRect(const SkRect&, SkRegion::Op, bool doAA); |
michael@0 | 312 | void clipDevRRect(const SkRRect&, SkRegion::Op, bool doAA); |
michael@0 | 313 | void clipDevPath(const SkPath&, SkRegion::Op, bool doAA); |
michael@0 | 314 | // An optimized version of clipDevRect(emptyRect, kIntersect, ...) |
michael@0 | 315 | void clipEmpty(); |
michael@0 | 316 | |
michael@0 | 317 | /** |
michael@0 | 318 | * isWideOpen returns true if the clip state corresponds to the infinite |
michael@0 | 319 | * plane (i.e., draws are not limited at all) |
michael@0 | 320 | */ |
michael@0 | 321 | bool isWideOpen() const; |
michael@0 | 322 | |
michael@0 | 323 | /** |
michael@0 | 324 | * The generation ID has three reserved values to indicate special |
michael@0 | 325 | * (potentially ignorable) cases |
michael@0 | 326 | */ |
michael@0 | 327 | static const int32_t kInvalidGenID = 0; //!< Invalid id that is never returned by |
michael@0 | 328 | //!< SkClipStack. Useful when caching clips |
michael@0 | 329 | //!< based on GenID. |
michael@0 | 330 | static const int32_t kEmptyGenID = 1; // no pixels writeable |
michael@0 | 331 | static const int32_t kWideOpenGenID = 2; // all pixels writeable |
michael@0 | 332 | |
michael@0 | 333 | int32_t getTopmostGenID() const; |
michael@0 | 334 | |
michael@0 | 335 | public: |
michael@0 | 336 | class Iter { |
michael@0 | 337 | public: |
michael@0 | 338 | enum IterStart { |
michael@0 | 339 | kBottom_IterStart = SkDeque::Iter::kFront_IterStart, |
michael@0 | 340 | kTop_IterStart = SkDeque::Iter::kBack_IterStart |
michael@0 | 341 | }; |
michael@0 | 342 | |
michael@0 | 343 | /** |
michael@0 | 344 | * Creates an uninitialized iterator. Must be reset() |
michael@0 | 345 | */ |
michael@0 | 346 | Iter(); |
michael@0 | 347 | |
michael@0 | 348 | Iter(const SkClipStack& stack, IterStart startLoc); |
michael@0 | 349 | |
michael@0 | 350 | /** |
michael@0 | 351 | * Return the clip element for this iterator. If next()/prev() returns NULL, then the |
michael@0 | 352 | * iterator is done. |
michael@0 | 353 | */ |
michael@0 | 354 | const Element* next(); |
michael@0 | 355 | const Element* prev(); |
michael@0 | 356 | |
michael@0 | 357 | /** |
michael@0 | 358 | * Moves the iterator to the topmost element with the specified RegionOp and returns that |
michael@0 | 359 | * element. If no clip element with that op is found, the first element is returned. |
michael@0 | 360 | */ |
michael@0 | 361 | const Element* skipToTopmost(SkRegion::Op op); |
michael@0 | 362 | |
michael@0 | 363 | /** |
michael@0 | 364 | * Restarts the iterator on a clip stack. |
michael@0 | 365 | */ |
michael@0 | 366 | void reset(const SkClipStack& stack, IterStart startLoc); |
michael@0 | 367 | |
michael@0 | 368 | private: |
michael@0 | 369 | const SkClipStack* fStack; |
michael@0 | 370 | SkDeque::Iter fIter; |
michael@0 | 371 | }; |
michael@0 | 372 | |
michael@0 | 373 | /** |
michael@0 | 374 | * The B2TIter iterates from the bottom of the stack to the top. |
michael@0 | 375 | * It inherits privately from Iter to prevent access to reverse iteration. |
michael@0 | 376 | */ |
michael@0 | 377 | class B2TIter : private Iter { |
michael@0 | 378 | public: |
michael@0 | 379 | B2TIter() {} |
michael@0 | 380 | |
michael@0 | 381 | /** |
michael@0 | 382 | * Wrap Iter's 2 parameter ctor to force initialization to the |
michael@0 | 383 | * beginning of the deque/bottom of the stack |
michael@0 | 384 | */ |
michael@0 | 385 | B2TIter(const SkClipStack& stack) |
michael@0 | 386 | : INHERITED(stack, kBottom_IterStart) { |
michael@0 | 387 | } |
michael@0 | 388 | |
michael@0 | 389 | using Iter::next; |
michael@0 | 390 | |
michael@0 | 391 | /** |
michael@0 | 392 | * Wrap Iter::reset to force initialization to the |
michael@0 | 393 | * beginning of the deque/bottom of the stack |
michael@0 | 394 | */ |
michael@0 | 395 | void reset(const SkClipStack& stack) { |
michael@0 | 396 | this->INHERITED::reset(stack, kBottom_IterStart); |
michael@0 | 397 | } |
michael@0 | 398 | |
michael@0 | 399 | private: |
michael@0 | 400 | |
michael@0 | 401 | typedef Iter INHERITED; |
michael@0 | 402 | }; |
michael@0 | 403 | |
michael@0 | 404 | /** |
michael@0 | 405 | * GetConservativeBounds returns a conservative bound of the current clip. |
michael@0 | 406 | * Since this could be the infinite plane (if inverse fills were involved) the |
michael@0 | 407 | * maxWidth and maxHeight parameters can be used to limit the returned bound |
michael@0 | 408 | * to the expected drawing area. Similarly, the offsetX and offsetY parameters |
michael@0 | 409 | * allow the caller to offset the returned bound to account for translated |
michael@0 | 410 | * drawing areas (i.e., those resulting from a saveLayer). For finite bounds, |
michael@0 | 411 | * the translation (+offsetX, +offsetY) is applied before the clamp to the |
michael@0 | 412 | * maximum rectangle: [0,maxWidth) x [0,maxHeight). |
michael@0 | 413 | * isIntersectionOfRects is an optional parameter that is true when |
michael@0 | 414 | * 'devBounds' is the result of an intersection of rects. In this case |
michael@0 | 415 | * 'devBounds' is the exact answer/clip. |
michael@0 | 416 | */ |
michael@0 | 417 | void getConservativeBounds(int offsetX, |
michael@0 | 418 | int offsetY, |
michael@0 | 419 | int maxWidth, |
michael@0 | 420 | int maxHeight, |
michael@0 | 421 | SkRect* devBounds, |
michael@0 | 422 | bool* isIntersectionOfRects = NULL) const; |
michael@0 | 423 | |
michael@0 | 424 | private: |
michael@0 | 425 | friend class Iter; |
michael@0 | 426 | |
michael@0 | 427 | SkDeque fDeque; |
michael@0 | 428 | int fSaveCount; |
michael@0 | 429 | |
michael@0 | 430 | // Generation ID for the clip stack. This is incremented for each |
michael@0 | 431 | // clipDevRect and clipDevPath call. 0 is reserved to indicate an |
michael@0 | 432 | // invalid ID. |
michael@0 | 433 | static int32_t gGenID; |
michael@0 | 434 | |
michael@0 | 435 | /** |
michael@0 | 436 | * Helper for clipDevPath, etc. |
michael@0 | 437 | */ |
michael@0 | 438 | void pushElement(const Element& element); |
michael@0 | 439 | |
michael@0 | 440 | /** |
michael@0 | 441 | * Restore the stack back to the specified save count. |
michael@0 | 442 | */ |
michael@0 | 443 | void restoreTo(int saveCount); |
michael@0 | 444 | |
michael@0 | 445 | /** |
michael@0 | 446 | * Return the next unique generation ID. |
michael@0 | 447 | */ |
michael@0 | 448 | static int32_t GetNextGenID(); |
michael@0 | 449 | }; |
michael@0 | 450 | |
michael@0 | 451 | #endif |