FourCC.h 690 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. namespace Gfx {
  8. struct [[gnu::packed]] FourCC {
  9. FourCC() = default;
  10. constexpr FourCC(char const name[4])
  11. {
  12. cc[0] = name[0];
  13. cc[1] = name[1];
  14. cc[2] = name[2];
  15. cc[3] = name[3];
  16. }
  17. bool operator==(FourCC const&) const = default;
  18. bool operator!=(FourCC const&) const = default;
  19. u32 to_u32() const
  20. {
  21. return (static_cast<u8>(cc[0]) << 24)
  22. | (static_cast<u8>(cc[1]) << 16)
  23. | (static_cast<u8>(cc[2]) << 8)
  24. | static_cast<u8>(cc[3]);
  25. }
  26. char cc[4];
  27. };
  28. }