ImageBinary.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. /// @addtogroup resource
  10. /// @{
  11. static constexpr const char* IMAGE_MAGIC = "ANKITEX1";
  12. /// Image type.
  13. /// @memberof ImageBinaryHeader
  14. enum class ImageBinaryType : U32
  15. {
  16. NONE,
  17. _2D,
  18. CUBE,
  19. _3D,
  20. _2D_ARRAY
  21. };
  22. /// The acceptable color types.
  23. /// @memberof ImageBinaryHeader
  24. enum class ImageBinaryColorFormat : U32
  25. {
  26. NONE,
  27. RGB8,
  28. RGBA8,
  29. SRGB8,
  30. };
  31. /// The available data compressions.
  32. /// @memberof ImageBinaryHeader
  33. enum class ImageBinaryDataCompression : U32
  34. {
  35. NONE,
  36. RAW = 1 << 0,
  37. S3TC = 1 << 1,
  38. ETC = 1 << 2,
  39. ASTC = 1 << 3
  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. U32 m_astcBlockSizeX;
  56. U32 m_astcBlockSizeY;
  57. Array<U8, 80> m_padding;
  58. template<typename TSerializer, typename TClass>
  59. static void serializeCommon(TSerializer& s, TClass self)
  60. {
  61. s.doArray("m_magic", offsetof(ImageBinaryHeader, m_magic), &self.m_magic[0], self.m_magic.getSize());
  62. s.doValue("m_width", offsetof(ImageBinaryHeader, m_width), self.m_width);
  63. s.doValue("m_height", offsetof(ImageBinaryHeader, m_height), self.m_height);
  64. s.doValue("m_depthOrLayerCount", offsetof(ImageBinaryHeader, m_depthOrLayerCount), self.m_depthOrLayerCount);
  65. s.doValue("m_type", offsetof(ImageBinaryHeader, m_type), self.m_type);
  66. s.doValue("m_colorFormat", offsetof(ImageBinaryHeader, m_colorFormat), self.m_colorFormat);
  67. s.doValue("m_compressionMask", offsetof(ImageBinaryHeader, m_compressionMask), self.m_compressionMask);
  68. s.doValue("m_isNormal", offsetof(ImageBinaryHeader, m_isNormal), self.m_isNormal);
  69. s.doValue("m_mipmapCount", offsetof(ImageBinaryHeader, m_mipmapCount), self.m_mipmapCount);
  70. s.doValue("m_astcBlockSizeX", offsetof(ImageBinaryHeader, m_astcBlockSizeX), self.m_astcBlockSizeX);
  71. s.doValue("m_astcBlockSizeY", offsetof(ImageBinaryHeader, m_astcBlockSizeY), self.m_astcBlockSizeY);
  72. s.doArray("m_padding", offsetof(ImageBinaryHeader, m_padding), &self.m_padding[0], self.m_padding.getSize());
  73. }
  74. template<typename TDeserializer>
  75. void deserialize(TDeserializer& deserializer)
  76. {
  77. serializeCommon<TDeserializer, ImageBinaryHeader&>(deserializer, *this);
  78. }
  79. template<typename TSerializer>
  80. void serialize(TSerializer& serializer) const
  81. {
  82. serializeCommon<TSerializer, const ImageBinaryHeader&>(serializer, *this);
  83. }
  84. };
  85. /// @}
  86. } // end namespace anki