diff --git a/CHANGELOG.md b/CHANGELOG.md index a94c41d..c4ba1b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,20 @@ ## [Unreleased] +## [0.2.0] - 2018-05-11 + +### Changed + +- Clone is now a weak reference clone +- Lots of api changes + +### Added + +- DeepClone trait for objects that are deep cloneable +- Most Font and Glyph related stuff +- Debug implementation for most types +- Travis CI + ## [0.1.2] - 2018-04-17 ### Changed diff --git a/Cargo.toml b/Cargo.toml index 4a0d7eb..2b9b501 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "blend2d" -version = "0.1.2" +version = "0.2.0" authors = ["Lukas Wirth "] edition = "2018" description = "Rust bindings for blend2d" @@ -12,7 +12,7 @@ readme = "README.md" exclude = ["assets", "examples"] [dependencies] -ffi = { package = "blend2d-sys", version = "0.2.0-pre", path = "blend2d-sys" } +ffi = { package = "blend2d-sys", version = "0.2.0", path = "blend2d-sys" } bitflags = "1.0.4" [[example]] diff --git a/blend2d-sys/Cargo.toml b/blend2d-sys/Cargo.toml index fdb3b6c..c00ce47 100644 --- a/blend2d-sys/Cargo.toml +++ b/blend2d-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "blend2d-sys" -version = "0.2.0-pre" +version = "0.2.0" authors = ["Lukas Wirth "] edition = "2018" description = "Raw ffi bindings for blend2d" @@ -12,5 +12,5 @@ build = "build.rs" links = "blend2d" [build-dependencies] -cmake = "^0.1" -bindgen = "^0.49.0" \ No newline at end of file +cmake = "0.1" +bindgen = "0.49" \ No newline at end of file diff --git a/src/context.rs b/src/context.rs index f908444..356cebf 100644 --- a/src/context.rs +++ b/src/context.rs @@ -1,6 +1,6 @@ use bitflags::bitflags; -use core::{fmt, marker::PhantomData, ptr}; +use core::{fmt, ptr}; use crate::{ array::Array, @@ -160,12 +160,11 @@ pub struct ContextHints { } #[repr(transparent)] -pub struct Context<'a> { +pub struct Context { core: ffi::BLContextCore, - _pd: PhantomData<&'a mut Image>, } -impl fmt::Debug for Context<'_> { +impl fmt::Debug for Context { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Context") .field("target_size", &self.target_size()) @@ -176,32 +175,29 @@ impl fmt::Debug for Context<'_> { } } -unsafe impl WrappedBlCore for Context<'_> { +unsafe impl WrappedBlCore for Context { type Core = ffi::BLContextCore; const IMPL_TYPE_INDEX: usize = crate::variant::ImplType::Context as usize; #[inline] fn from_core(core: Self::Core) -> Self { - Context { - core, - _pd: PhantomData, - } + Context { core } } } -impl<'a> Context<'a> { +impl Context { /// Creates a new context that renders to the given [`Image`]. #[inline] - pub fn new(target: &'a mut Image) -> Result> { + pub fn new(target: &mut Image) -> Result { Self::new_with_options(target, None) } /// Creates a new context with optional creation info that renders to the /// given [`Image`]. pub fn new_with_options( - target: &'a mut Image, + target: &mut Image, info: Option, - ) -> Result> { + ) -> Result { unsafe { let mut this = Context::from_core(*Self::none()); let info = info.map(|info| ffi::BLContextCreateInfo { @@ -410,7 +406,7 @@ impl<'a> Context<'a> { } // FIXME? make functions generic over a Stroke/FillStyle trait? -impl Context<'_> { +impl Context { #[inline] pub fn fill_rule(&self) -> FillRule { (self.state().fillRule as u32).into() @@ -491,7 +487,7 @@ impl Context<'_> { } } -impl Context<'_> { +impl Context { #[inline] pub fn stroke_alpha(&self) -> f64 { self.state().styleAlpha[ContextOpType::Stroke as usize] @@ -676,7 +672,7 @@ impl Context<'_> { } /// Clip Operations -impl Context<'_> { +impl Context { #[inline] pub fn restore_clipping(&mut self) -> Result<()> { unsafe { errcode_to_result(ffi::blContextRestoreClipping(self.core_mut())) } @@ -699,7 +695,7 @@ impl Context<'_> { } /// Clear Operations -impl Context<'_> { +impl Context { #[inline] pub fn clear_all(&mut self) -> Result<()> { unsafe { errcode_to_result(ffi::blContextClearAll(self.core_mut())) } @@ -756,7 +752,7 @@ impl Context<'_> { } /// Fill Operations -impl Context<'_> { +impl Context { #[inline] pub fn fill_geometry(&mut self, geo: &T) -> Result<()> { unsafe { @@ -881,7 +877,7 @@ impl Context<'_> { } /// Stroke Operations -impl Context<'_> { +impl Context { #[inline] pub fn stroke_geometry(&mut self, geo: &T) -> Result<()> { unsafe { @@ -1021,7 +1017,7 @@ impl Context<'_> { } } -impl MatrixTransform for Context<'_> { +impl MatrixTransform for Context { #[inline] #[doc(hidden)] fn apply_matrix_op(&mut self, op: Matrix2DOp, data: &[f64]) -> Result<()> { @@ -1035,14 +1031,14 @@ impl MatrixTransform for Context<'_> { } } -impl PartialEq for Context<'_> { +impl PartialEq for Context { #[inline] fn eq(&self, other: &Self) -> bool { self.impl_equals(other) } } -impl Drop for Context<'_> { +impl Drop for Context { fn drop(&mut self) { unsafe { ffi::blContextReset(&mut self.core) }; }