Flutter Engine
 
Loading...
Searching...
No Matches
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>
10
11namespace impeller {
12
13class 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 uint64_t GetHash() const;
28
29 explicit operator Scalar() const { return static_cast<float>(num_) / den_; }
30
31 Rational Invert() const;
32
33 private:
34 int32_t num_;
35 uint32_t den_;
36};
37
38} // namespace impeller
39
40#endif // FLUTTER_IMPELLER_GEOMETRY_RATIONAL_H_
constexpr Rational(int32_t num, uint32_t den)
Definition rational.h:17
Rational Invert() const
Definition rational.cc:46
constexpr Rational(int32_t num)
Definition rational.h:15
bool operator<(const Rational &that) const
Definition rational.cc:28
int32_t GetNumerator() const
Definition rational.h:19
uint64_t GetHash() const
Definition rational.cc:38
uint32_t GetDenominator() const
Definition rational.h:21
bool operator==(const Rational &that) const
Definition rational.cc:18
float Scalar
Definition scalar.h:19