Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-render

Source of release 0.6.2

0.6.2 / src / gfx / four_cc.lucb

#==============================================================================================
#
#   four_cc - FourCC: a four-character code
#
#   DESCRIPTION:
#       Port of Libraries/LibGfx/FourCC.h (lines 1-61). The struct is in types_four_cc; its
#       AK::Traits specialization (hash = to_u32) is FourCcTraits in types_traits. The C++
#       defaulted operator== is Luce's structural `==` on the struct.
#
#==============================================================================================

## Ported from Libraries/LibGfx/FourCC.h:16 Gfx::FourCC::FourCC.
pub func four_cc_construct(this: FourCc*, name: u8[4]):
    this.cc[0] = name[0]
    this.cc[1] = name[1]
    this.cc[2] = name[2]
    this.cc[3] = name[3]

## Ported from Libraries/LibGfx/FourCC.h:24 Gfx::FourCC::from_u32.
pub func four_cc_from_u32(value: u32) -> FourCc:
    var result: FourCc
    result.cc[0] = (u8)(value >> 24)
    result.cc[1] = (u8)(value >> 16)
    result.cc[2] = (u8)(value >> 8)
    result.cc[3] = (u8)value
    return result

## Ported from Libraries/LibGfx/FourCC.h:37 Gfx::FourCC::to_u32.
pub func four_cc_to_u32(this: const FourCc*) -> u32:
    return ((u32)this.cc[0] << 24) | ((u32)this.cc[1] << 16) | ((u32)this.cc[2] << 8) | (u32)this.cc[3]

## Ported from Libraries/LibGfx/FourCC.h:45 Gfx::FourCC::operator<.
pub func four_cc_lt(this: const FourCc*, other: FourCc) -> bool:
    return four_cc_to_u32(this) < four_cc_to_u32(&other)