TextureLayoutTexture.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include "../../Include/RmlUi/Core/Texture.h"
  3. #include "TextureLayoutRow.h"
  4. namespace Rml {
  5. class TextureLayout;
  6. /**
  7. A texture layout texture is a single rectangular area which sub-rectangles are placed on within
  8. a complete texture layout.
  9. */
  10. class TextureLayoutTexture {
  11. public:
  12. TextureLayoutTexture();
  13. ~TextureLayoutTexture();
  14. /// Returns the texture's dimensions. This is only valid after the texture has been generated.
  15. /// @return The texture's dimensions.
  16. Vector2i GetDimensions() const;
  17. /// Attempts to position unplaced rectangles from the layout into this texture. The size of
  18. /// this texture will be determined by its contents.
  19. /// @param[in] layout The layout to position rectangles from.
  20. /// @param[in] maximum_dimensions The maximum dimensions of this texture. If this is not big enough to place all the rectangles, then as many will
  21. /// be placed as possible.
  22. /// @return The number of placed rectangles.
  23. int Generate(TextureLayout& layout, int maximum_dimensions);
  24. /// Allocates the texture.
  25. /// @return The allocated texture data.
  26. Vector<byte> AllocateTexture();
  27. private:
  28. using RowList = Vector<TextureLayoutRow>;
  29. Vector2i dimensions;
  30. RowList rows;
  31. };
  32. } // namespace Rml