Bumping manifests a=b2g-bump
[gecko.git] / image / src / Orientation.h
blobce1b27edd35b62d621c686c3bab83c4d5af0b8d7
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.
32 struct Orientation
34 explicit Orientation(Angle aRotation = Angle::D0,
35 Flip mFlip = Flip::Unflipped)
36 : rotation(aRotation)
37 , flip(mFlip)
38 { }
40 bool IsIdentity() const {
41 return (rotation == Angle::D0) && (flip == Flip::Unflipped);
44 bool SwapsWidthAndHeight() const {
45 return (rotation == Angle::D90) || (rotation == Angle::D270);
48 bool operator==(const Orientation& aOther) const {
49 return (rotation == aOther.rotation) && (flip == aOther.flip);
52 bool operator!=(const Orientation& aOther) const {
53 return !(*this == aOther);
56 Angle rotation;
57 Flip flip;
63 #endif