mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Replace use of gleam in webgl with sparkle.
This commit is contained in:
parent
ec1da1d01c
commit
1cefae7181
16 changed files with 103 additions and 72 deletions
|
@ -29,11 +29,12 @@ half = "1"
|
|||
ipc-channel = "0.12"
|
||||
log = "0.4"
|
||||
num-traits = "0.2"
|
||||
offscreen_gl_context = {version = "0.23", features = ["serde", "osmesa"]}
|
||||
offscreen_gl_context = {version = "0.25", features = ["serde", "osmesa"]}
|
||||
raqote = {git = "https://github.com/jrmuizel/raqote", optional = true}
|
||||
pixels = {path = "../pixels"}
|
||||
serde_bytes = "0.10"
|
||||
servo_config = {path = "../config"}
|
||||
sparkle = "0.1"
|
||||
webrender = {git = "https://github.com/servo/webrender"}
|
||||
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
|
||||
webrender_traits = {path = "../webrender_traits"}
|
||||
|
|
|
@ -7,7 +7,6 @@ use canvas_traits::webgl::{
|
|||
GLContextAttributes, GLLimits, WebGLCommand, WebGLCommandBacktrace, WebGLVersion,
|
||||
};
|
||||
use euclid::default::Size2D;
|
||||
use gleam::gl;
|
||||
use offscreen_gl_context::{
|
||||
ColorAttachmentType, DrawBuffer, GLContext, GLContextAttributes as RawGLContextAttributes,
|
||||
GLContextDispatcher,
|
||||
|
@ -15,6 +14,7 @@ use offscreen_gl_context::{
|
|||
use offscreen_gl_context::{GLLimits as RawGLLimits, GLVersion};
|
||||
use offscreen_gl_context::{NativeGLContext, NativeGLContextHandle, NativeGLContextMethods};
|
||||
use offscreen_gl_context::{OSMesaContext, OSMesaContextHandle};
|
||||
use sparkle::gl;
|
||||
|
||||
pub trait CloneableDispatcher: GLContextDispatcher {
|
||||
fn clone(&self) -> Box<dyn GLContextDispatcher>;
|
||||
|
@ -84,7 +84,7 @@ impl GLContextFactory {
|
|||
size.to_i32(),
|
||||
attributes,
|
||||
ColorAttachmentType::Texture,
|
||||
gl::GlType::default(),
|
||||
gl::GlType::Gl,
|
||||
Self::gl_version(webgl_version),
|
||||
Some(handle),
|
||||
None,
|
||||
|
@ -120,7 +120,7 @@ impl GLContextFactory {
|
|||
size.to_i32(),
|
||||
attributes,
|
||||
ColorAttachmentType::Texture,
|
||||
gl::GlType::default(),
|
||||
gl::GlType::Gl,
|
||||
Self::gl_version(webgl_version),
|
||||
None,
|
||||
None,
|
||||
|
@ -171,7 +171,7 @@ impl GLContextWrapper {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn gl(&self) -> &dyn gl::Gl {
|
||||
pub fn gl(&self) -> &gl::Gl {
|
||||
match *self {
|
||||
GLContextWrapper::Native(ref ctx) => ctx.gl(),
|
||||
GLContextWrapper::OSMesa(ref ctx) => ctx.gl(),
|
||||
|
|
|
@ -8,12 +8,12 @@ use canvas_traits::webgl::*;
|
|||
use embedder_traits::EventLoopWaker;
|
||||
use euclid::default::Size2D;
|
||||
use fnv::FnvHashMap;
|
||||
use gleam::gl;
|
||||
use half::f16;
|
||||
use ipc_channel::ipc::{self, OpaqueIpcMessage};
|
||||
use ipc_channel::router::ROUTER;
|
||||
use offscreen_gl_context::{DrawBuffer, GLContext, NativeGLContextMethods};
|
||||
use pixels::{self, PixelFormat};
|
||||
use sparkle::gl;
|
||||
use std::borrow::Cow;
|
||||
use std::cell::Cell;
|
||||
use std::cell::RefCell;
|
||||
|
@ -1573,7 +1573,7 @@ impl WebGLImpl {
|
|||
}
|
||||
|
||||
fn initialize_framebuffer(
|
||||
gl: &dyn gl::Gl,
|
||||
gl: &gl::Gl,
|
||||
state: &GLState,
|
||||
color: bool,
|
||||
depth: bool,
|
||||
|
@ -1633,7 +1633,7 @@ impl WebGLImpl {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn link_program(gl: &dyn gl::Gl, program: WebGLProgramId) -> ProgramLinkInfo {
|
||||
fn link_program(gl: &gl::Gl, program: WebGLProgramId) -> ProgramLinkInfo {
|
||||
gl.link_program(program.get());
|
||||
let mut linked = [0];
|
||||
unsafe {
|
||||
|
@ -1706,13 +1706,13 @@ impl WebGLImpl {
|
|||
}
|
||||
}
|
||||
|
||||
fn finish(gl: &dyn gl::Gl, chan: &WebGLSender<()>) {
|
||||
fn finish(gl: &gl::Gl, chan: &WebGLSender<()>) {
|
||||
gl.finish();
|
||||
chan.send(()).unwrap();
|
||||
}
|
||||
|
||||
fn shader_precision_format(
|
||||
gl: &dyn gl::Gl,
|
||||
gl: &gl::Gl,
|
||||
shader_type: u32,
|
||||
precision_type: u32,
|
||||
chan: &WebGLSender<(i32, i32, i32)>,
|
||||
|
@ -1722,7 +1722,7 @@ impl WebGLImpl {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn get_extensions(gl: &dyn gl::Gl, chan: &WebGLSender<String>) {
|
||||
fn get_extensions(gl: &gl::Gl, chan: &WebGLSender<String>) {
|
||||
let mut ext_count = [0];
|
||||
unsafe {
|
||||
gl.get_integer_v(gl::NUM_EXTENSIONS, &mut ext_count);
|
||||
|
@ -1743,7 +1743,7 @@ impl WebGLImpl {
|
|||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6
|
||||
fn get_framebuffer_attachment_parameter(
|
||||
gl: &dyn gl::Gl,
|
||||
gl: &gl::Gl,
|
||||
target: u32,
|
||||
attachment: u32,
|
||||
pname: u32,
|
||||
|
@ -1754,18 +1754,13 @@ impl WebGLImpl {
|
|||
}
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7
|
||||
fn get_renderbuffer_parameter(
|
||||
gl: &dyn gl::Gl,
|
||||
target: u32,
|
||||
pname: u32,
|
||||
chan: &WebGLSender<i32>,
|
||||
) {
|
||||
fn get_renderbuffer_parameter(gl: &gl::Gl, target: u32, pname: u32, chan: &WebGLSender<i32>) {
|
||||
let parameter = gl.get_renderbuffer_parameter_iv(target, pname);
|
||||
chan.send(parameter).unwrap();
|
||||
}
|
||||
|
||||
fn uniform_location(
|
||||
gl: &dyn gl::Gl,
|
||||
gl: &gl::Gl,
|
||||
program_id: WebGLProgramId,
|
||||
name: &str,
|
||||
chan: &WebGLSender<i32>,
|
||||
|
@ -1775,18 +1770,18 @@ impl WebGLImpl {
|
|||
chan.send(location).unwrap();
|
||||
}
|
||||
|
||||
fn shader_info_log(gl: &dyn gl::Gl, shader_id: WebGLShaderId, chan: &WebGLSender<String>) {
|
||||
fn shader_info_log(gl: &gl::Gl, shader_id: WebGLShaderId, chan: &WebGLSender<String>) {
|
||||
let log = gl.get_shader_info_log(shader_id.get());
|
||||
chan.send(log).unwrap();
|
||||
}
|
||||
|
||||
fn program_info_log(gl: &dyn gl::Gl, program_id: WebGLProgramId, chan: &WebGLSender<String>) {
|
||||
fn program_info_log(gl: &gl::Gl, program_id: WebGLProgramId, chan: &WebGLSender<String>) {
|
||||
let log = gl.get_program_info_log(program_id.get());
|
||||
chan.send(log).unwrap();
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn create_buffer(gl: &dyn gl::Gl, chan: &WebGLSender<Option<WebGLBufferId>>) {
|
||||
fn create_buffer(gl: &gl::Gl, chan: &WebGLSender<Option<WebGLBufferId>>) {
|
||||
let buffer = gl.gen_buffers(1)[0];
|
||||
let buffer = if buffer == 0 {
|
||||
None
|
||||
|
@ -1797,7 +1792,7 @@ impl WebGLImpl {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn create_framebuffer(gl: &dyn gl::Gl, chan: &WebGLSender<Option<WebGLFramebufferId>>) {
|
||||
fn create_framebuffer(gl: &gl::Gl, chan: &WebGLSender<Option<WebGLFramebufferId>>) {
|
||||
let framebuffer = gl.gen_framebuffers(1)[0];
|
||||
let framebuffer = if framebuffer == 0 {
|
||||
None
|
||||
|
@ -1808,7 +1803,7 @@ impl WebGLImpl {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn create_renderbuffer(gl: &dyn gl::Gl, chan: &WebGLSender<Option<WebGLRenderbufferId>>) {
|
||||
fn create_renderbuffer(gl: &gl::Gl, chan: &WebGLSender<Option<WebGLRenderbufferId>>) {
|
||||
let renderbuffer = gl.gen_renderbuffers(1)[0];
|
||||
let renderbuffer = if renderbuffer == 0 {
|
||||
None
|
||||
|
@ -1819,7 +1814,7 @@ impl WebGLImpl {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn create_texture(gl: &dyn gl::Gl, chan: &WebGLSender<Option<WebGLTextureId>>) {
|
||||
fn create_texture(gl: &gl::Gl, chan: &WebGLSender<Option<WebGLTextureId>>) {
|
||||
let texture = gl.gen_textures(1)[0];
|
||||
let texture = if texture == 0 {
|
||||
None
|
||||
|
@ -1830,7 +1825,7 @@ impl WebGLImpl {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn create_program(gl: &dyn gl::Gl, chan: &WebGLSender<Option<WebGLProgramId>>) {
|
||||
fn create_program(gl: &gl::Gl, chan: &WebGLSender<Option<WebGLProgramId>>) {
|
||||
let program = gl.create_program();
|
||||
let program = if program == 0 {
|
||||
None
|
||||
|
@ -1841,7 +1836,7 @@ impl WebGLImpl {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn create_shader(gl: &dyn gl::Gl, shader_type: u32, chan: &WebGLSender<Option<WebGLShaderId>>) {
|
||||
fn create_shader(gl: &gl::Gl, shader_type: u32, chan: &WebGLSender<Option<WebGLShaderId>>) {
|
||||
let shader = gl.create_shader(shader_type);
|
||||
let shader = if shader == 0 {
|
||||
None
|
||||
|
@ -1852,7 +1847,7 @@ impl WebGLImpl {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn create_vertex_array(gl: &dyn gl::Gl, chan: &WebGLSender<Option<WebGLVertexArrayId>>) {
|
||||
fn create_vertex_array(gl: &gl::Gl, chan: &WebGLSender<Option<WebGLVertexArrayId>>) {
|
||||
let vao = gl.gen_vertex_arrays(1)[0];
|
||||
let vao = if vao == 0 {
|
||||
None
|
||||
|
@ -1864,7 +1859,7 @@ impl WebGLImpl {
|
|||
|
||||
#[inline]
|
||||
fn bind_framebuffer<Native: NativeGLContextMethods>(
|
||||
gl: &dyn gl::Gl,
|
||||
gl: &gl::Gl,
|
||||
target: u32,
|
||||
request: WebGLFramebufferBindingRequest,
|
||||
ctx: &GLContext<Native>,
|
||||
|
@ -1880,7 +1875,7 @@ impl WebGLImpl {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn compile_shader(gl: &dyn gl::Gl, shader_id: WebGLShaderId, source: &str) {
|
||||
fn compile_shader(gl: &gl::Gl, shader_id: WebGLShaderId, source: &str) {
|
||||
gl.shader_source(shader_id.get(), &[source.as_bytes()]);
|
||||
gl.compile_shader(shader_id.get());
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ webgl_backtrace = []
|
|||
cssparser = "0.25"
|
||||
euclid = "0.20"
|
||||
ipc-channel = "0.12"
|
||||
gleam = "0.6.7"
|
||||
lazy_static = "1"
|
||||
malloc_size_of = { path = "../malloc_size_of" }
|
||||
malloc_size_of_derive = "0.1"
|
||||
|
@ -25,6 +24,7 @@ pixels = {path = "../pixels"}
|
|||
serde = "1.0"
|
||||
serde_bytes = "0.10"
|
||||
servo_config = {path = "../config"}
|
||||
sparkle = "0.1"
|
||||
typetag = "0.1"
|
||||
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
|
||||
webvr_traits = {path = "../webvr_traits"}
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use euclid::default::{Rect, Size2D};
|
||||
use gleam::gl;
|
||||
use gleam::gl::Gl;
|
||||
use ipc_channel::ipc::{IpcBytesReceiver, IpcBytesSender, IpcSharedMemory};
|
||||
use pixels::PixelFormat;
|
||||
use sparkle::gl;
|
||||
use sparkle::gl::Gl;
|
||||
use std::borrow::Cow;
|
||||
use std::fmt;
|
||||
use std::num::NonZeroU32;
|
||||
|
@ -549,7 +549,7 @@ pub enum WebVRCommand {
|
|||
// Trait object that handles WebVR commands.
|
||||
// Receives the texture id and size associated to the WebGLContext.
|
||||
pub trait WebVRRenderHandler: Send {
|
||||
fn handle(&mut self, gl: &dyn Gl, command: WebVRCommand, texture: Option<(u32, Size2D<i32>)>);
|
||||
fn handle(&mut self, gl: &Gl, command: WebVRCommand, texture: Option<(u32, Size2D<i32>)>);
|
||||
}
|
||||
|
||||
/// WebGL commands required to implement DOMToTexture feature.
|
||||
|
@ -758,9 +758,9 @@ macro_rules! gl_enums {
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME: These should come from gleam
|
||||
// FIXME: These should come from sparkle
|
||||
mod gl_ext_constants {
|
||||
use gleam::gl::types::GLenum;
|
||||
use sparkle::gl::types::GLenum;
|
||||
|
||||
pub const COMPRESSED_RGB_S3TC_DXT1_EXT: GLenum = 0x83F0;
|
||||
pub const COMPRESSED_RGBA_S3TC_DXT1_EXT: GLenum = 0x83F1;
|
||||
|
|
|
@ -52,7 +52,6 @@ encoding_rs = "0.8"
|
|||
enum-iterator = "0.2.0"
|
||||
euclid = "0.20"
|
||||
fnv = "1.0"
|
||||
gleam = "0.6"
|
||||
headers = "0.2"
|
||||
html5ever = "0.23"
|
||||
http = "0.1"
|
||||
|
@ -100,6 +99,7 @@ servo_geometry = {path = "../geometry" }
|
|||
servo-media = {git = "https://github.com/servo/media"}
|
||||
servo_rand = {path = "../rand"}
|
||||
servo_url = {path = "../url"}
|
||||
sparkle = "0.1"
|
||||
smallvec = { version = "0.6", features = ["std", "union"] }
|
||||
style = {path = "../style", features = ["servo"]}
|
||||
style_traits = {path = "../style_traits"}
|
||||
|
|
|
@ -20,9 +20,9 @@ use crate::dom::webglrenderingcontext::WebGLRenderingContext;
|
|||
use crate::dom::webgltexture::TexCompression;
|
||||
use canvas_traits::webgl::{GlType, WebGLVersion};
|
||||
use fnv::{FnvHashMap, FnvHashSet};
|
||||
use gleam::gl::{self, GLenum};
|
||||
use js::jsapi::JSObject;
|
||||
use malloc_size_of::MallocSizeOf;
|
||||
use sparkle::gl::{self, GLenum};
|
||||
use std::collections::HashMap;
|
||||
use std::iter::FromIterator;
|
||||
use std::ptr::NonNull;
|
||||
|
|
|
@ -62,7 +62,7 @@ media = {path = "../media"}
|
|||
msg = {path = "../msg"}
|
||||
net = {path = "../net"}
|
||||
net_traits = {path = "../net_traits"}
|
||||
offscreen_gl_context = "0.23"
|
||||
offscreen_gl_context = "0.25"
|
||||
profile = {path = "../profile"}
|
||||
profile_traits = {path = "../profile_traits"}
|
||||
script = {path = "../script"}
|
||||
|
@ -72,6 +72,7 @@ servo_config = {path = "../config"}
|
|||
servo_geometry = {path = "../geometry"}
|
||||
servo-media = {git = "https://github.com/servo/media"}
|
||||
servo_url = {path = "../url"}
|
||||
sparkle = "0.1"
|
||||
style = {path = "../style", features = ["servo"]}
|
||||
style_traits = {path = "../style_traits", features = ["servo"]}
|
||||
webrender = {git = "https://github.com/servo/webrender"}
|
||||
|
|
|
@ -412,7 +412,11 @@ where
|
|||
} else {
|
||||
let dispatcher =
|
||||
Box::new(MainThreadDispatcher::new(compositor_proxy.clone())) as Box<_>;
|
||||
GLContextFactory::current_native_handle(dispatcher, window.gl().get_type())
|
||||
let gl_type = match window.gl().get_type() {
|
||||
gl::GlType::Gl => sparkle::gl::GlType::Gl,
|
||||
gl::GlType::Gles => sparkle::gl::GlType::Gles,
|
||||
};
|
||||
GLContextFactory::current_native_handle(dispatcher, gl_type)
|
||||
};
|
||||
|
||||
let (external_image_handlers, external_images) = WebrenderExternalImageHandlers::new();
|
||||
|
|
|
@ -22,8 +22,9 @@ gleam = "0.6"
|
|||
ipc-channel = "0.12"
|
||||
log = "0.4"
|
||||
msg = {path = "../msg"}
|
||||
rust-webvr = { version = "0.14.2", features = ["mock", "openvr", "vrexternal"] }
|
||||
rust-webvr-api = "0.14"
|
||||
rust-webvr = {version = "0.16", features = ["mock", "openvr", "vrexternal"]}
|
||||
rust-webvr-api = "0.16"
|
||||
script_traits = {path = "../script_traits"}
|
||||
servo_config = {path = "../config"}
|
||||
sparkle = "0.1"
|
||||
webvr_traits = {path = "../webvr_traits" }
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
use canvas_traits::webgl;
|
||||
use crossbeam_channel::{unbounded, Receiver, Sender};
|
||||
use euclid::default::Size2D;
|
||||
use gleam::gl::Gl;
|
||||
use ipc_channel::ipc;
|
||||
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use rust_webvr::VRServiceManager;
|
||||
use script_traits::ConstellationMsg;
|
||||
use servo_config::pref;
|
||||
use sparkle::gl::Gl;
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::mpsc;
|
||||
|
@ -429,12 +429,7 @@ impl WebVRCompositorHandler {
|
|||
|
||||
impl webgl::WebVRRenderHandler for WebVRCompositorHandler {
|
||||
#[allow(unsafe_code)]
|
||||
fn handle(
|
||||
&mut self,
|
||||
gl: &dyn Gl,
|
||||
cmd: webgl::WebVRCommand,
|
||||
texture: Option<(u32, Size2D<i32>)>,
|
||||
) {
|
||||
fn handle(&mut self, gl: &Gl, cmd: webgl::WebVRCommand, texture: Option<(u32, Size2D<i32>)>) {
|
||||
match cmd {
|
||||
webgl::WebVRCommand::Create(compositor_id) => {
|
||||
if let Some(compositor) = self.create_compositor(compositor_id) {
|
||||
|
|
|
@ -13,5 +13,5 @@ path = "lib.rs"
|
|||
[dependencies]
|
||||
ipc-channel = "0.12"
|
||||
msg = {path = "../msg"}
|
||||
rust-webvr-api = { version = "0.14", features = ["ipc"] }
|
||||
rust-webvr-api = {version = "0.16", features = ["ipc"]}
|
||||
serde = "1.0"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue