NaCl Player API
NaCl Player API Documentation
common.h
Go to the documentation of this file.
1 // Copyright (c) 2016 Samsung Electronics. 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 NACL_PLAYER_COMMON_H_
6 #define NACL_PLAYER_COMMON_H_
7 
8 #include <cstdint>
9 
13 namespace Samsung {
14 namespace NaClPlayer {
15 
17 typedef double TimeTicks;
18 
20 typedef double TimeDelta;
21 
23 class Point {
24  public:
25  int32_t x;
26  int32_t y;
27 
28  Point() : x(0), y(0) { }
29  Point(int32_t xx, int32_t yy) : x(xx), y(yy) { }
30  Point(const Point& p) : x(p.x), y(p.y) { }
31 
32  Point& operator=(const Point& p) {
33  if (this == &p) return *this;
34 
35  x = p.x;
36  y = p.y;
37  return *this;
38  }
39 };
40 
42 class Size {
43  public:
44  int32_t width;
45  int32_t height;
46 
47  Size() : width(0), height(0) { }
48  Size(int32_t w, int32_t h) : width(w), height(h) { }
49  Size(const Size& s) : width(s.width), height(s.height) { }
50 
51  Size& operator=(const Size& s) {
52  if (this == &s) return *this;
53 
54  width = s.width;
55  height = s.height;
56  return *this;
57  }
58 };
59 
61 class Rect {
62  public:
63  Point position;
64  Size size;
65 
66  Rect() : position(), size() { }
67  Rect(const Point& p, const Size& s) : position(p), size(s) { }
68  Rect(int32_t x, int32_t y, int32_t width, int32_t height)
69  : position(x, y), size(width, height)
70  { }
71 
72  Rect operator=(const Rect& r) {
73  if (this == &r) return *this;
74 
75  position = r.position;
76  size = r.size;
77  return *this;
78  }
79 
80  int32_t& x() { return position.x; }
81  int32_t x() const { return position.x; }
82 
83  int32_t& y() { return position.y; }
84  int32_t y() const { return position.y; }
85 
86  int32_t& width() { return size.width; }
87  int32_t width() const { return size.width; }
88 
89  int32_t& height() { return size.height; }
90  int32_t height() const { return size.height; }
91 };
92 
94 class Rational {
95  public:
96  int32_t numerator;
97  int32_t denominator;
98 
99  Rational() : numerator(0), denominator(1) { }
100  Rational(int32_t num, int32_t den) : numerator(num), denominator(den) { }
101  Rational(const Rational& r)
102  : numerator(r.numerator), denominator(r.denominator)
103  { }
104 
105  Rational& operator=(const Rational& r) {
106  if (this == &r) return *this;
107 
108  numerator = r.numerator;
109  denominator = r.denominator;
110  return *this;
111  }
112 };
113 
114 } // namespace NaClPlayer
115 } // namespace Samsung
116 
117 #endif // NACL_PLAYER_COMMON_H_
Represents 2D rectangle with integral coordinates.
Definition: common.h:61
Defines 2D point with integral coordinates.
Definition: common.h:23
Defines integral size of 2D rectangle.
Definition: common.h:42
double TimeTicks
timestamp in seconds
Definition: common.h:17
Represents a rational number.
Definition: common.h:94
double TimeDelta
difference of two timestamps in seconds
Definition: common.h:20