mirror of
https://github.com/servo/servo.git
synced 2025-06-08 16:43:28 +00:00
clippy: fix warnings in various modules in components (#31568)
* clippy: fix warnings in various modules in components * fix: unit tests * fix: build on android * fix: all samplers use new_boxed
This commit is contained in:
parent
19f1f2a8f4
commit
3a5ca785d3
24 changed files with 107 additions and 118 deletions
|
@ -13,9 +13,7 @@ pub use crate::platform::*;
|
||||||
mod platform {
|
mod platform {
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
|
|
||||||
use jemallocator;
|
pub use jemallocator::Jemalloc as Allocator;
|
||||||
|
|
||||||
pub use self::jemallocator::Jemalloc as Allocator;
|
|
||||||
|
|
||||||
/// Get the size of a heap block.
|
/// Get the size of a heap block.
|
||||||
pub unsafe extern "C" fn usable_size(ptr: *const c_void) -> usize {
|
pub unsafe extern "C" fn usable_size(ptr: *const c_void) -> usize {
|
||||||
|
|
|
@ -92,19 +92,19 @@ impl BackgroundHangMonitorRegister for HangMonitorRegister {
|
||||||
target_os = "windows",
|
target_os = "windows",
|
||||||
any(target_arch = "x86_64", target_arch = "x86")
|
any(target_arch = "x86_64", target_arch = "x86")
|
||||||
))]
|
))]
|
||||||
let sampler = crate::sampler_windows::WindowsSampler::new();
|
let sampler = crate::sampler_windows::WindowsSampler::new_boxed();
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
let sampler = crate::sampler_mac::MacOsSampler::new();
|
let sampler = crate::sampler_mac::MacOsSampler::new_boxed();
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
not(any(target_arch = "arm", target_arch = "aarch64"))
|
not(any(target_arch = "arm", target_arch = "aarch64"))
|
||||||
))]
|
))]
|
||||||
let sampler = crate::sampler_linux::LinuxSampler::new();
|
let sampler = crate::sampler_linux::LinuxSampler::new_boxed();
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
target_os = "android",
|
target_os = "android",
|
||||||
all(target_os = "linux", any(target_arch = "arm", target_arch = "aarch64"))
|
all(target_os = "linux", any(target_arch = "arm", target_arch = "aarch64"))
|
||||||
))]
|
))]
|
||||||
let sampler = crate::sampler::DummySampler::new();
|
let sampler = crate::sampler::DummySampler::new_boxed();
|
||||||
|
|
||||||
// When a component is registered, and there's an exit request that
|
// When a component is registered, and there's an exit request that
|
||||||
// reached BHM, we want an exit signal to be delivered to the
|
// reached BHM, we want an exit signal to be delivered to the
|
||||||
|
@ -208,7 +208,7 @@ impl BackgroundHangMonitorChan {
|
||||||
BackgroundHangMonitorChan {
|
BackgroundHangMonitorChan {
|
||||||
sender,
|
sender,
|
||||||
_tether: tether,
|
_tether: tether,
|
||||||
component_id: component_id,
|
component_id,
|
||||||
disconnected: Default::default(),
|
disconnected: Default::default(),
|
||||||
monitoring_enabled,
|
monitoring_enabled,
|
||||||
}
|
}
|
||||||
|
@ -312,14 +312,14 @@ struct BackgroundHangMonitorWorker {
|
||||||
monitoring_enabled: bool,
|
monitoring_enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MonitoredComponentSender = Sender<(MonitoredComponentId, MonitoredComponentMsg)>;
|
||||||
|
type MonitoredComponentReceiver = Receiver<(MonitoredComponentId, MonitoredComponentMsg)>;
|
||||||
|
|
||||||
impl BackgroundHangMonitorWorker {
|
impl BackgroundHangMonitorWorker {
|
||||||
fn new(
|
fn new(
|
||||||
constellation_chan: IpcSender<HangMonitorAlert>,
|
constellation_chan: IpcSender<HangMonitorAlert>,
|
||||||
control_port: IpcReceiver<BackgroundHangMonitorControlMsg>,
|
control_port: IpcReceiver<BackgroundHangMonitorControlMsg>,
|
||||||
(port_sender, port): (
|
(port_sender, port): (Arc<MonitoredComponentSender>, MonitoredComponentReceiver),
|
||||||
Arc<Sender<(MonitoredComponentId, MonitoredComponentMsg)>>,
|
|
||||||
Receiver<(MonitoredComponentId, MonitoredComponentMsg)>,
|
|
||||||
),
|
|
||||||
tether_port: Receiver<Never>,
|
tether_port: Receiver<Never>,
|
||||||
monitoring_enabled: bool,
|
monitoring_enabled: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -360,7 +360,7 @@ impl BackgroundHangMonitorWorker {
|
||||||
let profile = stack.to_hangprofile();
|
let profile = stack.to_hangprofile();
|
||||||
let name = match self.component_names.get(&id) {
|
let name = match self.component_names.get(&id) {
|
||||||
Some(ref s) => format!("\"{}\"", s),
|
Some(ref s) => format!("\"{}\"", s),
|
||||||
None => format!("null"),
|
None => "null".to_string(),
|
||||||
};
|
};
|
||||||
let json = format!(
|
let json = format!(
|
||||||
"{}{{ \"name\": {}, \"namespace\": {}, \"index\": {}, \"type\": \"{:?}\", \
|
"{}{{ \"name\": {}, \"namespace\": {}, \"index\": {}, \"type\": \"{:?}\", \
|
||||||
|
@ -389,12 +389,10 @@ impl BackgroundHangMonitorWorker {
|
||||||
.checked_sub(Instant::now() - self.last_sample)
|
.checked_sub(Instant::now() - self.last_sample)
|
||||||
.unwrap_or_else(|| Duration::from_millis(0));
|
.unwrap_or_else(|| Duration::from_millis(0));
|
||||||
after(duration)
|
after(duration)
|
||||||
} else {
|
} else if self.monitoring_enabled {
|
||||||
if self.monitoring_enabled {
|
|
||||||
after(Duration::from_millis(100))
|
after(Duration::from_millis(100))
|
||||||
} else {
|
} else {
|
||||||
never()
|
never()
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let received = select! {
|
let received = select! {
|
||||||
|
@ -403,13 +401,8 @@ impl BackgroundHangMonitorWorker {
|
||||||
// gets disconnected.
|
// gets disconnected.
|
||||||
Some(event.unwrap())
|
Some(event.unwrap())
|
||||||
},
|
},
|
||||||
recv(self.tether_port) -> event => {
|
recv(self.tether_port) -> _ => {
|
||||||
// This arm can only reached by a tether disconnection
|
// This arm can only reached by a tether disconnection
|
||||||
match event {
|
|
||||||
Ok(x) => match x {}
|
|
||||||
Err(_) => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// All associated `HangMonitorRegister` and
|
// All associated `HangMonitorRegister` and
|
||||||
// `BackgroundHangMonitorChan` have been dropped. Suppress
|
// `BackgroundHangMonitorChan` have been dropped. Suppress
|
||||||
// `signal_to_exit` and exit the BHM.
|
// `signal_to_exit` and exit the BHM.
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
use backtrace;
|
|
||||||
use msg::constellation_msg::{HangProfile, HangProfileSymbol};
|
use msg::constellation_msg::{HangProfile, HangProfileSymbol};
|
||||||
|
|
||||||
const MAX_NATIVE_FRAMES: usize = 1024;
|
const MAX_NATIVE_FRAMES: usize = 1024;
|
||||||
|
@ -18,7 +17,7 @@ pub struct DummySampler;
|
||||||
|
|
||||||
impl DummySampler {
|
impl DummySampler {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn new() -> Box<dyn Sampler> {
|
pub fn new_boxed() -> Box<dyn Sampler> {
|
||||||
Box::new(DummySampler)
|
Box::new(DummySampler)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,12 +63,12 @@ impl NativeStack {
|
||||||
instruction_ptr: *mut std::ffi::c_void,
|
instruction_ptr: *mut std::ffi::c_void,
|
||||||
stack_ptr: *mut std::ffi::c_void,
|
stack_ptr: *mut std::ffi::c_void,
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ()> {
|
||||||
if !(self.count < MAX_NATIVE_FRAMES) {
|
if self.count >= MAX_NATIVE_FRAMES {
|
||||||
return Err(());
|
return Err(());
|
||||||
}
|
}
|
||||||
self.instruction_ptrs[self.count] = instruction_ptr;
|
self.instruction_ptrs[self.count] = instruction_ptr;
|
||||||
self.stack_ptrs[self.count] = stack_ptr;
|
self.stack_ptrs[self.count] = stack_ptr;
|
||||||
self.count = self.count + 1;
|
self.count += 1;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +84,7 @@ impl NativeStack {
|
||||||
// TODO: use the demangled or C++ demangled symbols if available.
|
// TODO: use the demangled or C++ demangled symbols if available.
|
||||||
let name = symbol
|
let name = symbol
|
||||||
.name()
|
.name()
|
||||||
.map(|n| String::from_utf8_lossy(&n.as_bytes()).to_string());
|
.map(|n| String::from_utf8_lossy(n.as_bytes()).to_string());
|
||||||
let filename = symbol.filename().map(|n| n.to_string_lossy().to_string());
|
let filename = symbol.filename().map(|n| n.to_string_lossy().to_string());
|
||||||
let lineno = symbol.lineno();
|
let lineno = symbol.lineno();
|
||||||
profile.backtrace.push(HangProfileSymbol {
|
profile.backtrace.push(HangProfileSymbol {
|
||||||
|
|
|
@ -6,9 +6,8 @@
|
||||||
|
|
||||||
use std::cell::UnsafeCell;
|
use std::cell::UnsafeCell;
|
||||||
use std::sync::atomic::{AtomicPtr, Ordering};
|
use std::sync::atomic::{AtomicPtr, Ordering};
|
||||||
use std::{io, mem, process, ptr, thread};
|
use std::{cmp, io, mem, process, ptr, thread};
|
||||||
|
|
||||||
use libc;
|
|
||||||
use nix::sys::signal::{sigaction, SaFlags, SigAction, SigHandler, SigSet, Signal};
|
use nix::sys::signal::{sigaction, SaFlags, SigAction, SigHandler, SigSet, Signal};
|
||||||
use unwind_sys::{
|
use unwind_sys::{
|
||||||
unw_cursor_t, unw_get_reg, unw_init_local, unw_step, UNW_ESUCCESS, UNW_REG_IP, UNW_REG_SP,
|
unw_cursor_t, unw_get_reg, unw_init_local, unw_step, UNW_ESUCCESS, UNW_REG_IP, UNW_REG_SP,
|
||||||
|
@ -138,7 +137,7 @@ pub struct LinuxSampler {
|
||||||
|
|
||||||
impl LinuxSampler {
|
impl LinuxSampler {
|
||||||
#[allow(unsafe_code, dead_code)]
|
#[allow(unsafe_code, dead_code)]
|
||||||
pub fn new() -> Box<dyn Sampler> {
|
pub fn new_boxed() -> Box<dyn Sampler> {
|
||||||
let thread_id = unsafe { libc::syscall(libc::SYS_gettid) as libc::pid_t };
|
let thread_id = unsafe { libc::syscall(libc::SYS_gettid) as libc::pid_t };
|
||||||
let handler = SigHandler::SigAction(sigprof_handler);
|
let handler = SigHandler::SigAction(sigprof_handler);
|
||||||
let action = SigAction::new(
|
let action = SigAction::new(
|
||||||
|
@ -181,12 +180,10 @@ fn step(cursor: *mut unw_cursor_t) -> Result<bool, i32> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let ret = unw_step(cursor);
|
let ret = unw_step(cursor);
|
||||||
if ret > 0 {
|
match ret.cmp(&0) {
|
||||||
Ok(true)
|
cmp::Ordering::Less => Err(ret),
|
||||||
} else if ret == 0 {
|
cmp::Ordering::Greater => Ok(true),
|
||||||
Ok(false)
|
cmp::Ordering::Equal => Ok(false),
|
||||||
} else {
|
|
||||||
Err(ret)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,6 +219,7 @@ impl Sampler for LinuxSampler {
|
||||||
let ret = unsafe { unw_init_local(cursor.as_mut_ptr(), context) };
|
let ret = unsafe { unw_init_local(cursor.as_mut_ptr(), context) };
|
||||||
result = if ret == UNW_ESUCCESS {
|
result = if ret == UNW_ESUCCESS {
|
||||||
let mut native_stack = NativeStack::new();
|
let mut native_stack = NativeStack::new();
|
||||||
|
#[allow(clippy::while_let_loop)] // False positive
|
||||||
loop {
|
loop {
|
||||||
let ip = match get_register(cursor.as_mut_ptr(), RegNum::Ip) {
|
let ip = match get_register(cursor.as_mut_ptr(), RegNum::Ip) {
|
||||||
Ok(ip) => ip,
|
Ok(ip) => ip,
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub struct MacOsSampler {
|
||||||
|
|
||||||
impl MacOsSampler {
|
impl MacOsSampler {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub fn new() -> Box<dyn Sampler> {
|
pub fn new_boxed() -> Box<dyn Sampler> {
|
||||||
let thread_id = unsafe { mach2::mach_init::mach_thread_self() };
|
let thread_id = unsafe { mach2::mach_init::mach_thread_self() };
|
||||||
Box::new(MacOsSampler { thread_id })
|
Box::new(MacOsSampler { thread_id })
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub struct WindowsSampler {
|
||||||
|
|
||||||
impl WindowsSampler {
|
impl WindowsSampler {
|
||||||
#[allow(unsafe_code, dead_code)]
|
#[allow(unsafe_code, dead_code)]
|
||||||
pub fn new() -> Box<dyn Sampler> {
|
pub fn new_boxed() -> Box<dyn Sampler> {
|
||||||
let thread_id = 0; // TODO: use winapi::um::processthreadsapi::GetThreadId
|
let thread_id = 0; // TODO: use winapi::um::processthreadsapi::GetThreadId
|
||||||
Box::new(WindowsSampler { thread_id })
|
Box::new(WindowsSampler { thread_id })
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,13 +20,13 @@ pub fn dom_struct(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
// Work around https://github.com/rust-lang/rust/issues/46489
|
// Work around https://github.com/rust-lang/rust/issues/46489
|
||||||
let attributes: TokenStream = attributes.to_string().parse().unwrap();
|
let attributes: TokenStream = attributes.to_string().parse().unwrap();
|
||||||
|
|
||||||
let output: TokenStream = attributes.into_iter().chain(input.into_iter()).collect();
|
let output: TokenStream = attributes.into_iter().chain(input).collect();
|
||||||
|
|
||||||
let item: Item = syn::parse(output).unwrap();
|
let item: Item = syn::parse(output).unwrap();
|
||||||
|
|
||||||
if let Item::Struct(s) = item {
|
if let Item::Struct(s) = item {
|
||||||
let s2 = s.clone();
|
let s2 = s.clone();
|
||||||
if s.generics.params.len() > 0 {
|
if !s.generics.params.is_empty() {
|
||||||
return quote!(#s2).into();
|
return quote!(#s2).into();
|
||||||
}
|
}
|
||||||
if let Fields::Named(ref f) = s.fields {
|
if let Fields::Named(ref f) = s.fields {
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#![recursion_limit = "128"]
|
#![recursion_limit = "128"]
|
||||||
|
|
||||||
use proc_macro2;
|
|
||||||
use quote::{quote, TokenStreamExt};
|
use quote::{quote, TokenStreamExt};
|
||||||
use syn::parse_quote;
|
use syn::parse_quote;
|
||||||
|
|
||||||
|
|
|
@ -531,7 +531,7 @@ impl<'a> Serialize for Ser<'a, Mime> {
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
{
|
{
|
||||||
serializer.serialize_str(&self.v.as_ref())
|
serializer.serialize_str(self.v.as_ref())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ static THREAD_TINT_COLORS: [ColorF; 8] = [
|
||||||
a: 0.7,
|
a: 0.7,
|
||||||
},
|
},
|
||||||
ColorF {
|
ColorF {
|
||||||
r: 255.0 / 255.0,
|
r: 1.0,
|
||||||
g: 212.0 / 255.0,
|
g: 212.0 / 255.0,
|
||||||
b: 83.0 / 255.0,
|
b: 83.0 / 255.0,
|
||||||
a: 0.7,
|
a: 0.7,
|
||||||
|
@ -110,7 +110,7 @@ static THREAD_TINT_COLORS: [ColorF; 8] = [
|
||||||
a: 0.7,
|
a: 0.7,
|
||||||
},
|
},
|
||||||
ColorF {
|
ColorF {
|
||||||
r: 255.0 / 255.0,
|
r: 1.0,
|
||||||
g: 249.0 / 255.0,
|
g: 249.0 / 255.0,
|
||||||
b: 201.0 / 255.0,
|
b: 201.0 / 255.0,
|
||||||
a: 0.7,
|
a: 0.7,
|
||||||
|
|
|
@ -29,16 +29,23 @@ const CHUNK_SIZE: usize = 16;
|
||||||
pub type FlowList = SmallVec<[UnsafeFlow; CHUNK_SIZE]>;
|
pub type FlowList = SmallVec<[UnsafeFlow; CHUNK_SIZE]>;
|
||||||
|
|
||||||
/// Vtable + pointer representation of a Flow trait object.
|
/// Vtable + pointer representation of a Flow trait object.
|
||||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
#[derive(Clone, Copy, Eq)]
|
||||||
pub struct UnsafeFlow(*const dyn Flow);
|
pub struct UnsafeFlow(*const dyn Flow);
|
||||||
|
|
||||||
unsafe impl Sync for UnsafeFlow {}
|
unsafe impl Sync for UnsafeFlow {}
|
||||||
unsafe impl Send for UnsafeFlow {}
|
unsafe impl Send for UnsafeFlow {}
|
||||||
|
impl PartialEq for UnsafeFlow {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
// Compare the pointers explicitly to avoid clippy lint
|
||||||
|
self.0 as *const u8 == other.0 as *const u8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn null_unsafe_flow() -> UnsafeFlow {
|
fn null_unsafe_flow() -> UnsafeFlow {
|
||||||
UnsafeFlow(ptr::null::<BlockFlow>())
|
UnsafeFlow(ptr::null::<BlockFlow>())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::not_unsafe_ptr_arg_deref)] // It has an unsafe block inside
|
||||||
pub fn mut_owned_flow_to_unsafe_flow(flow: *mut FlowRef) -> UnsafeFlow {
|
pub fn mut_owned_flow_to_unsafe_flow(flow: *mut FlowRef) -> UnsafeFlow {
|
||||||
unsafe { UnsafeFlow(&**flow) }
|
unsafe { UnsafeFlow(&**flow) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
|
#![allow(clippy::type_complexity)]
|
||||||
|
|
||||||
mod media_channel;
|
mod media_channel;
|
||||||
mod media_thread;
|
mod media_thread;
|
||||||
|
|
|
@ -74,6 +74,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::wrong_self_convention)] // It is an alias to the underlying module
|
||||||
pub fn to_opaque(self) -> ipc_channel::ipc::OpaqueIpcReceiver {
|
pub fn to_opaque(self) -> ipc_channel::ipc::OpaqueIpcReceiver {
|
||||||
match self {
|
match self {
|
||||||
GLPlayerReceiver::Ipc(receiver) => receiver.to_opaque(),
|
GLPlayerReceiver::Ipc(receiver) => receiver.to_opaque(),
|
||||||
|
|
|
@ -79,14 +79,14 @@ impl GLPlayerThread {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
GLPlayerMsg::Lock(id, handler_sender) => {
|
GLPlayerMsg::Lock(id, handler_sender) => {
|
||||||
self.players.get(&id).map(|sender| {
|
if let Some(sender) = self.players.get(&id) {
|
||||||
sender.send(GLPlayerMsgForward::Lock(handler_sender)).ok();
|
sender.send(GLPlayerMsgForward::Lock(handler_sender)).ok();
|
||||||
});
|
}
|
||||||
},
|
},
|
||||||
GLPlayerMsg::Unlock(id) => {
|
GLPlayerMsg::Unlock(id) => {
|
||||||
self.players.get(&id).map(|sender| {
|
if let Some(sender) = self.players.get(&id) {
|
||||||
sender.send(GLPlayerMsgForward::Unlock()).ok();
|
sender.send(GLPlayerMsgForward::Unlock()).ok();
|
||||||
});
|
}
|
||||||
},
|
},
|
||||||
GLPlayerMsg::Exit => return true,
|
GLPlayerMsg::Exit => return true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,9 +49,7 @@ pub fn rgba8_get_rect(pixels: &[u8], size: Size2D<u64>, rect: Rect<u64>) -> Cow<
|
||||||
pub fn rgba8_byte_swap_colors_inplace(pixels: &mut [u8]) {
|
pub fn rgba8_byte_swap_colors_inplace(pixels: &mut [u8]) {
|
||||||
assert!(pixels.len() % 4 == 0);
|
assert!(pixels.len() % 4 == 0);
|
||||||
for rgba in pixels.chunks_mut(4) {
|
for rgba in pixels.chunks_mut(4) {
|
||||||
let b = rgba[0];
|
rgba.swap(0, 2);
|
||||||
rgba[0] = rgba[2];
|
|
||||||
rgba[2] = b;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +77,7 @@ pub fn rgba8_premultiply_inplace(pixels: &mut [u8]) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn multiply_u8_color(a: u8, b: u8) -> u8 {
|
pub fn multiply_u8_color(a: u8, b: u8) -> u8 {
|
||||||
return (a as u32 * b as u32 / 255) as u8;
|
(a as u32 * b as u32 / 255) as u8
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clip(
|
pub fn clip(
|
||||||
|
|
|
@ -30,8 +30,8 @@ pub struct Profiler {
|
||||||
created: Instant,
|
created: Instant,
|
||||||
}
|
}
|
||||||
|
|
||||||
const JEMALLOC_HEAP_ALLOCATED_STR: &'static str = "jemalloc-heap-allocated";
|
const JEMALLOC_HEAP_ALLOCATED_STR: &str = "jemalloc-heap-allocated";
|
||||||
const SYSTEM_HEAP_ALLOCATED_STR: &'static str = "system-heap-allocated";
|
const SYSTEM_HEAP_ALLOCATED_STR: &str = "system-heap-allocated";
|
||||||
|
|
||||||
impl Profiler {
|
impl Profiler {
|
||||||
pub fn create(period: Option<f64>) -> ProfilerChan {
|
pub fn create(period: Option<f64>) -> ProfilerChan {
|
||||||
|
@ -84,7 +84,7 @@ impl Profiler {
|
||||||
|
|
||||||
pub fn new(port: IpcReceiver<ProfilerMsg>) -> Profiler {
|
pub fn new(port: IpcReceiver<ProfilerMsg>) -> Profiler {
|
||||||
Profiler {
|
Profiler {
|
||||||
port: port,
|
port,
|
||||||
reporters: HashMap::new(),
|
reporters: HashMap::new(),
|
||||||
created: Instant::now(),
|
created: Instant::now(),
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ impl Profiler {
|
||||||
|
|
||||||
println!("|");
|
println!("|");
|
||||||
println!("End memory reports");
|
println!("End memory reports");
|
||||||
println!("");
|
println!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ impl ReportsTree {
|
||||||
ReportsTree {
|
ReportsTree {
|
||||||
size: 0,
|
size: 0,
|
||||||
count: 0,
|
count: 0,
|
||||||
path_seg: path_seg,
|
path_seg,
|
||||||
children: vec![],
|
children: vec![],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ impl ReportsTree {
|
||||||
fn insert(&mut self, path: &[String], size: usize) {
|
fn insert(&mut self, path: &[String], size: usize) {
|
||||||
let mut t: &mut ReportsTree = self;
|
let mut t: &mut ReportsTree = self;
|
||||||
for path_seg in path {
|
for path_seg in path {
|
||||||
let i = match t.find_child(&path_seg) {
|
let i = match t.find_child(path_seg) {
|
||||||
Some(i) => i,
|
Some(i) => i,
|
||||||
None => {
|
None => {
|
||||||
let new_t = ReportsTree::new(path_seg.clone());
|
let new_t = ReportsTree::new(path_seg.clone());
|
||||||
|
@ -352,7 +352,7 @@ impl ReportsForest {
|
||||||
|
|
||||||
fn print(&mut self) {
|
fn print(&mut self) {
|
||||||
// Fill in sizes of interior nodes, and recursively sort the sub-trees.
|
// Fill in sizes of interior nodes, and recursively sort the sub-trees.
|
||||||
for (_, tree) in &mut self.trees {
|
for tree in self.trees.values_mut() {
|
||||||
tree.compute_interior_node_sizes_and_sort();
|
tree.compute_interior_node_sizes_and_sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ impl ReportsForest {
|
||||||
// single node) come after non-degenerate trees. Secondary sort: alphabetical order of the
|
// single node) come after non-degenerate trees. Secondary sort: alphabetical order of the
|
||||||
// root node's path_seg.
|
// root node's path_seg.
|
||||||
let mut v = vec![];
|
let mut v = vec![];
|
||||||
for (_, tree) in &self.trees {
|
for tree in self.trees.values() {
|
||||||
v.push(tree);
|
v.push(tree);
|
||||||
}
|
}
|
||||||
v.sort_by(|a, b| {
|
v.sort_by(|a, b| {
|
||||||
|
@ -412,9 +412,9 @@ mod system_reporter {
|
||||||
let mut report = |path, size| {
|
let mut report = |path, size| {
|
||||||
if let Some(size) = size {
|
if let Some(size) = size {
|
||||||
reports.push(Report {
|
reports.push(Report {
|
||||||
path: path,
|
path,
|
||||||
kind: ReportKind::NonExplicitSize,
|
kind: ReportKind::NonExplicitSize,
|
||||||
size: size,
|
size,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -663,7 +663,7 @@ mod system_reporter {
|
||||||
|
|
||||||
// Construct the segment name from its pathname and permissions.
|
// Construct the segment name from its pathname and permissions.
|
||||||
curr_seg_name.clear();
|
curr_seg_name.clear();
|
||||||
if pathname == "" || pathname.starts_with("[stack:") {
|
if pathname.is_empty() || pathname.starts_with("[stack:") {
|
||||||
// Anonymous memory. Entries marked with "[stack:nnn]"
|
// Anonymous memory. Entries marked with "[stack:nnn]"
|
||||||
// look like thread stacks but they may include other
|
// look like thread stacks but they may include other
|
||||||
// anonymous mappings, so we can't trust them and just
|
// anonymous mappings, so we can't trust them and just
|
||||||
|
@ -674,7 +674,7 @@ mod system_reporter {
|
||||||
}
|
}
|
||||||
curr_seg_name.push_str(" (");
|
curr_seg_name.push_str(" (");
|
||||||
curr_seg_name.push_str(perms);
|
curr_seg_name.push_str(perms);
|
||||||
curr_seg_name.push_str(")");
|
curr_seg_name.push(')');
|
||||||
|
|
||||||
looking_for = LookingFor::Rss;
|
looking_for = LookingFor::Rss;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -184,9 +184,9 @@ impl Profiler {
|
||||||
})
|
})
|
||||||
.expect("Thread spawning failed");
|
.expect("Thread spawning failed");
|
||||||
// decide if we need to spawn the timer thread
|
// decide if we need to spawn the timer thread
|
||||||
match option {
|
match *option {
|
||||||
&OutputOptions::FileName(_) => { /* no timer thread needed */ },
|
OutputOptions::FileName(_) => { /* no timer thread needed */ },
|
||||||
&OutputOptions::Stdout(period) => {
|
OutputOptions::Stdout(period) => {
|
||||||
// Spawn a timer thread
|
// Spawn a timer thread
|
||||||
let chan = chan.clone();
|
let chan = chan.clone();
|
||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
|
@ -241,11 +241,11 @@ impl Profiler {
|
||||||
output: Option<OutputOptions>,
|
output: Option<OutputOptions>,
|
||||||
) -> Profiler {
|
) -> Profiler {
|
||||||
Profiler {
|
Profiler {
|
||||||
port: port,
|
port,
|
||||||
buckets: BTreeMap::new(),
|
buckets: BTreeMap::new(),
|
||||||
output: output,
|
output,
|
||||||
last_msg: None,
|
last_msg: None,
|
||||||
trace: trace,
|
trace,
|
||||||
blocked_layout_queries: HashMap::new(),
|
blocked_layout_queries: HashMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ impl Profiler {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_or_insert(&mut self, k: (ProfilerCategory, Option<TimerMetadata>), t: f64) {
|
fn find_or_insert(&mut self, k: (ProfilerCategory, Option<TimerMetadata>), t: f64) {
|
||||||
self.buckets.entry(k).or_insert_with(Vec::new).push(t);
|
self.buckets.entry(k).or_default().push(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_msg(&mut self, msg: ProfilerMsg) -> bool {
|
fn handle_msg(&mut self, msg: ProfilerMsg) -> bool {
|
||||||
|
@ -321,24 +321,24 @@ impl Profiler {
|
||||||
match self.output {
|
match self.output {
|
||||||
Some(OutputOptions::FileName(ref filename)) => {
|
Some(OutputOptions::FileName(ref filename)) => {
|
||||||
let path = Path::new(&filename);
|
let path = Path::new(&filename);
|
||||||
let mut file = match File::create(&path) {
|
let mut file = match File::create(path) {
|
||||||
Err(e) => panic!("Couldn't create {}: {}", path.display(), e),
|
Err(e) => panic!("Couldn't create {}: {}", path.display(), e),
|
||||||
Ok(file) => file,
|
Ok(file) => file,
|
||||||
};
|
};
|
||||||
write!(
|
writeln!(
|
||||||
file,
|
file,
|
||||||
"_category_\t_incremental?_\t_iframe?_\t_url_\t_mean (ms)_\t\
|
"_category_\t_incremental?_\t_iframe?_\t_url_\t_mean (ms)_\t\
|
||||||
_median (ms)_\t_min (ms)_\t_max (ms)_\t_events_\n"
|
_median (ms)_\t_min (ms)_\t_max (ms)_\t_events_"
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
for (&(ref category, ref meta), ref mut data) in &mut self.buckets {
|
for ((category, meta), ref mut data) in &mut self.buckets {
|
||||||
data.sort_by(|a, b| a.partial_cmp(b).expect("No NaN values in profiles"));
|
data.sort_by(|a, b| a.partial_cmp(b).expect("No NaN values in profiles"));
|
||||||
let data_len = data.len();
|
let data_len = data.len();
|
||||||
if data_len > 0 {
|
if data_len > 0 {
|
||||||
let (mean, median, min, max) = Self::get_statistics(data);
|
let (mean, median, min, max) = Self::get_statistics(data);
|
||||||
write!(
|
writeln!(
|
||||||
file,
|
file,
|
||||||
"{}\t{}\t{:15.4}\t{:15.4}\t{:15.4}\t{:15.4}\t{:15}\n",
|
"{}\t{}\t{:15.4}\t{:15.4}\t{:15.4}\t{:15.4}\t{:15}",
|
||||||
category.format(&self.output),
|
category.format(&self.output),
|
||||||
meta.format(&self.output),
|
meta.format(&self.output),
|
||||||
mean,
|
mean,
|
||||||
|
@ -351,9 +351,9 @@ impl Profiler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(file, "_url\t_blocked layout queries_\n").unwrap();
|
writeln!(file, "_url\t_blocked layout queries_").unwrap();
|
||||||
for (url, count) in &self.blocked_layout_queries {
|
for (url, count) in &self.blocked_layout_queries {
|
||||||
write!(file, "{}\t{}\n", url, count).unwrap();
|
writeln!(file, "{}\t{}", url, count).unwrap();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Some(OutputOptions::Stdout(_)) => {
|
Some(OutputOptions::Stdout(_)) => {
|
||||||
|
@ -374,7 +374,7 @@ impl Profiler {
|
||||||
" _events_"
|
" _events_"
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
for (&(ref category, ref meta), ref mut data) in &mut self.buckets {
|
for ((category, meta), ref mut data) in &mut self.buckets {
|
||||||
data.sort_by(|a, b| a.partial_cmp(b).expect("No NaN values in profiles"));
|
data.sort_by(|a, b| a.partial_cmp(b).expect("No NaN values in profiles"));
|
||||||
let data_len = data.len();
|
let data_len = data.len();
|
||||||
if data_len > 0 {
|
if data_len > 0 {
|
||||||
|
@ -393,13 +393,13 @@ impl Profiler {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writeln!(&mut lock, "").unwrap();
|
writeln!(&mut lock).unwrap();
|
||||||
|
|
||||||
writeln!(&mut lock, "_url_\t_blocked layout queries_").unwrap();
|
writeln!(&mut lock, "_url_\t_blocked layout queries_").unwrap();
|
||||||
for (url, count) in &self.blocked_layout_queries {
|
for (url, count) in &self.blocked_layout_queries {
|
||||||
writeln!(&mut lock, "{}\t{}", url, count).unwrap();
|
writeln!(&mut lock, "{}\t{}", url, count).unwrap();
|
||||||
}
|
}
|
||||||
writeln!(&mut lock, "").unwrap();
|
writeln!(&mut lock).unwrap();
|
||||||
},
|
},
|
||||||
None => { /* Do nothing if no output option has been set */ },
|
None => { /* Do nothing if no output option has been set */ },
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,7 +37,7 @@ impl TraceDump {
|
||||||
{
|
{
|
||||||
let mut file = fs::File::create(trace_file_path)?;
|
let mut file = fs::File::create(trace_file_path)?;
|
||||||
write_prologue(&mut file)?;
|
write_prologue(&mut file)?;
|
||||||
Ok(TraceDump { file: file })
|
Ok(TraceDump { file })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write one trace to the trace dump file.
|
/// Write one trace to the trace dump file.
|
||||||
|
|
|
@ -204,10 +204,7 @@ impl<I: RangeIndex> Range<I> {
|
||||||
/// ~~~
|
/// ~~~
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(begin: I, length: I) -> Range<I> {
|
pub fn new(begin: I, length: I) -> Range<I> {
|
||||||
Range {
|
Range { begin, length }
|
||||||
begin: begin,
|
|
||||||
length: length,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -36,7 +36,7 @@ impl ThreadId {
|
||||||
ThreadId(NonZeroUsize::new(number).unwrap())
|
ThreadId(NonZeroUsize::new(number).unwrap())
|
||||||
}
|
}
|
||||||
pub fn current() -> ThreadId {
|
pub fn current() -> ThreadId {
|
||||||
THREAD_ID.with(|tls| tls.clone())
|
THREAD_ID.with(|tls| *tls)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,10 +46,13 @@ thread_local! { static THREAD_ID: ThreadId = ThreadId::new() }
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct AtomicOptThreadId(AtomicUsize);
|
pub struct AtomicOptThreadId(AtomicUsize);
|
||||||
|
|
||||||
impl AtomicOptThreadId {
|
impl Default for AtomicOptThreadId {
|
||||||
pub fn new() -> AtomicOptThreadId {
|
fn default() -> Self {
|
||||||
AtomicOptThreadId(AtomicUsize::new(0))
|
AtomicOptThreadId(AtomicUsize::new(0))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AtomicOptThreadId {
|
||||||
pub fn store(&self, value: Option<ThreadId>, ordering: Ordering) {
|
pub fn store(&self, value: Option<ThreadId>, ordering: Ordering) {
|
||||||
let number = value.map(|id| id.0.get()).unwrap_or(0);
|
let number = value.map(|id| id.0.get()).unwrap_or(0);
|
||||||
self.0.store(number, ordering);
|
self.0.store(number, ordering);
|
||||||
|
@ -75,14 +78,17 @@ pub struct HandOverHandMutex {
|
||||||
guard: UnsafeCell<Option<MutexGuard<'static, ()>>>,
|
guard: UnsafeCell<Option<MutexGuard<'static, ()>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HandOverHandMutex {
|
impl Default for HandOverHandMutex {
|
||||||
pub fn new() -> HandOverHandMutex {
|
fn default() -> Self {
|
||||||
HandOverHandMutex {
|
Self {
|
||||||
mutex: Mutex::new(()),
|
mutex: Mutex::new(()),
|
||||||
owner: AtomicOptThreadId::new(),
|
owner: AtomicOptThreadId::default(),
|
||||||
guard: UnsafeCell::new(None),
|
guard: UnsafeCell::new(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl HandOverHandMutex {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn set_guard_and_owner<'a>(&'a self, guard: MutexGuard<'a, ()>) {
|
unsafe fn set_guard_and_owner<'a>(&'a self, guard: MutexGuard<'a, ()>) {
|
||||||
// The following two lines allow us to unsafely store
|
// The following two lines allow us to unsafely store
|
||||||
|
@ -107,7 +113,7 @@ impl HandOverHandMutex {
|
||||||
assert_eq!(old_owner, Some(ThreadId::current()));
|
assert_eq!(old_owner, Some(ThreadId::current()));
|
||||||
}
|
}
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub fn lock<'a>(&'a self) -> LockResult<()> {
|
pub fn lock(&self) -> LockResult<()> {
|
||||||
let (guard, result) = match self.mutex.lock() {
|
let (guard, result) = match self.mutex.lock() {
|
||||||
Ok(guard) => (guard, Ok(())),
|
Ok(guard) => (guard, Ok(())),
|
||||||
Err(err) => (err.into_inner(), Err(PoisonError::new(()))),
|
Err(err) => (err.into_inner(), Err(PoisonError::new(()))),
|
||||||
|
@ -163,9 +169,9 @@ impl<T> ReentrantMutex<T> {
|
||||||
pub fn new(data: T) -> ReentrantMutex<T> {
|
pub fn new(data: T) -> ReentrantMutex<T> {
|
||||||
trace!("{:?} Creating new lock.", ThreadId::current());
|
trace!("{:?} Creating new lock.", ThreadId::current());
|
||||||
ReentrantMutex {
|
ReentrantMutex {
|
||||||
mutex: HandOverHandMutex::new(),
|
mutex: HandOverHandMutex::default(),
|
||||||
count: Cell::new(0),
|
count: Cell::new(0),
|
||||||
data: data,
|
data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +179,7 @@ impl<T> ReentrantMutex<T> {
|
||||||
trace!("{:?} Locking.", ThreadId::current());
|
trace!("{:?} Locking.", ThreadId::current());
|
||||||
if self.mutex.owner() != Some(ThreadId::current()) {
|
if self.mutex.owner() != Some(ThreadId::current()) {
|
||||||
trace!("{:?} Becoming owner.", ThreadId::current());
|
trace!("{:?} Becoming owner.", ThreadId::current());
|
||||||
if let Err(_) = self.mutex.lock() {
|
if self.mutex.lock().is_err() {
|
||||||
trace!("{:?} Poison!", ThreadId::current());
|
trace!("{:?} Poison!", ThreadId::current());
|
||||||
return Err(PoisonError::new(self.mk_guard()));
|
return Err(PoisonError::new(self.mk_guard()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,16 +31,16 @@ fn main() {
|
||||||
println!("Binding generation completed in {:?}", start.elapsed());
|
println!("Binding generation completed in {:?}", start.elapsed());
|
||||||
|
|
||||||
let json = out_dir.join("InterfaceObjectMapData.json");
|
let json = out_dir.join("InterfaceObjectMapData.json");
|
||||||
let json: Value = serde_json::from_reader(File::open(&json).unwrap()).unwrap();
|
let json: Value = serde_json::from_reader(File::open(json).unwrap()).unwrap();
|
||||||
let mut map = phf_codegen::Map::new();
|
let mut map = phf_codegen::Map::new();
|
||||||
for (key, value) in json.as_object().unwrap() {
|
for (key, value) in json.as_object().unwrap() {
|
||||||
map.entry(Bytes(key), value.as_str().unwrap());
|
map.entry(Bytes(key), value.as_str().unwrap());
|
||||||
}
|
}
|
||||||
let phf = PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("InterfaceObjectMapPhf.rs");
|
let phf = PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("InterfaceObjectMapPhf.rs");
|
||||||
let mut phf = File::create(&phf).unwrap();
|
let mut phf = File::create(phf).unwrap();
|
||||||
write!(
|
writeln!(
|
||||||
&mut phf,
|
&mut phf,
|
||||||
"pub static MAP: phf::Map<&'static [u8], fn(JSContext, HandleObject)> = {};\n",
|
"pub static MAP: phf::Map<&'static [u8], fn(JSContext, HandleObject)> = {};",
|
||||||
map.build(),
|
map.build(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -387,7 +387,7 @@ where
|
||||||
embedder.register_webxr(&mut webxr_main_thread, embedder_proxy.clone());
|
embedder.register_webxr(&mut webxr_main_thread, embedder_proxy.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
let wgpu_image_handler = webgpu::WGPUExternalImages::new();
|
let wgpu_image_handler = webgpu::WGPUExternalImages::default();
|
||||||
let wgpu_image_map = wgpu_image_handler.images.clone();
|
let wgpu_image_map = wgpu_image_handler.images.clone();
|
||||||
external_image_handlers.set_handler(
|
external_image_handlers.set_handler(
|
||||||
Box::new(wgpu_image_handler),
|
Box::new(wgpu_image_handler),
|
||||||
|
|
|
@ -176,7 +176,7 @@ impl ServoUrl {
|
||||||
// Strip `scheme://`, which is hardly useful for identifying websites
|
// Strip `scheme://`, which is hardly useful for identifying websites
|
||||||
let mut st = self.as_str();
|
let mut st = self.as_str();
|
||||||
st = st.strip_prefix(self.scheme()).unwrap_or(st);
|
st = st.strip_prefix(self.scheme()).unwrap_or(st);
|
||||||
st = st.strip_prefix(":").unwrap_or(st);
|
st = st.strip_prefix(':').unwrap_or(st);
|
||||||
st = st.trim_start_matches('/');
|
st = st.trim_start_matches('/');
|
||||||
|
|
||||||
// Don't want to return an empty string
|
// Don't want to return an empty string
|
||||||
|
|
|
@ -919,8 +919,8 @@ impl<'a> WGPU<'a> {
|
||||||
pipeline_id,
|
pipeline_id,
|
||||||
} => {
|
} => {
|
||||||
let desc = DeviceDescriptor {
|
let desc = DeviceDescriptor {
|
||||||
label: descriptor.label.as_ref().map(|l| crate::Cow::from(l)),
|
label: descriptor.label.as_ref().map(crate::Cow::from),
|
||||||
features: descriptor.features.clone(),
|
features: descriptor.features,
|
||||||
limits: descriptor.limits.clone(),
|
limits: descriptor.limits.clone(),
|
||||||
};
|
};
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
|
@ -1336,20 +1336,12 @@ webgpu_resource!(WebGPUSurface, id::SurfaceId);
|
||||||
webgpu_resource!(WebGPUTexture, id::TextureId);
|
webgpu_resource!(WebGPUTexture, id::TextureId);
|
||||||
webgpu_resource!(WebGPUTextureView, id::TextureViewId);
|
webgpu_resource!(WebGPUTextureView, id::TextureViewId);
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
pub struct WGPUExternalImages {
|
pub struct WGPUExternalImages {
|
||||||
pub images: Arc<Mutex<HashMap<u64, PresentationData>>>,
|
pub images: Arc<Mutex<HashMap<u64, PresentationData>>>,
|
||||||
pub locked_ids: HashMap<u64, Vec<u8>>,
|
pub locked_ids: HashMap<u64, Vec<u8>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WGPUExternalImages {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
images: Arc::new(Mutex::new(HashMap::new())),
|
|
||||||
locked_ids: HashMap::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WebrenderExternalImageApi for WGPUExternalImages {
|
impl WebrenderExternalImageApi for WGPUExternalImages {
|
||||||
fn lock(&mut self, id: u64) -> (WebrenderImageSource, Size2D<i32>) {
|
fn lock(&mut self, id: u64) -> (WebrenderImageSource, Size2D<i32>) {
|
||||||
let size;
|
let size;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue