ImageBinary.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. // WARNING: This file is auto generated.
  6. #pragma once
  7. #include <AnKi/Resource/Common.h>
  8. namespace anki
  9. {
  10. /// @addtogroup resource
  11. /// @{
  12. static constexpr const char* IMAGE_MAGIC = "ANKITEX1";
  13. /// Image type.
  14. /// @memberof ImageBinaryHeader
  15. enum class ImageBinaryType : U32
  16. {
  17. NONE,
  18. _2D,
  19. CUBE,
  20. _3D,
  21. _2D_ARRAY
  22. };
  23. /// The acceptable color types.
  24. /// @memberof ImageBinaryHeader
  25. enum class ImageBinaryColorFormat : U32
  26. {
  27. NONE,
  28. RGB8,
  29. RGBA8,
  30. SRGB8,
  31. };
  32. /// The available data compressions.
  33. /// @memberof ImageBinaryHeader
  34. enum class ImageBinaryDataCompression : U32
  35. {
  36. NONE,
  37. RAW = 1 << 0,
  38. S3TC = 1 << 1,
  39. ETC = 1 << 2
  40. };
  41. ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(ImageBinaryDataCompression)
  42. /// The 1st things that appears in a image binary.
  43. class ImageBinaryHeader
  44. {
  45. public:
  46. Array<U8, 8> m_magic;
  47. U32 m_width;
  48. U32 m_height;
  49. U32 m_depthOrLayerCount;
  50. ImageBinaryType m_type;
  51. ImageBinaryColorFormat m_colorFormat;
  52. ImageBinaryDataCompression m_compressionMask;
  53. U32 m_isNormal;
  54. U32 m_mipmapCount;
  55. Array<U8, 88> m_padding;
  56. template<typename TSerializer, typename TClass>
  57. static void serializeCommon(TSerializer& s, TClass self)
  58. {
  59. s.doArray("m_magic", offsetof(ImageBinaryHeader, m_magic), &self.m_magic[0], self.m_magic.getSize());
  60. s.doValue("m_width", offsetof(ImageBinaryHeader, m_width), self.m_width);
  61. s.doValue("m_height", offsetof(ImageBinaryHeader, m_height), self.m_height);
  62. s.doValue("m_depthOrLayerCount", offsetof(ImageBinaryHeader, m_depthOrLayerCount), self.m_depthOrLayerCount);
  63. s.doValue("m_type", offsetof(ImageBinaryHeader, m_type), self.m_type);
  64. s.doValue("m_colorFormat", offsetof(ImageBinaryHeader, m_colorFormat), self.m_colorFormat);
  65. s.doValue("m_compressionMask", offsetof(ImageBinaryHeader, m_compressionMask), self.m_compressionMask);
  66. s.doValue("m_isNormal", offsetof(ImageBinaryHeader, m_isNormal), self.m_isNormal);
  67. s.doValue("m_mipmapCount", offsetof(ImageBinaryHeader, m_mipmapCount), self.m_mipmapCount);
  68. s.doArray("m_padding", offsetof(ImageBinaryHeader, m_padding), &self.m_padding[0], self.m_padding.getSize());
  69. }
  70. template<typename TDeserializer>
  71. void deserialize(TDeserializer& deserializer)
  72. {
  73. serializeCommon<TDeserializer, ImageBinaryHeader&>(deserializer, *this);
  74. }
  75. template<typename TSerializer>
  76. void serialize(TSerializer& serializer) const
  77. {
  78. serializeCommon<TSerializer, const ImageBinaryHeader&>(serializer, *this);
  79. }
  80. };
  81. /// @}
  82. } // end namespace anki