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_image_Orientation_h
7 #define mozilla_image_Orientation_h
14 enum class Angle
: uint8_t { D0
, D90
, D180
, D270
};
16 enum class Flip
: uint8_t { Unflipped
, Horizontal
};
19 * A struct that describes an image's orientation as a rotation optionally
20 * followed by a reflection. This may be used to be indicate an image's inherent
21 * orientation or a desired orientation for the image.
24 explicit Orientation(Angle aRotation
= Angle::D0
,
25 Flip mFlip
= Flip::Unflipped
)
26 : rotation(aRotation
), flip(mFlip
) {}
28 bool IsIdentity() const {
29 return (rotation
== Angle::D0
) && (flip
== Flip::Unflipped
);
32 bool SwapsWidthAndHeight() const {
33 return (rotation
== Angle::D90
) || (rotation
== Angle::D270
);
36 bool operator==(const Orientation
& aOther
) const {
37 return (rotation
== aOther
.rotation
) && (flip
== aOther
.flip
);
40 bool operator!=(const Orientation
& aOther
) const {
41 return !(*this == aOther
);
49 } // namespace mozilla
51 #endif // mozilla_image_Orientation_h