/src/mozilla-central/image/Orientation.h
Line | Count | Source (jump to first uncovered line) |
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 | | explicit Orientation(Angle aRotation = Angle::D0, |
34 | | Flip mFlip = Flip::Unflipped) |
35 | | : rotation(aRotation) |
36 | | , flip(mFlip) |
37 | 0 | { } |
38 | | |
39 | 0 | bool IsIdentity() const { |
40 | 0 | return (rotation == Angle::D0) && (flip == Flip::Unflipped); |
41 | 0 | } |
42 | | |
43 | 0 | bool SwapsWidthAndHeight() const { |
44 | 0 | return (rotation == Angle::D90) || (rotation == Angle::D270); |
45 | 0 | } |
46 | | |
47 | 0 | bool operator==(const Orientation& aOther) const { |
48 | 0 | return (rotation == aOther.rotation) && (flip == aOther.flip); |
49 | 0 | } |
50 | | |
51 | 0 | bool operator!=(const Orientation& aOther) const { |
52 | 0 | return !(*this == aOther); |
53 | 0 | } |
54 | | |
55 | | Angle rotation; |
56 | | Flip flip; |
57 | | }; |
58 | | |
59 | | } // namespace image |
60 | | } // namespace mozilla |
61 | | |
62 | | #endif // mozilla_image_Orientation_h |