Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/gfxQuad.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2
 * This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#ifndef GFX_QUAD_H
7
#define GFX_QUAD_H
8
9
#include "gfxTypes.h"
10
#include "gfxRect.h"
11
#include "gfxLineSegment.h"
12
#include <algorithm>
13
14
struct gfxQuad {
15
    gfxQuad(const gfxPoint& aOne, const gfxPoint& aTwo, const gfxPoint& aThree, const gfxPoint& aFour)
16
    {
17
        mPoints[0] = aOne;
18
        mPoints[1] = aTwo;
19
        mPoints[2] = aThree;
20
        mPoints[3] = aFour;
21
    }
22
23
    bool Contains(const gfxPoint& aPoint)
24
0
    {
25
0
        return (gfxLineSegment(mPoints[0], mPoints[1]).PointsOnSameSide(aPoint, mPoints[2]) &&
26
0
                gfxLineSegment(mPoints[1], mPoints[2]).PointsOnSameSide(aPoint, mPoints[3]) &&
27
0
                gfxLineSegment(mPoints[2], mPoints[3]).PointsOnSameSide(aPoint, mPoints[0]) &&
28
0
                gfxLineSegment(mPoints[3], mPoints[0]).PointsOnSameSide(aPoint, mPoints[1]));
29
0
    }
30
31
    gfxRect GetBounds()
32
0
    {
33
0
        gfxFloat min_x, max_x;
34
0
        gfxFloat min_y, max_y;
35
0
36
0
        min_x = max_x = mPoints[0].x;
37
0
        min_y = max_y = mPoints[0].y;
38
0
39
0
        for (int i=1; i<4; i++) {
40
0
          min_x = std::min(mPoints[i].x, min_x);
41
0
          max_x = std::max(mPoints[i].x, max_x);
42
0
          min_y = std::min(mPoints[i].y, min_y);
43
0
          max_y = std::max(mPoints[i].y, max_y);
44
0
        }
45
0
        return gfxRect(min_x, min_y, max_x - min_x, max_y - min_y);
46
0
    }
47
48
    gfxPoint mPoints[4];
49
};
50
51
#endif /* GFX_QUAD_H */