• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
22  * with an offset bounding box. The clips in 'fClipStack' are in
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 
GrClipData()31     GrClipData()
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 
48     bool operator!=(const GrClipData& other) const {
49         return !(*this == other);
50     }
51 
52     void getConservativeBounds(const GrSurface* surface,
53                                GrIRect* devResult,
54                                bool* isIntersectionOfRects = NULL) const;
55 };
56 
57 #endif
58