Skip to content

Commit b7fe5e0

Browse files
authored
Update to objc2 frameworks v0.3.2 (#285)
1 parent 4280d75 commit b7fe5e0

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,19 @@ features = [
8181
]
8282

8383
[target.'cfg(target_vendor = "apple")'.dependencies]
84-
objc2-core-graphics = { version = "0.3.1", default-features = false, features = [
84+
objc2-core-graphics = { version = "0.3.2", default-features = false, features = [
8585
"std",
8686
"objc2",
8787
"CGColorSpace",
8888
"CGDataProvider",
8989
"CGImage",
9090
] }
9191
objc2 = "0.6.0"
92-
objc2-core-foundation = { version = "0.3.1", default-features = false, features = [
92+
objc2-core-foundation = { version = "0.3.2", default-features = false, features = [
9393
"std",
9494
"CFCGTypes",
9595
] }
96-
objc2-foundation = { version = "0.3.1", default-features = false, features = [
96+
objc2-foundation = { version = "0.3.2", default-features = false, features = [
9797
"std",
9898
"objc2-core-foundation",
9999
"NSDictionary",
@@ -103,7 +103,7 @@ objc2-foundation = { version = "0.3.1", default-features = false, features = [
103103
"NSThread",
104104
"NSValue",
105105
] }
106-
objc2-quartz-core = { version = "0.3.1", default-features = false, features = [
106+
objc2-quartz-core = { version = "0.3.2", default-features = false, features = [
107107
"std",
108108
"objc2-core-foundation",
109109
"CALayer",

src/backends/cg.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use objc2::{define_class, msg_send, AllocAnyThread, DefinedClass, MainThreadMark
88
use objc2_core_foundation::{CFRetained, CGPoint};
99
use objc2_core_graphics::{
1010
CGBitmapInfo, CGColorRenderingIntent, CGColorSpace, CGDataProvider, CGImage, CGImageAlphaInfo,
11+
CGImageByteOrderInfo, CGImageComponentInfo, CGImagePixelFormatInfo,
1112
};
1213
use objc2_foundation::{
1314
ns_string, NSDictionary, NSKeyValueChangeKey, NSKeyValueChangeNewKey,
@@ -223,7 +224,7 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> SurfaceInterface<D, W> for CGImpl<
223224
layer.setContentsGravity(unsafe { kCAGravityTopLeft });
224225

225226
// Initialize color space here, to reduce work later on.
226-
let color_space = unsafe { CGColorSpace::new_device_rgb() }.unwrap();
227+
let color_space = CGColorSpace::new_device_rgb().unwrap();
227228

228229
// Grab initial width and height from the layer (whose properties have just been initialized
229230
// by the observer using `NSKeyValueObservingOptionInitial`).
@@ -308,6 +309,17 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> BufferInterface for BufferImpl<'_,
308309
}
309310
};
310311

312+
// `CGBitmapInfo` consists of a combination of `CGImageAlphaInfo`, `CGImageComponentInfo`
313+
// `CGImageByteOrderInfo` and `CGImagePixelFormatInfo` (see e.g. `CGBitmapInfoMake`).
314+
//
315+
// TODO: Use `CGBitmapInfo::new` once the next version of objc2-core-graphics is released.
316+
let bitmap_info = CGBitmapInfo(
317+
CGImageAlphaInfo::NoneSkipFirst.0
318+
| CGImageComponentInfo::Integer.0
319+
| CGImageByteOrderInfo::Order32Little.0
320+
| CGImagePixelFormatInfo::Packed.0,
321+
);
322+
311323
let image = unsafe {
312324
CGImage::new(
313325
self.imp.width,
@@ -316,8 +328,7 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> BufferInterface for BufferImpl<'_,
316328
32,
317329
self.imp.width * 4,
318330
Some(&self.imp.color_space),
319-
// TODO: This looks incorrect!
320-
CGBitmapInfo::ByteOrder32Little | CGBitmapInfo(CGImageAlphaInfo::NoneSkipFirst.0),
331+
bitmap_info,
321332
Some(&data_provider),
322333
ptr::null(),
323334
false,

0 commit comments

Comments
 (0)