mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Replace sparkle
with glow
in components/canvas
(#33918)
* Replace sparkle with glow in components/canvas Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Replace safe_gl with #34300 Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
910e8dc89f
commit
063071ba72
12 changed files with 958 additions and 703 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -714,7 +714,6 @@ dependencies = [
|
|||
"range",
|
||||
"raqote",
|
||||
"servo_arc",
|
||||
"sparkle",
|
||||
"style",
|
||||
"style_traits",
|
||||
"surfman",
|
||||
|
@ -6918,15 +6917,6 @@ dependencies = [
|
|||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sparkle"
|
||||
version = "0.1.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74fc6c6346da9177de9894230716709c223c62adbf910a5c1e6096b2ee2e58e0"
|
||||
dependencies = [
|
||||
"gl_generator",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "speexdsp-resampler"
|
||||
version = "0.1.0"
|
||||
|
|
|
@ -117,7 +117,6 @@ servo_arc = { git = "https://github.com/servo/stylo", branch = "2024-10-04", fea
|
|||
servo_atoms = { git = "https://github.com/servo/stylo", branch = "2024-10-04" }
|
||||
smallbitvec = "2.5.3"
|
||||
smallvec = "1.13"
|
||||
sparkle = "0.1.26"
|
||||
static_assertions = "1.1"
|
||||
string_cache = "0.8"
|
||||
string_cache_codegen = "0.5"
|
||||
|
|
|
@ -39,7 +39,6 @@ pixels = { path = "../pixels" }
|
|||
range = { path = "../range" }
|
||||
raqote = "0.8.5"
|
||||
servo_arc = { workspace = true }
|
||||
sparkle = { workspace = true }
|
||||
style = { workspace = true }
|
||||
style_traits = { workspace = true }
|
||||
surfman = { workspace = true }
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use canvas_traits::webgl::{GLLimits, WebGLVersion};
|
||||
use sparkle::gl;
|
||||
use sparkle::gl::{GLenum, Gl, GlType};
|
||||
use glow::{self as gl, Context as Gl, HasContext};
|
||||
type GLenum = u32;
|
||||
|
||||
pub trait GLLimitsDetect {
|
||||
fn detect(gl: &Gl, webgl_version: WebGLVersion) -> Self;
|
||||
|
@ -32,7 +32,7 @@ impl GLLimitsDetect for GLLimits {
|
|||
max_vertex_output_vectors,
|
||||
max_fragment_input_vectors,
|
||||
);
|
||||
if gl.get_type() == GlType::Gles {
|
||||
if gl.version().is_embedded {
|
||||
max_fragment_uniform_vectors = gl.get_integer(gl::MAX_FRAGMENT_UNIFORM_VECTORS);
|
||||
max_varying_vectors = gl.get_integer(gl::MAX_VARYING_VECTORS);
|
||||
max_vertex_uniform_vectors = gl.get_integer(gl::MAX_VERTEX_UNIFORM_VECTORS);
|
||||
|
@ -220,7 +220,7 @@ macro_rules! create_fun {
|
|||
unsafe {
|
||||
self.$glcall(parameter, &mut value);
|
||||
}
|
||||
if self.get_error() != gl::NO_ERROR {
|
||||
if unsafe { self.get_error() } != gl::NO_ERROR {
|
||||
None
|
||||
} else {
|
||||
Some(value[0] as $rstype)
|
||||
|
@ -234,14 +234,26 @@ macro_rules! create_fun {
|
|||
}
|
||||
|
||||
impl<'a> GLExt for &'a Gl {
|
||||
create_fun!(try_get_integer, get_integer, i32, get_integer_v, u32);
|
||||
create_fun!(try_get_integer64, get_integer64, i64, get_integer64_v, u64);
|
||||
create_fun!(
|
||||
try_get_integer,
|
||||
get_integer,
|
||||
i32,
|
||||
get_parameter_i32_slice,
|
||||
u32
|
||||
);
|
||||
create_fun!(
|
||||
try_get_integer64,
|
||||
get_integer64,
|
||||
i64,
|
||||
get_parameter_i64_slice,
|
||||
u64
|
||||
);
|
||||
create_fun!(
|
||||
try_get_signed_integer,
|
||||
get_signed_integer,
|
||||
i32,
|
||||
get_integer_v,
|
||||
get_parameter_i32_slice,
|
||||
i32
|
||||
);
|
||||
create_fun!(try_get_float, get_float, f32, get_float_v, f32);
|
||||
create_fun!(try_get_float, get_float, f32, get_parameter_f32_slice, f32);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -320,6 +320,7 @@ impl<'a> WebXRContexts<WebXRSurfman> for WebXRBridgeContexts<'a> {
|
|||
)?;
|
||||
Some(&mut data.ctx)
|
||||
}
|
||||
|
||||
fn bindings(&mut self, device: &Device, context_id: WebXRContextId) -> Option<&glow::Context> {
|
||||
let data = WebGLThread::make_current_if_needed(
|
||||
device,
|
||||
|
@ -327,6 +328,6 @@ impl<'a> WebXRContexts<WebXRSurfman> for WebXRBridgeContexts<'a> {
|
|||
self.contexts,
|
||||
self.bound_context_id,
|
||||
)?;
|
||||
Some(&data.glow)
|
||||
Some(&data.gl)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -219,11 +219,11 @@ impl VertexArrayObject {
|
|||
let mut has_active_attrib = false;
|
||||
let mut has_divisor_0 = false;
|
||||
for active_info in active_attribs {
|
||||
if active_info.location < 0 {
|
||||
let Some(location) = active_info.location else {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
has_active_attrib = true;
|
||||
let attrib = &attribs[active_info.location as usize];
|
||||
let attrib = &attribs[location as usize];
|
||||
if attrib.divisor == 0 {
|
||||
has_divisor_0 = true;
|
||||
}
|
||||
|
|
|
@ -294,13 +294,17 @@ impl WebGL2RenderingContext {
|
|||
for prog_attrib in program.active_attribs().iter() {
|
||||
let attrib = handle_potential_webgl_error!(
|
||||
self.base,
|
||||
vao.get_vertex_attrib(prog_attrib.location as u32)
|
||||
// TODO(#34300): remove unwrap
|
||||
vao.get_vertex_attrib(prog_attrib.location.unwrap_or(u32::MAX))
|
||||
.ok_or(InvalidOperation),
|
||||
return
|
||||
);
|
||||
|
||||
let current_vertex_attrib =
|
||||
self.base.current_vertex_attribs()[prog_attrib.location as usize];
|
||||
// TODO(#34300): remove unwrap
|
||||
let current_vertex_attrib = self.base.current_vertex_attribs()[prog_attrib
|
||||
.location
|
||||
.map(|l| l as usize)
|
||||
.unwrap_or(usize::MAX)];
|
||||
let attrib_data_base_type = if !attrib.enabled_as_array {
|
||||
match current_vertex_attrib {
|
||||
VertexAttrib::Int(_, _, _, _) => constants::INT,
|
||||
|
|
|
@ -173,9 +173,9 @@ impl WebGLProgram {
|
|||
let mut used_locs = FnvHashSet::default();
|
||||
let mut used_names = FnvHashSet::default();
|
||||
for active_attrib in &*link_info.active_attribs {
|
||||
if active_attrib.location == -1 {
|
||||
let Some(location) = active_attrib.location else {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let columns = match active_attrib.type_ {
|
||||
constants::FLOAT_MAT2 => 2,
|
||||
constants::FLOAT_MAT3 => 3,
|
||||
|
@ -185,7 +185,7 @@ impl WebGLProgram {
|
|||
assert!(used_names.insert(&*active_attrib.name));
|
||||
for column in 0..columns {
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#6.31
|
||||
if !used_locs.insert(active_attrib.location as u32 + column) {
|
||||
if !used_locs.insert(location + column) {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
@ -364,7 +364,8 @@ impl WebGLProgram {
|
|||
.borrow()
|
||||
.iter()
|
||||
.find(|attrib| attrib.name == *name)
|
||||
.map_or(-1, |attrib| attrib.location);
|
||||
.and_then(|attrib| attrib.location.map(|l| l as i32))
|
||||
.unwrap_or(-1);
|
||||
Ok(location)
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,10 @@ pub use base::generic_channel::GenericSender as WebGLSender;
|
|||
/// Result type for send()/recv() calls in in WebGLCommands.
|
||||
pub use base::generic_channel::SendResult as WebGLSendResult;
|
||||
use euclid::default::{Rect, Size2D};
|
||||
use glow as gl;
|
||||
use glow::{
|
||||
self as gl, NativeBuffer, NativeFence, NativeFramebuffer, NativeProgram, NativeQuery,
|
||||
NativeRenderbuffer, NativeSampler, NativeShader, NativeTexture, NativeVertexArray,
|
||||
};
|
||||
use ipc_channel::ipc::{IpcBytesReceiver, IpcBytesSender, IpcSender, IpcSharedMemory};
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use pixels::PixelFormat;
|
||||
|
@ -632,18 +635,43 @@ macro_rules! define_resource_id {
|
|||
}
|
||||
}
|
||||
};
|
||||
($name:ident, $type:tt, $glow:tt) => {
|
||||
impl $name {
|
||||
#[inline]
|
||||
pub fn glow(self) -> $glow {
|
||||
$glow(self.0)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_glow(glow: $glow) -> Self {
|
||||
Self(glow.0)
|
||||
}
|
||||
}
|
||||
define_resource_id!($name, $type);
|
||||
};
|
||||
}
|
||||
|
||||
define_resource_id!(WebGLBufferId, u32);
|
||||
define_resource_id!(WebGLFramebufferId, u32);
|
||||
define_resource_id!(WebGLRenderbufferId, u32);
|
||||
define_resource_id!(WebGLTextureId, u32);
|
||||
define_resource_id!(WebGLProgramId, u32);
|
||||
define_resource_id!(WebGLQueryId, u32);
|
||||
define_resource_id!(WebGLSamplerId, u32);
|
||||
define_resource_id!(WebGLShaderId, u32);
|
||||
define_resource_id!(WebGLBufferId, u32, NativeBuffer);
|
||||
define_resource_id!(WebGLFramebufferId, u32, NativeFramebuffer);
|
||||
define_resource_id!(WebGLRenderbufferId, u32, NativeRenderbuffer);
|
||||
define_resource_id!(WebGLTextureId, u32, NativeTexture);
|
||||
define_resource_id!(WebGLProgramId, u32, NativeProgram);
|
||||
define_resource_id!(WebGLQueryId, u32, NativeQuery);
|
||||
define_resource_id!(WebGLSamplerId, u32, NativeSampler);
|
||||
define_resource_id!(WebGLShaderId, u32, NativeShader);
|
||||
define_resource_id!(WebGLSyncId, u64);
|
||||
define_resource_id!(WebGLVertexArrayId, u32);
|
||||
impl WebGLSyncId {
|
||||
#[inline]
|
||||
pub fn glow(&self) -> NativeFence {
|
||||
NativeFence(self.0.get() as _)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_glow(glow: NativeFence) -> Self {
|
||||
Self::maybe_new(glow.0 as _).expect("Glow should have valid fence")
|
||||
}
|
||||
}
|
||||
define_resource_id!(WebGLVertexArrayId, u32, NativeVertexArray);
|
||||
define_resource_id!(WebXRLayerManagerId, u32);
|
||||
|
||||
#[derive(
|
||||
|
@ -708,7 +736,7 @@ pub struct ActiveAttribInfo {
|
|||
/// The type of the attribute.
|
||||
pub type_: u32,
|
||||
/// The location of the attribute.
|
||||
pub location: i32,
|
||||
pub location: Option<u32>,
|
||||
}
|
||||
|
||||
/// Description of a single active uniform.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[readbuffer.html]
|
||||
[WebGL test #28: the color should be [0,0,0,255\]\nat (0, 0) expected: 0,0,0,255 was 0,0,255,255]
|
||||
[WebGL test #28: the color should be [0,0,0,255\]\nat (0, 0) expected: 0,0,0,255 was 0,0,0,0]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #15: getError expected: INVALID_OPERATION. Was INVALID_ENUM : calling readBuffer with GL_COLOR_ATTACHMENTi that exceeds MAX_COLOR_ATTACHMENT on fbo should generate INVALID_OPERATION.]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[readbuffer.html]
|
||||
[WebGL test #28: the color should be [0,0,0,255\]\nat (0, 0) expected: 0,0,0,255 was 0,0,255,255]
|
||||
[WebGL test #28: the color should be [0,0,0,255\]\nat (0, 0) expected: 0,0,0,255 was 0,0,0,0]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #15: getError expected: INVALID_OPERATION. Was INVALID_ENUM : calling readBuffer with GL_COLOR_ATTACHMENTi that exceeds MAX_COLOR_ATTACHMENT on fbo should generate INVALID_OPERATION.]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue