aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu/GrClipData.h
blob: c9d934d96e6b711cc050125e33eef74360a004a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58

/*
 * Copyright 2010 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */



#ifndef GrClip_DEFINED
#define GrClip_DEFINED

#include "GrRect.h"
#include "SkClipStack.h"

class GrSurface;

/**
 * GrClipData encapsulates the information required to construct the clip
 * masks. 'fOrigin' is only non-zero when saveLayer has been called
 * with an offset bounding box. The clips in 'fClipStack' are in 
 * device coordinates (i.e., they have been translated by -fOrigin w.r.t.
 * the canvas' device coordinates).
 */
class GrClipData : public SkNoncopyable {
public:
    const SkClipStack*  fClipStack;
    SkIPoint            fOrigin;

    GrClipData() 
        : fClipStack(NULL) {
        fOrigin.setZero();
    }

    bool operator==(const GrClipData& other) const {
        if (fOrigin != other.fOrigin) {
            return false;
        }

        if (NULL != fClipStack && NULL != other.fClipStack) {
            return *fClipStack == *other.fClipStack;
        }

        return fClipStack == other.fClipStack;
    }

    bool operator!=(const GrClipData& other) const { 
        return !(*this == other); 
    }

    void getConservativeBounds(const GrSurface* surface, 
                               GrIRect* devResult,
                               bool* isIntersectionOfRects = NULL) const;
};

#endif