2012-08-01 20:08:47 +00:00
|
|
|
/*
|
|
|
|
* 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 "SkClipStack.h"
|
2014-03-31 17:55:12 +00:00
|
|
|
#include "GrSurface.h"
|
2012-08-01 20:08:47 +00:00
|
|
|
|
2013-07-17 21:39:42 +00:00
|
|
|
struct SkIRect;
|
2012-08-01 20:08:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GrClipData encapsulates the information required to construct the clip
|
|
|
|
* masks. 'fOrigin' is only non-zero when saveLayer has been called
|
2012-08-23 18:09:54 +00:00
|
|
|
* with an offset bounding box. The clips in 'fClipStack' are in
|
2012-08-01 20:08:47 +00:00
|
|
|
* device coordinates (i.e., they have been translated by -fOrigin w.r.t.
|
|
|
|
* the canvas' device coordinates).
|
|
|
|
*/
|
2014-04-07 19:34:38 +00:00
|
|
|
class GrClipData : SkNoncopyable {
|
2012-08-01 20:08:47 +00:00
|
|
|
public:
|
|
|
|
const SkClipStack* fClipStack;
|
|
|
|
SkIPoint fOrigin;
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
GrClipData()
|
2012-08-01 20:08:47 +00:00
|
|
|
: fClipStack(NULL) {
|
|
|
|
fOrigin.setZero();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const GrClipData& other) const {
|
|
|
|
if (fOrigin != other.fOrigin) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-09-05 20:34:00 +00:00
|
|
|
if (fClipStack && other.fClipStack) {
|
2012-08-01 20:08:47 +00:00
|
|
|
return *fClipStack == *other.fClipStack;
|
|
|
|
}
|
|
|
|
|
|
|
|
return fClipStack == other.fClipStack;
|
|
|
|
}
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
bool operator!=(const GrClipData& other) const {
|
|
|
|
return !(*this == other);
|
2012-08-01 20:08:47 +00:00
|
|
|
}
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
void getConservativeBounds(const GrSurface* surface,
|
2014-03-31 17:55:12 +00:00
|
|
|
SkIRect* devResult,
|
|
|
|
bool* isIntersectionOfRects = NULL) const {
|
|
|
|
this->getConservativeBounds(surface->width(), surface->height(),
|
|
|
|
devResult, isIntersectionOfRects);
|
|
|
|
}
|
|
|
|
|
|
|
|
void getConservativeBounds(int width, int height,
|
2013-07-17 21:39:42 +00:00
|
|
|
SkIRect* devResult,
|
2012-08-01 20:08:47 +00:00
|
|
|
bool* isIntersectionOfRects = NULL) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|