image/src/Orientation.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
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: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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 MOZILLA_IMAGELIB_ORIENTATION_H_
michael@0 7 #define MOZILLA_IMAGELIB_ORIENTATION_H_
michael@0 8
michael@0 9 #include <stdint.h>
michael@0 10 #include "mozilla/TypedEnum.h"
michael@0 11
michael@0 12 namespace mozilla {
michael@0 13 namespace image {
michael@0 14
michael@0 15 MOZ_BEGIN_ENUM_CLASS(Angle, uint8_t)
michael@0 16 D0,
michael@0 17 D90,
michael@0 18 D180,
michael@0 19 D270
michael@0 20 MOZ_END_ENUM_CLASS(Angle)
michael@0 21
michael@0 22 MOZ_BEGIN_ENUM_CLASS(Flip, uint8_t)
michael@0 23 Unflipped,
michael@0 24 Horizontal
michael@0 25 MOZ_END_ENUM_CLASS(Flip)
michael@0 26
michael@0 27 /**
michael@0 28 * A struct that describes an image's orientation as a rotation optionally
michael@0 29 * followed by a reflection. This may be used to be indicate an image's inherent
michael@0 30 * orientation or a desired orientation for the image.
michael@0 31 */
michael@0 32 struct Orientation
michael@0 33 {
michael@0 34 Orientation(Angle aRotation = Angle::D0, Flip mFlip = Flip::Unflipped)
michael@0 35 : rotation(aRotation)
michael@0 36 , flip(mFlip)
michael@0 37 { }
michael@0 38
michael@0 39 bool IsIdentity() const {
michael@0 40 return (rotation == Angle::D0) && (flip == Flip::Unflipped);
michael@0 41 }
michael@0 42
michael@0 43 bool SwapsWidthAndHeight() const {
michael@0 44 return (rotation == Angle::D90) || (rotation == Angle::D270);
michael@0 45 }
michael@0 46
michael@0 47 bool operator==(const Orientation& aOther) const {
michael@0 48 return (rotation == aOther.rotation) && (flip == aOther.flip);
michael@0 49 }
michael@0 50
michael@0 51 bool operator!=(const Orientation& aOther) const {
michael@0 52 return !(*this == aOther);
michael@0 53 }
michael@0 54
michael@0 55 Angle rotation;
michael@0 56 Flip flip;
michael@0 57 };
michael@0 58
michael@0 59 }
michael@0 60 }
michael@0 61
michael@0 62 #endif

mercurial