File tree Expand file tree Collapse file tree 2 files changed +2
-8
lines changed Expand file tree Collapse file tree 2 files changed +2
-8
lines changed Original file line number Diff line number Diff line change 1
- use std:: time:: Instant ;
2
1
use winit:: event:: { Event , WindowEvent } ;
3
2
use winit:: event_loop:: { ControlFlow , EventLoop } ;
4
3
use winit:: window:: WindowBuilder ;
@@ -20,10 +19,7 @@ fn main() {
20
19
} ;
21
20
let buffer = vec ! [ 0x00FF00FF ; ( width * height) as usize ] ;
22
21
23
- let start = Instant :: now ( ) ;
24
22
graphics_context. set_buffer ( & buffer, width as u16 , height as u16 ) ;
25
- let elapsed = Instant :: now ( ) -start;
26
- println ! ( "Set in: {}ms" , elapsed. as_millis( ) ) ;
27
23
}
28
24
Event :: WindowEvent {
29
25
event : WindowEvent :: CloseRequested ,
Original file line number Diff line number Diff line change @@ -34,17 +34,14 @@ impl X11Impl {
34
34
impl GraphicsContextImpl for X11Impl {
35
35
36
36
unsafe fn set_buffer ( & mut self , buffer : & [ u32 ] , width : u16 , height : u16 ) {
37
- let mut owned_buffer = vec ! [ 0 ; ( width as usize ) * ( height as usize ) ] ;
38
- owned_buffer. copy_from_slice ( buffer) ;
39
-
40
37
//create image
41
38
let image = ( self . lib . XCreateImage ) (
42
39
self . handle . display as * mut Display ,
43
40
self . visual ,
44
41
self . depth as u32 ,
45
42
ZPixmap ,
46
43
0 ,
47
- Box :: leak ( owned_buffer . into_boxed_slice ( ) ) . as_mut_ptr ( ) as * mut c_char ,
44
+ ( buffer . as_ptr ( ) ) as * mut c_char ,
48
45
width as u32 ,
49
46
height as u32 ,
50
47
32 ,
@@ -69,6 +66,7 @@ impl GraphicsContextImpl for X11Impl {
69
66
height as c_uint
70
67
) ;
71
68
69
+ ( * image) . data = std:: ptr:: null_mut ( ) ;
72
70
( self . lib . XDestroyImage ) ( image) ;
73
71
}
74
72
You can’t perform that action at this time.
0 commit comments