blob: 078b61ec35cf46a93dfac8810529a1be13b859f6 [file] [log] [blame]
robertphillips@google.coma2d71482012-08-01 20:08:47 +00001
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
17class 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.comfbfcd562012-08-23 18:09:54 +000022 * with an offset bounding box. The clips in 'fClipStack' are in
robertphillips@google.coma2d71482012-08-01 20:08:47 +000023 * device coordinates (i.e., they have been translated by -fOrigin w.r.t.
24 * the canvas' device coordinates).
25 */
26class GrClipData : public SkNoncopyable {
27public:
28 const SkClipStack* fClipStack;
29 SkIPoint fOrigin;
30
rmistry@google.comfbfcd562012-08-23 18:09:54 +000031 GrClipData()
robertphillips@google.coma2d71482012-08-01 20:08:47 +000032 : 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.comfbfcd562012-08-23 18:09:54 +000048 bool operator!=(const GrClipData& other) const {
49 return !(*this == other);
robertphillips@google.coma2d71482012-08-01 20:08:47 +000050 }
51
rmistry@google.comfbfcd562012-08-23 18:09:54 +000052 void getConservativeBounds(const GrSurface* surface,
robertphillips@google.coma2d71482012-08-01 20:08:47 +000053 GrIRect* devResult,
54 bool* isIntersectionOfRects = NULL) const;
55};
56
57#endif