mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Create a cairo surface from the SDL surface
This commit is contained in:
parent
4afdbe89c2
commit
52034ec12c
2 changed files with 15 additions and 4 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 3e500c5dab572358ed8b42268e3ad67138b0e95e
|
||||
Subproject commit a0b609597d8fdae8c46152bf72ae4a80ce06adfe
|
|
@ -1,4 +1,5 @@
|
|||
import azure::cairo;
|
||||
import azure::cairo::bindgen::*;
|
||||
|
||||
fn on_main(f: fn~()) {
|
||||
let builder = task::builder();
|
||||
|
@ -23,7 +24,7 @@ fn main() {
|
|||
[sdl::video::swsurface],
|
||||
[sdl::video::doublebuf]);
|
||||
assert ptr::is_not_null(screen);
|
||||
let surface = sdl::video::create_rgb_surface(
|
||||
let sdl_surf = sdl::video::create_rgb_surface(
|
||||
[sdl::video::swsurface],
|
||||
320, 200, 32,
|
||||
0x00FF0000u32,
|
||||
|
@ -31,14 +32,24 @@ fn main() {
|
|||
0x000000FFu32,
|
||||
0x00000000u32
|
||||
);
|
||||
assert ptr::is_not_null(surface);
|
||||
assert ptr::is_not_null(sdl_surf);
|
||||
let cairo_surf = unsafe {
|
||||
cairo_image_surface_create_for_data(
|
||||
unsafe::reinterpret_cast((*sdl_surf).pixels),
|
||||
cairo::CAIRO_FORMAT_RGB24,
|
||||
(*sdl_surf).w,
|
||||
(*sdl_surf).h,
|
||||
(*sdl_surf).pitch as libc::c_int
|
||||
)
|
||||
};
|
||||
loop {
|
||||
sdl::video::blit_surface(surface, ptr::null(),
|
||||
sdl::video::blit_surface(sdl_surf, ptr::null(),
|
||||
screen, ptr::null());
|
||||
sdl::video::flip(screen);
|
||||
sdl::event::poll_event {|_event|
|
||||
}
|
||||
}
|
||||
cairo_surface_destroy(cairo_surf);
|
||||
sdl::quit();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue