Skip to main content

sdl3_sys/generated/
surface.rs

1//! SDL surfaces are buffers of pixels in system RAM. These are useful for
2//! passing around and manipulating images that are not stored in GPU memory.
3//!
4//! [`SDL_Surface`] makes serious efforts to manage images in various formats, and
5//! provides a reasonable toolbox for transforming the data, including copying
6//! between surfaces, filling rectangles in the image data, etc.
7//!
8//! There is also a simple .bmp loader, [`SDL_LoadBMP()`], and a simple .png
9//! loader, [`SDL_LoadPNG()`]. SDL itself does not provide loaders for other file
10//! formats, but there are several excellent external libraries that do,
11//! including its own satellite library,
12//! [SDL_image](https://wiki.libsdl.org/SDL3_image)
13//! .
14//!
15//! In general these functions are thread-safe in that they can be called on
16//! different threads with different surfaces. You should not try to modify any
17//! surface from two threads simultaneously.
18
19use super::stdinc::*;
20
21use super::error::*;
22
23use super::blendmode::*;
24
25use super::pixels::*;
26
27use super::properties::*;
28
29use super::rect::*;
30
31use super::iostream::*;
32
33/// The flags on an [`SDL_Surface`].
34///
35/// These are generally considered read-only.
36///
37/// ## Availability
38/// This datatype is available since SDL 3.2.0.
39///
40/// ## Known values (`sdl3-sys`)
41/// | Associated constant | Global constant | Description |
42/// | ------------------- | --------------- | ----------- |
43/// | [`PREALLOCATED`](SDL_SurfaceFlags::PREALLOCATED) | [`SDL_SURFACE_PREALLOCATED`] | Surface uses preallocated pixel memory |
44/// | [`LOCK_NEEDED`](SDL_SurfaceFlags::LOCK_NEEDED) | [`SDL_SURFACE_LOCK_NEEDED`] | Surface needs to be locked to access pixels |
45/// | [`LOCKED`](SDL_SurfaceFlags::LOCKED) | [`SDL_SURFACE_LOCKED`] | Surface is currently locked |
46/// | [`SIMD_ALIGNED`](SDL_SurfaceFlags::SIMD_ALIGNED) | [`SDL_SURFACE_SIMD_ALIGNED`] | Surface uses pixel memory allocated with [`SDL_aligned_alloc()`] |
47#[repr(transparent)]
48#[derive(Clone, Copy, Default, PartialEq, Eq, Hash)]
49pub struct SDL_SurfaceFlags(pub Uint32);
50
51impl ::core::cmp::PartialEq<Uint32> for SDL_SurfaceFlags {
52    #[inline(always)]
53    fn eq(&self, other: &Uint32) -> bool {
54        &self.0 == other
55    }
56}
57
58impl ::core::cmp::PartialEq<SDL_SurfaceFlags> for Uint32 {
59    #[inline(always)]
60    fn eq(&self, other: &SDL_SurfaceFlags) -> bool {
61        self == &other.0
62    }
63}
64
65impl From<SDL_SurfaceFlags> for Uint32 {
66    #[inline(always)]
67    fn from(value: SDL_SurfaceFlags) -> Self {
68        value.0
69    }
70}
71
72#[cfg(feature = "debug-impls")]
73impl ::core::fmt::Debug for SDL_SurfaceFlags {
74    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
75        let mut first = true;
76        let all_bits = 0;
77        write!(f, "SDL_SurfaceFlags(")?;
78        let all_bits = all_bits | Self::PREALLOCATED.0;
79        if (Self::PREALLOCATED != 0 || self.0 == 0)
80            && *self & Self::PREALLOCATED == Self::PREALLOCATED
81        {
82            if !first {
83                write!(f, " | ")?;
84            }
85            first = false;
86            write!(f, "PREALLOCATED")?;
87        }
88        let all_bits = all_bits | Self::LOCK_NEEDED.0;
89        if (Self::LOCK_NEEDED != 0 || self.0 == 0) && *self & Self::LOCK_NEEDED == Self::LOCK_NEEDED
90        {
91            if !first {
92                write!(f, " | ")?;
93            }
94            first = false;
95            write!(f, "LOCK_NEEDED")?;
96        }
97        let all_bits = all_bits | Self::LOCKED.0;
98        if (Self::LOCKED != 0 || self.0 == 0) && *self & Self::LOCKED == Self::LOCKED {
99            if !first {
100                write!(f, " | ")?;
101            }
102            first = false;
103            write!(f, "LOCKED")?;
104        }
105        let all_bits = all_bits | Self::SIMD_ALIGNED.0;
106        if (Self::SIMD_ALIGNED != 0 || self.0 == 0)
107            && *self & Self::SIMD_ALIGNED == Self::SIMD_ALIGNED
108        {
109            if !first {
110                write!(f, " | ")?;
111            }
112            first = false;
113            write!(f, "SIMD_ALIGNED")?;
114        }
115
116        if self.0 & !all_bits != 0 {
117            if !first {
118                write!(f, " | ")?;
119            }
120            write!(f, "{:#x}", self.0)?;
121        } else if first {
122            write!(f, "0")?;
123        }
124        write!(f, ")")
125    }
126}
127
128impl ::core::ops::BitAnd for SDL_SurfaceFlags {
129    type Output = Self;
130
131    #[inline(always)]
132    fn bitand(self, rhs: Self) -> Self::Output {
133        Self(self.0 & rhs.0)
134    }
135}
136
137impl ::core::ops::BitAndAssign for SDL_SurfaceFlags {
138    #[inline(always)]
139    fn bitand_assign(&mut self, rhs: Self) {
140        self.0 &= rhs.0;
141    }
142}
143
144impl ::core::ops::BitOr for SDL_SurfaceFlags {
145    type Output = Self;
146
147    #[inline(always)]
148    fn bitor(self, rhs: Self) -> Self::Output {
149        Self(self.0 | rhs.0)
150    }
151}
152
153impl ::core::ops::BitOrAssign for SDL_SurfaceFlags {
154    #[inline(always)]
155    fn bitor_assign(&mut self, rhs: Self) {
156        self.0 |= rhs.0;
157    }
158}
159
160impl ::core::ops::BitXor for SDL_SurfaceFlags {
161    type Output = Self;
162
163    #[inline(always)]
164    fn bitxor(self, rhs: Self) -> Self::Output {
165        Self(self.0 ^ rhs.0)
166    }
167}
168
169impl ::core::ops::BitXorAssign for SDL_SurfaceFlags {
170    #[inline(always)]
171    fn bitxor_assign(&mut self, rhs: Self) {
172        self.0 ^= rhs.0;
173    }
174}
175
176impl ::core::ops::Not for SDL_SurfaceFlags {
177    type Output = Self;
178
179    #[inline(always)]
180    fn not(self) -> Self::Output {
181        Self(!self.0)
182    }
183}
184
185impl SDL_SurfaceFlags {
186    /// Surface uses preallocated pixel memory
187    pub const PREALLOCATED: Self = Self((0x00000001 as Uint32));
188    /// Surface needs to be locked to access pixels
189    pub const LOCK_NEEDED: Self = Self((0x00000002 as Uint32));
190    /// Surface is currently locked
191    pub const LOCKED: Self = Self((0x00000004 as Uint32));
192    /// Surface uses pixel memory allocated with [`SDL_aligned_alloc()`]
193    pub const SIMD_ALIGNED: Self = Self((0x00000008 as Uint32));
194}
195
196/// Surface uses preallocated pixel memory
197pub const SDL_SURFACE_PREALLOCATED: SDL_SurfaceFlags = SDL_SurfaceFlags::PREALLOCATED;
198/// Surface needs to be locked to access pixels
199pub const SDL_SURFACE_LOCK_NEEDED: SDL_SurfaceFlags = SDL_SurfaceFlags::LOCK_NEEDED;
200/// Surface is currently locked
201pub const SDL_SURFACE_LOCKED: SDL_SurfaceFlags = SDL_SurfaceFlags::LOCKED;
202/// Surface uses pixel memory allocated with [`SDL_aligned_alloc()`]
203pub const SDL_SURFACE_SIMD_ALIGNED: SDL_SurfaceFlags = SDL_SurfaceFlags::SIMD_ALIGNED;
204
205impl SDL_SurfaceFlags {
206    /// Initialize a `SDL_SurfaceFlags` from a raw value.
207    #[inline(always)]
208    pub const fn new(value: Uint32) -> Self {
209        Self(value)
210    }
211}
212
213impl SDL_SurfaceFlags {
214    /// Get a copy of the inner raw value.
215    #[inline(always)]
216    pub const fn value(&self) -> Uint32 {
217        self.0
218    }
219}
220
221#[cfg(feature = "metadata")]
222impl sdl3_sys::metadata::GroupMetadata for SDL_SurfaceFlags {
223    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
224        &crate::metadata::surface::METADATA_SDL_SurfaceFlags;
225}
226
227/// The scaling mode.
228///
229/// ## Availability
230/// This enum is available since SDL 3.2.0.
231///
232/// ## Known values (`sdl3-sys`)
233/// | Associated constant | Global constant | Description |
234/// | ------------------- | --------------- | ----------- |
235/// | [`INVALID`](SDL_ScaleMode::INVALID) | [`SDL_SCALEMODE_INVALID`] | |
236/// | [`NEAREST`](SDL_ScaleMode::NEAREST) | [`SDL_SCALEMODE_NEAREST`] | nearest pixel sampling |
237/// | [`LINEAR`](SDL_ScaleMode::LINEAR) | [`SDL_SCALEMODE_LINEAR`] | linear filtering |
238/// | [`PIXELART`](SDL_ScaleMode::PIXELART) | [`SDL_SCALEMODE_PIXELART`] | nearest pixel sampling with improved scaling for pixel art, available since SDL 3.4.0 |
239#[repr(transparent)]
240#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
241pub struct SDL_ScaleMode(pub ::core::ffi::c_int);
242
243impl ::core::cmp::PartialEq<::core::ffi::c_int> for SDL_ScaleMode {
244    #[inline(always)]
245    fn eq(&self, other: &::core::ffi::c_int) -> bool {
246        &self.0 == other
247    }
248}
249
250impl ::core::cmp::PartialEq<SDL_ScaleMode> for ::core::ffi::c_int {
251    #[inline(always)]
252    fn eq(&self, other: &SDL_ScaleMode) -> bool {
253        self == &other.0
254    }
255}
256
257impl From<SDL_ScaleMode> for ::core::ffi::c_int {
258    #[inline(always)]
259    fn from(value: SDL_ScaleMode) -> Self {
260        value.0
261    }
262}
263
264#[cfg(feature = "debug-impls")]
265impl ::core::fmt::Debug for SDL_ScaleMode {
266    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
267        #[allow(unreachable_patterns)]
268        f.write_str(match *self {
269            Self::INVALID => "SDL_SCALEMODE_INVALID",
270            Self::NEAREST => "SDL_SCALEMODE_NEAREST",
271            Self::LINEAR => "SDL_SCALEMODE_LINEAR",
272            Self::PIXELART => "SDL_SCALEMODE_PIXELART",
273
274            _ => return write!(f, "SDL_ScaleMode({})", self.0),
275        })
276    }
277}
278
279impl SDL_ScaleMode {
280    pub const INVALID: Self = Self((-1_i32 as ::core::ffi::c_int));
281    /// nearest pixel sampling
282    pub const NEAREST: Self = Self((0_i32 as ::core::ffi::c_int));
283    /// linear filtering
284    pub const LINEAR: Self = Self((1_i32 as ::core::ffi::c_int));
285    /// nearest pixel sampling with improved scaling for pixel art, available since SDL 3.4.0
286    pub const PIXELART: Self = Self((2_i32 as ::core::ffi::c_int));
287}
288
289pub const SDL_SCALEMODE_INVALID: SDL_ScaleMode = SDL_ScaleMode::INVALID;
290/// nearest pixel sampling
291pub const SDL_SCALEMODE_NEAREST: SDL_ScaleMode = SDL_ScaleMode::NEAREST;
292/// linear filtering
293pub const SDL_SCALEMODE_LINEAR: SDL_ScaleMode = SDL_ScaleMode::LINEAR;
294/// nearest pixel sampling with improved scaling for pixel art, available since SDL 3.4.0
295pub const SDL_SCALEMODE_PIXELART: SDL_ScaleMode = SDL_ScaleMode::PIXELART;
296
297impl SDL_ScaleMode {
298    /// Initialize a `SDL_ScaleMode` from a raw value.
299    #[inline(always)]
300    pub const fn new(value: ::core::ffi::c_int) -> Self {
301        Self(value)
302    }
303}
304
305impl SDL_ScaleMode {
306    /// Get a copy of the inner raw value.
307    #[inline(always)]
308    pub const fn value(&self) -> ::core::ffi::c_int {
309        self.0
310    }
311}
312
313#[cfg(feature = "metadata")]
314impl sdl3_sys::metadata::GroupMetadata for SDL_ScaleMode {
315    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
316        &crate::metadata::surface::METADATA_SDL_ScaleMode;
317}
318
319/// The flip mode.
320///
321/// ## Availability
322/// This enum is available since SDL 3.2.0.
323///
324/// ## Known values (`sdl3-sys`)
325/// | Associated constant | Global constant | Description |
326/// | ------------------- | --------------- | ----------- |
327/// | [`NONE`](SDL_FlipMode::NONE) | [`SDL_FLIP_NONE`] | Do not flip |
328/// | [`HORIZONTAL`](SDL_FlipMode::HORIZONTAL) | [`SDL_FLIP_HORIZONTAL`] | flip horizontally |
329/// | [`VERTICAL`](SDL_FlipMode::VERTICAL) | [`SDL_FLIP_VERTICAL`] | flip vertically |
330/// | [`HORIZONTAL_AND_VERTICAL`](SDL_FlipMode::HORIZONTAL_AND_VERTICAL) | [`SDL_FLIP_HORIZONTAL_AND_VERTICAL`] | flip horizontally and vertically (not a diagonal flip) |
331#[repr(transparent)]
332#[derive(Clone, Copy, Default, PartialEq, Eq, Hash)]
333pub struct SDL_FlipMode(pub ::core::ffi::c_int);
334
335impl ::core::cmp::PartialEq<::core::ffi::c_int> for SDL_FlipMode {
336    #[inline(always)]
337    fn eq(&self, other: &::core::ffi::c_int) -> bool {
338        &self.0 == other
339    }
340}
341
342impl ::core::cmp::PartialEq<SDL_FlipMode> for ::core::ffi::c_int {
343    #[inline(always)]
344    fn eq(&self, other: &SDL_FlipMode) -> bool {
345        self == &other.0
346    }
347}
348
349impl From<SDL_FlipMode> for ::core::ffi::c_int {
350    #[inline(always)]
351    fn from(value: SDL_FlipMode) -> Self {
352        value.0
353    }
354}
355
356#[cfg(feature = "debug-impls")]
357impl ::core::fmt::Debug for SDL_FlipMode {
358    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
359        let mut first = true;
360        let all_bits = 0;
361        write!(f, "SDL_FlipMode(")?;
362        let all_bits = all_bits | Self::NONE.0;
363        if (Self::NONE != 0 || self.0 == 0) && *self & Self::NONE == Self::NONE {
364            if !first {
365                write!(f, " | ")?;
366            }
367            first = false;
368            write!(f, "NONE")?;
369        }
370        let all_bits = all_bits | Self::HORIZONTAL.0;
371        if (Self::HORIZONTAL != 0 || self.0 == 0) && *self & Self::HORIZONTAL == Self::HORIZONTAL {
372            if !first {
373                write!(f, " | ")?;
374            }
375            first = false;
376            write!(f, "HORIZONTAL")?;
377        }
378        let all_bits = all_bits | Self::VERTICAL.0;
379        if (Self::VERTICAL != 0 || self.0 == 0) && *self & Self::VERTICAL == Self::VERTICAL {
380            if !first {
381                write!(f, " | ")?;
382            }
383            first = false;
384            write!(f, "VERTICAL")?;
385        }
386        let all_bits = all_bits | Self::HORIZONTAL_AND_VERTICAL.0;
387        if (Self::HORIZONTAL_AND_VERTICAL != 0 || self.0 == 0)
388            && *self & Self::HORIZONTAL_AND_VERTICAL == Self::HORIZONTAL_AND_VERTICAL
389        {
390            if !first {
391                write!(f, " | ")?;
392            }
393            first = false;
394            write!(f, "HORIZONTAL_AND_VERTICAL")?;
395        }
396
397        if self.0 & !all_bits != 0 {
398            if !first {
399                write!(f, " | ")?;
400            }
401            write!(f, "{:#x}", self.0)?;
402        } else if first {
403            write!(f, "0")?;
404        }
405        write!(f, ")")
406    }
407}
408
409impl ::core::ops::BitAnd for SDL_FlipMode {
410    type Output = Self;
411
412    #[inline(always)]
413    fn bitand(self, rhs: Self) -> Self::Output {
414        Self(self.0 & rhs.0)
415    }
416}
417
418impl ::core::ops::BitAndAssign for SDL_FlipMode {
419    #[inline(always)]
420    fn bitand_assign(&mut self, rhs: Self) {
421        self.0 &= rhs.0;
422    }
423}
424
425impl ::core::ops::BitOr for SDL_FlipMode {
426    type Output = Self;
427
428    #[inline(always)]
429    fn bitor(self, rhs: Self) -> Self::Output {
430        Self(self.0 | rhs.0)
431    }
432}
433
434impl ::core::ops::BitOrAssign for SDL_FlipMode {
435    #[inline(always)]
436    fn bitor_assign(&mut self, rhs: Self) {
437        self.0 |= rhs.0;
438    }
439}
440
441impl ::core::ops::BitXor for SDL_FlipMode {
442    type Output = Self;
443
444    #[inline(always)]
445    fn bitxor(self, rhs: Self) -> Self::Output {
446        Self(self.0 ^ rhs.0)
447    }
448}
449
450impl ::core::ops::BitXorAssign for SDL_FlipMode {
451    #[inline(always)]
452    fn bitxor_assign(&mut self, rhs: Self) {
453        self.0 ^= rhs.0;
454    }
455}
456
457impl ::core::ops::Not for SDL_FlipMode {
458    type Output = Self;
459
460    #[inline(always)]
461    fn not(self) -> Self::Output {
462        Self(!self.0)
463    }
464}
465
466impl SDL_FlipMode {
467    /// Do not flip
468    pub const NONE: Self = Self((0 as ::core::ffi::c_int));
469    /// flip horizontally
470    pub const HORIZONTAL: Self = Self((1 as ::core::ffi::c_int));
471    /// flip vertically
472    pub const VERTICAL: Self = Self((2 as ::core::ffi::c_int));
473    /// flip horizontally and vertically (not a diagonal flip)
474    pub const HORIZONTAL_AND_VERTICAL: Self = Self((SDL_FLIP_HORIZONTAL.0 | SDL_FLIP_VERTICAL.0));
475}
476
477/// Do not flip
478pub const SDL_FLIP_NONE: SDL_FlipMode = SDL_FlipMode::NONE;
479/// flip horizontally
480pub const SDL_FLIP_HORIZONTAL: SDL_FlipMode = SDL_FlipMode::HORIZONTAL;
481/// flip vertically
482pub const SDL_FLIP_VERTICAL: SDL_FlipMode = SDL_FlipMode::VERTICAL;
483/// flip horizontally and vertically (not a diagonal flip)
484pub const SDL_FLIP_HORIZONTAL_AND_VERTICAL: SDL_FlipMode = SDL_FlipMode::HORIZONTAL_AND_VERTICAL;
485
486impl SDL_FlipMode {
487    /// Initialize a `SDL_FlipMode` from a raw value.
488    #[inline(always)]
489    pub const fn new(value: ::core::ffi::c_int) -> Self {
490        Self(value)
491    }
492}
493
494impl SDL_FlipMode {
495    /// Get a copy of the inner raw value.
496    #[inline(always)]
497    pub const fn value(&self) -> ::core::ffi::c_int {
498        self.0
499    }
500}
501
502#[cfg(feature = "metadata")]
503impl sdl3_sys::metadata::GroupMetadata for SDL_FlipMode {
504    const GROUP_METADATA: &'static sdl3_sys::metadata::Group =
505        &crate::metadata::surface::METADATA_SDL_FlipMode;
506}
507
508/// A collection of pixels used in software blitting.
509///
510/// Pixels are arranged in memory in rows, with the top row first. Each row
511/// occupies an amount of memory given by the pitch (sometimes known as the row
512/// stride in non-SDL APIs).
513///
514/// Within each row, pixels are arranged from left to right until the width is
515/// reached. Each pixel occupies a number of bits appropriate for its format,
516/// with most formats representing each pixel as one or more whole bytes (in
517/// some indexed formats, instead multiple pixels are packed into each byte),
518/// and a byte order given by the format. After encoding all pixels, any
519/// remaining bytes to reach the pitch are used as padding to reach a desired
520/// alignment, and have undefined contents.
521///
522/// When a surface holds YUV format data, the planes are assumed to be
523/// contiguous without padding between them, e.g. a 32x32 surface in NV12
524/// format with a pitch of 32 would consist of 32x32 bytes of Y plane followed
525/// by 32x16 bytes of UV plane.
526///
527/// When a surface holds MJPG format data, pixels points at the compressed JPEG
528/// image and pitch is the length of that data.
529///
530/// ## Availability
531/// This struct is available since SDL 3.2.0.
532///
533/// ## See also
534/// - [`SDL_CreateSurface`]
535/// - [`SDL_DestroySurface`]
536#[repr(C)]
537#[cfg_attr(feature = "debug-impls", derive(Debug))]
538pub struct SDL_Surface {
539    /// The flags of the surface, read-only
540    pub flags: SDL_SurfaceFlags,
541    /// The format of the surface, read-only
542    pub format: SDL_PixelFormat,
543    /// The width of the surface, read-only.
544    pub w: ::core::ffi::c_int,
545    /// The height of the surface, read-only.
546    pub h: ::core::ffi::c_int,
547    /// The distance in bytes between rows of pixels, read-only
548    pub pitch: ::core::ffi::c_int,
549    /// A pointer to the pixels of the surface, the pixels are writeable if non-NULL
550    pub pixels: *mut ::core::ffi::c_void,
551    /// Application reference count, used when freeing surface
552    pub refcount: ::core::ffi::c_int,
553    /// Reserved for internal use
554    pub reserved: *mut ::core::ffi::c_void,
555    #[doc(hidden)]
556    __non_exhaustive: ::sdl3_sys::NonExhaustive,
557}
558
559/// Evaluates to true if the surface needs to be locked before access.
560///
561/// ## Availability
562/// This macro is available since SDL 3.2.0.
563#[inline(always)]
564pub const unsafe fn SDL_MUSTLOCK(S: *const SDL_Surface) -> ::core::primitive::bool {
565    ((unsafe { (&raw const (*S).flags).read() }.0 & SDL_SURFACE_LOCK_NEEDED.0)
566        == SDL_SURFACE_LOCK_NEEDED.0)
567}
568
569unsafe extern "C" {
570    /// Allocate a new surface with a specific pixel format.
571    ///
572    /// The pixels of the new surface are initialized to zero.
573    ///
574    /// ## Parameters
575    /// - `width`: the width of the surface.
576    /// - `height`: the height of the surface.
577    /// - `format`: the [`SDL_PixelFormat`] for the new surface's pixel format.
578    ///
579    /// ## Return value
580    /// Returns the new [`SDL_Surface`] structure that is created or NULL on failure;
581    ///   call [`SDL_GetError()`] for more information.
582    ///
583    /// ## Thread safety
584    /// It is safe to call this function from any thread.
585    ///
586    /// ## Availability
587    /// This function is available since SDL 3.2.0.
588    ///
589    /// ## See also
590    /// - [`SDL_CreateSurfaceFrom`]
591    /// - [`SDL_DestroySurface`]
592    pub fn SDL_CreateSurface(
593        width: ::core::ffi::c_int,
594        height: ::core::ffi::c_int,
595        format: SDL_PixelFormat,
596    ) -> *mut SDL_Surface;
597}
598
599unsafe extern "C" {
600    /// Allocate a new surface with a specific pixel format and existing pixel
601    /// data.
602    ///
603    /// No copy is made of the pixel data. Pixel data is not managed automatically;
604    /// you must free the surface before you free the pixel data.
605    ///
606    /// Pitch is the offset in bytes from one row of pixels to the next, e.g.
607    /// `width*4` for [`SDL_PIXELFORMAT_RGBA8888`].
608    ///
609    /// You may pass NULL for pixels and 0 for pitch to create a surface that you
610    /// will fill in with valid values later.
611    ///
612    /// ## Parameters
613    /// - `width`: the width of the surface.
614    /// - `height`: the height of the surface.
615    /// - `format`: the [`SDL_PixelFormat`] for the new surface's pixel format.
616    /// - `pixels`: a pointer to existing pixel data.
617    /// - `pitch`: the number of bytes between each row, including padding.
618    ///
619    /// ## Return value
620    /// Returns the new [`SDL_Surface`] structure that is created or NULL on failure;
621    ///   call [`SDL_GetError()`] for more information.
622    ///
623    /// ## Thread safety
624    /// It is safe to call this function from any thread.
625    ///
626    /// ## Availability
627    /// This function is available since SDL 3.2.0.
628    ///
629    /// ## See also
630    /// - [`SDL_CreateSurface`]
631    /// - [`SDL_DestroySurface`]
632    pub fn SDL_CreateSurfaceFrom(
633        width: ::core::ffi::c_int,
634        height: ::core::ffi::c_int,
635        format: SDL_PixelFormat,
636        pixels: *mut ::core::ffi::c_void,
637        pitch: ::core::ffi::c_int,
638    ) -> *mut SDL_Surface;
639}
640
641unsafe extern "C" {
642    /// Free a surface.
643    ///
644    /// It is safe to pass NULL to this function.
645    ///
646    /// ## Parameters
647    /// - `surface`: the [`SDL_Surface`] to free.
648    ///
649    /// ## Thread safety
650    /// No other thread should be using the surface when it is freed.
651    ///
652    /// ## Availability
653    /// This function is available since SDL 3.2.0.
654    ///
655    /// ## See also
656    /// - [`SDL_CreateSurface`]
657    /// - [`SDL_CreateSurfaceFrom`]
658    pub fn SDL_DestroySurface(surface: *mut SDL_Surface);
659}
660
661unsafe extern "C" {
662    /// Get the properties associated with a surface.
663    ///
664    /// The following properties are understood by SDL:
665    ///
666    /// - [`SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT`]\: for HDR10 and floating point
667    ///   surfaces, this defines the value of 100% diffuse white, with higher
668    ///   values being displayed in the High Dynamic Range headroom. This defaults
669    ///   to 203 for HDR10 surfaces and 1.0 for floating point surfaces.
670    /// - [`SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT`]\: for HDR10 and floating point
671    ///   surfaces, this defines the maximum dynamic range used by the content, in
672    ///   terms of the SDR white point. This defaults to 0.0, which disables tone
673    ///   mapping.
674    /// - [`SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING`]\: the tone mapping operator
675    ///   used when compressing from a surface with high dynamic range to another
676    ///   with lower dynamic range. Currently this supports "chrome", which uses
677    ///   the same tone mapping that Chrome uses for HDR content, the form "*=N",
678    ///   where N is a floating point scale factor applied in linear space, and
679    ///   "none", which disables tone mapping. This defaults to "chrome".
680    /// - [`SDL_PROP_SURFACE_HOTSPOT_X_NUMBER`]\: the hotspot pixel offset from the
681    ///   left edge of the image, if this surface is being used as a cursor.
682    /// - [`SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER`]\: the hotspot pixel offset from the
683    ///   top edge of the image, if this surface is being used as a cursor.
684    /// - [`SDL_PROP_SURFACE_ROTATION_FLOAT`]\: the number of degrees a surface's data
685    ///   is meant to be rotated clockwise to make the image right-side up. Default
686    ///   0. This is used by the camera API, if a mobile device is oriented
687    ///   differently than what its camera provides (i.e. - the camera always
688    ///   provides portrait images but the phone is being held in landscape
689    ///   orientation). Since SDL 3.4.0.
690    ///
691    /// ## Parameters
692    /// - `surface`: the [`SDL_Surface`] structure to query.
693    ///
694    /// ## Return value
695    /// Returns a valid property ID on success or 0 on failure; call
696    ///   [`SDL_GetError()`] for more information.
697    ///
698    /// ## Thread safety
699    /// It is safe to call this function from any thread.
700    ///
701    /// ## Availability
702    /// This function is available since SDL 3.2.0.
703    pub fn SDL_GetSurfaceProperties(surface: *mut SDL_Surface) -> SDL_PropertiesID;
704}
705
706pub const SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT: *const ::core::ffi::c_char =
707    c"SDL.surface.SDR_white_point".as_ptr();
708
709pub const SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT: *const ::core::ffi::c_char =
710    c"SDL.surface.HDR_headroom".as_ptr();
711
712pub const SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING: *const ::core::ffi::c_char =
713    c"SDL.surface.tonemap".as_ptr();
714
715pub const SDL_PROP_SURFACE_HOTSPOT_X_NUMBER: *const ::core::ffi::c_char =
716    c"SDL.surface.hotspot.x".as_ptr();
717
718pub const SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER: *const ::core::ffi::c_char =
719    c"SDL.surface.hotspot.y".as_ptr();
720
721pub const SDL_PROP_SURFACE_ROTATION_FLOAT: *const ::core::ffi::c_char =
722    c"SDL.surface.rotation".as_ptr();
723
724unsafe extern "C" {
725    /// Set the colorspace used by a surface.
726    ///
727    /// Setting the colorspace doesn't change the pixels, only how they are
728    /// interpreted in color operations.
729    ///
730    /// ## Parameters
731    /// - `surface`: the [`SDL_Surface`] structure to update.
732    /// - `colorspace`: an [`SDL_Colorspace`] value describing the surface
733    ///   colorspace.
734    ///
735    /// ## Return value
736    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
737    ///   information.
738    ///
739    /// ## Thread safety
740    /// This function can be called on different threads with
741    ///   different surfaces.
742    ///
743    /// ## Availability
744    /// This function is available since SDL 3.2.0.
745    ///
746    /// ## See also
747    /// - [`SDL_GetSurfaceColorspace`]
748    pub fn SDL_SetSurfaceColorspace(
749        surface: *mut SDL_Surface,
750        colorspace: SDL_Colorspace,
751    ) -> ::core::primitive::bool;
752}
753
754unsafe extern "C" {
755    /// Get the colorspace used by a surface.
756    ///
757    /// The colorspace defaults to [`SDL_COLORSPACE_SRGB_LINEAR`] for floating point
758    /// formats, [`SDL_COLORSPACE_HDR10`] for 10-bit formats, [`SDL_COLORSPACE_SRGB`] for
759    /// other RGB surfaces and [`SDL_COLORSPACE_BT709_FULL`] for YUV textures.
760    ///
761    /// ## Parameters
762    /// - `surface`: the [`SDL_Surface`] structure to query.
763    ///
764    /// ## Return value
765    /// Returns the colorspace used by the surface, or [`SDL_COLORSPACE_UNKNOWN`] if
766    ///   the surface is NULL.
767    ///
768    /// ## Thread safety
769    /// This function can be called on different threads with
770    ///   different surfaces.
771    ///
772    /// ## Availability
773    /// This function is available since SDL 3.2.0.
774    ///
775    /// ## See also
776    /// - [`SDL_SetSurfaceColorspace`]
777    pub fn SDL_GetSurfaceColorspace(surface: *mut SDL_Surface) -> SDL_Colorspace;
778}
779
780unsafe extern "C" {
781    /// Create a palette and associate it with a surface.
782    ///
783    /// This function creates a palette compatible with the provided surface. The
784    /// palette is then returned for you to modify, and the surface will
785    /// automatically use the new palette in future operations. You do not need to
786    /// destroy the returned palette, it will be freed when the reference count
787    /// reaches 0, usually when the surface is destroyed.
788    ///
789    /// Bitmap surfaces (with format [`SDL_PIXELFORMAT_INDEX1LSB`] or
790    /// [`SDL_PIXELFORMAT_INDEX1MSB`]) will have the palette initialized with 0 as
791    /// white and 1 as black. Other surfaces will get a palette initialized with
792    /// white in every entry.
793    ///
794    /// If this function is called for a surface that already has a palette, a new
795    /// palette will be created to replace it.
796    ///
797    /// ## Parameters
798    /// - `surface`: the [`SDL_Surface`] structure to update.
799    ///
800    /// ## Return value
801    /// Returns a new [`SDL_Palette`] structure on success or NULL on failure (e.g. if
802    ///   the surface didn't have an index format); call [`SDL_GetError()`] for
803    ///   more information.
804    ///
805    /// ## Thread safety
806    /// This function can be called on different threads with
807    ///   different surfaces.
808    ///
809    /// ## Availability
810    /// This function is available since SDL 3.2.0.
811    ///
812    /// ## See also
813    /// - [`SDL_SetPaletteColors`]
814    pub fn SDL_CreateSurfacePalette(surface: *mut SDL_Surface) -> *mut SDL_Palette;
815}
816
817unsafe extern "C" {
818    /// Set the palette used by a surface.
819    ///
820    /// Setting the palette keeps an internal reference to the palette, which can
821    /// be safely destroyed afterwards.
822    ///
823    /// A single palette can be shared with many surfaces.
824    ///
825    /// ## Parameters
826    /// - `surface`: the [`SDL_Surface`] structure to update.
827    /// - `palette`: the [`SDL_Palette`] structure to use.
828    ///
829    /// ## Return value
830    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
831    ///   information.
832    ///
833    /// ## Thread safety
834    /// This function can be called on different threads with
835    ///   different surfaces.
836    ///
837    /// ## Availability
838    /// This function is available since SDL 3.2.0.
839    ///
840    /// ## See also
841    /// - [`SDL_CreatePalette`]
842    /// - [`SDL_GetSurfacePalette`]
843    pub fn SDL_SetSurfacePalette(
844        surface: *mut SDL_Surface,
845        palette: *mut SDL_Palette,
846    ) -> ::core::primitive::bool;
847}
848
849unsafe extern "C" {
850    /// Get the palette used by a surface.
851    ///
852    /// ## Parameters
853    /// - `surface`: the [`SDL_Surface`] structure to query.
854    ///
855    /// ## Return value
856    /// Returns a pointer to the palette used by the surface, or NULL if there is
857    ///   no palette used.
858    ///
859    /// ## Thread safety
860    /// It is safe to call this function from any thread.
861    ///
862    /// ## Availability
863    /// This function is available since SDL 3.2.0.
864    ///
865    /// ## See also
866    /// - [`SDL_SetSurfacePalette`]
867    pub fn SDL_GetSurfacePalette(surface: *mut SDL_Surface) -> *mut SDL_Palette;
868}
869
870unsafe extern "C" {
871    /// Add an alternate version of a surface.
872    ///
873    /// This function adds an alternate version of this surface, usually used for
874    /// content with high DPI representations like cursors or icons. The size,
875    /// format, and content do not need to match the original surface, and these
876    /// alternate versions will not be updated when the original surface changes.
877    ///
878    /// This function adds a reference to the alternate version, so you should call
879    /// [`SDL_DestroySurface()`] on the image after this call.
880    ///
881    /// ## Parameters
882    /// - `surface`: the [`SDL_Surface`] structure to update.
883    /// - `image`: a pointer to an alternate [`SDL_Surface`] to associate with this
884    ///   surface.
885    ///
886    /// ## Return value
887    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
888    ///   information.
889    ///
890    /// ## Thread safety
891    /// This function can be called on different threads with
892    ///   different surfaces.
893    ///
894    /// ## Availability
895    /// This function is available since SDL 3.2.0.
896    ///
897    /// ## See also
898    /// - [`SDL_RemoveSurfaceAlternateImages`]
899    /// - [`SDL_GetSurfaceImages`]
900    /// - [`SDL_SurfaceHasAlternateImages`]
901    pub fn SDL_AddSurfaceAlternateImage(
902        surface: *mut SDL_Surface,
903        image: *mut SDL_Surface,
904    ) -> ::core::primitive::bool;
905}
906
907unsafe extern "C" {
908    /// Return whether a surface has alternate versions available.
909    ///
910    /// ## Parameters
911    /// - `surface`: the [`SDL_Surface`] structure to query.
912    ///
913    /// ## Return value
914    /// Returns true if alternate versions are available or false otherwise.
915    ///
916    /// ## Thread safety
917    /// It is safe to call this function from any thread.
918    ///
919    /// ## Availability
920    /// This function is available since SDL 3.2.0.
921    ///
922    /// ## See also
923    /// - [`SDL_AddSurfaceAlternateImage`]
924    /// - [`SDL_RemoveSurfaceAlternateImages`]
925    /// - [`SDL_GetSurfaceImages`]
926    pub fn SDL_SurfaceHasAlternateImages(surface: *mut SDL_Surface) -> ::core::primitive::bool;
927}
928
929unsafe extern "C" {
930    /// Get an array including all versions of a surface.
931    ///
932    /// This returns all versions of a surface, with the surface being queried as
933    /// the first element in the returned array.
934    ///
935    /// Freeing the array of surfaces does not affect the surfaces in the array.
936    /// They are still referenced by the surface being queried and will be cleaned
937    /// up normally.
938    ///
939    /// ## Parameters
940    /// - `surface`: the [`SDL_Surface`] structure to query.
941    /// - `count`: a pointer filled in with the number of surface pointers
942    ///   returned, may be NULL.
943    ///
944    /// ## Return value
945    /// Returns a NULL terminated array of [`SDL_Surface`] pointers or NULL on
946    ///   failure; call [`SDL_GetError()`] for more information. This should be
947    ///   freed with [`SDL_free()`] when it is no longer needed.
948    ///
949    /// ## Thread safety
950    /// This function can be called on different threads with
951    ///   different surfaces.
952    ///
953    /// ## Availability
954    /// This function is available since SDL 3.2.0.
955    ///
956    /// ## See also
957    /// - [`SDL_AddSurfaceAlternateImage`]
958    /// - [`SDL_RemoveSurfaceAlternateImages`]
959    /// - [`SDL_SurfaceHasAlternateImages`]
960    pub fn SDL_GetSurfaceImages(
961        surface: *mut SDL_Surface,
962        count: *mut ::core::ffi::c_int,
963    ) -> *mut *mut SDL_Surface;
964}
965
966unsafe extern "C" {
967    /// Remove all alternate versions of a surface.
968    ///
969    /// This function removes a reference from all the alternative versions,
970    /// destroying them if this is the last reference to them.
971    ///
972    /// ## Parameters
973    /// - `surface`: the [`SDL_Surface`] structure to update.
974    ///
975    /// ## Thread safety
976    /// This function can be called on different threads with
977    ///   different surfaces.
978    ///
979    /// ## Availability
980    /// This function is available since SDL 3.2.0.
981    ///
982    /// ## See also
983    /// - [`SDL_AddSurfaceAlternateImage`]
984    /// - [`SDL_GetSurfaceImages`]
985    /// - [`SDL_SurfaceHasAlternateImages`]
986    pub fn SDL_RemoveSurfaceAlternateImages(surface: *mut SDL_Surface);
987}
988
989unsafe extern "C" {
990    /// Set up a surface for directly accessing the pixels.
991    ///
992    /// Between calls to [`SDL_LockSurface()`] / [`SDL_UnlockSurface()`], you can write to
993    /// and read from `surface->pixels`, using the pixel format stored in
994    /// `surface->format`. Once you are done accessing the surface, you should use
995    /// [`SDL_UnlockSurface()`] to release it.
996    ///
997    /// Not all surfaces require locking. If `SDL_MUSTLOCK(surface)` evaluates to
998    /// 0, then you can read and write to the surface at any time, and the pixel
999    /// format of the surface will not change.
1000    ///
1001    /// ## Parameters
1002    /// - `surface`: the [`SDL_Surface`] structure to be locked.
1003    ///
1004    /// ## Return value
1005    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1006    ///   information.
1007    ///
1008    /// ## Thread safety
1009    /// This function can be called on different threads with
1010    ///   different surfaces. The locking referred to by this function
1011    ///   is making the pixels available for direct access, not
1012    ///   thread-safe locking.
1013    ///
1014    /// ## Availability
1015    /// This function is available since SDL 3.2.0.
1016    ///
1017    /// ## See also
1018    /// - [`SDL_MUSTLOCK`]
1019    /// - [`SDL_UnlockSurface`]
1020    pub fn SDL_LockSurface(surface: *mut SDL_Surface) -> ::core::primitive::bool;
1021}
1022
1023unsafe extern "C" {
1024    /// Release a surface after directly accessing the pixels.
1025    ///
1026    /// ## Parameters
1027    /// - `surface`: the [`SDL_Surface`] structure to be unlocked.
1028    ///
1029    /// ## Thread safety
1030    /// This function is not thread safe. The locking referred to by
1031    ///   this function is making the pixels available for direct
1032    ///   access, not thread-safe locking.
1033    ///
1034    /// ## Availability
1035    /// This function is available since SDL 3.2.0.
1036    ///
1037    /// ## See also
1038    /// - [`SDL_LockSurface`]
1039    pub fn SDL_UnlockSurface(surface: *mut SDL_Surface);
1040}
1041
1042unsafe extern "C" {
1043    /// Load a BMP or PNG image from a seekable SDL data stream.
1044    ///
1045    /// The new surface should be freed with [`SDL_DestroySurface()`]. Not doing so
1046    /// will result in a memory leak.
1047    ///
1048    /// ## Parameters
1049    /// - `src`: the data stream for the surface.
1050    /// - `closeio`: if true, calls [`SDL_CloseIO()`] on `src` before returning, even
1051    ///   in the case of an error.
1052    ///
1053    /// ## Return value
1054    /// Returns a pointer to a new [`SDL_Surface`] structure or NULL on failure; call
1055    ///   [`SDL_GetError()`] for more information.
1056    ///
1057    /// ## Thread safety
1058    /// It is safe to call this function from any thread.
1059    ///
1060    /// ## Availability
1061    /// This function is available since SDL 3.4.0.
1062    ///
1063    /// ## See also
1064    /// - [`SDL_DestroySurface`]
1065    /// - [`SDL_LoadSurface`]
1066    pub fn SDL_LoadSurface_IO(
1067        src: *mut SDL_IOStream,
1068        closeio: ::core::primitive::bool,
1069    ) -> *mut SDL_Surface;
1070}
1071
1072unsafe extern "C" {
1073    /// Load a BMP or PNG image from a file.
1074    ///
1075    /// The new surface should be freed with [`SDL_DestroySurface()`]. Not doing so
1076    /// will result in a memory leak.
1077    ///
1078    /// ## Parameters
1079    /// - `file`: the file to load.
1080    ///
1081    /// ## Return value
1082    /// Returns a pointer to a new [`SDL_Surface`] structure or NULL on failure; call
1083    ///   [`SDL_GetError()`] for more information.
1084    ///
1085    /// ## Thread safety
1086    /// It is safe to call this function from any thread.
1087    ///
1088    /// ## Availability
1089    /// This function is available since SDL 3.4.0.
1090    ///
1091    /// ## See also
1092    /// - [`SDL_DestroySurface`]
1093    /// - [`SDL_LoadSurface_IO`]
1094    pub fn SDL_LoadSurface(file: *const ::core::ffi::c_char) -> *mut SDL_Surface;
1095}
1096
1097unsafe extern "C" {
1098    /// Load a BMP image from a seekable SDL data stream.
1099    ///
1100    /// The new surface should be freed with [`SDL_DestroySurface()`]. Not doing so
1101    /// will result in a memory leak.
1102    ///
1103    /// ## Parameters
1104    /// - `src`: the data stream for the surface.
1105    /// - `closeio`: if true, calls [`SDL_CloseIO()`] on `src` before returning, even
1106    ///   in the case of an error.
1107    ///
1108    /// ## Return value
1109    /// Returns a pointer to a new [`SDL_Surface`] structure or NULL on failure; call
1110    ///   [`SDL_GetError()`] for more information.
1111    ///
1112    /// ## Thread safety
1113    /// It is safe to call this function from any thread.
1114    ///
1115    /// ## Availability
1116    /// This function is available since SDL 3.2.0.
1117    ///
1118    /// ## See also
1119    /// - [`SDL_DestroySurface`]
1120    /// - [`SDL_LoadBMP`]
1121    /// - [`SDL_SaveBMP_IO`]
1122    pub fn SDL_LoadBMP_IO(
1123        src: *mut SDL_IOStream,
1124        closeio: ::core::primitive::bool,
1125    ) -> *mut SDL_Surface;
1126}
1127
1128unsafe extern "C" {
1129    /// Load a BMP image from a file.
1130    ///
1131    /// The new surface should be freed with [`SDL_DestroySurface()`]. Not doing so
1132    /// will result in a memory leak.
1133    ///
1134    /// ## Parameters
1135    /// - `file`: the BMP file to load.
1136    ///
1137    /// ## Return value
1138    /// Returns a pointer to a new [`SDL_Surface`] structure or NULL on failure; call
1139    ///   [`SDL_GetError()`] for more information.
1140    ///
1141    /// ## Thread safety
1142    /// It is safe to call this function from any thread.
1143    ///
1144    /// ## Availability
1145    /// This function is available since SDL 3.2.0.
1146    ///
1147    /// ## See also
1148    /// - [`SDL_DestroySurface`]
1149    /// - [`SDL_LoadBMP_IO`]
1150    /// - [`SDL_SaveBMP`]
1151    pub fn SDL_LoadBMP(file: *const ::core::ffi::c_char) -> *mut SDL_Surface;
1152}
1153
1154unsafe extern "C" {
1155    /// Save a surface to a seekable SDL data stream in BMP format.
1156    ///
1157    /// Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the
1158    /// BMP directly. Other RGB formats with 8-bit or higher get converted to a
1159    /// 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit
1160    /// surface before they are saved. YUV and paletted 1-bit and 4-bit formats are
1161    /// not supported.
1162    ///
1163    /// ## Parameters
1164    /// - `surface`: the [`SDL_Surface`] structure containing the image to be saved.
1165    /// - `dst`: a data stream to save to.
1166    /// - `closeio`: if true, calls [`SDL_CloseIO()`] on `dst` before returning, even
1167    ///   in the case of an error.
1168    ///
1169    /// ## Return value
1170    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1171    ///   information.
1172    ///
1173    /// ## Thread safety
1174    /// This function can be called on different threads with
1175    ///   different surfaces.
1176    ///
1177    /// ## Availability
1178    /// This function is available since SDL 3.2.0.
1179    ///
1180    /// ## See also
1181    /// - [`SDL_LoadBMP_IO`]
1182    /// - [`SDL_SaveBMP`]
1183    pub fn SDL_SaveBMP_IO(
1184        surface: *mut SDL_Surface,
1185        dst: *mut SDL_IOStream,
1186        closeio: ::core::primitive::bool,
1187    ) -> ::core::primitive::bool;
1188}
1189
1190unsafe extern "C" {
1191    /// Save a surface to a file in BMP format.
1192    ///
1193    /// Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the
1194    /// BMP directly. Other RGB formats with 8-bit or higher get converted to a
1195    /// 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit
1196    /// surface before they are saved. YUV and paletted 1-bit and 4-bit formats are
1197    /// not supported.
1198    ///
1199    /// ## Parameters
1200    /// - `surface`: the [`SDL_Surface`] structure containing the image to be saved.
1201    /// - `file`: a file to save to.
1202    ///
1203    /// ## Return value
1204    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1205    ///   information.
1206    ///
1207    /// ## Thread safety
1208    /// This function can be called on different threads with
1209    ///   different surfaces.
1210    ///
1211    /// ## Availability
1212    /// This function is available since SDL 3.2.0.
1213    ///
1214    /// ## See also
1215    /// - [`SDL_LoadBMP`]
1216    /// - [`SDL_SaveBMP_IO`]
1217    pub fn SDL_SaveBMP(
1218        surface: *mut SDL_Surface,
1219        file: *const ::core::ffi::c_char,
1220    ) -> ::core::primitive::bool;
1221}
1222
1223unsafe extern "C" {
1224    /// Load a PNG image from a seekable SDL data stream.
1225    ///
1226    /// This is intended as a convenience function for loading images from trusted
1227    /// sources. If you want to load arbitrary images you should use libpng or
1228    /// another image loading library designed with security in mind.
1229    ///
1230    /// The new surface should be freed with [`SDL_DestroySurface()`]. Not doing so
1231    /// will result in a memory leak.
1232    ///
1233    /// ## Parameters
1234    /// - `src`: the data stream for the surface.
1235    /// - `closeio`: if true, calls [`SDL_CloseIO()`] on `src` before returning, even
1236    ///   in the case of an error.
1237    ///
1238    /// ## Return value
1239    /// Returns a pointer to a new [`SDL_Surface`] structure or NULL on failure; call
1240    ///   [`SDL_GetError()`] for more information.
1241    ///
1242    /// ## Thread safety
1243    /// It is safe to call this function from any thread.
1244    ///
1245    /// ## Availability
1246    /// This function is available since SDL 3.4.0.
1247    ///
1248    /// ## See also
1249    /// - [`SDL_DestroySurface`]
1250    /// - [`SDL_LoadPNG`]
1251    /// - [`SDL_SavePNG_IO`]
1252    pub fn SDL_LoadPNG_IO(
1253        src: *mut SDL_IOStream,
1254        closeio: ::core::primitive::bool,
1255    ) -> *mut SDL_Surface;
1256}
1257
1258unsafe extern "C" {
1259    /// Load a PNG image from a file.
1260    ///
1261    /// This is intended as a convenience function for loading images from trusted
1262    /// sources. If you want to load arbitrary images you should use libpng or
1263    /// another image loading library designed with security in mind.
1264    ///
1265    /// The new surface should be freed with [`SDL_DestroySurface()`]. Not doing so
1266    /// will result in a memory leak.
1267    ///
1268    /// ## Parameters
1269    /// - `file`: the PNG file to load.
1270    ///
1271    /// ## Return value
1272    /// Returns a pointer to a new [`SDL_Surface`] structure or NULL on failure; call
1273    ///   [`SDL_GetError()`] for more information.
1274    ///
1275    /// ## Thread safety
1276    /// It is safe to call this function from any thread.
1277    ///
1278    /// ## Availability
1279    /// This function is available since SDL 3.4.0.
1280    ///
1281    /// ## See also
1282    /// - [`SDL_DestroySurface`]
1283    /// - [`SDL_LoadPNG_IO`]
1284    /// - [`SDL_SavePNG`]
1285    pub fn SDL_LoadPNG(file: *const ::core::ffi::c_char) -> *mut SDL_Surface;
1286}
1287
1288unsafe extern "C" {
1289    /// Save a surface to a seekable SDL data stream in PNG format.
1290    ///
1291    /// ## Parameters
1292    /// - `surface`: the [`SDL_Surface`] structure containing the image to be saved.
1293    /// - `dst`: a data stream to save to.
1294    /// - `closeio`: if true, calls [`SDL_CloseIO()`] on `dst` before returning, even
1295    ///   in the case of an error.
1296    ///
1297    /// ## Return value
1298    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1299    ///   information.
1300    ///
1301    /// ## Thread safety
1302    /// This function can be called on different threads with
1303    ///   different surfaces.
1304    ///
1305    /// ## Availability
1306    /// This function is available since SDL 3.4.0.
1307    ///
1308    /// ## See also
1309    /// - [`SDL_LoadPNG_IO`]
1310    /// - [`SDL_SavePNG`]
1311    pub fn SDL_SavePNG_IO(
1312        surface: *mut SDL_Surface,
1313        dst: *mut SDL_IOStream,
1314        closeio: ::core::primitive::bool,
1315    ) -> ::core::primitive::bool;
1316}
1317
1318unsafe extern "C" {
1319    /// Save a surface to a file in PNG format.
1320    ///
1321    /// ## Parameters
1322    /// - `surface`: the [`SDL_Surface`] structure containing the image to be saved.
1323    /// - `file`: a file to save to.
1324    ///
1325    /// ## Return value
1326    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1327    ///   information.
1328    ///
1329    /// ## Thread safety
1330    /// This function can be called on different threads with
1331    ///   different surfaces.
1332    ///
1333    /// ## Availability
1334    /// This function is available since SDL 3.4.0.
1335    ///
1336    /// ## See also
1337    /// - [`SDL_LoadPNG`]
1338    /// - [`SDL_SavePNG_IO`]
1339    pub fn SDL_SavePNG(
1340        surface: *mut SDL_Surface,
1341        file: *const ::core::ffi::c_char,
1342    ) -> ::core::primitive::bool;
1343}
1344
1345unsafe extern "C" {
1346    /// Set the RLE acceleration hint for a surface.
1347    ///
1348    /// If RLE is enabled, color key and alpha blending blits are much faster, but
1349    /// the surface must be locked before directly accessing the pixels.
1350    ///
1351    /// ## Parameters
1352    /// - `surface`: the [`SDL_Surface`] structure to optimize.
1353    /// - `enabled`: true to enable RLE acceleration, false to disable it.
1354    ///
1355    /// ## Return value
1356    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1357    ///   information.
1358    ///
1359    /// ## Thread safety
1360    /// This function can be called on different threads with
1361    ///   different surfaces.
1362    ///
1363    /// ## Availability
1364    /// This function is available since SDL 3.2.0.
1365    ///
1366    /// ## See also
1367    /// - [`SDL_BlitSurface`]
1368    /// - [`SDL_LockSurface`]
1369    /// - [`SDL_UnlockSurface`]
1370    pub fn SDL_SetSurfaceRLE(
1371        surface: *mut SDL_Surface,
1372        enabled: ::core::primitive::bool,
1373    ) -> ::core::primitive::bool;
1374}
1375
1376unsafe extern "C" {
1377    /// Returns whether the surface is RLE enabled.
1378    ///
1379    /// It is safe to pass a NULL `surface` here; it will return false.
1380    ///
1381    /// ## Parameters
1382    /// - `surface`: the [`SDL_Surface`] structure to query.
1383    ///
1384    /// ## Return value
1385    /// Returns true if the surface is RLE enabled, false otherwise.
1386    ///
1387    /// ## Thread safety
1388    /// It is safe to call this function from any thread.
1389    ///
1390    /// ## Availability
1391    /// This function is available since SDL 3.2.0.
1392    ///
1393    /// ## See also
1394    /// - [`SDL_SetSurfaceRLE`]
1395    pub fn SDL_SurfaceHasRLE(surface: *mut SDL_Surface) -> ::core::primitive::bool;
1396}
1397
1398unsafe extern "C" {
1399    /// Set the color key (transparent pixel) in a surface.
1400    ///
1401    /// The color key defines a pixel value that will be treated as transparent in
1402    /// a blit. For example, one can use this to specify that cyan pixels should be
1403    /// considered transparent, and therefore not rendered.
1404    ///
1405    /// It is a pixel of the format used by the surface, as generated by
1406    /// [`SDL_MapRGB()`].
1407    ///
1408    /// ## Parameters
1409    /// - `surface`: the [`SDL_Surface`] structure to update.
1410    /// - `enabled`: true to enable color key, false to disable color key.
1411    /// - `key`: the transparent pixel.
1412    ///
1413    /// ## Return value
1414    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1415    ///   information.
1416    ///
1417    /// ## Thread safety
1418    /// This function can be called on different threads with
1419    ///   different surfaces.
1420    ///
1421    /// ## Availability
1422    /// This function is available since SDL 3.2.0.
1423    ///
1424    /// ## See also
1425    /// - [`SDL_GetSurfaceColorKey`]
1426    /// - [`SDL_SetSurfaceRLE`]
1427    /// - [`SDL_SurfaceHasColorKey`]
1428    pub fn SDL_SetSurfaceColorKey(
1429        surface: *mut SDL_Surface,
1430        enabled: ::core::primitive::bool,
1431        key: Uint32,
1432    ) -> ::core::primitive::bool;
1433}
1434
1435unsafe extern "C" {
1436    /// Returns whether the surface has a color key.
1437    ///
1438    /// It is safe to pass a NULL `surface` here; it will return false.
1439    ///
1440    /// ## Parameters
1441    /// - `surface`: the [`SDL_Surface`] structure to query.
1442    ///
1443    /// ## Return value
1444    /// Returns true if the surface has a color key, false otherwise.
1445    ///
1446    /// ## Thread safety
1447    /// It is safe to call this function from any thread.
1448    ///
1449    /// ## Availability
1450    /// This function is available since SDL 3.2.0.
1451    ///
1452    /// ## See also
1453    /// - [`SDL_SetSurfaceColorKey`]
1454    /// - [`SDL_GetSurfaceColorKey`]
1455    pub fn SDL_SurfaceHasColorKey(surface: *mut SDL_Surface) -> ::core::primitive::bool;
1456}
1457
1458unsafe extern "C" {
1459    /// Get the color key (transparent pixel) for a surface.
1460    ///
1461    /// The color key is a pixel of the format used by the surface, as generated by
1462    /// [`SDL_MapRGB()`].
1463    ///
1464    /// If the surface doesn't have color key enabled this function returns false.
1465    ///
1466    /// ## Parameters
1467    /// - `surface`: the [`SDL_Surface`] structure to query.
1468    /// - `key`: a pointer filled in with the transparent pixel.
1469    ///
1470    /// ## Return value
1471    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1472    ///   information.
1473    ///
1474    /// ## Thread safety
1475    /// It is safe to call this function from any thread.
1476    ///
1477    /// ## Availability
1478    /// This function is available since SDL 3.2.0.
1479    ///
1480    /// ## See also
1481    /// - [`SDL_SetSurfaceColorKey`]
1482    /// - [`SDL_SurfaceHasColorKey`]
1483    pub fn SDL_GetSurfaceColorKey(
1484        surface: *mut SDL_Surface,
1485        key: *mut Uint32,
1486    ) -> ::core::primitive::bool;
1487}
1488
1489unsafe extern "C" {
1490    /// Set an additional color value multiplied into blit operations.
1491    ///
1492    /// When this surface is blitted, during the blit operation each source color
1493    /// channel is modulated by the appropriate color value according to the
1494    /// following formula:
1495    ///
1496    /// `srcC = srcC * (color / 255)`
1497    ///
1498    /// ## Parameters
1499    /// - `surface`: the [`SDL_Surface`] structure to update.
1500    /// - `r`: the red color value multiplied into blit operations.
1501    /// - `g`: the green color value multiplied into blit operations.
1502    /// - `b`: the blue color value multiplied into blit operations.
1503    ///
1504    /// ## Return value
1505    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1506    ///   information.
1507    ///
1508    /// ## Thread safety
1509    /// This function can be called on different threads with
1510    ///   different surfaces.
1511    ///
1512    /// ## Availability
1513    /// This function is available since SDL 3.2.0.
1514    ///
1515    /// ## See also
1516    /// - [`SDL_GetSurfaceColorMod`]
1517    /// - [`SDL_SetSurfaceAlphaMod`]
1518    pub fn SDL_SetSurfaceColorMod(
1519        surface: *mut SDL_Surface,
1520        r: Uint8,
1521        g: Uint8,
1522        b: Uint8,
1523    ) -> ::core::primitive::bool;
1524}
1525
1526unsafe extern "C" {
1527    /// Get the additional color value multiplied into blit operations.
1528    ///
1529    /// ## Parameters
1530    /// - `surface`: the [`SDL_Surface`] structure to query.
1531    /// - `r`: a pointer filled in with the current red color value.
1532    /// - `g`: a pointer filled in with the current green color value.
1533    /// - `b`: a pointer filled in with the current blue color value.
1534    ///
1535    /// ## Return value
1536    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1537    ///   information.
1538    ///
1539    /// ## Thread safety
1540    /// This function can be called on different threads with
1541    ///   different surfaces.
1542    ///
1543    /// ## Availability
1544    /// This function is available since SDL 3.2.0.
1545    ///
1546    /// ## See also
1547    /// - [`SDL_GetSurfaceAlphaMod`]
1548    /// - [`SDL_SetSurfaceColorMod`]
1549    pub fn SDL_GetSurfaceColorMod(
1550        surface: *mut SDL_Surface,
1551        r: *mut Uint8,
1552        g: *mut Uint8,
1553        b: *mut Uint8,
1554    ) -> ::core::primitive::bool;
1555}
1556
1557unsafe extern "C" {
1558    /// Set an additional alpha value used in blit operations.
1559    ///
1560    /// When this surface is blitted, during the blit operation the source alpha
1561    /// value is modulated by this alpha value according to the following formula:
1562    ///
1563    /// `srcA = srcA * (alpha / 255)`
1564    ///
1565    /// ## Parameters
1566    /// - `surface`: the [`SDL_Surface`] structure to update.
1567    /// - `alpha`: the alpha value multiplied into blit operations.
1568    ///
1569    /// ## Return value
1570    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1571    ///   information.
1572    ///
1573    /// ## Thread safety
1574    /// This function can be called on different threads with
1575    ///   different surfaces.
1576    ///
1577    /// ## Availability
1578    /// This function is available since SDL 3.2.0.
1579    ///
1580    /// ## See also
1581    /// - [`SDL_GetSurfaceAlphaMod`]
1582    /// - [`SDL_SetSurfaceColorMod`]
1583    pub fn SDL_SetSurfaceAlphaMod(
1584        surface: *mut SDL_Surface,
1585        alpha: Uint8,
1586    ) -> ::core::primitive::bool;
1587}
1588
1589unsafe extern "C" {
1590    /// Get the additional alpha value used in blit operations.
1591    ///
1592    /// ## Parameters
1593    /// - `surface`: the [`SDL_Surface`] structure to query.
1594    /// - `alpha`: a pointer filled in with the current alpha value.
1595    ///
1596    /// ## Return value
1597    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1598    ///   information.
1599    ///
1600    /// ## Thread safety
1601    /// It is safe to call this function from any thread.
1602    ///
1603    /// ## Availability
1604    /// This function is available since SDL 3.2.0.
1605    ///
1606    /// ## See also
1607    /// - [`SDL_GetSurfaceColorMod`]
1608    /// - [`SDL_SetSurfaceAlphaMod`]
1609    pub fn SDL_GetSurfaceAlphaMod(
1610        surface: *mut SDL_Surface,
1611        alpha: *mut Uint8,
1612    ) -> ::core::primitive::bool;
1613}
1614
1615unsafe extern "C" {
1616    /// Set the blend mode used for blit operations.
1617    ///
1618    /// To copy a surface to another surface (or texture) without blending with the
1619    /// existing data, the blendmode of the SOURCE surface should be set to
1620    /// [`SDL_BLENDMODE_NONE`].
1621    ///
1622    /// ## Parameters
1623    /// - `surface`: the [`SDL_Surface`] structure to update.
1624    /// - `blendMode`: the [`SDL_BlendMode`] to use for blit blending.
1625    ///
1626    /// ## Return value
1627    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1628    ///   information.
1629    ///
1630    /// ## Thread safety
1631    /// This function can be called on different threads with
1632    ///   different surfaces.
1633    ///
1634    /// ## Availability
1635    /// This function is available since SDL 3.2.0.
1636    ///
1637    /// ## See also
1638    /// - [`SDL_GetSurfaceBlendMode`]
1639    pub fn SDL_SetSurfaceBlendMode(
1640        surface: *mut SDL_Surface,
1641        blendMode: SDL_BlendMode,
1642    ) -> ::core::primitive::bool;
1643}
1644
1645unsafe extern "C" {
1646    /// Get the blend mode used for blit operations.
1647    ///
1648    /// ## Parameters
1649    /// - `surface`: the [`SDL_Surface`] structure to query.
1650    /// - `blendMode`: a pointer filled in with the current [`SDL_BlendMode`].
1651    ///
1652    /// ## Return value
1653    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1654    ///   information.
1655    ///
1656    /// ## Thread safety
1657    /// It is safe to call this function from any thread.
1658    ///
1659    /// ## Availability
1660    /// This function is available since SDL 3.2.0.
1661    ///
1662    /// ## See also
1663    /// - [`SDL_SetSurfaceBlendMode`]
1664    pub fn SDL_GetSurfaceBlendMode(
1665        surface: *mut SDL_Surface,
1666        blendMode: *mut SDL_BlendMode,
1667    ) -> ::core::primitive::bool;
1668}
1669
1670unsafe extern "C" {
1671    /// Set the clipping rectangle for a surface.
1672    ///
1673    /// When `surface` is the destination of a blit, only the area within the clip
1674    /// rectangle is drawn into.
1675    ///
1676    /// Note that blits are automatically clipped to the edges of the source and
1677    /// destination surfaces.
1678    ///
1679    /// ## Parameters
1680    /// - `surface`: the [`SDL_Surface`] structure to be clipped.
1681    /// - `rect`: the [`SDL_Rect`] structure representing the clipping rectangle, or
1682    ///   NULL to disable clipping.
1683    ///
1684    /// ## Return value
1685    /// Returns true if the rectangle intersects the surface, otherwise false and
1686    ///   blits will be completely clipped.
1687    ///
1688    /// ## Thread safety
1689    /// This function can be called on different threads with
1690    ///   different surfaces.
1691    ///
1692    /// ## Availability
1693    /// This function is available since SDL 3.2.0.
1694    ///
1695    /// ## See also
1696    /// - [`SDL_GetSurfaceClipRect`]
1697    pub fn SDL_SetSurfaceClipRect(
1698        surface: *mut SDL_Surface,
1699        rect: *const SDL_Rect,
1700    ) -> ::core::primitive::bool;
1701}
1702
1703unsafe extern "C" {
1704    /// Get the clipping rectangle for a surface.
1705    ///
1706    /// When `surface` is the destination of a blit, only the area within the clip
1707    /// rectangle is drawn into.
1708    ///
1709    /// ## Parameters
1710    /// - `surface`: the [`SDL_Surface`] structure representing the surface to be
1711    ///   clipped.
1712    /// - `rect`: an [`SDL_Rect`] structure filled in with the clipping rectangle for
1713    ///   the surface.
1714    ///
1715    /// ## Return value
1716    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1717    ///   information.
1718    ///
1719    /// ## Thread safety
1720    /// This function can be called on different threads with
1721    ///   different surfaces.
1722    ///
1723    /// ## Availability
1724    /// This function is available since SDL 3.2.0.
1725    ///
1726    /// ## See also
1727    /// - [`SDL_SetSurfaceClipRect`]
1728    pub fn SDL_GetSurfaceClipRect(
1729        surface: *mut SDL_Surface,
1730        rect: *mut SDL_Rect,
1731    ) -> ::core::primitive::bool;
1732}
1733
1734unsafe extern "C" {
1735    /// Flip a surface vertically or horizontally.
1736    ///
1737    /// ## Parameters
1738    /// - `surface`: the surface to flip.
1739    /// - `flip`: the direction to flip.
1740    ///
1741    /// ## Return value
1742    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1743    ///   information.
1744    ///
1745    /// ## Thread safety
1746    /// This function can be called on different threads with
1747    ///   different surfaces.
1748    ///
1749    /// ## Availability
1750    /// This function is available since SDL 3.2.0.
1751    pub fn SDL_FlipSurface(
1752        surface: *mut SDL_Surface,
1753        flip: SDL_FlipMode,
1754    ) -> ::core::primitive::bool;
1755}
1756
1757unsafe extern "C" {
1758    /// Return a copy of a surface rotated clockwise a number of degrees.
1759    ///
1760    /// The angle of rotation can be negative for counter-clockwise rotation.
1761    ///
1762    /// When the rotation isn't a multiple of 90 degrees, the resulting surface is
1763    /// larger than the original, with the background filled in with the colorkey,
1764    /// if available, or RGBA 255/255/255/0 if not.
1765    ///
1766    /// If `surface` has the [`SDL_PROP_SURFACE_ROTATION_FLOAT`] property set on it,
1767    /// the new copy will have the adjusted value set: if the rotation property is
1768    /// 90 and `angle` was 30, the new surface will have a property value of 60
1769    /// (that is: to be upright vs gravity, this surface needs to rotate 60 more
1770    /// degrees). However, note that further rotations on the new surface in this
1771    /// example will produce unexpected results, since the image will have resized
1772    /// and padded to accommodate the not-90 degree angle.
1773    ///
1774    /// ## Parameters
1775    /// - `surface`: the surface to rotate.
1776    /// - `angle`: the rotation angle, in degrees.
1777    ///
1778    /// ## Return value
1779    /// Returns a rotated copy of the surface or NULL on failure; call
1780    ///   [`SDL_GetError()`] for more information.
1781    ///
1782    /// ## Thread safety
1783    /// This function can be called on different threads with
1784    ///   different surfaces.
1785    ///
1786    /// ## Availability
1787    /// This function is available since SDL 3.4.0.
1788    pub fn SDL_RotateSurface(
1789        surface: *mut SDL_Surface,
1790        angle: ::core::ffi::c_float,
1791    ) -> *mut SDL_Surface;
1792}
1793
1794unsafe extern "C" {
1795    /// Creates a new surface identical to the existing surface.
1796    ///
1797    /// If the original surface has alternate images, the new surface will have a
1798    /// reference to them as well.
1799    ///
1800    /// The returned surface should be freed with [`SDL_DestroySurface()`].
1801    ///
1802    /// ## Parameters
1803    /// - `surface`: the surface to duplicate.
1804    ///
1805    /// ## Return value
1806    /// Returns a copy of the surface or NULL on failure; call [`SDL_GetError()`] for
1807    ///   more information.
1808    ///
1809    /// ## Thread safety
1810    /// This function can be called on different threads with
1811    ///   different surfaces.
1812    ///
1813    /// ## Availability
1814    /// This function is available since SDL 3.2.0.
1815    ///
1816    /// ## See also
1817    /// - [`SDL_DestroySurface`]
1818    pub fn SDL_DuplicateSurface(surface: *mut SDL_Surface) -> *mut SDL_Surface;
1819}
1820
1821unsafe extern "C" {
1822    /// Creates a new surface identical to the existing surface, scaled to the
1823    /// desired size.
1824    ///
1825    /// The returned surface should be freed with [`SDL_DestroySurface()`].
1826    ///
1827    /// ## Parameters
1828    /// - `surface`: the surface to duplicate and scale.
1829    /// - `width`: the width of the new surface.
1830    /// - `height`: the height of the new surface.
1831    /// - `scaleMode`: the [`SDL_ScaleMode`] to be used.
1832    ///
1833    /// ## Return value
1834    /// Returns a copy of the surface or NULL on failure; call [`SDL_GetError()`] for
1835    ///   more information.
1836    ///
1837    /// ## Thread safety
1838    /// This function can be called on different threads with
1839    ///   different surfaces.
1840    ///
1841    /// ## Availability
1842    /// This function is available since SDL 3.2.0.
1843    ///
1844    /// ## See also
1845    /// - [`SDL_DestroySurface`]
1846    pub fn SDL_ScaleSurface(
1847        surface: *mut SDL_Surface,
1848        width: ::core::ffi::c_int,
1849        height: ::core::ffi::c_int,
1850        scaleMode: SDL_ScaleMode,
1851    ) -> *mut SDL_Surface;
1852}
1853
1854unsafe extern "C" {
1855    /// Copy an existing surface to a new surface of the specified format.
1856    ///
1857    /// This function is used to optimize images for faster *repeat* blitting. This
1858    /// is accomplished by converting the original and storing the result as a new
1859    /// surface. The new, optimized surface can then be used as the source for
1860    /// future blits, making them faster.
1861    ///
1862    /// If you are converting to an indexed surface and want to map colors to a
1863    /// palette, you can use [`SDL_ConvertSurfaceAndColorspace()`] instead.
1864    ///
1865    /// If the original surface has alternate images, the new surface will have a
1866    /// reference to them as well.
1867    ///
1868    /// ## Parameters
1869    /// - `surface`: the existing [`SDL_Surface`] structure to convert.
1870    /// - `format`: the new pixel format.
1871    ///
1872    /// ## Return value
1873    /// Returns the new [`SDL_Surface`] structure that is created or NULL on failure;
1874    ///   call [`SDL_GetError()`] for more information.
1875    ///
1876    /// ## Thread safety
1877    /// This function can be called on different threads with
1878    ///   different surfaces.
1879    ///
1880    /// ## Availability
1881    /// This function is available since SDL 3.2.0.
1882    ///
1883    /// ## See also
1884    /// - [`SDL_ConvertSurfaceAndColorspace`]
1885    /// - [`SDL_DestroySurface`]
1886    pub fn SDL_ConvertSurface(
1887        surface: *mut SDL_Surface,
1888        format: SDL_PixelFormat,
1889    ) -> *mut SDL_Surface;
1890}
1891
1892unsafe extern "C" {
1893    /// Copy an existing surface to a new surface of the specified format and
1894    /// colorspace.
1895    ///
1896    /// This function converts an existing surface to a new format and colorspace
1897    /// and returns the new surface. This will perform any pixel format and
1898    /// colorspace conversion needed.
1899    ///
1900    /// If the original surface has alternate images, the new surface will have a
1901    /// reference to them as well.
1902    ///
1903    /// ## Parameters
1904    /// - `surface`: the existing [`SDL_Surface`] structure to convert.
1905    /// - `format`: the new pixel format.
1906    /// - `palette`: an optional palette to use for indexed formats, may be NULL.
1907    /// - `colorspace`: the new colorspace.
1908    /// - `props`: an [`SDL_PropertiesID`] with additional color properties, or 0.
1909    ///
1910    /// ## Return value
1911    /// Returns the new [`SDL_Surface`] structure that is created or NULL on failure;
1912    ///   call [`SDL_GetError()`] for more information.
1913    ///
1914    /// ## Thread safety
1915    /// This function can be called on different threads with
1916    ///   different surfaces.
1917    ///
1918    /// ## Availability
1919    /// This function is available since SDL 3.2.0.
1920    ///
1921    /// ## See also
1922    /// - [`SDL_ConvertSurface`]
1923    /// - [`SDL_DestroySurface`]
1924    pub fn SDL_ConvertSurfaceAndColorspace(
1925        surface: *mut SDL_Surface,
1926        format: SDL_PixelFormat,
1927        palette: *mut SDL_Palette,
1928        colorspace: SDL_Colorspace,
1929        props: SDL_PropertiesID,
1930    ) -> *mut SDL_Surface;
1931}
1932
1933unsafe extern "C" {
1934    /// Copy a block of pixels of one format to another format.
1935    ///
1936    /// ## Parameters
1937    /// - `width`: the width of the block to copy, in pixels.
1938    /// - `height`: the height of the block to copy, in pixels.
1939    /// - `src_format`: an [`SDL_PixelFormat`] value of the `src` pixels format.
1940    /// - `src`: a pointer to the source pixels.
1941    /// - `src_pitch`: the pitch of the source pixels, in bytes.
1942    /// - `dst_format`: an [`SDL_PixelFormat`] value of the `dst` pixels format.
1943    /// - `dst`: a pointer to be filled in with new pixel data.
1944    /// - `dst_pitch`: the pitch of the destination pixels, in bytes.
1945    ///
1946    /// ## Return value
1947    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1948    ///   information.
1949    ///
1950    /// ## Thread safety
1951    /// The same destination pixels should not be used from two
1952    ///   threads at once. It is safe to use the same source pixels
1953    ///   from multiple threads.
1954    ///
1955    /// ## Availability
1956    /// This function is available since SDL 3.2.0.
1957    ///
1958    /// ## See also
1959    /// - [`SDL_ConvertPixelsAndColorspace`]
1960    pub fn SDL_ConvertPixels(
1961        width: ::core::ffi::c_int,
1962        height: ::core::ffi::c_int,
1963        src_format: SDL_PixelFormat,
1964        src: *const ::core::ffi::c_void,
1965        src_pitch: ::core::ffi::c_int,
1966        dst_format: SDL_PixelFormat,
1967        dst: *mut ::core::ffi::c_void,
1968        dst_pitch: ::core::ffi::c_int,
1969    ) -> ::core::primitive::bool;
1970}
1971
1972unsafe extern "C" {
1973    /// Copy a block of pixels of one format and colorspace to another format and
1974    /// colorspace.
1975    ///
1976    /// ## Parameters
1977    /// - `width`: the width of the block to copy, in pixels.
1978    /// - `height`: the height of the block to copy, in pixels.
1979    /// - `src_format`: an [`SDL_PixelFormat`] value of the `src` pixels format.
1980    /// - `src_colorspace`: an [`SDL_Colorspace`] value describing the colorspace of
1981    ///   the `src` pixels.
1982    /// - `src_properties`: an [`SDL_PropertiesID`] with additional source color
1983    ///   properties, or 0.
1984    /// - `src`: a pointer to the source pixels.
1985    /// - `src_pitch`: the pitch of the source pixels, in bytes.
1986    /// - `dst_format`: an [`SDL_PixelFormat`] value of the `dst` pixels format.
1987    /// - `dst_colorspace`: an [`SDL_Colorspace`] value describing the colorspace of
1988    ///   the `dst` pixels.
1989    /// - `dst_properties`: an [`SDL_PropertiesID`] with additional destination color
1990    ///   properties, or 0.
1991    /// - `dst`: a pointer to be filled in with new pixel data.
1992    /// - `dst_pitch`: the pitch of the destination pixels, in bytes.
1993    ///
1994    /// ## Return value
1995    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
1996    ///   information.
1997    ///
1998    /// ## Thread safety
1999    /// The same destination pixels should not be used from two
2000    ///   threads at once. It is safe to use the same source pixels
2001    ///   from multiple threads.
2002    ///
2003    /// ## Availability
2004    /// This function is available since SDL 3.2.0.
2005    ///
2006    /// ## See also
2007    /// - [`SDL_ConvertPixels`]
2008    pub fn SDL_ConvertPixelsAndColorspace(
2009        width: ::core::ffi::c_int,
2010        height: ::core::ffi::c_int,
2011        src_format: SDL_PixelFormat,
2012        src_colorspace: SDL_Colorspace,
2013        src_properties: SDL_PropertiesID,
2014        src: *const ::core::ffi::c_void,
2015        src_pitch: ::core::ffi::c_int,
2016        dst_format: SDL_PixelFormat,
2017        dst_colorspace: SDL_Colorspace,
2018        dst_properties: SDL_PropertiesID,
2019        dst: *mut ::core::ffi::c_void,
2020        dst_pitch: ::core::ffi::c_int,
2021    ) -> ::core::primitive::bool;
2022}
2023
2024unsafe extern "C" {
2025    /// Premultiply the alpha on a block of pixels.
2026    ///
2027    /// This is safe to use with src == dst, but not for other overlapping areas.
2028    ///
2029    /// ## Parameters
2030    /// - `width`: the width of the block to convert, in pixels.
2031    /// - `height`: the height of the block to convert, in pixels.
2032    /// - `src_format`: an [`SDL_PixelFormat`] value of the `src` pixels format.
2033    /// - `src`: a pointer to the source pixels.
2034    /// - `src_pitch`: the pitch of the source pixels, in bytes.
2035    /// - `dst_format`: an [`SDL_PixelFormat`] value of the `dst` pixels format.
2036    /// - `dst`: a pointer to be filled in with premultiplied pixel data.
2037    /// - `dst_pitch`: the pitch of the destination pixels, in bytes.
2038    /// - `linear`: true to convert from sRGB to linear space for the alpha
2039    ///   multiplication, false to do multiplication in sRGB space.
2040    ///
2041    /// ## Return value
2042    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2043    ///   information.
2044    ///
2045    /// ## Thread safety
2046    /// The same destination pixels should not be used from two
2047    ///   threads at once. It is safe to use the same source pixels
2048    ///   from multiple threads.
2049    ///
2050    /// ## Availability
2051    /// This function is available since SDL 3.2.0.
2052    pub fn SDL_PremultiplyAlpha(
2053        width: ::core::ffi::c_int,
2054        height: ::core::ffi::c_int,
2055        src_format: SDL_PixelFormat,
2056        src: *const ::core::ffi::c_void,
2057        src_pitch: ::core::ffi::c_int,
2058        dst_format: SDL_PixelFormat,
2059        dst: *mut ::core::ffi::c_void,
2060        dst_pitch: ::core::ffi::c_int,
2061        linear: ::core::primitive::bool,
2062    ) -> ::core::primitive::bool;
2063}
2064
2065unsafe extern "C" {
2066    /// Premultiply the alpha in a surface.
2067    ///
2068    /// This is safe to use with src == dst, but not for other overlapping areas.
2069    ///
2070    /// ## Parameters
2071    /// - `surface`: the surface to modify.
2072    /// - `linear`: true to convert from sRGB to linear space for the alpha
2073    ///   multiplication, false to do multiplication in sRGB space.
2074    ///
2075    /// ## Return value
2076    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2077    ///   information.
2078    ///
2079    /// ## Thread safety
2080    /// This function can be called on different threads with
2081    ///   different surfaces.
2082    ///
2083    /// ## Availability
2084    /// This function is available since SDL 3.2.0.
2085    pub fn SDL_PremultiplySurfaceAlpha(
2086        surface: *mut SDL_Surface,
2087        linear: ::core::primitive::bool,
2088    ) -> ::core::primitive::bool;
2089}
2090
2091unsafe extern "C" {
2092    /// Clear a surface with a specific color, with floating point precision.
2093    ///
2094    /// This function handles all surface formats, and ignores any clip rectangle.
2095    ///
2096    /// If the surface is YUV, the color is assumed to be in the sRGB colorspace,
2097    /// otherwise the color is assumed to be in the colorspace of the surface.
2098    ///
2099    /// ## Parameters
2100    /// - `surface`: the [`SDL_Surface`] to clear.
2101    /// - `r`: the red component of the pixel, normally in the range 0-1.
2102    /// - `g`: the green component of the pixel, normally in the range 0-1.
2103    /// - `b`: the blue component of the pixel, normally in the range 0-1.
2104    /// - `a`: the alpha component of the pixel, normally in the range 0-1.
2105    ///
2106    /// ## Return value
2107    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2108    ///   information.
2109    ///
2110    /// ## Thread safety
2111    /// This function can be called on different threads with
2112    ///   different surfaces.
2113    ///
2114    /// ## Availability
2115    /// This function is available since SDL 3.2.0.
2116    pub fn SDL_ClearSurface(
2117        surface: *mut SDL_Surface,
2118        r: ::core::ffi::c_float,
2119        g: ::core::ffi::c_float,
2120        b: ::core::ffi::c_float,
2121        a: ::core::ffi::c_float,
2122    ) -> ::core::primitive::bool;
2123}
2124
2125unsafe extern "C" {
2126    /// Perform a fast fill of a rectangle with a specific color.
2127    ///
2128    /// `color` should be a pixel of the format used by the surface, and can be
2129    /// generated by [`SDL_MapRGB()`] or [`SDL_MapRGBA()`]. If the color value contains an
2130    /// alpha component then the destination is simply filled with that alpha
2131    /// information, no blending takes place.
2132    ///
2133    /// If there is a clip rectangle set on the destination (set via
2134    /// [`SDL_SetSurfaceClipRect()`]), then this function will fill based on the
2135    /// intersection of the clip rectangle and `rect`.
2136    ///
2137    /// ## Parameters
2138    /// - `dst`: the [`SDL_Surface`] structure that is the drawing target.
2139    /// - `rect`: the [`SDL_Rect`] structure representing the rectangle to fill, or
2140    ///   NULL to fill the entire surface.
2141    /// - `color`: the color to fill with.
2142    ///
2143    /// ## Return value
2144    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2145    ///   information.
2146    ///
2147    /// ## Thread safety
2148    /// This function can be called on different threads with
2149    ///   different surfaces.
2150    ///
2151    /// ## Availability
2152    /// This function is available since SDL 3.2.0.
2153    ///
2154    /// ## See also
2155    /// - [`SDL_FillSurfaceRects`]
2156    pub fn SDL_FillSurfaceRect(
2157        dst: *mut SDL_Surface,
2158        rect: *const SDL_Rect,
2159        color: Uint32,
2160    ) -> ::core::primitive::bool;
2161}
2162
2163unsafe extern "C" {
2164    /// Perform a fast fill of a set of rectangles with a specific color.
2165    ///
2166    /// `color` should be a pixel of the format used by the surface, and can be
2167    /// generated by [`SDL_MapRGB()`] or [`SDL_MapRGBA()`]. If the color value contains an
2168    /// alpha component then the destination is simply filled with that alpha
2169    /// information, no blending takes place.
2170    ///
2171    /// If there is a clip rectangle set on the destination (set via
2172    /// [`SDL_SetSurfaceClipRect()`]), then this function will fill based on the
2173    /// intersection of the clip rectangle and `rect`.
2174    ///
2175    /// ## Parameters
2176    /// - `dst`: the [`SDL_Surface`] structure that is the drawing target.
2177    /// - `rects`: an array of [`SDL_Rect`]s representing the rectangles to fill.
2178    /// - `count`: the number of rectangles in the array.
2179    /// - `color`: the color to fill with.
2180    ///
2181    /// ## Return value
2182    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2183    ///   information.
2184    ///
2185    /// ## Thread safety
2186    /// This function can be called on different threads with
2187    ///   different surfaces.
2188    ///
2189    /// ## Availability
2190    /// This function is available since SDL 3.2.0.
2191    ///
2192    /// ## See also
2193    /// - [`SDL_FillSurfaceRect`]
2194    pub fn SDL_FillSurfaceRects(
2195        dst: *mut SDL_Surface,
2196        rects: *const SDL_Rect,
2197        count: ::core::ffi::c_int,
2198        color: Uint32,
2199    ) -> ::core::primitive::bool;
2200}
2201
2202unsafe extern "C" {
2203    /// Performs a fast blit from the source surface to the destination surface
2204    /// with clipping.
2205    ///
2206    /// If either `srcrect` or `dstrect` are NULL, the entire surface (`src` or
2207    /// `dst`) is copied while ensuring clipping to `dst->clip_rect`.
2208    ///
2209    /// The blit function should not be called on a locked surface.
2210    ///
2211    /// The blit semantics for surfaces with and without blending and colorkey are
2212    /// defined as follows:
2213    ///
2214    /// ```text
2215    ///    RGBA->RGB:
2216    ///      Source surface blend mode set to SDL_BLENDMODE_BLEND:
2217    ///       alpha-blend (using the source alpha-channel and per-surface alpha)
2218    ///       SDL_SRCCOLORKEY ignored.
2219    ///     Source surface blend mode set to SDL_BLENDMODE_NONE:
2220    ///       copy RGB.
2221    ///       if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
2222    ///       RGB values of the source color key, ignoring alpha in the
2223    ///       comparison.
2224    ///
2225    ///   RGB->RGBA:
2226    ///     Source surface blend mode set to SDL_BLENDMODE_BLEND:
2227    ///       alpha-blend (using the source per-surface alpha)
2228    ///     Source surface blend mode set to SDL_BLENDMODE_NONE:
2229    ///       copy RGB, set destination alpha to source per-surface alpha value.
2230    ///     both:
2231    ///       if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
2232    ///       source color key.
2233    ///
2234    ///   RGBA->RGBA:
2235    ///     Source surface blend mode set to SDL_BLENDMODE_BLEND:
2236    ///       alpha-blend (using the source alpha-channel and per-surface alpha)
2237    ///       SDL_SRCCOLORKEY ignored.
2238    ///     Source surface blend mode set to SDL_BLENDMODE_NONE:
2239    ///       copy all of RGBA to the destination.
2240    ///       if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
2241    ///       RGB values of the source color key, ignoring alpha in the
2242    ///       comparison.
2243    ///
2244    ///   RGB->RGB:
2245    ///     Source surface blend mode set to SDL_BLENDMODE_BLEND:
2246    ///       alpha-blend (using the source per-surface alpha)
2247    ///     Source surface blend mode set to SDL_BLENDMODE_NONE:
2248    ///       copy RGB.
2249    ///     both:
2250    ///       if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
2251    ///       source color key.
2252    /// ```
2253    ///
2254    /// ## Parameters
2255    /// - `src`: the [`SDL_Surface`] structure to be copied from.
2256    /// - `srcrect`: the [`SDL_Rect`] structure representing the rectangle to be
2257    ///   copied, or NULL to copy the entire surface.
2258    /// - `dst`: the [`SDL_Surface`] structure that is the blit target.
2259    /// - `dstrect`: the [`SDL_Rect`] structure representing the x and y position in
2260    ///   the destination surface, or NULL for (0,0). The width and
2261    ///   height are ignored, and are copied from `srcrect`. If you
2262    ///   want a specific width and height, you should use
2263    ///   [`SDL_BlitSurfaceScaled()`].
2264    ///
2265    /// ## Return value
2266    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2267    ///   information.
2268    ///
2269    /// ## Thread safety
2270    /// Only one thread should be using the `src` and `dst` surfaces
2271    ///   at any given time.
2272    ///
2273    /// ## Availability
2274    /// This function is available since SDL 3.2.0.
2275    ///
2276    /// ## See also
2277    /// - [`SDL_BlitSurfaceScaled`]
2278    pub fn SDL_BlitSurface(
2279        src: *mut SDL_Surface,
2280        srcrect: *const SDL_Rect,
2281        dst: *mut SDL_Surface,
2282        dstrect: *const SDL_Rect,
2283    ) -> ::core::primitive::bool;
2284}
2285
2286unsafe extern "C" {
2287    /// Perform low-level surface blitting only.
2288    ///
2289    /// This is a semi-private blit function and it performs low-level surface
2290    /// blitting, assuming the input rectangles have already been clipped.
2291    ///
2292    /// ## Parameters
2293    /// - `src`: the [`SDL_Surface`] structure to be copied from.
2294    /// - `srcrect`: the [`SDL_Rect`] structure representing the rectangle to be
2295    ///   copied, may not be NULL.
2296    /// - `dst`: the [`SDL_Surface`] structure that is the blit target.
2297    /// - `dstrect`: the [`SDL_Rect`] structure representing the target rectangle in
2298    ///   the destination surface, may not be NULL.
2299    ///
2300    /// ## Return value
2301    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2302    ///   information.
2303    ///
2304    /// ## Thread safety
2305    /// Only one thread should be using the `src` and `dst` surfaces
2306    ///   at any given time.
2307    ///
2308    /// ## Availability
2309    /// This function is available since SDL 3.2.0.
2310    ///
2311    /// ## See also
2312    /// - [`SDL_BlitSurface`]
2313    pub fn SDL_BlitSurfaceUnchecked(
2314        src: *mut SDL_Surface,
2315        srcrect: *const SDL_Rect,
2316        dst: *mut SDL_Surface,
2317        dstrect: *const SDL_Rect,
2318    ) -> ::core::primitive::bool;
2319}
2320
2321unsafe extern "C" {
2322    /// Perform a scaled blit to a destination surface, which may be of a different
2323    /// format.
2324    ///
2325    /// ## Parameters
2326    /// - `src`: the [`SDL_Surface`] structure to be copied from.
2327    /// - `srcrect`: the [`SDL_Rect`] structure representing the rectangle to be
2328    ///   copied, or NULL to copy the entire surface.
2329    /// - `dst`: the [`SDL_Surface`] structure that is the blit target.
2330    /// - `dstrect`: the [`SDL_Rect`] structure representing the target rectangle in
2331    ///   the destination surface, or NULL to fill the entire
2332    ///   destination surface.
2333    /// - `scaleMode`: the [`SDL_ScaleMode`] to be used.
2334    ///
2335    /// ## Return value
2336    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2337    ///   information.
2338    ///
2339    /// ## Thread safety
2340    /// Only one thread should be using the `src` and `dst` surfaces
2341    ///   at any given time.
2342    ///
2343    /// ## Availability
2344    /// This function is available since SDL 3.2.0.
2345    ///
2346    /// ## See also
2347    /// - [`SDL_BlitSurface`]
2348    pub fn SDL_BlitSurfaceScaled(
2349        src: *mut SDL_Surface,
2350        srcrect: *const SDL_Rect,
2351        dst: *mut SDL_Surface,
2352        dstrect: *const SDL_Rect,
2353        scaleMode: SDL_ScaleMode,
2354    ) -> ::core::primitive::bool;
2355}
2356
2357unsafe extern "C" {
2358    /// Perform low-level surface scaled blitting only.
2359    ///
2360    /// This is a semi-private function and it performs low-level surface blitting,
2361    /// assuming the input rectangles have already been clipped.
2362    ///
2363    /// ## Parameters
2364    /// - `src`: the [`SDL_Surface`] structure to be copied from.
2365    /// - `srcrect`: the [`SDL_Rect`] structure representing the rectangle to be
2366    ///   copied, may not be NULL.
2367    /// - `dst`: the [`SDL_Surface`] structure that is the blit target.
2368    /// - `dstrect`: the [`SDL_Rect`] structure representing the target rectangle in
2369    ///   the destination surface, may not be NULL.
2370    /// - `scaleMode`: the [`SDL_ScaleMode`] to be used.
2371    ///
2372    /// ## Return value
2373    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2374    ///   information.
2375    ///
2376    /// ## Thread safety
2377    /// Only one thread should be using the `src` and `dst` surfaces
2378    ///   at any given time.
2379    ///
2380    /// ## Availability
2381    /// This function is available since SDL 3.2.0.
2382    ///
2383    /// ## See also
2384    /// - [`SDL_BlitSurfaceScaled`]
2385    pub fn SDL_BlitSurfaceUncheckedScaled(
2386        src: *mut SDL_Surface,
2387        srcrect: *const SDL_Rect,
2388        dst: *mut SDL_Surface,
2389        dstrect: *const SDL_Rect,
2390        scaleMode: SDL_ScaleMode,
2391    ) -> ::core::primitive::bool;
2392}
2393
2394unsafe extern "C" {
2395    /// Perform a stretched pixel copy from one surface to another.
2396    ///
2397    /// ## Parameters
2398    /// - `src`: the [`SDL_Surface`] structure to be copied from.
2399    /// - `srcrect`: the [`SDL_Rect`] structure representing the rectangle to be
2400    ///   copied, or NULL to copy the entire surface.
2401    /// - `dst`: the [`SDL_Surface`] structure that is the blit target.
2402    /// - `dstrect`: the [`SDL_Rect`] structure representing the target rectangle in
2403    ///   the destination surface, or NULL to fill the entire
2404    ///   destination surface.
2405    /// - `scaleMode`: the [`SDL_ScaleMode`] to be used.
2406    ///
2407    /// ## Return value
2408    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2409    ///   information.
2410    ///
2411    /// ## Thread safety
2412    /// Only one thread should be using the `src` and `dst` surfaces
2413    ///   at any given time.
2414    ///
2415    /// ## Availability
2416    /// This function is available since SDL 3.4.0.
2417    ///
2418    /// ## See also
2419    /// - [`SDL_BlitSurfaceScaled`]
2420    pub fn SDL_StretchSurface(
2421        src: *mut SDL_Surface,
2422        srcrect: *const SDL_Rect,
2423        dst: *mut SDL_Surface,
2424        dstrect: *const SDL_Rect,
2425        scaleMode: SDL_ScaleMode,
2426    ) -> ::core::primitive::bool;
2427}
2428
2429unsafe extern "C" {
2430    /// Perform a tiled blit to a destination surface, which may be of a different
2431    /// format.
2432    ///
2433    /// The pixels in `srcrect` will be repeated as many times as needed to
2434    /// completely fill `dstrect`.
2435    ///
2436    /// ## Parameters
2437    /// - `src`: the [`SDL_Surface`] structure to be copied from.
2438    /// - `srcrect`: the [`SDL_Rect`] structure representing the rectangle to be
2439    ///   copied, or NULL to copy the entire surface.
2440    /// - `dst`: the [`SDL_Surface`] structure that is the blit target.
2441    /// - `dstrect`: the [`SDL_Rect`] structure representing the target rectangle in
2442    ///   the destination surface, or NULL to fill the entire surface.
2443    ///
2444    /// ## Return value
2445    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2446    ///   information.
2447    ///
2448    /// ## Thread safety
2449    /// Only one thread should be using the `src` and `dst` surfaces
2450    ///   at any given time.
2451    ///
2452    /// ## Availability
2453    /// This function is available since SDL 3.2.0.
2454    ///
2455    /// ## See also
2456    /// - [`SDL_BlitSurface`]
2457    pub fn SDL_BlitSurfaceTiled(
2458        src: *mut SDL_Surface,
2459        srcrect: *const SDL_Rect,
2460        dst: *mut SDL_Surface,
2461        dstrect: *const SDL_Rect,
2462    ) -> ::core::primitive::bool;
2463}
2464
2465unsafe extern "C" {
2466    /// Perform a scaled and tiled blit to a destination surface, which may be of a
2467    /// different format.
2468    ///
2469    /// The pixels in `srcrect` will be scaled and repeated as many times as needed
2470    /// to completely fill `dstrect`.
2471    ///
2472    /// ## Parameters
2473    /// - `src`: the [`SDL_Surface`] structure to be copied from.
2474    /// - `srcrect`: the [`SDL_Rect`] structure representing the rectangle to be
2475    ///   copied, or NULL to copy the entire surface.
2476    /// - `scale`: the scale used to transform srcrect into the destination
2477    ///   rectangle, e.g. a 32x32 texture with a scale of 2 would fill
2478    ///   64x64 tiles.
2479    /// - `scaleMode`: scale algorithm to be used.
2480    /// - `dst`: the [`SDL_Surface`] structure that is the blit target.
2481    /// - `dstrect`: the [`SDL_Rect`] structure representing the target rectangle in
2482    ///   the destination surface, or NULL to fill the entire surface.
2483    ///
2484    /// ## Return value
2485    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2486    ///   information.
2487    ///
2488    /// ## Thread safety
2489    /// Only one thread should be using the `src` and `dst` surfaces
2490    ///   at any given time.
2491    ///
2492    /// ## Availability
2493    /// This function is available since SDL 3.2.0.
2494    ///
2495    /// ## See also
2496    /// - [`SDL_BlitSurface`]
2497    pub fn SDL_BlitSurfaceTiledWithScale(
2498        src: *mut SDL_Surface,
2499        srcrect: *const SDL_Rect,
2500        scale: ::core::ffi::c_float,
2501        scaleMode: SDL_ScaleMode,
2502        dst: *mut SDL_Surface,
2503        dstrect: *const SDL_Rect,
2504    ) -> ::core::primitive::bool;
2505}
2506
2507unsafe extern "C" {
2508    /// Perform a scaled blit using the 9-grid algorithm to a destination surface,
2509    /// which may be of a different format.
2510    ///
2511    /// The pixels in the source surface are split into a 3x3 grid, using the
2512    /// different corner sizes for each corner, and the sides and center making up
2513    /// the remaining pixels. The corners are then scaled using `scale` and fit
2514    /// into the corners of the destination rectangle. The sides and center are
2515    /// then stretched into place to cover the remaining destination rectangle.
2516    ///
2517    /// ## Parameters
2518    /// - `src`: the [`SDL_Surface`] structure to be copied from.
2519    /// - `srcrect`: the [`SDL_Rect`] structure representing the rectangle to be used
2520    ///   for the 9-grid, or NULL to use the entire surface.
2521    /// - `left_width`: the width, in pixels, of the left corners in `srcrect`.
2522    /// - `right_width`: the width, in pixels, of the right corners in `srcrect`.
2523    /// - `top_height`: the height, in pixels, of the top corners in `srcrect`.
2524    /// - `bottom_height`: the height, in pixels, of the bottom corners in
2525    ///   `srcrect`.
2526    /// - `scale`: the scale used to transform the corner of `srcrect` into the
2527    ///   corner of `dstrect`, or 0.0f for an unscaled blit.
2528    /// - `scaleMode`: scale algorithm to be used.
2529    /// - `dst`: the [`SDL_Surface`] structure that is the blit target.
2530    /// - `dstrect`: the [`SDL_Rect`] structure representing the target rectangle in
2531    ///   the destination surface, or NULL to fill the entire surface.
2532    ///
2533    /// ## Return value
2534    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2535    ///   information.
2536    ///
2537    /// ## Thread safety
2538    /// Only one thread should be using the `src` and `dst` surfaces
2539    ///   at any given time.
2540    ///
2541    /// ## Availability
2542    /// This function is available since SDL 3.2.0.
2543    ///
2544    /// ## See also
2545    /// - [`SDL_BlitSurface`]
2546    pub fn SDL_BlitSurface9Grid(
2547        src: *mut SDL_Surface,
2548        srcrect: *const SDL_Rect,
2549        left_width: ::core::ffi::c_int,
2550        right_width: ::core::ffi::c_int,
2551        top_height: ::core::ffi::c_int,
2552        bottom_height: ::core::ffi::c_int,
2553        scale: ::core::ffi::c_float,
2554        scaleMode: SDL_ScaleMode,
2555        dst: *mut SDL_Surface,
2556        dstrect: *const SDL_Rect,
2557    ) -> ::core::primitive::bool;
2558}
2559
2560unsafe extern "C" {
2561    /// Map an RGB triple to an opaque pixel value for a surface.
2562    ///
2563    /// This function maps the RGB color value to the specified pixel format and
2564    /// returns the pixel value best approximating the given RGB color value for
2565    /// the given pixel format.
2566    ///
2567    /// If the surface has a palette, the index of the closest matching color in
2568    /// the palette will be returned.
2569    ///
2570    /// If the surface pixel format has an alpha component it will be returned as
2571    /// all 1 bits (fully opaque).
2572    ///
2573    /// If the pixel format bpp (color depth) is less than 32-bpp then the unused
2574    /// upper bits of the return value can safely be ignored (e.g., with a 16-bpp
2575    /// format the return value can be assigned to a Uint16, and similarly a Uint8
2576    /// for an 8-bpp format).
2577    ///
2578    /// ## Parameters
2579    /// - `surface`: the surface to use for the pixel format and palette.
2580    /// - `r`: the red component of the pixel in the range 0-255.
2581    /// - `g`: the green component of the pixel in the range 0-255.
2582    /// - `b`: the blue component of the pixel in the range 0-255.
2583    ///
2584    /// ## Return value
2585    /// Returns a pixel value.
2586    ///
2587    /// ## Thread safety
2588    /// This function can be called on different threads with
2589    ///   different surfaces.
2590    ///
2591    /// ## Availability
2592    /// This function is available since SDL 3.2.0.
2593    ///
2594    /// ## See also
2595    /// - [`SDL_MapSurfaceRGBA`]
2596    pub fn SDL_MapSurfaceRGB(surface: *mut SDL_Surface, r: Uint8, g: Uint8, b: Uint8) -> Uint32;
2597}
2598
2599unsafe extern "C" {
2600    /// Map an RGBA quadruple to a pixel value for a surface.
2601    ///
2602    /// This function maps the RGBA color value to the specified pixel format and
2603    /// returns the pixel value best approximating the given RGBA color value for
2604    /// the given pixel format.
2605    ///
2606    /// If the surface pixel format has no alpha component the alpha value will be
2607    /// ignored (as it will be in formats with a palette).
2608    ///
2609    /// If the surface has a palette, the index of the closest matching color in
2610    /// the palette will be returned.
2611    ///
2612    /// If the pixel format bpp (color depth) is less than 32-bpp then the unused
2613    /// upper bits of the return value can safely be ignored (e.g., with a 16-bpp
2614    /// format the return value can be assigned to a Uint16, and similarly a Uint8
2615    /// for an 8-bpp format).
2616    ///
2617    /// ## Parameters
2618    /// - `surface`: the surface to use for the pixel format and palette.
2619    /// - `r`: the red component of the pixel in the range 0-255.
2620    /// - `g`: the green component of the pixel in the range 0-255.
2621    /// - `b`: the blue component of the pixel in the range 0-255.
2622    /// - `a`: the alpha component of the pixel in the range 0-255.
2623    ///
2624    /// ## Return value
2625    /// Returns a pixel value.
2626    ///
2627    /// ## Thread safety
2628    /// This function can be called on different threads with
2629    ///   different surfaces.
2630    ///
2631    /// ## Availability
2632    /// This function is available since SDL 3.2.0.
2633    ///
2634    /// ## See also
2635    /// - [`SDL_MapSurfaceRGB`]
2636    pub fn SDL_MapSurfaceRGBA(
2637        surface: *mut SDL_Surface,
2638        r: Uint8,
2639        g: Uint8,
2640        b: Uint8,
2641        a: Uint8,
2642    ) -> Uint32;
2643}
2644
2645unsafe extern "C" {
2646    /// Retrieves a single pixel from a surface.
2647    ///
2648    /// This function prioritizes correctness over speed: it is suitable for unit
2649    /// tests, but is not intended for use in a game engine.
2650    ///
2651    /// Like [`SDL_GetRGBA`], this uses the entire 0..255 range when converting color
2652    /// components from pixel formats with less than 8 bits per RGB component.
2653    ///
2654    /// ## Parameters
2655    /// - `surface`: the surface to read.
2656    /// - `x`: the horizontal coordinate, 0 <= x < width.
2657    /// - `y`: the vertical coordinate, 0 <= y < height.
2658    /// - `r`: a pointer filled in with the red channel, 0-255, or NULL to ignore
2659    ///   this channel.
2660    /// - `g`: a pointer filled in with the green channel, 0-255, or NULL to
2661    ///   ignore this channel.
2662    /// - `b`: a pointer filled in with the blue channel, 0-255, or NULL to
2663    ///   ignore this channel.
2664    /// - `a`: a pointer filled in with the alpha channel, 0-255, or NULL to
2665    ///   ignore this channel.
2666    ///
2667    /// ## Return value
2668    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2669    ///   information.
2670    ///
2671    /// ## Thread safety
2672    /// This function can be called on different threads with
2673    ///   different surfaces.
2674    ///
2675    /// ## Availability
2676    /// This function is available since SDL 3.2.0.
2677    pub fn SDL_ReadSurfacePixel(
2678        surface: *mut SDL_Surface,
2679        x: ::core::ffi::c_int,
2680        y: ::core::ffi::c_int,
2681        r: *mut Uint8,
2682        g: *mut Uint8,
2683        b: *mut Uint8,
2684        a: *mut Uint8,
2685    ) -> ::core::primitive::bool;
2686}
2687
2688unsafe extern "C" {
2689    /// Retrieves a single pixel from a surface.
2690    ///
2691    /// This function prioritizes correctness over speed: it is suitable for unit
2692    /// tests, but is not intended for use in a game engine.
2693    ///
2694    /// ## Parameters
2695    /// - `surface`: the surface to read.
2696    /// - `x`: the horizontal coordinate, 0 <= x < width.
2697    /// - `y`: the vertical coordinate, 0 <= y < height.
2698    /// - `r`: a pointer filled in with the red channel, normally in the range
2699    ///   0-1, or NULL to ignore this channel.
2700    /// - `g`: a pointer filled in with the green channel, normally in the range
2701    ///   0-1, or NULL to ignore this channel.
2702    /// - `b`: a pointer filled in with the blue channel, normally in the range
2703    ///   0-1, or NULL to ignore this channel.
2704    /// - `a`: a pointer filled in with the alpha channel, normally in the range
2705    ///   0-1, or NULL to ignore this channel.
2706    ///
2707    /// ## Return value
2708    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2709    ///   information.
2710    ///
2711    /// ## Thread safety
2712    /// This function can be called on different threads with
2713    ///   different surfaces.
2714    ///
2715    /// ## Availability
2716    /// This function is available since SDL 3.2.0.
2717    pub fn SDL_ReadSurfacePixelFloat(
2718        surface: *mut SDL_Surface,
2719        x: ::core::ffi::c_int,
2720        y: ::core::ffi::c_int,
2721        r: *mut ::core::ffi::c_float,
2722        g: *mut ::core::ffi::c_float,
2723        b: *mut ::core::ffi::c_float,
2724        a: *mut ::core::ffi::c_float,
2725    ) -> ::core::primitive::bool;
2726}
2727
2728unsafe extern "C" {
2729    /// Writes a single pixel to a surface.
2730    ///
2731    /// This function prioritizes correctness over speed: it is suitable for unit
2732    /// tests, but is not intended for use in a game engine.
2733    ///
2734    /// Like [`SDL_MapRGBA`], this uses the entire 0..255 range when converting color
2735    /// components from pixel formats with less than 8 bits per RGB component.
2736    ///
2737    /// ## Parameters
2738    /// - `surface`: the surface to write.
2739    /// - `x`: the horizontal coordinate, 0 <= x < width.
2740    /// - `y`: the vertical coordinate, 0 <= y < height.
2741    /// - `r`: the red channel value, 0-255.
2742    /// - `g`: the green channel value, 0-255.
2743    /// - `b`: the blue channel value, 0-255.
2744    /// - `a`: the alpha channel value, 0-255.
2745    ///
2746    /// ## Return value
2747    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2748    ///   information.
2749    ///
2750    /// ## Thread safety
2751    /// This function can be called on different threads with
2752    ///   different surfaces.
2753    ///
2754    /// ## Availability
2755    /// This function is available since SDL 3.2.0.
2756    pub fn SDL_WriteSurfacePixel(
2757        surface: *mut SDL_Surface,
2758        x: ::core::ffi::c_int,
2759        y: ::core::ffi::c_int,
2760        r: Uint8,
2761        g: Uint8,
2762        b: Uint8,
2763        a: Uint8,
2764    ) -> ::core::primitive::bool;
2765}
2766
2767unsafe extern "C" {
2768    /// Writes a single pixel to a surface.
2769    ///
2770    /// This function prioritizes correctness over speed: it is suitable for unit
2771    /// tests, but is not intended for use in a game engine.
2772    ///
2773    /// ## Parameters
2774    /// - `surface`: the surface to write.
2775    /// - `x`: the horizontal coordinate, 0 <= x < width.
2776    /// - `y`: the vertical coordinate, 0 <= y < height.
2777    /// - `r`: the red channel value, normally in the range 0-1.
2778    /// - `g`: the green channel value, normally in the range 0-1.
2779    /// - `b`: the blue channel value, normally in the range 0-1.
2780    /// - `a`: the alpha channel value, normally in the range 0-1.
2781    ///
2782    /// ## Return value
2783    /// Returns true on success or false on failure; call [`SDL_GetError()`] for more
2784    ///   information.
2785    ///
2786    /// ## Thread safety
2787    /// This function can be called on different threads with
2788    ///   different surfaces.
2789    ///
2790    /// ## Availability
2791    /// This function is available since SDL 3.2.0.
2792    pub fn SDL_WriteSurfacePixelFloat(
2793        surface: *mut SDL_Surface,
2794        x: ::core::ffi::c_int,
2795        y: ::core::ffi::c_int,
2796        r: ::core::ffi::c_float,
2797        g: ::core::ffi::c_float,
2798        b: ::core::ffi::c_float,
2799        a: ::core::ffi::c_float,
2800    ) -> ::core::primitive::bool;
2801}
2802
2803#[cfg(doc)]
2804use crate::everything::*;