From 39cd8372f5e2841bc2cc8e8d5ae047b60520b775 Mon Sep 17 00:00:00 2001 From: Andres Date: Mon, 1 May 2017 02:53:27 -0700 Subject: [PATCH] remove TextureOwner trait --- src/sdl2/render.rs | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/sdl2/render.rs b/src/sdl2/render.rs index b85737da..f451770d 100644 --- a/src/sdl2/render.rs +++ b/src/sdl2/render.rs @@ -254,7 +254,7 @@ impl<'s> RenderTarget for Surface<'s> { type Context = SurfaceContext<'s>; } -impl<'r, 't, TC: TextureOwner> RenderTarget for TextureTarget<'r, 't, TC> { +impl<'r, 't, TC> RenderTarget for TextureTarget<'r, 't, TC> { type Context = TC; } @@ -440,9 +440,7 @@ impl Canvas { } } -impl Canvas - where T::Context: TextureOwner -{ +impl Canvas { /// Determine whether a window supports the use of render targets. pub fn render_target_supported(&self) -> bool { unsafe { ll::SDL_RenderTargetSupported(self.context.raw) == 1 } @@ -720,7 +718,7 @@ impl TextureCreator { } } -pub struct TextureTarget<'r, 't, TC: TextureOwner> { +pub struct TextureTarget<'r, 't, TC> { raw_renderer: &'r *mut ll::SDL_Renderer, _texture_marker: PhantomData<&'t ()>, // unfortunately there is no way to know which kind of Renderer we have here at compile time, @@ -728,16 +726,7 @@ pub struct TextureTarget<'r, 't, TC: TextureOwner> { _texture_target: PhantomData, } -/// Represents structs that are the "source" of the Renderer. -/// -/// You should *not* implement this trait outside of this crate. -pub trait TextureOwner {} - -impl<'s> TextureOwner for SurfaceContext<'s> {} - -impl TextureOwner for WindowContext {} - -impl<'r, 't, TC: TextureOwner> Drop for TextureTarget<'r, 't, TC> { +impl<'r, 't, TC> Drop for TextureTarget<'r, 't, TC> { // `Drop` cannot be specialized. Get around this through run-time check of Target Kind fn drop(&mut self) { unsafe { @@ -1192,7 +1181,7 @@ impl Canvas { /// ``` pub type TextureCanvas<'r, 't, TC> = Canvas>; -impl<'r, 't, TC: TextureOwner> Canvas> { +impl<'r, 't, TC> Canvas> { /// Replace the target of the `TextureCanvas` with a different `Texture` /// /// Returns the new `TextureCanvas` and releases the `&mut` borrow on the old `Texture`