ImageBinary.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. ASTC = 1 << 3
  41. };
  42. ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(ImageBinaryDataCompression)
  43. /// The 1st things that appears in a image binary.
  44. class ImageBinaryHeader
  45. {
  46. public:
  47. Array<U8, 8> m_magic;
  48. U32 m_width;
  49. U32 m_height;
  50. U32 m_depthOrLayerCount;
  51. ImageBinaryType m_type;
  52. ImageBinaryColorFormat m_colorFormat;
  53. ImageBinaryDataCompression m_compressionMask;
  54. U32 m_isNormal;
  55. U32 m_mipmapCount;
  56. U32 m_astcBlockSizeX;
  57. U32 m_astcBlockSizeY;
  58. Array<U8, 80> m_padding;
  59. template<typename TSerializer, typename TClass>
  60. static void serializeCommon(TSerializer& s, TClass self)
  61. {
  62. s.doArray("m_magic", offsetof(ImageBinaryHeader, m_magic), &self.m_magic[0], self.m_magic.getSize());
  63. s.doValue("m_width", offsetof(ImageBinaryHeader, m_width), self.m_width);
  64. s.doValue("m_height", offsetof(ImageBinaryHeader, m_height), self.m_height);
  65. s.doValue("m_depthOrLayerCount", offsetof(ImageBinaryHeader, m_depthOrLayerCount), self.m_depthOrLayerCount);
  66. s.doValue("m_type", offsetof(ImageBinaryHeader, m_type), self.m_type);
  67. s.doValue("m_colorFormat", offsetof(ImageBinaryHeader, m_colorFormat), self.m_colorFormat);
  68. s.doValue("m_compressionMask", offsetof(ImageBinaryHeader, m_compressionMask), self.m_compressionMask);
  69. s.doValue("m_isNormal", offsetof(ImageBinaryHeader, m_isNormal), self.m_isNormal);
  70. s.doValue("m_mipmapCount", offsetof(ImageBinaryHeader, m_mipmapCount), self.m_mipmapCount);
  71. s.doValue("m_astcBlockSizeX", offsetof(ImageBinaryHeader, m_astcBlockSizeX), self.m_astcBlockSizeX);
  72. s.doValue("m_astcBlockSizeY", offsetof(ImageBinaryHeader, m_astcBlockSizeY), self.m_astcBlockSizeY);
  73. s.doArray("m_padding", offsetof(ImageBinaryHeader, m_padding), &self.m_padding[0], self.m_padding.getSize());
  74. }
  75. template<typename TDeserializer>
  76. void deserialize(TDeserializer& deserializer)
  77. {
  78. serializeCommon<TDeserializer, ImageBinaryHeader&>(deserializer, *this);
  79. }
  80. template<typename TSerializer>
  81. void serialize(TSerializer& serializer) const
  82. {
  83. serializeCommon<TSerializer, const ImageBinaryHeader&>(serializer, *this);
  84. }
  85. };
  86. /// @}
  87. } // end namespace anki