Bug 1610307 [wpt PR 21266] - Update wpt metadata, a=testonly
[gecko.git] / image / Orientation.h
blobd77039dae4c6e03f7cd7c9fa57ee8cf50ffb0adb
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
9 #include <stdint.h>
11 namespace mozilla {
12 namespace image {
14 enum class Angle : uint8_t { D0, D90, D180, D270 };
16 enum class Flip : uint8_t { Unflipped, Horizontal };
18 /**
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.
23 struct Orientation {
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);
44 Angle rotation;
45 Flip flip;
48 } // namespace image
49 } // namespace mozilla
51 #endif // mozilla_image_Orientation_h