gfx/thebes/gfxQuad.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial