Line data Source code
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/. */
5 :
6 : #ifndef mozilla_image_Orientation_h
7 : #define mozilla_image_Orientation_h
8 :
9 : #include <stdint.h>
10 :
11 : namespace mozilla {
12 : namespace image {
13 :
14 : enum class Angle : uint8_t {
15 : D0,
16 : D90,
17 : D180,
18 : D270
19 : };
20 :
21 : enum class Flip : uint8_t {
22 : Unflipped,
23 : Horizontal
24 : };
25 :
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.
30 : */
31 : struct Orientation
32 : {
33 53 : explicit Orientation(Angle aRotation = Angle::D0,
34 : Flip mFlip = Flip::Unflipped)
35 53 : : rotation(aRotation)
36 53 : , flip(mFlip)
37 53 : { }
38 :
39 0 : bool IsIdentity() const {
40 0 : return (rotation == Angle::D0) && (flip == Flip::Unflipped);
41 : }
42 :
43 0 : bool SwapsWidthAndHeight() const {
44 0 : return (rotation == Angle::D90) || (rotation == Angle::D270);
45 : }
46 :
47 14 : bool operator==(const Orientation& aOther) const {
48 14 : return (rotation == aOther.rotation) && (flip == aOther.flip);
49 : }
50 :
51 14 : bool operator!=(const Orientation& aOther) const {
52 14 : return !(*this == aOther);
53 : }
54 :
55 : Angle rotation;
56 : Flip flip;
57 : };
58 :
59 : } // namespace image
60 : } // namespace mozilla
61 :
62 : #endif // mozilla_image_Orientation_h
|