atlas.h 832 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef ATLAS_H__INCLUDED
  2. #define ATLAS_H__INCLUDED
  3. enum AtlasResult {
  4. Atlas_Success = 0,
  5. Atlas_ErrorDoesntFit,
  6. Atlas_ErrorInsufficientTemp
  7. };
  8. struct AtlasVec { unsigned int x, y; };
  9. struct AtlasContext {
  10. /* temporary buffer/scrap space for atlas to use */
  11. /* worst case consumption: 4 * sizeof(unsigned int) * (1 + rects_count) */
  12. struct {
  13. void *ptr;
  14. unsigned int size;
  15. } temp_storage;
  16. /* input */
  17. unsigned int width, height;
  18. const struct AtlasVec *rects;
  19. unsigned int rects_count;
  20. unsigned int rects_stride;
  21. /* output */
  22. struct AtlasVec *pos;
  23. unsigned int pos_stride;
  24. };
  25. /* TODO ?
  26. struct AtlasStats {
  27. unsigned int wasted_pixels;
  28. struct AtlasVec min_waste, max_waste;
  29. unsigned int exact_matches;
  30. };
  31. */
  32. enum AtlasResult atlasCompute(const struct AtlasContext* context);
  33. #endif /* ATLAS_H__INCLUDED */