mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
webxr: Use the same texture format as the original GL context's framebuffer when creating an XR GL layer.
This commit is contained in:
parent
778b48fa47
commit
5bd1e86d42
6 changed files with 43 additions and 17 deletions
|
@ -4,14 +4,14 @@
|
|||
|
||||
use super::webgl_thread::{GLState, WebGLImpl};
|
||||
use canvas_traits::webgl::{
|
||||
GLContextAttributes, GLLimits, WebGLCommand, WebGLCommandBacktrace, WebGLVersion,
|
||||
GLContextAttributes, GLFormats, GLLimits, WebGLCommand, WebGLCommandBacktrace, WebGLVersion,
|
||||
};
|
||||
use euclid::default::Size2D;
|
||||
use offscreen_gl_context::{
|
||||
ColorAttachmentType, DrawBuffer, GLContext, GLContextAttributes as RawGLContextAttributes,
|
||||
GLContextDispatcher,
|
||||
};
|
||||
use offscreen_gl_context::{GLLimits as RawGLLimits, GLVersion};
|
||||
use offscreen_gl_context::{GLFormats as RawGLFormats, GLLimits as RawGLLimits, GLVersion};
|
||||
use offscreen_gl_context::{NativeGLContext, NativeGLContextHandle, NativeGLContextMethods};
|
||||
use offscreen_gl_context::{OSMesaContext, OSMesaContextHandle};
|
||||
use sparkle::gl;
|
||||
|
@ -179,7 +179,7 @@ impl GLContextWrapper {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_info(&self) -> (Size2D<i32>, u32, GLLimits) {
|
||||
pub fn get_info(&self) -> (Size2D<i32>, u32, GLLimits, GLFormats) {
|
||||
match *self {
|
||||
GLContextWrapper::Native(ref ctx) => {
|
||||
let (real_size, texture_id) = {
|
||||
|
@ -191,8 +191,9 @@ impl GLContextWrapper {
|
|||
};
|
||||
|
||||
let limits = ctx.borrow_limits().clone();
|
||||
let formats = map_formats(ctx.borrow_formats());
|
||||
|
||||
(real_size, texture_id, map_limits(limits))
|
||||
(real_size, texture_id, map_limits(limits), formats)
|
||||
},
|
||||
GLContextWrapper::OSMesa(ref ctx) => {
|
||||
let (real_size, texture_id) = {
|
||||
|
@ -204,8 +205,9 @@ impl GLContextWrapper {
|
|||
};
|
||||
|
||||
let limits = ctx.borrow_limits().clone();
|
||||
let formats = map_formats(ctx.borrow_formats());
|
||||
|
||||
(real_size, texture_id, map_limits(limits))
|
||||
(real_size, texture_id, map_limits(limits), formats)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -260,3 +262,10 @@ pub fn map_attrs_to_script_attrs(attrs: RawGLContextAttributes) -> GLContextAttr
|
|||
preserve_drawing_buffer: attrs.preserve_drawing_buffer,
|
||||
}
|
||||
}
|
||||
|
||||
fn map_formats(formats: &RawGLFormats) -> GLFormats {
|
||||
GLFormats {
|
||||
texture_format: formats.texture,
|
||||
texture_type: formats.texture_type,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -238,7 +238,7 @@ impl WebGLThread {
|
|||
WebGLMsg::CreateContext(version, size, attributes, result_sender) => {
|
||||
let result = self.create_webgl_context(version, size, attributes);
|
||||
result_sender
|
||||
.send(result.map(|(id, limits, share_mode)| {
|
||||
.send(result.map(|(id, limits, share_mode, framebuffer_format)| {
|
||||
let data = Self::make_current_if_needed(
|
||||
id,
|
||||
&self.contexts,
|
||||
|
@ -276,6 +276,7 @@ impl WebGLThread {
|
|||
share_mode,
|
||||
glsl_version,
|
||||
api_type,
|
||||
framebuffer_format,
|
||||
}
|
||||
}))
|
||||
.unwrap();
|
||||
|
@ -406,7 +407,7 @@ impl WebGLThread {
|
|||
version: WebGLVersion,
|
||||
size: Size2D<u32>,
|
||||
attributes: GLContextAttributes,
|
||||
) -> Result<(WebGLContextId, GLLimits, WebGLContextShareMode), String> {
|
||||
) -> Result<(WebGLContextId, GLLimits, WebGLContextShareMode, GLFormats), String> {
|
||||
// Creating a new GLContext may make the current bound context_id dirty.
|
||||
// Clear it to ensure that make_current() is called in subsequent commands.
|
||||
self.bound_context_id = None;
|
||||
|
@ -434,7 +435,7 @@ impl WebGLThread {
|
|||
.next_id(WebrenderImageHandlerType::WebGL)
|
||||
.0 as usize,
|
||||
);
|
||||
let (size, texture_id, limits) = ctx.get_info();
|
||||
let (size, texture_id, limits, framebuffer_formats) = ctx.get_info();
|
||||
let use_apple_vertex_arrays = needs_apple_vertex_arrays(ctx.gl(), version);
|
||||
self.contexts.insert(
|
||||
id,
|
||||
|
@ -458,7 +459,7 @@ impl WebGLThread {
|
|||
},
|
||||
);
|
||||
|
||||
Ok((id, limits, share_mode))
|
||||
Ok((id, limits, share_mode, framebuffer_formats))
|
||||
}
|
||||
|
||||
/// Resizes a WebGLContext
|
||||
|
@ -476,7 +477,7 @@ impl WebGLThread {
|
|||
.expect("Missing WebGL context!");
|
||||
match data.ctx.resize(size) {
|
||||
Ok(old_draw_buffer) => {
|
||||
let (real_size, texture_id, _) = data.ctx.get_info();
|
||||
let (real_size, texture_id, _, _) = data.ctx.get_info();
|
||||
let info = self.cached_context_info.get_mut(&context_id).unwrap();
|
||||
if let ContextRenderState::Locked(ref mut in_use) = info.render_state {
|
||||
// If there's already an outdated draw buffer present, we can ignore
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue