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_
10 #include "mozilla/TypedEnum.h"
15 MOZ_BEGIN_ENUM_CLASS(Angle
, uint8_t)
20 MOZ_END_ENUM_CLASS(Angle
)
22 MOZ_BEGIN_ENUM_CLASS(Flip
, uint8_t)
25 MOZ_END_ENUM_CLASS(Flip
)
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.
34 explicit Orientation(Angle aRotation
= Angle::D0
,
35 Flip mFlip
= Flip::Unflipped
)
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
);