Skip to content
Merged
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
8 changes: 4 additions & 4 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions imaging_skia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ imaging = { features = ["std"], workspace = true }
imaging_wgpu = { default-features = false, optional = true, workspace = true }
kurbo = { default-features = true, workspace = true }
peniko = { default-features = true, workspace = true }
skia-safe = { version = "0.93.1" }
skia-safe = { version = "0.97.0" }
wgpu = { optional = true, version = "28.0.0" }

[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
foreign-types-shared = { version = "0.3", optional = true }
oaty = "0.1"
skia-safe = { version = "0.93.1", features = ["metal"] }
skia-safe = { version = "0.97.0", features = ["metal"] }

[target.'cfg(windows)'.dependencies]
ash = { version = "0.38.0", optional = true }
skia-safe = { version = "0.93.1", features = [
skia-safe = { version = "0.97.0", features = [
"d3d",
"vulkan",
# gl/svg/textlayout are enabled merely to match precompiled skia requirements
Expand All @@ -54,7 +54,7 @@ windows = { version = "0.62.0", optional = true, features = [

[target.'cfg(not(any(target_os = "macos", target_os = "ios", windows)))'.dependencies]
ash = { version = "0.38.0", optional = true }
skia-safe = { version = "0.93.1", features = ["vulkan"] }
skia-safe = { version = "0.97.0", features = ["vulkan"] }

[lints]
workspace = true
Expand Down
5 changes: 3 additions & 2 deletions imaging_skia/src/d3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Dx12Backend {
memory_allocator: None,
protected_context: sk::gpu::Protected::No,
};
let context = unsafe { sk::gpu::DirectContext::new_d3d(&backend_context, None) }.ok_or(
let context = unsafe { sk::gpu::direct_contexts::make_d3d(&backend_context, None) }.ok_or(
Error::CreateGpuContext("unable to create Skia D3D12 context"),
)?;
Ok(Self { context })
Expand All @@ -80,13 +80,14 @@ impl Dx12Backend {
let resource: ID3D12Resource = unsafe { hal_texture.raw_resource().clone() };
let texture_info = sk::gpu::d3d::TextureResourceInfo::from_resource(resource)
.with_state(D3D12_RESOURCE_STATE_COMMON);
let backend_texture = sk::gpu::BackendTexture::new_d3d(
let backend_texture = sk::gpu::backend_textures::make_d3d(
(width, height),
&sk::gpu::d3d::TextureResourceInfo {
format: dxgi_format_for_wgpu_texture_format(format)?,
level_count: 1,
..texture_info
},
"imaging_skia d3d texture",
);
sk::gpu::surfaces::wrap_backend_texture(
self.direct_context(),
Expand Down
45 changes: 19 additions & 26 deletions imaging_skia/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1753,8 +1753,8 @@ fn tile_mode_from_extend(extend: peniko::Extend) -> sk::TileMode {

fn gradient_shader_cs_from_cs_tag(
color_space: ColorSpaceTag,
) -> sk::gradient_shader::interpolation::ColorSpace {
use sk::gradient_shader::interpolation::ColorSpace as SkCs;
) -> sk::gradient::interpolation::ColorSpace {
use sk::gradient::interpolation::ColorSpace as SkCs;

match color_space {
ColorSpaceTag::Srgb => SkCs::SRGB,
Expand All @@ -1775,8 +1775,8 @@ fn gradient_shader_cs_from_cs_tag(

fn gradient_shader_hue_method_from_hue_direction(
direction: HueDirection,
) -> sk::gradient_shader::interpolation::HueMethod {
use sk::gradient_shader::interpolation::HueMethod as SkHue;
) -> sk::gradient::interpolation::HueMethod {
use sk::gradient::interpolation::HueMethod as SkHue;

match direction {
HueDirection::Shorter => SkHue::Shorter,
Expand Down Expand Up @@ -1841,31 +1841,29 @@ fn brush_to_paint(
let tile_mode = tile_mode_from_extend(grad.extend);
let local = affine_to_matrix(paint_xf);

let interpolation = sk::gradient_shader::Interpolation {
let interpolation = sk::gradient::Interpolation {
color_space: gradient_shader_cs_from_cs_tag(grad.interpolation_cs),
in_premul: match grad.interpolation_alpha_space {
InterpolationAlphaSpace::Premultiplied => {
sk::gradient_shader::interpolation::InPremul::Yes
sk::gradient::interpolation::InPremul::Yes
}
InterpolationAlphaSpace::Unpremultiplied => {
sk::gradient_shader::interpolation::InPremul::No
sk::gradient::interpolation::InPremul::No
}
},
hue_method: gradient_shader_hue_method_from_hue_direction(grad.hue_direction),
};
let gradient_colors =
sk::gradient::Colors::new(&colors[..], Some(&pos[..]), tile_mode, None);
let gradient = sk::gradient::Gradient::new(gradient_colors, interpolation);

match &grad.kind {
peniko::GradientKind::Linear(line) => {
let p0 = sk::Point::new(f64_to_f32(line.start.x), f64_to_f32(line.start.y));
let p1 = sk::Point::new(f64_to_f32(line.end.x), f64_to_f32(line.end.y));
if let Some(shader) = sk::gradient_shader::linear_with_interpolation(
(p0, p1),
(&colors[..], None),
&pos[..],
tile_mode,
interpolation,
Some(&local),
) {
if let Some(shader) =
sk::gradient::shaders::linear_gradient((p0, p1), &gradient, Some(&local))
{
paint.set_shader(shader);
}
}
Expand All @@ -1879,13 +1877,10 @@ fn brush_to_paint(
sk::Point::new(f64_to_f32(rad.end_center.x), f64_to_f32(rad.end_center.y));
let end_radius = rad.end_radius;

if let Some(shader) = sk::gradient_shader::two_point_conical_with_interpolation(
if let Some(shader) = sk::gradient::shaders::two_point_conical_gradient(
(start_center, start_radius),
(end_center, end_radius),
(&colors[..], None),
&pos[..],
tile_mode,
interpolation,
&gradient,
Some(&local),
) {
paint.set_shader(shader);
Expand All @@ -1897,13 +1892,10 @@ fn brush_to_paint(
// `peniko` uses radians; Skia uses degrees for sweep gradient angles.
let start = rad_to_deg(sweep.start_angle);
let end = rad_to_deg(sweep.end_angle);
if let Some(shader) = sk::gradient_shader::sweep_with_interpolation(
if let Some(shader) = sk::gradient::shaders::sweep_gradient(
center,
(&colors[..], None),
Some(&pos[..]),
tile_mode,
Some((start, end)),
interpolation,
(start, end),
&gradient,
Some(&local),
) {
paint.set_shader(shader);
Expand Down Expand Up @@ -2504,6 +2496,7 @@ mod tests {
sink.finish_picture().unwrap()
}

#[cfg(feature = "gpu")]
fn assert_solid_rgba_image(image: &RgbaImage, expected: [u8; 4]) {
assert_eq!(
image.data.len(),
Expand Down
10 changes: 9 additions & 1 deletion imaging_snapshot_tests/src/cases/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ impl SnapshotCase for GmGlyphRunsGradientFill {
"gm_glyph_runs_gradient_fill"
}

fn skia_max_diff_pixels(&self) -> u64 {
4
}

fn run(&self, sink: &mut dyn PaintSink, width: f64, height: f64) {
background(sink, width, height, Color::from_rgba8(247, 241, 232, 255));
let mut painter = Painter::new(sink);
Expand Down Expand Up @@ -229,7 +233,7 @@ impl SnapshotCase for GmGlyphRunsImageStroke {
}

fn vello_max_diff_pixels(&self) -> u64 {
4
8
}

fn run(&self, sink: &mut dyn PaintSink, width: f64, height: f64) {
Expand Down Expand Up @@ -263,6 +267,10 @@ impl SnapshotCase for GmTextEditorLorem {
matches!(backend, "tiny_skia" | "vello_cpu" | "skia")
}

fn skia_max_diff_pixels(&self) -> u64 {
64
}

fn run(&self, sink: &mut dyn PaintSink, width: f64, height: f64) {
const TAB_TEXT: &str = "lorem_notes.md";
const STATUS_TEXT: &str = "UTF-8 Ln 18, Col 24 Spaces: 4";
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading