diff -r 000000000000 -r 6474c204b198 gfx/skia/trunk/src/pathops/SkPathOpsRect.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gfx/skia/trunk/src/pathops/SkPathOpsRect.h Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,63 @@ +/* + * Copyright 2012 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#ifndef SkPathOpsRect_DEFINED +#define SkPathOpsRect_DEFINED + +#include "SkPathOpsPoint.h" + +struct SkDRect { + double fLeft, fTop, fRight, fBottom; + + void add(const SkDPoint& pt) { + if (fLeft > pt.fX) { + fLeft = pt.fX; + } + if (fTop > pt.fY) { + fTop = pt.fY; + } + if (fRight < pt.fX) { + fRight = pt.fX; + } + if (fBottom < pt.fY) { + fBottom = pt.fY; + } + } + + bool contains(const SkDPoint& pt) const { + return approximately_between(fLeft, pt.fX, fRight) + && approximately_between(fTop, pt.fY, fBottom); + } + + bool intersects(SkDRect* r) const { + SkASSERT(fLeft <= fRight); + SkASSERT(fTop <= fBottom); + SkASSERT(r->fLeft <= r->fRight); + SkASSERT(r->fTop <= r->fBottom); + return r->fLeft <= fRight && fLeft <= r->fRight && r->fTop <= fBottom && fTop <= r->fBottom; + } + + void set(const SkDPoint& pt) { + fLeft = fRight = pt.fX; + fTop = fBottom = pt.fY; + } + + double width() const { + return fRight - fLeft; + } + + double height() const { + return fBottom - fTop; + } + + void setBounds(const SkDLine&); + void setBounds(const SkDCubic&); + void setBounds(const SkDQuad&); + void setRawBounds(const SkDCubic&); + void setRawBounds(const SkDQuad&); +}; + +#endif