Skip to content

Commit 5675553

Browse files
flukejonesclaude
andcommitted
feat(cg): use IOSurface with single-buffering
Back the CoreGraphics buffer with an IOSurface instead of CGDataProvider. IOSurface is shared zero-copy with the compositor, avoiding the internal copy QuartzCore did on present. - keep single-buffer model; block on `is_in_use` in next_buffer before writing, since the compositor reads the surface directly (no internal copy to rely on) - stride uses surface.bytes_per_row (may be padded for alignment) - present sets CALayer.contents to the IOSurface, disabling actions to avoid the contents fade - scale content to fill via kCAGravityResize + nearest-neighbour filters - IOSurface supports Opaque|Premultiplied only; update supports_alpha_mode and AlphaMode platform docs accordingly - swap deps: drop CGDataProvider/CGImage, add objc2-io-surface + CF Number/String/Dictionary features Replaces the branch's earlier triple/unbounded-buffer commits; upstream moved to single-buffering (rust-windowing#343) while rust-windowing#329 kept multi-buffering. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 840683c commit 5675553

3 files changed

Lines changed: 245 additions & 250 deletions

File tree

Cargo.toml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ libc = "0.2.180"
9696
objc2-core-graphics = { version = "0.3.2", default-features = false, features = [
9797
"std",
9898
"objc2",
99-
"libc",
10099
"CGColorSpace",
101-
"CGDataProvider",
102-
"CGImage",
103100
] }
104101
objc2-core-foundation = { version = "0.3.2", default-features = false, features = [
105102
"std",
106103
"CFCGTypes",
104+
"CFNumber",
105+
"CFString",
106+
"CFDictionary",
107107
] }
108108
objc2-foundation = { version = "0.3.2", default-features = false, features = [
109109
"std",
@@ -114,14 +114,21 @@ objc2-foundation = { version = "0.3.2", default-features = false, features = [
114114
"NSString",
115115
"NSThread",
116116
"NSValue",
117-
"NSNull",
118117
] }
119118
objc2-quartz-core = { version = "0.3.2", default-features = false, features = [
120119
"std",
121120
"objc2-core-foundation",
122121
"CALayer",
123122
"CATransaction",
124123
] }
124+
objc2-io-surface = { version = "0.3.2", default-features = false, features = [
125+
"std",
126+
"libc",
127+
"objc2",
128+
"objc2-core-foundation",
129+
"IOSurfaceRef",
130+
"IOSurfaceTypes",
131+
] }
125132

126133
# Web dependencies.
127134
[target.'cfg(target_family = "wasm")'.dependencies]

0 commit comments

Comments
 (0)