Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

Commit aeb8108

Browse files
author
bors-servo
authored
Auto merge of #87 - snapview:display, r=KiChjang
Adds an additional display function + bumps core-foundation dependency version This is a small pull request, basically it adds the following things: 1. Adds a missing `CGDisplayCreateImage()` function, so that now the user has all required functions to capture static images (it was already implemented for window capturing and now the display capturing is also possible). 2. Adds a couple functions to `CGRect`. 3. Updates the version for `core-foundation` from `0.3` to `0.4`. I'm not sure if using `0.3` makes sense if we can use `0.4`. For me personally it was required to change it as my project depends on several crates, including the latest `core-foundation` version, so when I have both `core-graphics` and `core-foundation` in my dependencies, `core-foundation` has been compiled twice (once for `0.4` which is the new version and once for the old `0.3` which has been downloaded and compiled as one of the `core-graphics` dependencies). So basically the people who use the both `core-graphics` and `core-foundation` (the last versions) would encounter the same problems (`core-foundation` is compiled twice and it may cause compile time errors like it was in my case). What are your thoughts on these? <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-graphics-rs/87) <!-- Reviewable:end -->
2 parents 93b2636 + f9f2226 commit aeb8108

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "core-graphics"
33
description = "Bindings to Core Graphics for OS X"
44
homepage = "https://github.com/servo/core-graphics-rs"
55
repository = "https://github.com/servo/core-graphics-rs"
6-
version = "0.8.2"
6+
version = "0.9.0"
77
authors = ["The Servo Project Developers"]
88
license = "MIT / Apache-2.0"
99

@@ -12,6 +12,6 @@ default = []
1212
elcapitan = []
1313

1414
[dependencies]
15-
libc = "0.2"
16-
core-foundation = "0.3"
1715
bitflags = "0.9"
16+
core-foundation = "0.4"
17+
libc = "0.2"

src/display.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ extern {
7676
pub fn CGDisplayPixelsHigh(display: CGDirectDisplayID) -> libc::size_t;
7777
pub fn CGDisplayPixelsWide(display: CGDirectDisplayID) -> libc::size_t;
7878
pub fn CGDisplayBounds(display: CGDirectDisplayID) -> CGRect;
79+
pub fn CGDisplayCreateImage(display: CGDirectDisplayID) -> CGImageRef;
7980

8081
// mouse stuff
8182
pub fn CGDisplayHideCursor(display: CGDirectDisplayID) -> CGError;

src/geometry.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ impl CGRect {
8585
Some(rect)
8686
}
8787
}
88+
89+
#[inline]
90+
pub fn is_empty(&self) -> bool {
91+
unsafe {
92+
// I use one, as it seems that `YES` is not available from this crate.
93+
ffi::CGRectIsEmpty(*self) == 1
94+
}
95+
}
96+
97+
#[inline]
98+
pub fn is_intersects(&self, other: &CGRect) -> bool {
99+
unsafe {
100+
// I use one, as it seems that `YES` is not available from this crate.
101+
ffi::CGRectIntersectsRect(*self, *other) == 1
102+
}
103+
}
88104
}
89105

90106
mod ffi {
@@ -97,6 +113,8 @@ mod ffi {
97113
pub fn CGRectInset(rect: CGRect, dx: CGFloat, dy: CGFloat) -> CGRect;
98114
pub fn CGRectMakeWithDictionaryRepresentation(dict: CFDictionaryRef,
99115
rect: *mut CGRect) -> boolean_t;
116+
pub fn CGRectIsEmpty(rect: CGRect) -> boolean_t;
117+
pub fn CGRectIntersectsRect(rect1: CGRect, rect2: CGRect) -> boolean_t;
100118
}
101119
}
102120

0 commit comments

Comments
 (0)