Bug 1454184 [wpt PR 10474] - [Resource Timing] Align TAO parsing to spec, a=testonly
[gecko.git] / image / Orientation.h
bloba0f2e1b75a0a0e2453197ff163c877b0e10e1438
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 {
15 D0,
16 D90,
17 D180,
18 D270
21 enum class Flip : uint8_t {
22 Unflipped,
23 Horizontal
26 /**
27 * A struct that describes an image's orientation as a rotation optionally
28 * followed by a reflection. This may be used to be indicate an image's inherent
29 * orientation or a desired orientation for the image.
31 struct Orientation
33 explicit Orientation(Angle aRotation = Angle::D0,
34 Flip mFlip = Flip::Unflipped)
35 : rotation(aRotation)
36 , flip(mFlip)
37 { }
39 bool IsIdentity() const {
40 return (rotation == Angle::D0) && (flip == Flip::Unflipped);
43 bool SwapsWidthAndHeight() const {
44 return (rotation == Angle::D90) || (rotation == Angle::D270);
47 bool operator==(const Orientation& aOther) const {
48 return (rotation == aOther.rotation) && (flip == aOther.flip);
51 bool operator!=(const Orientation& aOther) const {
52 return !(*this == aOther);
55 Angle rotation;
56 Flip flip;
59 } // namespace image
60 } // namespace mozilla
62 #endif // mozilla_image_Orientation_h