| Flutter Impeller |

rational.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_IMPELLER_GEOMETRY_RATIONAL_H_
6 #define FLUTTER_IMPELLER_GEOMETRY_RATIONAL_H_
7
8 #include <cstdint>
9 #include "impeller/geometry/scalar.h"
10
11 namespace impeller {
12
13 class Rational {
14 public:
15 constexpr explicit Rational(int32_t num) : num_(num), den_(1) {}
16
17 constexpr Rational(int32_t num, uint32_t den) : num_(num), den_(den) {}
18
19 int32_t GetNumerator() const { return num_; }
20
21 uint32_t GetDenominator() const { return den_; }
22
23 bool operator==(const Rational& that) const;
24
25 bool operator!=(const Rational& that) const;
26
27 bool operator<(const Rational& that) const;
28
29 uint64_t GetHash() const;
30
31 explicit operator Scalar() const { return static_cast<float>(num_) / den_; }
32
33 Rational Invert() const;
34
35 private:
36 int32_t num_;
37 uint32_t den_;
38 };
39
40 } // namespace impeller
41
42 #endif // FLUTTER_IMPELLER_GEOMETRY_RATIONAL_H_
impeller::Rational
Definition: rational.h:13
impeller::Rational::operator!=
bool operator!=(const Rational &that) const
Definition: rational.cc:28
impeller::Rational::Rational
constexpr Rational(int32_t num, uint32_t den)
Definition: rational.h:17
impeller::Rational::Invert
Rational Invert() const
Definition: rational.cc:50
impeller::Rational::Rational
constexpr Rational(int32_t num)
Definition: rational.h:15
impeller::Rational::operator<
bool operator<(const Rational &that) const
Definition: rational.cc:32
impeller::Rational::GetNumerator
int32_t GetNumerator() const
Definition: rational.h:19
impeller::Rational::GetHash
uint64_t GetHash() const
Definition: rational.cc:42
impeller::Rational::GetDenominator
uint32_t GetDenominator() const
Definition: rational.h:21
impeller::Rational::operator==
bool operator==(const Rational &that) const
Definition: rational.cc:18
impeller
Definition: allocation.cc:12
impeller::Scalar
float Scalar
Definition: scalar.h:18
scalar.h