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.

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

mercurial