SDL_surface_c.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. #include "SDL_internal.h"
  19. #ifndef SDL_surface_c_h_
  20. #define SDL_surface_c_h_
  21. // Useful functions and variables from SDL_surface.c
  22. #include "SDL_blit.h"
  23. // Surface internal flags
  24. typedef Uint32 SDL_SurfaceDataFlags;
  25. #define SDL_INTERNAL_SURFACE_DONTFREE 0x00000001u /**< Surface is referenced internally */
  26. #define SDL_INTERNAL_SURFACE_STACK 0x00000002u /**< Surface is allocated on the stack */
  27. #define SDL_INTERNAL_SURFACE_RLEACCEL 0x00000004u /**< Surface is RLE encoded */
  28. // Surface internal data definition
  29. struct SDL_Surface
  30. {
  31. // Public API definition
  32. SDL_SurfaceFlags flags; /**< The flags of the surface, read-only */
  33. SDL_PixelFormat format; /**< The format of the surface, read-only */
  34. int w; /**< The width of the surface, read-only. */
  35. int h; /**< The height of the surface, read-only. */
  36. int pitch; /**< The distance in bytes between rows of pixels, read-only */
  37. void *pixels; /**< A pointer to the pixels of the surface, the pixels are writeable if non-NULL */
  38. int refcount; /**< Application reference count, used when freeing surface */
  39. void *reserved; /**< Reserved for internal use */
  40. // Private API definition
  41. /** flags for this surface */
  42. SDL_SurfaceDataFlags internal_flags;
  43. /** properties for this surface */
  44. SDL_PropertiesID props;
  45. /** detailed format for this surface */
  46. const SDL_PixelFormatDetails *fmt;
  47. /** Pixel colorspace */
  48. SDL_Colorspace colorspace;
  49. /** palette for indexed surfaces */
  50. SDL_Palette *palette;
  51. /** Alternate representation of images */
  52. int num_images;
  53. SDL_Surface **images;
  54. /** information needed for surfaces requiring locks */
  55. int locked;
  56. /** clipping information */
  57. SDL_Rect clip_rect;
  58. /** info for fast blit mapping to other surfaces */
  59. SDL_BlitMap map;
  60. };
  61. // Surface functions
  62. extern bool SDL_SurfaceValid(SDL_Surface *surface);
  63. extern void SDL_UpdateSurfaceLockFlag(SDL_Surface *surface);
  64. extern bool SDL_CalculateSurfaceSize(SDL_PixelFormat format, int width, int height, size_t *size, size_t *pitch, bool minimalPitch);
  65. extern float SDL_GetDefaultSDRWhitePoint(SDL_Colorspace colorspace);
  66. extern float SDL_GetSurfaceSDRWhitePoint(SDL_Surface *surface, SDL_Colorspace colorspace);
  67. extern float SDL_GetDefaultHDRHeadroom(SDL_Colorspace colorspace);
  68. extern float SDL_GetSurfaceHDRHeadroom(SDL_Surface *surface, SDL_Colorspace colorspace);
  69. extern SDL_Surface *SDL_GetSurfaceImage(SDL_Surface *surface, float display_scale);
  70. #endif // SDL_surface_c_h_