Skip to content

Commit 8df1749

Browse files
authored
Merge pull request rust-skia#1113 from pragmatrix/m135
Milestone 135
2 parents 0f6adb3 + f2be4a7 commit 8df1749

File tree

10 files changed

+65
-45
lines changed

10 files changed

+65
-45
lines changed

README.md

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

33
[![crates.io](https://img.shields.io/crates/v/skia-safe)](https://crates.io/crates/skia-safe) [![license](https://img.shields.io/crates/l/skia-safe)](LICENSE) [![Windows QA](https://github.com/rust-skia/rust-skia/actions/workflows/windows-qa.yaml/badge.svg?branch=master)](https://github.com/rust-skia/rust-skia/actions/workflows/windows-qa.yaml) [![Linux QA](https://github.com/rust-skia/rust-skia/actions/workflows/linux-qa.yaml/badge.svg?branch=master)](https://github.com/rust-skia/rust-skia/actions/workflows/linux-qa.yaml) [![macOS QA](https://github.com/rust-skia/rust-skia/actions/workflows/macos-qa.yaml/badge.svg?branch=master)](https://github.com/rust-skia/rust-skia/actions/workflows/macos-qa.yaml)
44

5-
Skia Submodule Status: chrome/m134 ([upstream changes][skia-upstream], [our changes][skia-ours]).
5+
Skia Submodule Status: chrome/m135 ([upstream changes][skia-upstream], [our changes][skia-ours]).
66

7-
[skia-upstream]: https://github.com/rust-skia/skia/compare/m134-0.82.0...google:chrome/m134
8-
[skia-ours]: https://github.com/google/skia/compare/chrome/m134...rust-skia:m134-0.82.0
7+
[skia-upstream]: https://github.com/rust-skia/skia/compare/m135-0.83.1...google:chrome/m135
8+
[skia-ours]: https://github.com/google/skia/compare/chrome/m135...rust-skia:m135-0.83.1
99

1010
## About
1111

skia-bindings/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ keywords = ["skia", "rust-bindings", "vulkan", "opengl", "pdf"]
99
categories = ["external-ffi-bindings", "graphics", "multimedia::images", "rendering::graphics-api", "visualization"]
1010
license = "MIT"
1111

12-
version = "0.83.0"
12+
version = "0.84.0"
1313
authors = ["LongYinan <[email protected]>", "Armin Sander <[email protected]>"]
1414
edition = "2021"
1515
rust-version.workspace = true
@@ -31,7 +31,7 @@ doctest = false
3131
# Metadata used from inside the packaged crate that defines where to download the Skia archive from.
3232
# Note: use short hashes here because of filesystem path size restrictions.
3333
[package.metadata]
34-
skia = "m134-0.82.0"
34+
skia = "m135-0.83.1"
3535

3636
[features]
3737
default = ["binary-cache", "embed-icudtl"]

skia-bindings/build_support/skia_bindgen.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,8 @@ const ENUM_REWRITES: &[EnumEntry] = &[
736736
("ImageDecodeStrategy", rewrite::k_xxx),
737737
// SkNamedPrimaries::CicpId, SkNamedTransferFn::CicpId
738738
("CicpId", rewrite::k_xxx),
739+
// `SkCodec::IsAnimated`s
740+
("IsAnimated", rewrite::k_xxx),
739741
];
740742

741743
pub(crate) mod rewrite {

skia-bindings/skia

Submodule skia updated 653 files

skia-bindings/src/bindings.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
#include "include/core/SkVertices.h"
7979
// docs/
8080
#include "include/docs/SkPDFDocument.h"
81+
#include "include/docs/SkPDFJpegHelpers.h"
82+
8183
// effects/
8284
#include "include/effects/Sk1DPathEffect.h"
8385
#include "include/effects/Sk2DPathEffect.h"
@@ -209,6 +211,10 @@ extern "C" int C_SkCodec_getRepetitionCount(SkCodec* self) {
209211
return self->getRepetitionCount();
210212
}
211213

214+
extern "C" SkCodec::IsAnimated C_SkCodec_isAnimated(SkCodec* self) {
215+
return self->isAnimated();
216+
}
217+
212218
// SkCodecs
213219

214220
extern "C" void C_SkCodecs_Decoder_CopyConstruct(SkCodecs::Decoder* uninitialized, const SkCodecs::Decoder* decoder) {
@@ -2593,6 +2599,12 @@ extern "C" SkColorFilter* C_SkOverdrawColorFilter_MakeWithSkColors(const SkColor
25932599

25942600
extern "C" {
25952601

2602+
void C_SkRuntimeEffect_Options_Construct(SkRuntimeEffect::Options* uninitialized, bool forceUnoptimized, const char* name, size_t length) {
2603+
new (uninitialized) SkRuntimeEffect::Options();
2604+
uninitialized->forceUnoptimized = forceUnoptimized;
2605+
uninitialized->fName = std::string_view(name, length);
2606+
}
2607+
25962608
SkRuntimeEffect *C_SkRuntimeEffect_MakeForColorFilter(
25972609
const SkString *sksl,
25982610
const SkRuntimeEffect::Options *options,
@@ -3132,7 +3144,11 @@ extern "C" void C_SkPDF_Metadata_destruct(SkPDF::Metadata* self) {
31323144
}
31333145

31343146
extern "C" SkDocument* C_SkPDF_MakeDocument(SkWStream* stream, const SkPDF::Metadata* metadata) {
3135-
return SkPDF::MakeDocument(stream, *metadata).release();
3147+
// We want to support JPeg encoding / decoding by default.
3148+
SkPDF::Metadata meta = *metadata;
3149+
meta.jpegDecoder = SkPDF::JPEG::Decode;
3150+
meta.jpegEncoder = SkPDF::JPEG::Encode;
3151+
return SkPDF::MakeDocument(stream, meta).release();
31363152
}
31373153

31383154
extern "C" void C_SkPDF_SetNodeId(SkCanvas* dst, int nodeID) {

skia-safe/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ categories = [
1818
]
1919
license = "MIT"
2020

21-
version = "0.82.0"
21+
version = "0.84.0"
2222
authors = ["Armin Sander <[email protected]>"]
2323
edition = "2021"
2424
rust-version.workspace = true
@@ -62,7 +62,7 @@ vulkan-window = ["dep:ash", "dep:vulkano", "winit/rwh_05"]
6262
[dependencies]
6363
bitflags = "2.0"
6464
lazy_static = "1.4"
65-
skia-bindings = { version = "=0.83.0", path = "../skia-bindings", default-features = false }
65+
skia-bindings = { version = "=0.84.0", path = "../skia-bindings", default-features = false }
6666

6767
# vulkan-window example
6868
ash = { version = "^0.38.0", optional = true }

skia-safe/src/codec/_codec.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ impl Default for FrameInfo {
6565
pub use sb::SkCodec_SkScanlineOrder as ScanlineOrder;
6666
variant_name!(ScanlineOrder::BottomUp);
6767

68+
pub use sb::SkCodec_IsAnimated as IsAnimated;
69+
variant_name!(IsAnimated::Yes);
70+
6871
pub struct Codec<'a> {
6972
inner: RefHandle<SkCodec>,
7073
pd: PhantomData<&'a mut dyn io::Read>,
@@ -382,6 +385,10 @@ impl Codec<'_> {
382385
}
383386
}
384387

388+
pub fn is_animated(&mut self) -> IsAnimated {
389+
unsafe { sb::C_SkCodec_isAnimated(self.native_mut()) }
390+
}
391+
385392
// TODO: Register
386393

387394
fn native(&self) -> &SkCodec {

skia-safe/src/core/milestone.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pub const MILESTONE: usize = 134;
1+
pub const MILESTONE: usize = 135;

skia-safe/src/core/paint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ impl Paint {
191191
self.native().fMiterLimit
192192
}
193193

194-
pub fn set_stroke_miter(&mut self, miter: scalar) -> &mut Self {
195-
unsafe { self.native_mut().setStrokeMiter(miter) }
194+
pub fn set_stroke_miter(&mut self, miter_limit: scalar) -> &mut Self {
195+
unsafe { self.native_mut().setStrokeMiter(miter_limit) }
196196
self
197197
}
198198

skia-safe/src/effects/runtime_effect.rs

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use crate::{
33
prelude::*,
44
Blender, ColorFilter, Data, Matrix, Shader,
55
};
6+
use core::ffi;
67
use sb::{SkFlattenable, SkRuntimeEffect_Child};
78
use skia_bindings::{
8-
self as sb, ShaderBuilderUniformResult, SkRefCntBase, SkRuntimeEffect, SkRuntimeEffect_Options,
9-
SkRuntimeEffect_Uniform,
9+
self as sb, ShaderBuilderUniformResult, SkRefCntBase, SkRuntimeEffect, SkRuntimeEffect_Uniform,
1010
};
1111
use std::{fmt, marker::PhantomData, ops::DerefMut, ptr};
1212

@@ -126,25 +126,10 @@ impl NativeRefCountedBase for SkRuntimeEffect {
126126
}
127127

128128
#[repr(C)]
129-
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
130-
pub struct Options {
129+
#[derive(Copy, Clone, PartialEq, Eq, Debug, Default)]
130+
pub struct Options<'a> {
131131
pub force_unoptimized: bool,
132-
allow_private_access: bool,
133-
stable_key: u32,
134-
max_version_allowed: sb::SkSL_Version,
135-
}
136-
137-
native_transmutable!(SkRuntimeEffect_Options, Options, options_layout);
138-
139-
impl Default for Options {
140-
fn default() -> Self {
141-
Options {
142-
force_unoptimized: false,
143-
allow_private_access: false,
144-
stable_key: 0,
145-
max_version_allowed: sb::SkSL_Version::k100,
146-
}
147-
}
132+
pub name: &'a str,
148133
}
149134

150135
impl fmt::Debug for RuntimeEffect {
@@ -161,49 +146,59 @@ impl fmt::Debug for RuntimeEffect {
161146
}
162147

163148
impl RuntimeEffect {
164-
pub fn make_for_color_filer<'a>(
149+
pub fn make_for_color_filter(
165150
sksl: impl AsRef<str>,
166-
options: impl Into<Option<&'a Options>>,
151+
options: impl for<'a, 'b> Into<Option<&'a Options<'b>>>,
167152
) -> Result<RuntimeEffect, String> {
168153
let str = interop::String::from_str(sksl);
169154
let options = options.into().copied().unwrap_or_default();
155+
let options = Self::construct_native_options(&options);
170156
let mut error = interop::String::default();
171157
RuntimeEffect::from_ptr(unsafe {
172-
sb::C_SkRuntimeEffect_MakeForColorFilter(
173-
str.native(),
174-
options.native(),
175-
error.native_mut(),
176-
)
158+
sb::C_SkRuntimeEffect_MakeForColorFilter(str.native(), &options, error.native_mut())
177159
})
178160
.ok_or_else(|| error.to_string())
179161
}
180162

181-
pub fn make_for_shader<'a>(
163+
pub fn make_for_shader(
182164
sksl: impl AsRef<str>,
183-
options: impl Into<Option<&'a Options>>,
165+
options: impl for<'a, 'b> Into<Option<&'a Options<'b>>>,
184166
) -> Result<RuntimeEffect, String> {
185167
let str = interop::String::from_str(sksl);
186168
let options = options.into().copied().unwrap_or_default();
169+
let options = Self::construct_native_options(&options);
187170
let mut error = interop::String::default();
188171
RuntimeEffect::from_ptr(unsafe {
189-
sb::C_SkRuntimeEffect_MakeForShader(str.native(), options.native(), error.native_mut())
172+
sb::C_SkRuntimeEffect_MakeForShader(str.native(), &options, error.native_mut())
190173
})
191174
.ok_or_else(|| error.to_string())
192175
}
193176

194-
pub fn make_for_blender<'a>(
177+
pub fn make_for_blender(
195178
sksl: impl AsRef<str>,
196-
options: impl Into<Option<&'a Options>>,
179+
options: impl for<'a, 'b> Into<Option<&'a Options<'b>>>,
197180
) -> Result<RuntimeEffect, String> {
198181
let str = interop::String::from_str(sksl);
199182
let options = options.into().copied().unwrap_or_default();
183+
let options = Self::construct_native_options(&options);
200184
let mut error = interop::String::default();
201185
RuntimeEffect::from_ptr(unsafe {
202-
sb::C_SkRuntimeEffect_MakeForBlender(str.native(), options.native(), error.native_mut())
186+
sb::C_SkRuntimeEffect_MakeForBlender(str.native(), &options, error.native_mut())
203187
})
204188
.ok_or_else(|| error.to_string())
205189
}
206190

191+
fn construct_native_options(options: &Options<'_>) -> sb::SkRuntimeEffect_Options {
192+
construct(|opt| unsafe {
193+
sb::C_SkRuntimeEffect_Options_Construct(
194+
opt,
195+
options.force_unoptimized,
196+
options.name.as_ptr() as *const ffi::c_char,
197+
options.name.len(),
198+
)
199+
})
200+
}
201+
207202
pub fn make_shader<'a>(
208203
&self,
209204
uniforms: impl Into<Data>,

0 commit comments

Comments
 (0)