blob: 1dc4b0d5f8ca989848c53e03fcdef2496e66d9f8 [file] [log] [blame]
robertphillips@google.coma2d71482012-08-01 20:08:47 +00001/*
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.coma2d71482012-08-01 20:08:47 +00008#ifndef GrClip_DEFINED
9#define GrClip_DEFINED
10
robertphillips@google.coma2d71482012-08-01 20:08:47 +000011#include "SkClipStack.h"
commit-bot@chromium.org8ddc26b2014-03-31 17:55:12 +000012#include "GrSurface.h"
robertphillips@google.coma2d71482012-08-01 20:08:47 +000013
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000014struct SkIRect;
robertphillips@google.coma2d71482012-08-01 20:08:47 +000015
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.comfbfcd562012-08-23 18:09:54 +000019 * with an offset bounding box. The clips in 'fClipStack' are in
robertphillips@google.coma2d71482012-08-01 20:08:47 +000020 * device coordinates (i.e., they have been translated by -fOrigin w.r.t.
21 * the canvas' device coordinates).
22 */
commit-bot@chromium.orge3beb6b2014-04-07 19:34:38 +000023class GrClipData : SkNoncopyable {
robertphillips@google.coma2d71482012-08-01 20:08:47 +000024public:
25 const SkClipStack* fClipStack;
26 SkIPoint fOrigin;
27
rmistry@google.comfbfcd562012-08-23 18:09:54 +000028 GrClipData()
robertphillips@google.coma2d71482012-08-01 20:08:47 +000029 : 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.comfbfcd562012-08-23 18:09:54 +000045 bool operator!=(const GrClipData& other) const {
46 return !(*this == other);
robertphillips@google.coma2d71482012-08-01 20:08:47 +000047 }
48
rmistry@google.comfbfcd562012-08-23 18:09:54 +000049 void getConservativeBounds(const GrSurface* surface,
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000050 SkIRect* devResult,
commit-bot@chromium.org8ddc26b2014-03-31 17:55:12 +000051 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.coma2d71482012-08-01 20:08:47 +000058 bool* isIntersectionOfRects = NULL) const;
59};
60
61#endif