gfx/skia/trunk/src/pathops/SkPathOpsRect.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/pathops/SkPathOpsRect.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,63 @@
     1.4 +/*
     1.5 + * Copyright 2012 Google Inc.
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +#ifndef SkPathOpsRect_DEFINED
    1.11 +#define SkPathOpsRect_DEFINED
    1.12 +
    1.13 +#include "SkPathOpsPoint.h"
    1.14 +
    1.15 +struct SkDRect {
    1.16 +    double fLeft, fTop, fRight, fBottom;
    1.17 +
    1.18 +    void add(const SkDPoint& pt) {
    1.19 +        if (fLeft > pt.fX) {
    1.20 +            fLeft = pt.fX;
    1.21 +        }
    1.22 +        if (fTop > pt.fY) {
    1.23 +            fTop = pt.fY;
    1.24 +        }
    1.25 +        if (fRight < pt.fX) {
    1.26 +            fRight = pt.fX;
    1.27 +        }
    1.28 +        if (fBottom < pt.fY) {
    1.29 +            fBottom = pt.fY;
    1.30 +        }
    1.31 +    }
    1.32 +
    1.33 +    bool contains(const SkDPoint& pt) const {
    1.34 +        return approximately_between(fLeft, pt.fX, fRight)
    1.35 +                && approximately_between(fTop, pt.fY, fBottom);
    1.36 +    }
    1.37 +
    1.38 +    bool intersects(SkDRect* r) const {
    1.39 +        SkASSERT(fLeft <= fRight);
    1.40 +        SkASSERT(fTop <= fBottom);
    1.41 +        SkASSERT(r->fLeft <= r->fRight);
    1.42 +        SkASSERT(r->fTop <= r->fBottom);
    1.43 +        return r->fLeft <= fRight && fLeft <= r->fRight && r->fTop <= fBottom && fTop <= r->fBottom;
    1.44 +    }
    1.45 +
    1.46 +    void set(const SkDPoint& pt) {
    1.47 +        fLeft = fRight = pt.fX;
    1.48 +        fTop = fBottom = pt.fY;
    1.49 +    }
    1.50 +
    1.51 +    double width() const {
    1.52 +        return fRight - fLeft;
    1.53 +    }
    1.54 +
    1.55 +    double height() const {
    1.56 +        return fBottom - fTop;
    1.57 +    }
    1.58 +
    1.59 +    void setBounds(const SkDLine&);
    1.60 +    void setBounds(const SkDCubic&);
    1.61 +    void setBounds(const SkDQuad&);
    1.62 +    void setRawBounds(const SkDCubic&);
    1.63 +    void setRawBounds(const SkDQuad&);
    1.64 +};
    1.65 +
    1.66 +#endif

mercurial