Skip to content

Commit 468cf78

Browse files
authored
Rename lifetime Buffer<'a> to Buffer<'surface> (#330)
To make it clearer that the buffer borrows from the surface.
1 parent 061aca8 commit 468cf78

File tree

11 files changed

+70
-70
lines changed

11 files changed

+70
-70
lines changed

src/backend_dispatch.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ macro_rules! make_dispatch {
7676

7777
impl<D: HasDisplayHandle, W: HasWindowHandle> SurfaceInterface<D, W> for SurfaceDispatch<D, W> {
7878
type Context = ContextDispatch<D>;
79-
type Buffer<'a> = BufferDispatch<'a> where Self: 'a;
79+
type Buffer<'surface> = BufferDispatch<'surface> where Self: 'surface;
8080

8181
fn new(window: W, display: &Self::Context) -> Result<Self, InitError<W>>
8282
where
@@ -138,7 +138,7 @@ macro_rules! make_dispatch {
138138
}
139139
}
140140

141-
pub(crate) enum BufferDispatch<'a> {
141+
pub(crate) enum BufferDispatch<'surface> {
142142
$(
143143
$(#[$attr])*
144144
$name($buffer_inner),
@@ -223,7 +223,7 @@ macro_rules! make_dispatch {
223223
make_dispatch! {
224224
<D, W> =>
225225
#[cfg(target_os = "android")]
226-
Android(D, backends::android::AndroidImpl<D, W>, backends::android::BufferImpl<'a>),
226+
Android(D, backends::android::AndroidImpl<D, W>, backends::android::BufferImpl<'surface>),
227227
#[cfg(all(
228228
feature = "x11",
229229
not(any(
@@ -234,7 +234,7 @@ make_dispatch! {
234234
target_os = "windows"
235235
))
236236
))]
237-
X11(std::sync::Arc<backends::x11::X11DisplayImpl<D>>, backends::x11::X11Impl<D, W>, backends::x11::BufferImpl<'a>),
237+
X11(std::sync::Arc<backends::x11::X11DisplayImpl<D>>, backends::x11::X11Impl<D, W>, backends::x11::BufferImpl<'surface>),
238238
#[cfg(all(
239239
feature = "wayland",
240240
not(any(
@@ -245,7 +245,7 @@ make_dispatch! {
245245
target_os = "windows"
246246
))
247247
))]
248-
Wayland(std::sync::Arc<backends::wayland::WaylandDisplayImpl<D>>, backends::wayland::WaylandImpl<D, W>, backends::wayland::BufferImpl<'a>),
248+
Wayland(std::sync::Arc<backends::wayland::WaylandDisplayImpl<D>>, backends::wayland::WaylandImpl<D, W>, backends::wayland::BufferImpl<'surface>),
249249
#[cfg(all(
250250
feature = "kms",
251251
not(any(
@@ -256,13 +256,13 @@ make_dispatch! {
256256
target_os = "windows"
257257
))
258258
))]
259-
Kms(std::sync::Arc<backends::kms::KmsDisplayImpl<D>>, backends::kms::KmsImpl<D, W>, backends::kms::BufferImpl<'a>),
259+
Kms(std::sync::Arc<backends::kms::KmsDisplayImpl<D>>, backends::kms::KmsImpl<D, W>, backends::kms::BufferImpl<'surface>),
260260
#[cfg(target_os = "windows")]
261-
Win32(D, backends::win32::Win32Impl<D, W>, backends::win32::BufferImpl<'a>),
261+
Win32(D, backends::win32::Win32Impl<D, W>, backends::win32::BufferImpl<'surface>),
262262
#[cfg(target_vendor = "apple")]
263-
CoreGraphics(D, backends::cg::CGImpl<D, W>, backends::cg::BufferImpl<'a>),
263+
CoreGraphics(D, backends::cg::CGImpl<D, W>, backends::cg::BufferImpl<'surface>),
264264
#[cfg(target_family = "wasm")]
265-
Web(backends::web::WebDisplayImpl<D>, backends::web::WebImpl<D, W>, backends::web::BufferImpl<'a>),
265+
Web(backends::web::WebDisplayImpl<D>, backends::web::WebImpl<D, W>, backends::web::BufferImpl<'surface>),
266266
#[cfg(target_os = "redox")]
267-
Orbital(D, backends::orbital::OrbitalImpl<D, W>, backends::orbital::BufferImpl<'a>),
267+
Orbital(D, backends::orbital::OrbitalImpl<D, W>, backends::orbital::BufferImpl<'surface>),
268268
}

src/backend_interface.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ pub(crate) trait ContextInterface<D: HasDisplayHandle + ?Sized> {
1414

1515
pub(crate) trait SurfaceInterface<D: HasDisplayHandle + ?Sized, W: HasWindowHandle + ?Sized> {
1616
type Context: ContextInterface<D>;
17-
type Buffer<'a>: BufferInterface
17+
type Buffer<'surface>: BufferInterface
1818
where
19-
Self: 'a;
19+
Self: 'surface;
2020

2121
fn new(window: W, context: &Self::Context) -> Result<Self, InitError<W>>
2222
where

src/backends/android.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ pub struct AndroidImpl<D, W> {
2424

2525
impl<D: HasDisplayHandle, W: HasWindowHandle> SurfaceInterface<D, W> for AndroidImpl<D, W> {
2626
type Context = D;
27-
type Buffer<'a>
28-
= BufferImpl<'a>
27+
type Buffer<'surface>
28+
= BufferImpl<'surface>
2929
where
30-
Self: 'a;
30+
Self: 'surface;
3131

3232
/// Create a new [`AndroidImpl`] from an [`AndroidNdkWindowHandle`].
3333
fn new(window: W, _display: &Self::Context) -> Result<Self, InitError<W>> {
@@ -115,8 +115,8 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> SurfaceInterface<D, W> for Android
115115
}
116116

117117
#[derive(Debug)]
118-
pub struct BufferImpl<'a> {
119-
native_window_buffer: NativeWindowBufferLockGuard<'a>,
118+
pub struct BufferImpl<'surface> {
119+
native_window_buffer: NativeWindowBufferLockGuard<'surface>,
120120
buffer: util::PixelBuffer,
121121
}
122122

src/backends/cg.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ impl<D, W> Drop for CGImpl<D, W> {
126126

127127
impl<D: HasDisplayHandle, W: HasWindowHandle> SurfaceInterface<D, W> for CGImpl<D, W> {
128128
type Context = D;
129-
type Buffer<'a>
130-
= BufferImpl<'a>
129+
type Buffer<'surface>
130+
= BufferImpl<'surface>
131131
where
132-
Self: 'a;
132+
Self: 'surface;
133133

134134
fn new(window_src: W, _display: &D) -> Result<Self, InitError<W>> {
135135
// `NSView`/`UIView` can only be accessed from the main thread.
@@ -271,12 +271,12 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> SurfaceInterface<D, W> for CGImpl<
271271
}
272272

273273
#[derive(Debug)]
274-
pub struct BufferImpl<'a> {
274+
pub struct BufferImpl<'surface> {
275275
width: usize,
276276
height: usize,
277-
color_space: &'a CGColorSpace,
277+
color_space: &'surface CGColorSpace,
278278
buffer: util::PixelBuffer,
279-
layer: &'a mut SendCALayer,
279+
layer: &'surface mut SendCALayer,
280280
}
281281

282282
impl BufferInterface for BufferImpl<'_> {

src/backends/kms.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ use crate::error::{InitError, SoftBufferError, SwResultExt};
2424
use crate::{util, Pixel};
2525

2626
#[derive(Debug, Clone)]
27-
struct DrmDevice<'a> {
27+
struct DrmDevice<'surface> {
2828
/// The underlying raw display file descriptor.
29-
fd: BorrowedFd<'a>,
29+
fd: BorrowedFd<'surface>,
3030
}
3131

3232
impl AsFd for DrmDevice<'_> {
@@ -97,9 +97,9 @@ struct Buffers {
9797
}
9898

9999
/// The buffer implementation.
100-
pub(crate) struct BufferImpl<'a> {
100+
pub(crate) struct BufferImpl<'surface> {
101101
/// The mapping of the dump buffer.
102-
mapping: DumbMapping<'a>,
102+
mapping: DumbMapping<'surface>,
103103

104104
/// The framebuffer object of the current front buffer.
105105
front_fb: framebuffer::Handle,
@@ -108,19 +108,19 @@ pub(crate) struct BufferImpl<'a> {
108108
crtc_handle: crtc::Handle,
109109

110110
/// This is used to change the front buffer.
111-
first_is_front: &'a mut bool,
111+
first_is_front: &'surface mut bool,
112112

113113
/// The current size.
114114
size: (NonZeroU32, NonZeroU32),
115115

116116
/// The device file descriptor.
117-
device: DrmDevice<'a>,
117+
device: DrmDevice<'surface>,
118118

119119
/// Age of the front buffer.
120-
front_age: &'a mut u8,
120+
front_age: &'surface mut u8,
121121

122122
/// Age of the back buffer.
123-
back_age: &'a mut u8,
123+
back_age: &'surface mut u8,
124124
}
125125

126126
impl fmt::Debug for BufferImpl<'_> {
@@ -145,10 +145,10 @@ struct SharedBuffer {
145145

146146
impl<D: HasDisplayHandle + ?Sized, W: HasWindowHandle> SurfaceInterface<D, W> for KmsImpl<D, W> {
147147
type Context = Arc<KmsDisplayImpl<D>>;
148-
type Buffer<'a>
149-
= BufferImpl<'a>
148+
type Buffer<'surface>
149+
= BufferImpl<'surface>
150150
where
151-
Self: 'a;
151+
Self: 'surface;
152152

153153
/// Create a new KMS backend.
154154
fn new(window: W, display: &Arc<KmsDisplayImpl<D>>) -> Result<Self, InitError<W>> {

src/backends/orbital.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> OrbitalImpl<D, W> {
7575

7676
impl<D: HasDisplayHandle, W: HasWindowHandle> SurfaceInterface<D, W> for OrbitalImpl<D, W> {
7777
type Context = D;
78-
type Buffer<'a>
79-
= BufferImpl<'a>
78+
type Buffer<'surface>
79+
= BufferImpl<'surface>
8080
where
81-
Self: 'a;
81+
Self: 'surface;
8282

8383
fn new(window: W, _display: &D) -> Result<Self, InitError<W>> {
8484
let raw = window.window_handle()?.as_raw();
@@ -144,11 +144,11 @@ enum Pixels {
144144
}
145145

146146
#[derive(Debug)]
147-
pub struct BufferImpl<'a> {
147+
pub struct BufferImpl<'surface> {
148148
window_fd: usize,
149149
width: u32,
150150
height: u32,
151-
presented: &'a mut bool,
151+
presented: &'surface mut bool,
152152
pixels: Pixels,
153153
}
154154

src/backends/wayland/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ impl<D: HasDisplayHandle + ?Sized, W: HasWindowHandle> SurfaceInterface<D, W>
9393
for WaylandImpl<D, W>
9494
{
9595
type Context = Arc<WaylandDisplayImpl<D>>;
96-
type Buffer<'a>
97-
= BufferImpl<'a>
96+
type Buffer<'surface>
97+
= BufferImpl<'surface>
9898
where
99-
Self: 'a;
99+
Self: 'surface;
100100

101101
fn new(window: W, display: &Arc<WaylandDisplayImpl<D>>) -> Result<Self, InitError<W>> {
102102
// Get the raw Wayland window.
@@ -208,11 +208,11 @@ impl<D: ?Sized, W: ?Sized> Drop for WaylandImpl<D, W> {
208208
}
209209

210210
#[derive(Debug)]
211-
pub struct BufferImpl<'a> {
212-
event_queue: &'a Mutex<EventQueue<State>>,
213-
surface: &'a wl_surface::WlSurface,
214-
front: &'a mut WaylandBuffer,
215-
back: &'a mut WaylandBuffer,
211+
pub struct BufferImpl<'surface> {
212+
event_queue: &'surface Mutex<EventQueue<State>>,
213+
surface: &'surface wl_surface::WlSurface,
214+
front: &'surface mut WaylandBuffer,
215+
back: &'surface mut WaylandBuffer,
216216
width: i32,
217217
height: i32,
218218
age: u8,

src/backends/web.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> WebImpl<D, W> {
126126

127127
impl<D: HasDisplayHandle, W: HasWindowHandle> SurfaceInterface<D, W> for WebImpl<D, W> {
128128
type Context = WebDisplayImpl<D>;
129-
type Buffer<'a>
130-
= BufferImpl<'a>
129+
type Buffer<'surface>
130+
= BufferImpl<'surface>
131131
where
132-
Self: 'a;
132+
Self: 'surface;
133133

134134
fn new(window: W, display: &WebDisplayImpl<D>) -> Result<Self, InitError<W>> {
135135
let raw = window.window_handle()?.as_raw();
@@ -304,10 +304,10 @@ impl Canvas {
304304
}
305305

306306
#[derive(Debug)]
307-
pub struct BufferImpl<'a> {
308-
canvas: &'a Canvas,
309-
buffer: &'a mut util::PixelBuffer,
310-
buffer_presented: &'a mut bool,
307+
pub struct BufferImpl<'surface> {
308+
canvas: &'surface Canvas,
309+
buffer: &'surface mut util::PixelBuffer,
310+
buffer_presented: &'surface mut bool,
311311
size: Option<(NonZeroU32, NonZeroU32)>,
312312
}
313313

src/backends/win32.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ struct BitmapInfo {
161161

162162
impl<D: HasDisplayHandle, W: HasWindowHandle> SurfaceInterface<D, W> for Win32Impl<D, W> {
163163
type Context = D;
164-
type Buffer<'a>
165-
= BufferImpl<'a>
164+
type Buffer<'surface>
165+
= BufferImpl<'surface>
166166
where
167-
Self: 'a;
167+
Self: 'surface;
168168

169169
/// Create a new `Win32Impl` from a `Win32WindowHandle`.
170170
fn new(window: W, _display: &D) -> Result<Self, crate::error::InitError<W>> {
@@ -240,10 +240,10 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> SurfaceInterface<D, W> for Win32Im
240240
}
241241

242242
#[derive(Debug)]
243-
pub struct BufferImpl<'a> {
244-
window: &'a OnlyUsedFromOrigin<HWND>,
245-
dc: &'a OnlyUsedFromOrigin<Gdi::HDC>,
246-
buffer: &'a mut Buffer,
243+
pub struct BufferImpl<'surface> {
244+
window: &'surface OnlyUsedFromOrigin<HWND>,
245+
dc: &'surface OnlyUsedFromOrigin<Gdi::HDC>,
246+
buffer: &'surface mut Buffer,
247247
}
248248

249249
impl BufferInterface for BufferImpl<'_> {

src/backends/x11.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@ struct ShmBuffer {
189189

190190
impl<D: HasDisplayHandle + ?Sized, W: HasWindowHandle> SurfaceInterface<D, W> for X11Impl<D, W> {
191191
type Context = Arc<X11DisplayImpl<D>>;
192-
type Buffer<'a>
193-
= BufferImpl<'a>
192+
type Buffer<'surface>
193+
= BufferImpl<'surface>
194194
where
195-
Self: 'a;
195+
Self: 'surface;
196196

197197
/// Create a new `X11Impl` from a `HasWindowHandle`.
198198
fn new(window_src: W, display: &Arc<X11DisplayImpl<D>>) -> Result<Self, InitError<W>> {
@@ -407,14 +407,14 @@ impl<D: HasDisplayHandle + ?Sized, W: HasWindowHandle> SurfaceInterface<D, W> fo
407407
}
408408

409409
#[derive(Debug)]
410-
pub struct BufferImpl<'a> {
410+
pub struct BufferImpl<'surface> {
411411
// Various fields that reference data in `X11Impl`.
412-
connection: &'a XCBConnection,
412+
connection: &'surface XCBConnection,
413413
window: xproto::Window,
414414
gc: xproto::Gcontext,
415415
depth: u8,
416-
buffer: &'a mut Buffer,
417-
buffer_presented: &'a mut bool,
416+
buffer: &'surface mut Buffer,
417+
buffer_presented: &'surface mut bool,
418418
size: Option<(NonZeroU16, NonZeroU16)>,
419419
}
420420

0 commit comments

Comments
 (0)