odin-blend2d

Odin bindings to Blend2D
Log | Files | Refs | README | LICENSE

var_p.h (1068B)


      1 
      2 // This file is part of Blend2D project <https://blend2d.com>
      3 //
      4 // See blend2d.h or LICENSE.md for license and copyright information
      5 // SPDX-License-Identifier: Zlib
      6 
      7 #ifndef BLEND2D_VAR_P_H_INCLUDED
      8 #define BLEND2D_VAR_P_H_INCLUDED
      9 
     10 #include "api-internal_p.h"
     11 #include "object_p.h"
     12 #include "rgba_p.h"
     13 #include "var.h"
     14 #include "support/math_p.h"
     15 
     16 //! \cond INTERNAL
     17 //! \addtogroup bl_globals
     18 //! \{
     19 
     20 namespace bl {
     21 namespace VarInternal {
     22 
     23 //! \name Variant - Internals - Initialization
     24 //! \{
     25 
     26 //! Initializes BLVar with \ref BLRgba and protects BLObjectInfo from payload that would conflict with BLObject tag.
     27 static BL_INLINE BLResult init_rgba(BLObjectCore* self, const BLRgba* rgba) noexcept {
     28   uint32_t r = bl_bit_cast<uint32_t>(rgba->r);
     29   uint32_t g = bl_bit_cast<uint32_t>(rgba->g);
     30   uint32_t b = bl_bit_cast<uint32_t>(rgba->b);
     31   uint32_t a = bl_max<uint32_t>(bl_bit_cast<uint32_t>(rgba->a), 0);
     32 
     33   self->_d.init_u32x4(r, g, b, a);
     34   return BL_SUCCESS;
     35 }
     36 
     37 //! \}
     38 
     39 } // {VarInternal}
     40 } // {bl}
     41 
     42 //! \}
     43 //! \endcond
     44 
     45 #endif // BLEND2D_VAR_P_H_INCLUDED