OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #ifndef SkClipStack_DEFINED | 8 #ifndef SkClipStack_DEFINED |
9 #define SkClipStack_DEFINED | 9 #define SkClipStack_DEFINED |
10 | 10 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 */ | 326 */ |
327 void getBounds(SkRect* canvFiniteBound, | 327 void getBounds(SkRect* canvFiniteBound, |
328 BoundsType* boundType, | 328 BoundsType* boundType, |
329 bool* isIntersectionOfRects = NULL) const; | 329 bool* isIntersectionOfRects = NULL) const; |
330 | 330 |
331 /** | 331 /** |
332 * Returns true if the input (r)rect in device space is entirely contained | 332 * Returns true if the input (r)rect in device space is entirely contained |
333 * by the clip. A return value of false does not guarantee that the (r)rect | 333 * by the clip. A return value of false does not guarantee that the (r)rect |
334 * is not contained by the clip. | 334 * is not contained by the clip. |
335 */ | 335 */ |
336 bool quickContains(const SkRect& devRect) const; | 336 bool quickContains(const SkRect& devRect) const { |
337 bool quickContains(const SkRRect& devRRect) const; | 337 return this->isWideOpen() || this->internalQuickContains(devRect); |
| 338 } |
| 339 |
| 340 bool quickContains(const SkRRect& devRRect) const { |
| 341 return this->isWideOpen() || this->internalQuickContains(devRRect); |
| 342 } |
338 | 343 |
339 /** | 344 /** |
340 * Flattens the clip stack into a single SkPath. Returns true if any of | 345 * Flattens the clip stack into a single SkPath. Returns true if any of |
341 * the clip stack components requires anti-aliasing. | 346 * the clip stack components requires anti-aliasing. |
342 */ | 347 */ |
343 bool asPath(SkPath* path) const; | 348 bool asPath(SkPath* path) const; |
344 | 349 |
345 void clipDevRect(const SkIRect& ir, SkRegion::Op op) { | 350 void clipDevRect(const SkIRect& ir, SkRegion::Op op) { |
346 SkRect r; | 351 SkRect r; |
347 r.set(ir); | 352 r.set(ir); |
348 this->clipDevRect(r, op, false); | 353 this->clipDevRect(r, op, false); |
349 } | 354 } |
350 void clipDevRect(const SkRect&, SkRegion::Op, bool doAA); | 355 void clipDevRect(const SkRect&, SkRegion::Op, bool doAA); |
351 void clipDevRRect(const SkRRect&, SkRegion::Op, bool doAA); | 356 void clipDevRRect(const SkRRect&, SkRegion::Op, bool doAA); |
352 void clipDevPath(const SkPath&, SkRegion::Op, bool doAA); | 357 void clipDevPath(const SkPath&, SkRegion::Op, bool doAA); |
353 // An optimized version of clipDevRect(emptyRect, kIntersect, ...) | 358 // An optimized version of clipDevRect(emptyRect, kIntersect, ...) |
354 void clipEmpty(); | 359 void clipEmpty(); |
355 | 360 |
356 /** | 361 /** |
357 * isWideOpen returns true if the clip state corresponds to the infinite | 362 * isWideOpen returns true if the clip state corresponds to the infinite |
358 * plane (i.e., draws are not limited at all) | 363 * plane (i.e., draws are not limited at all) |
359 */ | 364 */ |
360 bool isWideOpen() const; | 365 bool isWideOpen() const { return this->getTopmostGenID() == kWideOpenGenID;
} |
361 | 366 |
362 /** | 367 /** |
363 * The generation ID has three reserved values to indicate special | 368 * The generation ID has three reserved values to indicate special |
364 * (potentially ignorable) cases | 369 * (potentially ignorable) cases |
365 */ | 370 */ |
366 static const int32_t kInvalidGenID = 0; //!< Invalid id that is never re
turned by | 371 static const int32_t kInvalidGenID = 0; //!< Invalid id that is never re
turned by |
367 //!< SkClipStack. Useful when ca
ching clips | 372 //!< SkClipStack. Useful when ca
ching clips |
368 //!< based on GenID. | 373 //!< based on GenID. |
369 static const int32_t kEmptyGenID = 1; // no pixels writeable | 374 static const int32_t kEmptyGenID = 1; // no pixels writeable |
370 static const int32_t kWideOpenGenID = 2; // all pixels writeable | 375 static const int32_t kWideOpenGenID = 2; // all pixels writeable |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 friend class Iter; | 477 friend class Iter; |
473 | 478 |
474 SkDeque fDeque; | 479 SkDeque fDeque; |
475 int fSaveCount; | 480 int fSaveCount; |
476 | 481 |
477 // Generation ID for the clip stack. This is incremented for each | 482 // Generation ID for the clip stack. This is incremented for each |
478 // clipDevRect and clipDevPath call. 0 is reserved to indicate an | 483 // clipDevRect and clipDevPath call. 0 is reserved to indicate an |
479 // invalid ID. | 484 // invalid ID. |
480 static int32_t gGenID; | 485 static int32_t gGenID; |
481 | 486 |
| 487 bool internalQuickContains(const SkRect& devRect) const; |
| 488 bool internalQuickContains(const SkRRect& devRRect) const; |
| 489 |
482 /** | 490 /** |
483 * Helper for clipDevPath, etc. | 491 * Helper for clipDevPath, etc. |
484 */ | 492 */ |
485 void pushElement(const Element& element); | 493 void pushElement(const Element& element); |
486 | 494 |
487 /** | 495 /** |
488 * Restore the stack back to the specified save count. | 496 * Restore the stack back to the specified save count. |
489 */ | 497 */ |
490 void restoreTo(int saveCount); | 498 void restoreTo(int saveCount); |
491 | 499 |
492 /** | 500 /** |
493 * Return the next unique generation ID. | 501 * Return the next unique generation ID. |
494 */ | 502 */ |
495 static int32_t GetNextGenID(); | 503 static int32_t GetNextGenID(); |
496 }; | 504 }; |
497 | 505 |
498 #endif | 506 #endif |
OLD | NEW |