| 1 |
// Take a look at the license at the top of the repository in the LICENSE file. |
| 2 |
|
| 3 |
use std::ops::Deref; |
| 4 |
|
| 5 |
pub use ffi::windows; |
| 6 |
#[cfg(feature = "use_glib")] |
| 7 |
use glib::translate::*; |
| 8 |
|
| 9 |
use crate::{Error, Format, Surface, SurfaceType, ffi}; |
| 10 |
|
| 11 |
declare_surface!(Win32Surface, SurfaceType::Win32); |
| 12 |
|
| 13 |
impl Win32Surface { |
| 14 |
#[doc(alias = "cairo_win32_surface_create")] |
| 15 |
pub fn create(hdc: windows::HDC) -> Result<Win32Surface, Error> { |
| 16 |
unsafe { Self::from_raw_full(ffi::cairo_win32_surface_create(hdc)) } |
| 17 |
} |
| 18 |
|
| 19 |
#[doc(alias = "cairo_win32_surface_create_with_format")] |
| 20 |
pub fn create_with_format(hdc: windows::HDC, format: Format) -> Result<Win32Surface, Error> { |
| 21 |
unsafe { |
| 22 |
Self::from_raw_full(ffi::cairo_win32_surface_create_with_format( |
| 23 |
hdc, |
| 24 |
format.into(), |
| 25 |
)) |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
#[doc(alias = "cairo_win32_surface_create_with_dib")] |
| 30 |
pub fn create_with_dib(format: Format, width: i32, height: i32) -> Result<Win32Surface, Error> { |
| 31 |
unsafe { |
| 32 |
Self::from_raw_full(ffi::cairo_win32_surface_create_with_dib( |
| 33 |
format.into(), |
| 34 |
width, |
| 35 |
height, |
| 36 |
)) |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
#[doc(alias = "cairo_win32_surface_create_with_ddb")] |
| 41 |
pub fn create_with_ddb( |
| 42 |
hdc: windows::HDC, |
| 43 |
format: Format, |
| 44 |
width: i32, |
| 45 |
height: i32, |
| 46 |
) -> Result<Win32Surface, Error> { |
| 47 |
unsafe { |
| 48 |
Self::from_raw_full(ffi::cairo_win32_surface_create_with_ddb( |
| 49 |
hdc, |
| 50 |
format.into(), |
| 51 |
width, |
| 52 |
height, |
| 53 |
)) |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
#[doc(alias = "cairo_win32_printing_surface_create")] |
| 58 |
pub fn printing_surface_create(hdc: windows::HDC) -> Result<Win32Surface, Error> { |
| 59 |
unsafe { Self::from_raw_full(ffi::cairo_win32_printing_surface_create(hdc)) } |
| 60 |
} |
| 61 |
} |