-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fabric: Geometry.h is spit to several separate files
Summary: We are about to add several additional functions to this file, so we need to split it to keep it manageable. All changes in this diff are cosmetical. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D22384429 fbshipit-source-id: d22592fba17ef04edb44388b4e1ff22112e9c020
- Loading branch information
1 parent
824d3a9
commit e23e932
Showing
6 changed files
with
413 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <tuple> | ||
|
||
#include <folly/Hash.h> | ||
#include <react/graphics/Float.h> | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
/* | ||
* Contains a point in a two-dimensional coordinate system. | ||
*/ | ||
struct Point { | ||
Float x{0}; | ||
Float y{0}; | ||
|
||
Point &operator+=(Point const &point) noexcept { | ||
x += point.x; | ||
y += point.y; | ||
return *this; | ||
} | ||
|
||
Point &operator-=(Point const &point) noexcept { | ||
x -= point.x; | ||
y -= point.y; | ||
return *this; | ||
} | ||
|
||
Point &operator*=(Point const &point) noexcept { | ||
x *= point.x; | ||
y *= point.y; | ||
return *this; | ||
} | ||
|
||
friend Point operator+(Point lhs, Point const &rhs) noexcept { | ||
return lhs += rhs; | ||
} | ||
|
||
friend Point operator-(Point lhs, Point const &rhs) noexcept { | ||
return lhs -= rhs; | ||
} | ||
}; | ||
|
||
inline bool operator==(Point const &rhs, Point const &lhs) noexcept { | ||
return std::tie(lhs.x, lhs.y) == std::tie(rhs.x, rhs.y); | ||
} | ||
|
||
inline bool operator!=(Point const &rhs, Point const &lhs) noexcept { | ||
return !(lhs == rhs); | ||
} | ||
|
||
} // namespace react | ||
} // namespace facebook | ||
|
||
namespace std { | ||
|
||
template <> | ||
struct hash<facebook::react::Point> { | ||
size_t operator()(facebook::react::Point const &point) const noexcept { | ||
return folly::hash::hash_combine(0, point.x, point.y); | ||
} | ||
}; | ||
|
||
} // namespace std |
Oops, something went wrong.