mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Implement image surfaces
This commit is contained in:
parent
b6f3bda0a4
commit
65fea92d7d
2 changed files with 29 additions and 2 deletions
|
@ -5,6 +5,12 @@ type rect<A> = { mut origin: point<A>, mut size: size<A> };
|
||||||
|
|
||||||
enum au = int;
|
enum au = int;
|
||||||
|
|
||||||
|
impl size for size<int> {
|
||||||
|
fn area() -> int {
|
||||||
|
self.width * self.height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn point<A:copy>(x: A, y: A) -> point<A> {
|
fn point<A:copy>(x: A, y: A) -> point<A> {
|
||||||
{mut x: x, mut y: y}
|
{mut x: x, mut y: y}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,30 @@
|
||||||
|
import gfx::geom;
|
||||||
|
import gfx::geom::size;
|
||||||
|
|
||||||
enum format {
|
enum format {
|
||||||
fo_rgba_8888
|
fo_rgba_8888
|
||||||
// TODO: RGB 565, others?
|
// TODO: RGB 565, others?
|
||||||
}
|
}
|
||||||
|
|
||||||
type surface = {
|
type image_surface = {
|
||||||
format: format
|
size: geom::size<int>,
|
||||||
|
format: format,
|
||||||
|
buffer: [u8]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
impl format for format {
|
||||||
|
fn bpp() -> uint {
|
||||||
|
alt self {
|
||||||
|
fo_rgba_8888 { 32u }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn image_surface(size: geom::size<int>, format: format) -> image_surface {
|
||||||
|
{
|
||||||
|
size: size,
|
||||||
|
format: format,
|
||||||
|
buffer: vec::from_elem((size.area() as uint) * format.bpp(), 0u8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue