namespace Dali
{
-namespace
-{
-constexpr uint32_t BitMaskOfN(uint32_t bits)
-{
- return (1 << bits) - 1;
-}
-
-} // unnamed namespace
-
AlphaFunction::AlphaFunction()
-: mBezierControlPoints(Vector4::ZERO),
- mCustom(nullptr),
- mBuiltin(DEFAULT),
- mMode(BUILTIN_FUNCTION)
+: mMode(BUILTIN_FUNCTION),
+ mBuiltin(DEFAULT)
{
}
AlphaFunction::AlphaFunction(BuiltinFunction function)
-: mBezierControlPoints(Vector4::ZERO),
- mCustom(nullptr),
- mBuiltin(function),
- mMode(BUILTIN_FUNCTION)
+: mMode(BUILTIN_FUNCTION),
+ mBuiltin(function)
{
}
AlphaFunction::AlphaFunction(AlphaFunctionPrototype function)
-: mBezierControlPoints(Vector4::ZERO),
- mCustom(function),
- mBuiltin(DEFAULT),
- mMode(CUSTOM_FUNCTION)
+: mMode(CUSTOM_FUNCTION),
+ mCustom(function)
{
}
AlphaFunction::AlphaFunction(const Vector2& controlPoint0, const Vector2& controlPoint1)
-: mBezierControlPoints(
+: mMode(BEZIER),
+ mBuiltin(DEFAULT),
+ mBezierControlPoints(
Vector4(Clamp(controlPoint0.x, 0.0f, 1.0f),
controlPoint0.y,
Clamp(controlPoint1.x, 0.0f, 1.0f),
- controlPoint1.y)),
- mCustom(nullptr),
- mBuiltin(DEFAULT),
- mMode(BEZIER)
+ controlPoint1.y))
{
}
Vector4 AlphaFunction::GetBezierControlPoints() const
{
- return mBezierControlPoints;
+ return (mMode == BEZIER) ? mBezierControlPoints : Vector4::ZERO;
}
AlphaFunctionPrototype AlphaFunction::GetCustomFunction() const
{
- return mCustom;
+ return (mMode == CUSTOM_FUNCTION) ? mCustom : nullptr;
}
AlphaFunction::BuiltinFunction AlphaFunction::GetBuiltinFunction() const
{
- return static_cast<AlphaFunction::BuiltinFunction>(mBuiltin & BitMaskOfN(Log<COUNT>::value + 1));
+ return mBuiltin;
}
AlphaFunction::Mode AlphaFunction::GetMode() const
{
- return static_cast<AlphaFunction::Mode>(mMode & BitMaskOfN(2));
+ return mMode;
}
} // namespace Dali
*
*/
+// EXTERNAL INCLUDES
+#include <cstdint> // uint8_t
+
// INTERNAL INCLUDES
#include <dali/public-api/common/constants.h>
#include <dali/public-api/common/dali-common.h>
* @brief Enumeration for built-in alpha functions.
* @SINCE_1_0.0
*/
- enum BuiltinFunction
+ enum BuiltinFunction : uint8_t
{
DEFAULT, ///< Linear @SINCE_1_0.0
LINEAR, ///< No transformation @SINCE_1_0.0
* @brief Enumeration for all possible functioning modes for the alpha function.
* @SINCE_1_0.0
*/
- enum Mode
+ enum Mode : uint8_t
{
BUILTIN_FUNCTION, ///< The user has specified a built-in function @SINCE_1_0.0
CUSTOM_FUNCTION, ///< The user has provided a custom function @SINCE_1_0.0
Mode GetMode() const;
private:
- Vector4 mBezierControlPoints; //< Control points for the bezier alpha function
- AlphaFunctionPrototype mCustom; //< Pointer to an alpha function
- BuiltinFunction mBuiltin : Log<COUNT>::value + 1; //< Enum indicating the built-in alpha function
- Mode mMode : 2; //< Enum indicating the functioning mode of the AlphaFunction
+ Mode mMode; //< Enum indicating the functioning mode of the AlphaFunction
+ BuiltinFunction mBuiltin; //< Enum indicating the built-in alpha function
+
+ union
+ {
+ Vector4 mBezierControlPoints; //< Control points for the bezier alpha function
+ AlphaFunctionPrototype mCustom; //< Pointer to an alpha function
+ };
};
/**