1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use crate::color::BlendMode;
use crate::{bind, Sdl};
use super::{RawSurface, Surface};
#[derive(Debug)]
pub struct Blended<S> {
surface: S,
mode: BlendMode,
}
impl<S> Blended<S> {
pub fn blend_mode(&self) -> &BlendMode {
&self.mode
}
}
impl<S: Surface> Blended<S> {
pub(super) fn new(surface: S, mode: BlendMode) -> Self {
let raw_mode = mode.into();
unsafe {
let ret = bind::SDL_SetSurfaceBlendMode(surface.as_ptr().as_ptr(), raw_mode);
if ret != 0 {
Sdl::error_then_panic("Setting surface blend mode");
}
}
Self { surface, mode }
}
}
impl<S: Surface> Surface for Blended<S> {
fn as_ptr(&self) -> std::ptr::NonNull<RawSurface> {
self.surface.as_ptr()
}
}