Skip to content

Commit e6037d8

Browse files
committed
Move samples out of piet and into local crate
- Cargo manifests have been cleaned up a bit - `piet` now no longer includes fonts within the crate published, making it smaller - `piet::Error::InvalidSampleArgs` is removed, which is specific to samples
1 parent fb6b4b7 commit e6037d8

39 files changed

+105
-92
lines changed

.github/workflows/snapshot.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
uses: actions-rs/cargo@v1
3232
with:
3333
command: run
34-
args: --manifest-path=piet-cairo/Cargo.toml --example=test-picture -- --all --out=cairo_samples --compare=./piet/snapshots/cairo
34+
args: --manifest-path=piet-cairo/Cargo.toml --example=test-picture -- --all --out=cairo_samples --compare=./samples/snapshots/cairo
3535
if: contains(matrix.os, 'ubuntu')
3636

3737
- name: upload failures (ubuntu+cairo)
@@ -45,7 +45,7 @@ jobs:
4545
uses: actions-rs/cargo@v1
4646
with:
4747
command: run
48-
args: --manifest-path=piet-coregraphics/Cargo.toml --example=test-picture -- --all --out=coregraphics_samples --compare=./piet/snapshots/coregraphics
48+
args: --manifest-path=piet-coregraphics/Cargo.toml --example=test-picture -- --all --out=coregraphics_samples --compare=./samples/snapshots/coregraphics
4949
if: contains(matrix.os, 'macOS')
5050

5151
- name: upload failures (macOS)
@@ -59,7 +59,7 @@ jobs:
5959
uses: actions-rs/cargo@v1
6060
with:
6161
command: run
62-
args: --manifest-path=piet-direct2d/Cargo.toml --example=test-picture -- --all --out=d2d_samples --compare=./piet/snapshots/d2d
62+
args: --manifest-path=piet-direct2d/Cargo.toml --example=test-picture -- --all --out=d2d_samples --compare=./samples/snapshots/d2d
6363
if: contains(matrix.os, 'windows')
6464

6565
- name: upload failures (d2d)

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "snapshots"]
2-
path = piet/snapshots
2+
path = samples/snapshots
33
url = https://github.com/linebender/piet-snapshots.git

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Piet uses 'snapshot testing' to verify that changes do not unexpectedly modify
44
behaviour. During CI, sample pictures are generated by the various `picture_{}`
5-
files in `piet`'s [`samples`] module, and the results are compared against
5+
files in the [`samples`] library, and the results are compared against
66
previously generated versions.
77

88
The previously generated versions are stored in a separate repository,
@@ -29,6 +29,6 @@ or @raphlinus (or another administrator) to set it up for you.
2929
`piet-snapshots`. Rebasing would cause the revision to be rewritten, which would
3030
mean that the commit referenced by the submodule would no longer exist.
3131

32-
[`samples`]: https://github.com/linebender/piet/tree/master/piet/src/samples
32+
[`samples`]: https://github.com/linebender/piet/tree/master/samples
3333
[`piet-snapshots`]: https://github.com/linebender/piet-snapshots
3434
[persisting workflow data using artifacts]: https://docs.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ default-members = [
1616
"piet-common",
1717
"piet-web",
1818
"piet-web/examples/basic",
19-
"piet-svg"
19+
"piet-svg",
20+
"samples"
2021
]

piet-cairo/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
22
name = "piet-cairo"
33
version = "0.5.0"
4+
edition = "2018"
45
authors = ["Raph Levien <[email protected]>"]
56
description = "Cairo backend for piet 2D graphics abstraction."
7+
readme = "../README.md"
68
license = "MIT/Apache-2.0"
79
repository = "https://github.com/linebender/piet"
8-
readme = "../README.md"
9-
edition = "2018"
1010
keywords = ["graphics", "2d"]
1111
categories = ["rendering::graphics-api"]
1212

@@ -20,7 +20,7 @@ unicode-segmentation = "1.3.0"
2020
xi-unicode = "0.3.0"
2121

2222
[dev-dependencies]
23-
piet = { version = "=0.5.0", path = "../piet", features = ["samples"] }
23+
samples = { path = "../samples" }
2424
cairo-rs = { version = "0.15.1", default-features = false, features = ["png"] }
2525
criterion = "0.3"
2626

piet-cairo/examples/test-picture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::process::Command;
66

77
use cairo::{Context, Format, ImageSurface};
88

9-
use piet::{samples, RenderContext};
9+
use piet::RenderContext;
1010
use piet_cairo::CairoRenderContext;
1111

1212
const HIDPI: f64 = 2.0;

piet-common/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
22
name = "piet-common"
33
version = "0.5.0"
4+
edition = "2018"
45
authors = ["Raph Levien <[email protected]>"]
56
description = "Selection of a single preferred back-end for piet"
7+
readme = "README.md"
68
license = "MIT/Apache-2.0"
79
repository = "https://github.com/linebender/piet"
8-
readme = "README.md"
9-
edition = "2018"
1010
keywords = ["graphics", "2d"]
1111

1212
[features]
@@ -35,6 +35,7 @@ serde = ["piet/serde"]
3535
[dependencies]
3636
piet = { version = "=0.5.0", path = "../piet" }
3737
piet-web = { version = "=0.5.0", path = "../piet-web", optional = true }
38+
3839
cfg-if = "1.0"
3940
png = { version = "0.17", optional = true }
4041

piet-coregraphics/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
22
name = "piet-coregraphics"
33
version = "0.5.0"
4+
edition = "2018"
45
authors = ["Jeff Muizelaar <[email protected]>, Raph Levien <[email protected]>, Colin Rofls <[email protected]>"]
56
description = "CoreGraphics backend for piet 2D graphics abstraction."
7+
readme = "../README.md"
68
license = "MIT/Apache-2.0"
79
repository = "https://github.com/linebender/piet"
8-
readme = "../README.md"
9-
edition = "2018"
1010
keywords = ["graphics", "2d"]
1111
categories = ["rendering::graphics-api"]
1212

@@ -21,5 +21,5 @@ core-foundation-sys = "0.8"
2121
associative-cache = "1.0"
2222

2323
[dev-dependencies]
24-
piet = { version = "=0.5.0", path = "../piet", features = ["samples"] }
2524
png = "0.17"
25+
samples = { path = "../samples" }

piet-coregraphics/examples/test-picture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use core_graphics::color_space::CGColorSpace;
88
use core_graphics::context::CGContext;
99

1010
use piet::kurbo::Size;
11-
use piet::{samples, RenderContext};
11+
use piet::RenderContext;
1212
use piet_coregraphics::CoreGraphicsContext;
1313

1414
const SCALE: f64 = 2.0;

piet-direct2d/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
[package]
22
name = "piet-direct2d"
33
version = "0.5.0"
4+
edition = "2018"
45
authors = ["Raph Levien <[email protected]>"]
56
description = "Direct2D backend for piet 2D graphics abstraction."
7+
readme = "../README.md"
68
license = "MIT/Apache-2.0"
79
repository = "https://github.com/linebender/piet"
8-
readme = "../README.md"
9-
edition = "2018"
1010
keywords = ["graphics", "2d"]
1111
categories = ["rendering::graphics-api"]
1212

1313
[dependencies]
1414
piet = { version = "=0.5.0", path = "../piet" }
15+
1516
utf16_lit = "2.0"
1617
associative-cache = "1.0"
1718

@@ -20,5 +21,5 @@ winapi = { version = "0.3.8", features = ["d2d1", "d2d1_1", "d2d1effects", "d2db
2021
dwrote = { version = "0.11.0", default_features = false }
2122

2223
[dev-dependencies]
23-
piet = { version = "=0.5.0", path = "../piet", features = ["samples"] }
2424
image = "0.24.0"
25+
samples = { path = "../samples" }

piet-direct2d/examples/test-picture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::path::Path;
44

55
use winapi::shared::dxgi::DXGI_MAP_READ;
66

7-
use piet::{samples, RenderContext};
7+
use piet::RenderContext;
88
use piet_direct2d::{D2DRenderContext, D2DText};
99

1010
const HIDPI: f32 = 2.0;

piet-svg/Cargo.toml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[package]
22
name = "piet-svg"
33
version = "0.5.0"
4+
edition = "2018"
45
authors = ["Benjamin Saunders <[email protected]>"]
56
description = "SVG backend for piet 2D graphics abstraction."
6-
edition = "2018"
7+
readme = "../README.md"
78
license = "MIT/Apache-2.0"
89
repository = "https://github.com/linebender/piet"
910
keywords = ["graphics", "2d"]
@@ -14,13 +15,14 @@ default = []
1415
evcxr = ["evcxr_runtime"]
1516

1617
[dependencies]
18+
piet = { version = "=0.5.0", path = "../piet" }
19+
20+
svg = "0.10.0"
1721
base64 = "0.13.0"
18-
evcxr_runtime = { version = "1.1.0", optional = true }
1922
font-kit = "0.10.1"
20-
image = { version = "0.24.0", default-features = false, features = ["png"] }
21-
piet = { version = "=0.5.0", path = "../piet" }
2223
rustybuzz = "0.4.0"
23-
svg = "0.10.0"
24+
evcxr_runtime = { version = "1.1.0", optional = true }
25+
image = { version = "0.24.0", default-features = false, features = ["png"] }
2426

2527
[dev-dependencies]
26-
piet = { version = "=0.5.0", path = "../piet", features = ["samples"] }
28+
samples = { path = "../samples" }

piet-svg/examples/basic-svg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::io;
44

5-
use piet::{samples, RenderContext};
5+
use piet::RenderContext;
66

77
fn main() {
88
let test_picture_number = std::env::args()

piet-web/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
22
name = "piet-web"
33
version = "0.5.0"
4+
edition = "2018"
45
authors = ["Raph Levien <[email protected]>"]
56
description = "Web canvas backend for piet 2D graphics abstraction."
67
license = "MIT/Apache-2.0"
78
repository = "https://github.com/linebender/piet"
89
readme = "../README.md"
9-
edition = "2018"
1010
keywords = ["graphics", "2d"]
1111
categories = ["rendering::graphics-api", "wasm"]
1212

piet-web/examples/basic/Cargo.toml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,21 @@ crate-type = ["cdylib"]
1111
default = ["console_error_panic_hook"]
1212

1313
[dependencies]
14-
piet = { path = "../../../piet", features = ["samples"] }
14+
piet = { path = "../../../piet" }
1515
piet-web = { path = "../.." }
16+
samples = { path = "../../../samples" }
1617

1718
wasm-bindgen = "0.2.30"
1819
console_error_panic_hook = { version = "0.1.6", optional = true }
1920

2021
[dependencies.web-sys]
2122
version = "0.3.10"
22-
features = ["console", "CanvasRenderingContext2d", "Window", "Document", "Element", "HtmlElement", "HtmlCanvasElement"]
23+
features = [
24+
"console",
25+
"CanvasRenderingContext2d",
26+
"Window",
27+
"Document",
28+
"Element",
29+
"HtmlElement",
30+
"HtmlCanvasElement"
31+
]

piet-web/examples/basic/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use wasm_bindgen::prelude::*;
44
use wasm_bindgen::JsCast;
55
use web_sys::{window, HtmlCanvasElement};
66

7-
use piet::{samples, RenderContext};
7+
use piet::RenderContext;
88
use piet_web::WebRenderContext;
99

1010
//TODO: figure out how to dynamically select the sample?

piet/Cargo.toml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
[package]
22
name = "piet"
3+
edition = "2018"
34
version = "0.5.0"
45
authors = ["Raph Levien <[email protected]>"]
56
description = "An abstraction for 2D graphics."
7+
readme = "../README.md"
68
license = "MIT/Apache-2.0"
79
repository = "https://github.com/linebender/piet"
8-
readme = "../README.md"
9-
edition = "2018"
1010
keywords = ["graphics", "2d"]
1111
categories = ["rendering::graphics-api"]
12-
include = ["src/**/*", "Cargo.toml", "snapshots/resources/*"]
12+
include = ["src/**/*", "Cargo.toml"]
1313

1414
[dependencies]
1515
image = { version = "0.24.0", optional = true, default-features = false }
1616
kurbo = "0.8.2"
17-
pico-args = { version = "0.4.0", optional = true }
18-
png = { version = "0.17", optional = true }
19-
os_info = { version = "3.0.0", optional = true, default-features = false }
2017
unic-bidi = "0.9"
2118

2219
[features]
23-
samples = ["pico-args", "png", "os_info"]
2420

2521
# passing on all the image features. AVIF is not supported because it does not
2622
# support decoding, and thats al we use `Image` for.

piet/snapshots

Lines changed: 0 additions & 1 deletion
This file was deleted.

piet/src/error.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ pub enum Error {
2222
MissingFont,
2323
/// Font data could not be loaded.
2424
FontLoadingFailed,
25-
/// The arguments provided to the CLI were invalid.
26-
#[cfg(feature = "samples")]
27-
InvalidSampleArgs,
2825
}
2926

3027
impl fmt::Display for Error {
@@ -44,8 +41,6 @@ impl fmt::Display for Error {
4441
write!(f, "Backend error: ")?;
4542
e.fmt(f)
4643
}
47-
#[cfg(feature = "samples")]
48-
Error::InvalidSampleArgs => write!(f, "Must pass either --all or a number"),
4944
}
5045
}
5146
}

piet/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ mod render_context;
4040
mod shapes;
4141
mod text;
4242

43-
#[cfg(feature = "samples")]
44-
pub mod samples;
45-
4643
pub use crate::color::*;
4744
pub use crate::conv::*;
4845
pub use crate::error::*;

samples/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "samples"
3+
version = "0.0.0"
4+
edition = "2018"
5+
publish = false
6+
7+
[dependencies]
8+
piet = { path = "../piet" }
9+
10+
png = "0.17"
11+
pico-args = "0.4.0"
12+
os_info = { version = "3.0.0", default-features = false }

samples/snapshots

Submodule snapshots added at b251dc4

piet/src/samples/mod.rs renamed to samples/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use std::fs::File;
77
use std::io::BufWriter;
88
use std::path::{Path, PathBuf};
99

10-
use crate::kurbo::Size;
11-
use crate::{Error, RenderContext};
10+
use piet::kurbo::Size;
11+
use piet::{Error, RenderContext};
1212

1313
mod picture_0;
1414
mod picture_1;
@@ -181,7 +181,7 @@ impl Args {
181181
};
182182

183183
if !(args.help || args.all || args.number.is_some() || args.compare_dir.is_some()) {
184-
Err(Box::new(Error::InvalidSampleArgs))
184+
Err("invalid sample args".into())
185185
} else {
186186
Ok(args)
187187
}

piet/src/samples/picture_0.rs renamed to samples/src/picture_0.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! A wide assortment of graphics meant to show off many different uses of piet
22
3-
use crate::kurbo::{Affine, BezPath, Line, Point, Rect, RoundedRect, Size, Vec2};
4-
use crate::{
3+
use piet::kurbo::{Affine, BezPath, Line, Point, Rect, RoundedRect, Size, Vec2};
4+
use piet::{
55
Color, Error, FontFamily, ImageFormat, InterpolationMode, RenderContext, Text, TextAttribute,
66
TextLayout, TextLayoutBuilder,
77
};

piet/src/samples/picture_1.rs renamed to samples/src/picture_1.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Rendering a cubic Bézier curve with its control points and handles
22
3-
use crate::kurbo::{BezPath, Line, Point, Size};
4-
use crate::{Color, Error, RenderContext};
3+
use piet::kurbo::{BezPath, Line, Point, Size};
4+
use piet::{Color, Error, RenderContext};
55

66
pub const SIZE: Size = Size::new(400., 200.);
77

piet/src/samples/picture_10.rs renamed to samples/src/picture_10.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Show the relationship between the layout rect and the inking/image rect.
22
3-
use crate::kurbo::{Size, Vec2};
4-
use crate::{Color, Error, RenderContext, Text, TextAttribute, TextLayout, TextLayoutBuilder};
3+
use piet::kurbo::{Size, Vec2};
4+
use piet::{Color, Error, RenderContext, Text, TextAttribute, TextLayout, TextLayoutBuilder};
55

66
pub const SIZE: Size = Size::new(400., 400.);
77

0 commit comments

Comments
 (0)