Skip to content

planeshift: Fork of the upstream #921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 85 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ members = [
"sparse_strips/vello_hybrid/examples/webgl",
"sparse_strips/vello_hybrid/examples/winit",
"sparse_strips/vello_toy",

"planeshift",
]

[workspace.package]
Expand Down
35 changes: 35 additions & 0 deletions planeshift/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[package]
name = "planeshift"
version = "0.1.0"
description = "TODO"
categories = ["gui"]
keywords = ["windowing", "compositor"]
edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true

[package.metadata.docs.rs]
all-features = true
# There are no platform specific docs.
default-target = "x86_64-unknown-linux-gnu"
targets = []

[features]
default = ["enable-winit"]
enable-winit = ["dep:winit"]

[lints]
workspace = true

[dependencies]
bitflags = "2.9.0"
euclid = "0.22.11"
image = { workspace = true }
winit = { workspace = true, optional = true }

[target.'cfg(target_os = "macos")'.dependencies]
block = "0.1"
cocoa = "0.26.0"
core-graphics = "0.24.0"
objc = "0.2"
49 changes: 49 additions & 0 deletions planeshift/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<div align="center">

# Planeshift

[![Apache 2.0 or MIT license.](https://img.shields.io/badge/license-Apache--2.0_OR_MIT-blue.svg)](#license)
\
[![Linebender Zulip chat.](https://img.shields.io/badge/Linebender-%23vello-blue?logo=Zulip)](https://xi.zulipchat.com/#narrow/channel/197075-vello)
[![GitHub Actions CI status.](https://img.shields.io/github/actions/workflow/status/linebender/vello/ci.yml?logo=github&label=CI)](https://github.com/linebender/vello/actions)

</div>

## Minimum supported Rust Version (MSRV)

This version of Planeshift has been verified to compile with **Rust 1.85** and later.

Future versions of Planeshift might increase the Rust version requirement.
It will not be treated as a breaking change and as such can even happen with small patch releases.

<details>
<summary>Click here if compiling fails.</summary>

As time has passed, some of Planeshift's dependencies could have released versions with a higher Rust requirement.
If you encounter a compilation issue due to a dependency and don't want to upgrade your Rust toolchain, then you could downgrade the dependency.

```sh
# Use the problematic dependency's name and version
cargo update -p package_name --precise 0.1.1
```

</details>

## Community

Discussion of Planeshift development happens in the [Linebender Zulip](https://xi.zulipchat.com/), specifically the [#vello stream](https://xi.zulipchat.com/#narrow/channel/197075-vello).
All public content can be read without logging in.

Contributions are welcome by pull request.
The [Rust code of conduct] applies.

## License

Licensed under either of

- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT license ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)

at your option.

[Rust code of conduct]: https://www.rust-lang.org/policies/code-of-conduct
105 changes: 105 additions & 0 deletions planeshift/src/backend.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Copyright 2018 the Vello Authors and The Pathfinder Project Developers
// SPDX-License-Identifier: Apache-2.0 OR MIT

use image::RgbaImage;

#[cfg(feature = "enable-winit")]
use winit::window::Window;

use crate::Rect;
use crate::{Connection, ConnectionError, LayerContainerInfo};
use crate::{LayerGeometryInfo, LayerId, LayerMap, LayerSurfaceInfo, LayerTreeInfo, Promise};

// Backend definition

pub trait Backend: Sized {
type NativeConnection;
type Host;

// Constructor
fn new(connection: Connection<Self::NativeConnection>) -> Result<Self, ConnectionError>;

// Transactions
fn begin_transaction(&self);
fn end_transaction(
&mut self,
promise: &Promise<()>,
tree_component: &LayerMap<LayerTreeInfo>,
container_component: &LayerMap<LayerContainerInfo>,
geometry_component: &LayerMap<LayerGeometryInfo>,
surface_component: &LayerMap<LayerSurfaceInfo>,
);

// Layer creation and destruction
fn add_container_layer(&mut self, new_layer: LayerId);
fn add_surface_layer(&mut self, new_layer: LayerId);
fn delete_layer(&mut self, layer: LayerId);

// Layer tree management
fn insert_before(
&mut self,
parent: LayerId,
new_child: LayerId,
reference: Option<LayerId>,
tree_component: &LayerMap<LayerTreeInfo>,
container_component: &LayerMap<LayerContainerInfo>,
geometry_component: &LayerMap<LayerGeometryInfo>,
);
fn remove_from_superlayer(
&mut self,
layer: LayerId,
parent: LayerId,
tree_component: &LayerMap<LayerTreeInfo>,
geometry_component: &LayerMap<LayerGeometryInfo>,
);

// Native hosting
unsafe fn host_layer(
&mut self,
layer: LayerId,
host: Self::Host,
tree_component: &LayerMap<LayerTreeInfo>,
container_component: &LayerMap<LayerContainerInfo>,
geometry_component: &LayerMap<LayerGeometryInfo>,
);
fn unhost_layer(&mut self, layer: LayerId);

// Geometry
fn set_layer_bounds(
&mut self,
layer: LayerId,
old_bounds: &Rect<f32>,
tree_component: &LayerMap<LayerTreeInfo>,
container_component: &LayerMap<LayerContainerInfo>,
geometry_component: &LayerMap<LayerGeometryInfo>,
);

// Miscellaneous layer flags
fn set_layer_surface_options(
&mut self,
layer: LayerId,
surface_component: &LayerMap<LayerSurfaceInfo>,
);

// Screenshots
fn screenshot_hosted_layer(
&mut self,
layer: LayerId,
transaction_promise: &Promise<()>,
tree_component: &LayerMap<LayerTreeInfo>,
container_component: &LayerMap<LayerContainerInfo>,
geometry_component: &LayerMap<LayerGeometryInfo>,
surface_component: &LayerMap<LayerSurfaceInfo>,
) -> Promise<RgbaImage>;

// `winit` integration
#[cfg(feature = "enable-winit")]
fn host_layer_in_window(
&mut self,
layer: LayerId,
window: &Window,
tree_component: &LayerMap<LayerTreeInfo>,
container_component: &LayerMap<LayerContainerInfo>,
geometry_component: &LayerMap<LayerGeometryInfo>,
) -> Result<(), ()>;
}
Loading