2022-02-11 13:53:21 +01:00
|
|
|
/* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
* Copyright 2011-2022 Blender Foundation */
|
2017-04-14 14:05:23 +02:00
|
|
|
|
|
|
|
|
#ifndef __UTIL_MATH_INT2_H__
|
|
|
|
|
#define __UTIL_MATH_INT2_H__
|
|
|
|
|
|
|
|
|
|
#ifndef __UTIL_MATH_H__
|
2021-10-24 14:19:19 +02:00
|
|
|
# error "Do not include this file directly, include util/types.h instead."
|
2017-04-14 14:05:23 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
|
* Declaration.
|
|
|
|
|
*/
|
|
|
|
|
|
2021-11-18 14:25:05 +01:00
|
|
|
#if !defined(__KERNEL_METAL__)
|
2017-04-14 14:05:23 +02:00
|
|
|
ccl_device_inline bool operator==(const int2 a, const int2 b);
|
|
|
|
|
ccl_device_inline int2 operator+(const int2 &a, const int2 &b);
|
|
|
|
|
ccl_device_inline int2 operator+=(int2 &a, const int2 &b);
|
|
|
|
|
ccl_device_inline int2 operator-(const int2 &a, const int2 &b);
|
|
|
|
|
ccl_device_inline int2 operator*(const int2 &a, const int2 &b);
|
|
|
|
|
ccl_device_inline int2 operator/(const int2 &a, const int2 &b);
|
2021-11-18 14:25:05 +01:00
|
|
|
#endif /* !__KERNEL_METAL__ */
|
2017-04-14 14:05:23 +02:00
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
|
* Definition.
|
|
|
|
|
*/
|
|
|
|
|
|
2021-11-18 14:25:05 +01:00
|
|
|
#if !defined(__KERNEL_METAL__)
|
2017-04-14 14:05:23 +02:00
|
|
|
ccl_device_inline bool operator==(const int2 a, const int2 b)
|
|
|
|
|
{
|
|
|
|
|
return (a.x == b.x && a.y == b.y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ccl_device_inline int2 operator+(const int2 &a, const int2 &b)
|
|
|
|
|
{
|
|
|
|
|
return make_int2(a.x + b.x, a.y + b.y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ccl_device_inline int2 operator+=(int2 &a, const int2 &b)
|
|
|
|
|
{
|
|
|
|
|
return a = a + b;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ccl_device_inline int2 operator-(const int2 &a, const int2 &b)
|
|
|
|
|
{
|
|
|
|
|
return make_int2(a.x - b.x, a.y - b.y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ccl_device_inline int2 operator*(const int2 &a, const int2 &b)
|
|
|
|
|
{
|
|
|
|
|
return make_int2(a.x * b.x, a.y * b.y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ccl_device_inline int2 operator/(const int2 &a, const int2 &b)
|
|
|
|
|
{
|
|
|
|
|
return make_int2(a.x / b.x, a.y / b.y);
|
|
|
|
|
}
|
2021-11-18 14:25:05 +01:00
|
|
|
#endif /* !__KERNEL_METAL__ */
|
2017-04-14 14:05:23 +02:00
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
|
|
|
|
#endif /* __UTIL_MATH_INT2_H__ */
|