mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
webgl: Return TEXTURE_IMMUTABLE_FORMAT as a boolean; don't panic on macOS for TEXTURE_IMMUTABLE_LEVELS.
This commit is contained in:
parent
3876d6dbdd
commit
9ce84d94de
5 changed files with 47 additions and 6 deletions
|
@ -1839,6 +1839,11 @@ impl WebGLImpl {
|
|||
.send(gl.get_tex_parameter_iv(target, param as u32))
|
||||
.unwrap();
|
||||
},
|
||||
WebGLCommand::GetTexParameterBool(target, param, ref sender) => {
|
||||
sender
|
||||
.send(gl.get_tex_parameter_iv(target, param as u32) != 0)
|
||||
.unwrap();
|
||||
},
|
||||
WebGLCommand::GetInternalFormatIntVec(target, internal_format, param, ref sender) => {
|
||||
match param {
|
||||
InternalFormatIntVec::Samples => {
|
||||
|
|
|
@ -449,6 +449,7 @@ pub enum WebGLCommand {
|
|||
GetCurrentVertexAttrib(u32, WebGLSender<[f32; 4]>),
|
||||
GetTexParameterFloat(u32, TexParameterFloat, WebGLSender<f32>),
|
||||
GetTexParameterInt(u32, TexParameterInt, WebGLSender<i32>),
|
||||
GetTexParameterBool(u32, TexParameterBool, WebGLSender<bool>),
|
||||
GetInternalFormatIntVec(u32, u32, InternalFormatIntVec, WebGLSender<Vec<i32>>),
|
||||
TexParameteri(u32, u32, i32),
|
||||
TexParameterf(u32, u32, f32),
|
||||
|
@ -886,9 +887,11 @@ parameters! {
|
|||
TextureMaxLevel = gl::TEXTURE_MAX_LEVEL,
|
||||
TextureCompareFunc = gl::TEXTURE_COMPARE_FUNC,
|
||||
TextureCompareMode = gl::TEXTURE_COMPARE_MODE,
|
||||
TextureImmutableFormat = gl::TEXTURE_IMMUTABLE_FORMAT,
|
||||
TextureImmutableLevels = gl::TEXTURE_IMMUTABLE_LEVELS,
|
||||
}),
|
||||
Bool(TexParameterBool {
|
||||
TextureImmutableFormat = gl::TEXTURE_IMMUTABLE_FORMAT,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
1
components/compositing/.#compositor.rs
Symbolic link
1
components/compositing/.#compositor.rs
Symbolic link
|
@ -0,0 +1 @@
|
|||
joshmatthews@joshmatthews-fcmd6r.1071
|
|
@ -2236,6 +2236,15 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
self.webgl_error(InvalidEnum);
|
||||
return NullValue();
|
||||
}
|
||||
|
||||
if let Some(value) = texture.maybe_get_tex_parameter(texparam) {
|
||||
match value {
|
||||
TexParameterValue::Float(v) => return DoubleValue(v as f64),
|
||||
TexParameterValue::Int(v) => return Int32Value(v),
|
||||
TexParameterValue::Bool(v) => return BooleanValue(v),
|
||||
}
|
||||
}
|
||||
|
||||
match texparam {
|
||||
TexParameter::Float(param) => {
|
||||
let (sender, receiver) = webgl_channel().unwrap();
|
||||
|
@ -2247,6 +2256,11 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
self.send_command(WebGLCommand::GetTexParameterInt(target, param, sender));
|
||||
Int32Value(receiver.recv().unwrap())
|
||||
},
|
||||
TexParameter::Bool(param) => {
|
||||
let (sender, receiver) = webgl_channel().unwrap();
|
||||
self.send_command(WebGLCommand::GetTexParameterBool(target, param, sender));
|
||||
BooleanValue(receiver.recv().unwrap())
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,10 @@ use crate::dom::webgl_validations::types::TexImageTarget;
|
|||
use crate::dom::webglframebuffer::WebGLFramebuffer;
|
||||
use crate::dom::webglobject::WebGLObject;
|
||||
use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext};
|
||||
use canvas_traits::webgl::{webgl_channel, TexDataType, TexFormat, WebGLResult, WebGLTextureId};
|
||||
use canvas_traits::webgl::{
|
||||
webgl_channel, TexDataType, TexFormat, TexParameter, TexParameterBool, TexParameterInt,
|
||||
WebGLResult, WebGLTextureId,
|
||||
};
|
||||
use canvas_traits::webgl::{DOMToTextureCommand, WebGLCommand, WebGLError};
|
||||
use dom_struct::dom_struct;
|
||||
use std::cell::Cell;
|
||||
|
@ -23,6 +26,7 @@ use std::cmp;
|
|||
pub enum TexParameterValue {
|
||||
Float(f32),
|
||||
Int(i32),
|
||||
Bool(bool),
|
||||
}
|
||||
|
||||
const MAX_LEVEL_COUNT: usize = 31;
|
||||
|
@ -37,7 +41,6 @@ pub struct WebGLTexture {
|
|||
/// The target to which this texture was bound the first time
|
||||
target: Cell<Option<u32>>,
|
||||
is_deleted: Cell<bool>,
|
||||
is_immutable: Cell<bool>,
|
||||
/// Stores information about mipmap levels and cubemap faces.
|
||||
#[ignore_malloc_size_of = "Arrays are cumbersome"]
|
||||
image_info_array: DomRefCell<[Option<ImageInfo>; MAX_LEVEL_COUNT * MAX_FACE_COUNT]>,
|
||||
|
@ -51,6 +54,8 @@ pub struct WebGLTexture {
|
|||
attached_to_dom: Cell<bool>,
|
||||
/// Framebuffer that this texture is attached to.
|
||||
attached_framebuffer: MutNullableDom<WebGLFramebuffer>,
|
||||
/// Number of immutable levels.
|
||||
immutable_levels: Cell<Option<u32>>,
|
||||
}
|
||||
|
||||
impl WebGLTexture {
|
||||
|
@ -60,7 +65,7 @@ impl WebGLTexture {
|
|||
id: id,
|
||||
target: Cell::new(None),
|
||||
is_deleted: Cell::new(false),
|
||||
is_immutable: Cell::new(false),
|
||||
immutable_levels: Cell::new(None),
|
||||
face_count: Cell::new(0),
|
||||
base_mipmap_level: 0,
|
||||
min_filter: Cell::new(constants::NEAREST_MIPMAP_LINEAR),
|
||||
|
@ -224,13 +229,25 @@ impl WebGLTexture {
|
|||
}
|
||||
|
||||
pub fn is_immutable(&self) -> bool {
|
||||
self.is_immutable.get()
|
||||
self.immutable_levels.get().is_some()
|
||||
}
|
||||
|
||||
pub fn target(&self) -> Option<u32> {
|
||||
self.target.get()
|
||||
}
|
||||
|
||||
pub fn maybe_get_tex_parameter(&self, param: TexParameter) -> Option<TexParameterValue> {
|
||||
match param {
|
||||
TexParameter::Int(TexParameterInt::TextureImmutableLevels) => Some(
|
||||
TexParameterValue::Int(self.immutable_levels.get().unwrap_or(0) as i32),
|
||||
),
|
||||
TexParameter::Bool(TexParameterBool::TextureImmutableFormat) => {
|
||||
Some(TexParameterValue::Bool(self.is_immutable()))
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// We have to follow the conversion rules for GLES 2.0. See:
|
||||
/// https://www.khronos.org/webgl/public-mailing-list/archives/1008/msg00014.html
|
||||
///
|
||||
|
@ -240,6 +257,7 @@ impl WebGLTexture {
|
|||
let (int_value, float_value) = match value {
|
||||
TexParameterValue::Int(int_value) => (int_value, int_value as f32),
|
||||
TexParameterValue::Float(float_value) => (float_value as i32, float_value),
|
||||
TexParameterValue::Bool(_) => unreachable!("no settable tex params should be booleans"),
|
||||
};
|
||||
|
||||
let update_filter = |filter: &Cell<u32>| {
|
||||
|
@ -465,7 +483,7 @@ impl WebGLTexture {
|
|||
depth = cmp::max(1, depth / 2);
|
||||
}
|
||||
|
||||
self.is_immutable.set(true);
|
||||
self.immutable_levels.set(Some(levels));
|
||||
|
||||
if let Some(fb) = self.attached_framebuffer.get() {
|
||||
fb.update_status();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue