robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2010 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 | |
| 9 | |
| 10 | |
| 11 | #ifndef GrClip_DEFINED |
| 12 | #define GrClip_DEFINED |
| 13 | |
| 14 | #include "GrRect.h" |
| 15 | #include "SkClipStack.h" |
| 16 | |
| 17 | class GrSurface; |
| 18 | |
| 19 | /** |
| 20 | * GrClipData encapsulates the information required to construct the clip |
| 21 | * masks. 'fOrigin' is only non-zero when saveLayer has been called |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 22 | * with an offset bounding box. The clips in 'fClipStack' are in |
robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 23 | * device coordinates (i.e., they have been translated by -fOrigin w.r.t. |
| 24 | * the canvas' device coordinates). |
| 25 | */ |
| 26 | class GrClipData : public SkNoncopyable { |
| 27 | public: |
| 28 | const SkClipStack* fClipStack; |
| 29 | SkIPoint fOrigin; |
| 30 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 31 | GrClipData() |
robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 32 | : fClipStack(NULL) { |
| 33 | fOrigin.setZero(); |
| 34 | } |
| 35 | |
| 36 | bool operator==(const GrClipData& other) const { |
| 37 | if (fOrigin != other.fOrigin) { |
| 38 | return false; |
| 39 | } |
| 40 | |
| 41 | if (NULL != fClipStack && NULL != other.fClipStack) { |
| 42 | return *fClipStack == *other.fClipStack; |
| 43 | } |
| 44 | |
| 45 | return fClipStack == other.fClipStack; |
| 46 | } |
| 47 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 48 | bool operator!=(const GrClipData& other) const { |
| 49 | return !(*this == other); |
robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 50 | } |
| 51 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 52 | void getConservativeBounds(const GrSurface* surface, |
robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 53 | GrIRect* devResult, |
| 54 | bool* isIntersectionOfRects = NULL) const; |
| 55 | }; |
| 56 | |
| 57 | #endif |