robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2010 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 8 | #ifndef GrClip_DEFINED |
| 9 | #define GrClip_DEFINED |
| 10 | |
robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 11 | #include "SkClipStack.h" |
commit-bot@chromium.org | 8ddc26b | 2014-03-31 17:55:12 +0000 | [diff] [blame] | 12 | #include "GrSurface.h" |
robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 13 | |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 14 | struct SkIRect; |
robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 15 | |
| 16 | /** |
| 17 | * GrClipData encapsulates the information required to construct the clip |
| 18 | * masks. 'fOrigin' is only non-zero when saveLayer has been called |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 19 | * with an offset bounding box. The clips in 'fClipStack' are in |
robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 20 | * device coordinates (i.e., they have been translated by -fOrigin w.r.t. |
| 21 | * the canvas' device coordinates). |
| 22 | */ |
commit-bot@chromium.org | e3beb6b | 2014-04-07 19:34:38 +0000 | [diff] [blame^] | 23 | class GrClipData : SkNoncopyable { |
robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 24 | public: |
| 25 | const SkClipStack* fClipStack; |
| 26 | SkIPoint fOrigin; |
| 27 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 28 | GrClipData() |
robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 29 | : fClipStack(NULL) { |
| 30 | fOrigin.setZero(); |
| 31 | } |
| 32 | |
| 33 | bool operator==(const GrClipData& other) const { |
| 34 | if (fOrigin != other.fOrigin) { |
| 35 | return false; |
| 36 | } |
| 37 | |
| 38 | if (NULL != fClipStack && NULL != other.fClipStack) { |
| 39 | return *fClipStack == *other.fClipStack; |
| 40 | } |
| 41 | |
| 42 | return fClipStack == other.fClipStack; |
| 43 | } |
| 44 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 45 | bool operator!=(const GrClipData& other) const { |
| 46 | return !(*this == other); |
robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 47 | } |
| 48 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 49 | void getConservativeBounds(const GrSurface* surface, |
commit-bot@chromium.org | fd03d4a | 2013-07-17 21:39:42 +0000 | [diff] [blame] | 50 | SkIRect* devResult, |
commit-bot@chromium.org | 8ddc26b | 2014-03-31 17:55:12 +0000 | [diff] [blame] | 51 | bool* isIntersectionOfRects = NULL) const { |
| 52 | this->getConservativeBounds(surface->width(), surface->height(), |
| 53 | devResult, isIntersectionOfRects); |
| 54 | } |
| 55 | |
| 56 | void getConservativeBounds(int width, int height, |
| 57 | SkIRect* devResult, |
robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 58 | bool* isIntersectionOfRects = NULL) const; |
| 59 | }; |
| 60 | |
| 61 | #endif |