mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Finally draw using azure
This commit is contained in:
parent
aa38e657dc
commit
1fdc9c6235
1 changed files with 14 additions and 9 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import libc::c_double;
|
||||||
import azure::bindgen::*;
|
import azure::bindgen::*;
|
||||||
import azure::cairo;
|
import azure::cairo;
|
||||||
import azure::cairo::bindgen::*;
|
import azure::cairo::bindgen::*;
|
||||||
|
@ -34,6 +35,7 @@ fn main() {
|
||||||
0x00000000u32
|
0x00000000u32
|
||||||
);
|
);
|
||||||
assert !sdl_surf.is_null();
|
assert !sdl_surf.is_null();
|
||||||
|
sdl::video::lock_surface(sdl_surf);
|
||||||
let cairo_surf = unsafe {
|
let cairo_surf = unsafe {
|
||||||
cairo_image_surface_create_for_data(
|
cairo_image_surface_create_for_data(
|
||||||
unsafe::reinterpret_cast((*sdl_surf).pixels),
|
unsafe::reinterpret_cast((*sdl_surf).pixels),
|
||||||
|
@ -48,27 +50,29 @@ fn main() {
|
||||||
assert !azure_target.is_null();
|
assert !azure_target.is_null();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
let color = {
|
||||||
|
r: 1f as azure::Float,
|
||||||
|
g: 1f as azure::Float,
|
||||||
|
b: 1f as azure::Float,
|
||||||
|
a: 0.5f as azure::Float
|
||||||
|
};
|
||||||
|
let pattern = CreateColorPattern(ptr::addr_of(color));
|
||||||
let rect = {
|
let rect = {
|
||||||
x: 200f as azure::Float,
|
x: 100f as azure::Float,
|
||||||
y: 200f as azure::Float,
|
y: 100f as azure::Float,
|
||||||
width: 100f as azure::Float,
|
width: 100f as azure::Float,
|
||||||
height: 100f as azure::Float
|
height: 100f as azure::Float
|
||||||
};
|
};
|
||||||
let color = {
|
|
||||||
r: 0f as azure::Float,
|
|
||||||
g: 1f as azure::Float,
|
|
||||||
b: 0f as azure::Float,
|
|
||||||
a: 1f as azure::Float
|
|
||||||
};
|
|
||||||
let pattern = CreateColorPattern(ptr::addr_of(color));
|
|
||||||
DrawTargetFillRect(
|
DrawTargetFillRect(
|
||||||
azure_target,
|
azure_target,
|
||||||
ptr::addr_of(rect),
|
ptr::addr_of(rect),
|
||||||
unsafe { unsafe::reinterpret_cast(pattern) });
|
unsafe { unsafe::reinterpret_cast(pattern) });
|
||||||
ReleaseColorPattern(pattern);
|
ReleaseColorPattern(pattern);
|
||||||
|
|
||||||
|
sdl::video::unlock_surface(sdl_surf);
|
||||||
sdl::video::blit_surface(sdl_surf, ptr::null(),
|
sdl::video::blit_surface(sdl_surf, ptr::null(),
|
||||||
screen, ptr::null());
|
screen, ptr::null());
|
||||||
|
sdl::video::lock_surface(sdl_surf);
|
||||||
sdl::video::flip(screen);
|
sdl::video::flip(screen);
|
||||||
let mut mustbreak = false;
|
let mut mustbreak = false;
|
||||||
sdl::event::poll_event {|event|
|
sdl::event::poll_event {|event|
|
||||||
|
@ -81,6 +85,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
ReleaseDrawTarget(azure_target);
|
ReleaseDrawTarget(azure_target);
|
||||||
cairo_surface_destroy(cairo_surf);
|
cairo_surface_destroy(cairo_surf);
|
||||||
|
sdl::video::unlock_surface(sdl_surf);
|
||||||
sdl::quit();
|
sdl::quit();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue