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