Skip to content

Commit

Permalink
Merge #13
Browse files Browse the repository at this point in the history
13: 0.2.0 r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <[email protected]>
  • Loading branch information
bors[bot] and Veykril committed May 11, 2019
2 parents 24d01a8 + dda8117 commit f1f116c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 27 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blend2d"
version = "0.1.2"
version = "0.2.0"
authors = ["Lukas Wirth <[email protected]>"]
edition = "2018"
description = "Rust bindings for blend2d"
Expand All @@ -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]]
Expand Down
6 changes: 3 additions & 3 deletions blend2d-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blend2d-sys"
version = "0.2.0-pre"
version = "0.2.0"
authors = ["Lukas Wirth <[email protected]>"]
edition = "2018"
description = "Raw ffi bindings for blend2d"
Expand All @@ -12,5 +12,5 @@ build = "build.rs"
links = "blend2d"

[build-dependencies]
cmake = "^0.1"
bindgen = "^0.49.0"
cmake = "0.1"
bindgen = "0.49"
40 changes: 18 additions & 22 deletions src/context.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bitflags::bitflags;

use core::{fmt, marker::PhantomData, ptr};
use core::{fmt, ptr};

use crate::{
array::Array,
Expand Down Expand Up @@ -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())
Expand All @@ -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<Context<'a>> {
pub fn new(target: &mut Image) -> Result<Context> {
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<ContextCreateInfo>,
) -> Result<Context<'a>> {
) -> Result<Context> {
unsafe {
let mut this = Context::from_core(*Self::none());
let info = info.map(|info| ffi::BLContextCreateInfo {
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -491,7 +487,7 @@ impl Context<'_> {
}
}

impl Context<'_> {
impl Context {
#[inline]
pub fn stroke_alpha(&self) -> f64 {
self.state().styleAlpha[ContextOpType::Stroke as usize]
Expand Down Expand Up @@ -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())) }
Expand All @@ -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())) }
Expand Down Expand Up @@ -756,7 +752,7 @@ impl Context<'_> {
}

/// Fill Operations
impl Context<'_> {
impl Context {
#[inline]
pub fn fill_geometry<T: Geometry + ?Sized>(&mut self, geo: &T) -> Result<()> {
unsafe {
Expand Down Expand Up @@ -881,7 +877,7 @@ impl Context<'_> {
}

/// Stroke Operations
impl Context<'_> {
impl Context {
#[inline]
pub fn stroke_geometry<T: Geometry + ?Sized>(&mut self, geo: &T) -> Result<()> {
unsafe {
Expand Down Expand Up @@ -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<()> {
Expand All @@ -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) };
}
Expand Down

0 comments on commit f1f116c

Please sign in to comment.