mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Update to gleam 0.5
This commit is contained in:
parent
696084863c
commit
0f91712800
18 changed files with 473 additions and 399 deletions
|
@ -3,6 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use euclid::Size2D;
|
||||
use gleam::gl;
|
||||
use nonzero::NonZeroU32;
|
||||
use offscreen_gl_context::{GLContextAttributes, GLLimits};
|
||||
use serde_bytes::ByteBuf;
|
||||
|
@ -206,16 +207,12 @@ pub enum WebGLCommand {
|
|||
FramebufferRenderbuffer(u32, u32, u32, Option<WebGLRenderbufferId>),
|
||||
FramebufferTexture2D(u32, u32, u32, Option<WebGLTextureId>, i32),
|
||||
GetExtensions(WebGLSender<String>),
|
||||
GetParameter(u32, WebGLSender<WebGLResult<WebGLParameter>>),
|
||||
GetTexParameter(u32, u32, WebGLSender<i32>),
|
||||
GetProgramParameter(WebGLProgramId, u32, WebGLSender<WebGLResult<WebGLParameter>>),
|
||||
GetShaderParameter(WebGLShaderId, u32, WebGLSender<WebGLResult<WebGLParameter>>),
|
||||
GetShaderPrecisionFormat(u32, u32, WebGLSender<(i32, i32, i32)>),
|
||||
GetActiveAttrib(WebGLProgramId, u32, WebGLSender<WebGLResult<(i32, u32, String)>>),
|
||||
GetActiveUniform(WebGLProgramId, u32, WebGLSender<WebGLResult<(i32, u32, String)>>),
|
||||
GetAttribLocation(WebGLProgramId, String, WebGLSender<Option<i32>>),
|
||||
GetUniformLocation(WebGLProgramId, String, WebGLSender<Option<i32>>),
|
||||
GetVertexAttrib(u32, u32, WebGLSender<WebGLResult<WebGLParameter>>),
|
||||
GetVertexAttribOffset(u32, u32, WebGLSender<isize>),
|
||||
GetShaderInfoLog(WebGLShaderId, WebGLSender<String>),
|
||||
GetProgramInfoLog(WebGLProgramId, WebGLSender<String>),
|
||||
|
@ -261,7 +258,6 @@ pub enum WebGLCommand {
|
|||
VertexAttrib(u32, f32, f32, f32, f32),
|
||||
VertexAttribPointer(u32, i32, u32, bool, i32, u32),
|
||||
VertexAttribPointer2f(u32, i32, bool, i32, u32),
|
||||
GetViewport(WebGLSender<(i32, i32, i32, i32)>),
|
||||
SetViewport(i32, i32, i32, i32),
|
||||
TexImage2D(u32, i32, i32, i32, i32, u32, u32, ByteBuf),
|
||||
TexParameteri(u32, u32, i32),
|
||||
|
@ -275,8 +271,18 @@ pub enum WebGLCommand {
|
|||
CreateVertexArray(WebGLSender<Option<WebGLVertexArrayId>>),
|
||||
DeleteVertexArray(WebGLVertexArrayId),
|
||||
BindVertexArray(Option<WebGLVertexArrayId>),
|
||||
AliasedPointSizeRange(WebGLSender<(f32, f32)>),
|
||||
AliasedLineWidthRange(WebGLSender<(f32, f32)>),
|
||||
GetParameterBool(ParameterBool, WebGLSender<bool>),
|
||||
GetParameterInt(ParameterInt, WebGLSender<i32>),
|
||||
GetParameterInt4(ParameterInt4, WebGLSender<[i32; 4]>),
|
||||
GetParameterFloat(ParameterFloat, WebGLSender<f32>),
|
||||
GetParameterFloat2(ParameterFloat2, WebGLSender<[f32; 2]>),
|
||||
GetProgramParameterBool(WebGLProgramId, ProgramParameterBool, WebGLSender<bool>),
|
||||
GetProgramParameterInt(WebGLProgramId, ProgramParameterInt, WebGLSender<i32>),
|
||||
GetShaderParameterBool(WebGLShaderId, ShaderParameterBool, WebGLSender<bool>),
|
||||
GetShaderParameterInt(WebGLShaderId, ShaderParameterInt, WebGLSender<i32>),
|
||||
GetVertexAttribBool(u32, VertexAttribBool, WebGLSender<WebGLResult<bool>>),
|
||||
GetVertexAttribInt(u32, VertexAttribInt, WebGLSender<WebGLResult<i32>>),
|
||||
GetVertexAttribFloat4(u32, VertexAttribFloat4, WebGLSender<WebGLResult<[f32; 4]>>),
|
||||
}
|
||||
|
||||
macro_rules! define_resource_id_struct {
|
||||
|
@ -376,25 +382,8 @@ pub enum WebGLFramebufferBindingRequest {
|
|||
Default,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub enum WebGLParameter {
|
||||
Int(i32),
|
||||
Bool(bool),
|
||||
String(String),
|
||||
Float(f32),
|
||||
FloatArray(Vec<f32>),
|
||||
Invalid,
|
||||
}
|
||||
|
||||
pub type WebGLResult<T> = Result<T, WebGLError>;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub enum WebGLShaderParameter {
|
||||
Int(i32),
|
||||
Bool(bool),
|
||||
Invalid,
|
||||
}
|
||||
|
||||
pub type WebVRDeviceId = u32;
|
||||
|
||||
// WebVR commands that must be called in the WebGL render thread.
|
||||
|
@ -481,10 +470,7 @@ impl fmt::Debug for WebGLCommand {
|
|||
FramebufferRenderbuffer(..) => "FramebufferRenderbuffer",
|
||||
FramebufferTexture2D(..) => "FramebufferTexture2D",
|
||||
GetExtensions(..) => "GetExtensions",
|
||||
GetParameter(..) => "GetParameter",
|
||||
GetTexParameter(..) => "GetTexParameter",
|
||||
GetProgramParameter(..) => "GetProgramParameter",
|
||||
GetShaderParameter(..) => "GetShaderParameter",
|
||||
GetShaderPrecisionFormat(..) => "GetShaderPrecisionFormat",
|
||||
GetActiveAttrib(..) => "GetActiveAttrib",
|
||||
GetActiveUniform(..) => "GetActiveUniform",
|
||||
|
@ -492,7 +478,6 @@ impl fmt::Debug for WebGLCommand {
|
|||
GetUniformLocation(..) => "GetUniformLocation",
|
||||
GetShaderInfoLog(..) => "GetShaderInfoLog",
|
||||
GetProgramInfoLog(..) => "GetProgramInfoLog",
|
||||
GetVertexAttrib(..) => "GetVertexAttrib",
|
||||
GetVertexAttribOffset(..) => "GetVertexAttribOffset",
|
||||
GetFramebufferAttachmentParameter(..) => "GetFramebufferAttachmentParameter",
|
||||
GetRenderbufferParameter(..) => "GetRenderbufferParameter",
|
||||
|
@ -536,7 +521,6 @@ impl fmt::Debug for WebGLCommand {
|
|||
VertexAttrib(..) => "VertexAttrib",
|
||||
VertexAttribPointer2f(..) => "VertexAttribPointer2f",
|
||||
VertexAttribPointer(..) => "VertexAttribPointer",
|
||||
GetViewport(..) => "GetViewport",
|
||||
SetViewport(..) => "SetViewport",
|
||||
TexImage2D(..) => "TexImage2D",
|
||||
TexParameteri(..) => "TexParameteri",
|
||||
|
@ -550,10 +534,169 @@ impl fmt::Debug for WebGLCommand {
|
|||
CreateVertexArray(..) => "CreateVertexArray",
|
||||
DeleteVertexArray(..) => "DeleteVertexArray",
|
||||
BindVertexArray(..) => "BindVertexArray",
|
||||
AliasedPointSizeRange(..) => "AliasedPointSizeRange",
|
||||
AliasedLineWidthRange(..) => "AliasedLineWidthRange",
|
||||
GetParameterBool(..) => "GetParameterBool",
|
||||
GetParameterInt(..) => "GetParameterInt",
|
||||
GetParameterInt4(..) => "GetParameterInt4",
|
||||
GetParameterFloat(..) => "GetParameterFloat",
|
||||
GetParameterFloat2(..) => "GetParameterFloat2",
|
||||
GetProgramParameterBool(..) => "GetProgramParameterBool",
|
||||
GetProgramParameterInt(..) => "GetProgramParameterInt",
|
||||
GetShaderParameterBool(..) => "GetShaderParameterBool",
|
||||
GetShaderParameterInt(..) => "GetShaderParameterInt",
|
||||
GetVertexAttribBool(..) => "GetVertexAttribBool",
|
||||
GetVertexAttribInt(..) => "GetVertexAttribInt",
|
||||
GetVertexAttribFloat4(..) => "GetVertexAttribFloat4",
|
||||
};
|
||||
|
||||
write!(f, "CanvasWebGLMsg::{}(..)", name)
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! parameters {
|
||||
($name:ident { $(
|
||||
$variant:ident($kind:ident { $(
|
||||
$param:ident = gl::$value:ident,
|
||||
)+ }),
|
||||
)+ }) => {
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
pub enum $name { $(
|
||||
$variant($kind),
|
||||
)+}
|
||||
|
||||
$(
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
#[repr(u32)]
|
||||
pub enum $kind { $(
|
||||
$param = gl::$value,
|
||||
)+}
|
||||
)+
|
||||
|
||||
impl $name {
|
||||
pub fn from_u32(value: u32) -> WebGLResult<Self> {
|
||||
match value {
|
||||
$($(gl::$value => Ok($name::$variant($kind::$param)),)+)+
|
||||
_ => Err(WebGLError::InvalidEnum)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parameters! {
|
||||
Parameter {
|
||||
Bool(ParameterBool {
|
||||
Blend = gl::BLEND,
|
||||
CullFace = gl::CULL_FACE,
|
||||
DepthTest = gl::DEPTH_TEST,
|
||||
DepthWritemask = gl::DEPTH_WRITEMASK,
|
||||
Dither = gl::DITHER,
|
||||
PolygonOffsetFill = gl::POLYGON_OFFSET_FILL,
|
||||
SampleCoverageInvert = gl::SAMPLE_COVERAGE_INVERT,
|
||||
StencilTest = gl::STENCIL_TEST,
|
||||
}),
|
||||
Int(ParameterInt {
|
||||
ActiveTexture = gl::ACTIVE_TEXTURE,
|
||||
AlphaBits = gl::ALPHA_BITS,
|
||||
BlendDstAlpha = gl::BLEND_DST_ALPHA,
|
||||
BlendDstRgb = gl::BLEND_DST_RGB,
|
||||
BlendEquationAlpha = gl::BLEND_EQUATION_ALPHA,
|
||||
BlendEquationRgb = gl::BLEND_EQUATION_RGB,
|
||||
BlendSrcAlpha = gl::BLEND_SRC_ALPHA,
|
||||
BlendSrcRgb = gl::BLEND_SRC_RGB,
|
||||
BlueBits = gl::BLUE_BITS,
|
||||
CullFaceMode = gl::CULL_FACE_MODE,
|
||||
DepthBits = gl::DEPTH_BITS,
|
||||
DepthFunc = gl::DEPTH_FUNC,
|
||||
FrontFace = gl::FRONT_FACE,
|
||||
GreenBits = gl::GREEN_BITS,
|
||||
MaxCombinedTextureImageUnits = gl::MAX_COMBINED_TEXTURE_IMAGE_UNITS,
|
||||
MaxCubeMapTextureSize = gl::MAX_CUBE_MAP_TEXTURE_SIZE,
|
||||
MaxRenderbufferSize = gl::MAX_RENDERBUFFER_SIZE,
|
||||
MaxTextureImageUnits = gl::MAX_TEXTURE_IMAGE_UNITS,
|
||||
MaxTextureSize = gl::MAX_TEXTURE_SIZE,
|
||||
MaxVertexAttribs = gl::MAX_VERTEX_ATTRIBS,
|
||||
MaxVertexTextureImageUnits = gl::MAX_VERTEX_TEXTURE_IMAGE_UNITS,
|
||||
PackAlignment = gl::PACK_ALIGNMENT,
|
||||
RedBits = gl::RED_BITS,
|
||||
SampleBuffers = gl::SAMPLE_BUFFERS,
|
||||
Samples = gl::SAMPLES,
|
||||
StencilBackFail = gl::STENCIL_BACK_FAIL,
|
||||
StencilBackFunc = gl::STENCIL_BACK_FUNC,
|
||||
StencilBackPassDepthFail = gl::STENCIL_BACK_PASS_DEPTH_FAIL,
|
||||
StencilBackPassDepthPass = gl::STENCIL_BACK_PASS_DEPTH_PASS,
|
||||
StencilBackRef = gl::STENCIL_BACK_REF,
|
||||
StencilBackValueMask = gl::STENCIL_BACK_VALUE_MASK,
|
||||
StencilBackWritemask = gl::STENCIL_BACK_WRITEMASK,
|
||||
StencilBits = gl::STENCIL_BITS,
|
||||
StencilClearValue = gl::STENCIL_CLEAR_VALUE,
|
||||
StencilFail = gl::STENCIL_FAIL,
|
||||
StencilFunc = gl::STENCIL_FUNC,
|
||||
StencilPassDepthFail = gl::STENCIL_PASS_DEPTH_FAIL,
|
||||
StencilPassDepthPass = gl::STENCIL_PASS_DEPTH_PASS,
|
||||
StencilRef = gl::STENCIL_REF,
|
||||
StencilValueMask = gl::STENCIL_VALUE_MASK,
|
||||
StencilWritemask = gl::STENCIL_WRITEMASK,
|
||||
SubpixelBits = gl::SUBPIXEL_BITS,
|
||||
UnpackAlignment = gl::UNPACK_ALIGNMENT,
|
||||
FragmentShaderDerivativeHint = gl::FRAGMENT_SHADER_DERIVATIVE_HINT,
|
||||
}),
|
||||
Int4(ParameterInt4 {
|
||||
Viewport = gl::VIEWPORT,
|
||||
}),
|
||||
Float(ParameterFloat {
|
||||
DepthClearValue = gl::DEPTH_CLEAR_VALUE,
|
||||
LineWidth = gl::LINE_WIDTH,
|
||||
PolygonOffsetFactor = gl::POLYGON_OFFSET_FACTOR,
|
||||
PolygonOffsetUnits = gl::POLYGON_OFFSET_UNITS,
|
||||
SampleCoverageValue = gl::SAMPLE_COVERAGE_VALUE,
|
||||
}),
|
||||
Float2(ParameterFloat2 {
|
||||
AliasedPointSizeRange = gl::ALIASED_POINT_SIZE_RANGE,
|
||||
AliasedLineWidthRange = gl::ALIASED_LINE_WIDTH_RANGE,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
parameters! {
|
||||
ProgramParameter {
|
||||
Bool(ProgramParameterBool {
|
||||
DeleteStatus = gl::DELETE_STATUS,
|
||||
LinkStatus = gl::LINK_STATUS,
|
||||
ValidateStatus = gl::VALIDATE_STATUS,
|
||||
}),
|
||||
Int(ProgramParameterInt {
|
||||
AttachedShaders = gl::ATTACHED_SHADERS,
|
||||
ActiveAttributes = gl::ACTIVE_ATTRIBUTES,
|
||||
ActiveUniforms = gl::ACTIVE_UNIFORMS,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
parameters! {
|
||||
ShaderParameter {
|
||||
Bool(ShaderParameterBool {
|
||||
DeleteStatus = gl::DELETE_STATUS,
|
||||
CompileStatus = gl::COMPILE_STATUS,
|
||||
}),
|
||||
Int(ShaderParameterInt {
|
||||
ShaderType = gl::SHADER_TYPE,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
parameters! {
|
||||
VertexAttrib {
|
||||
Bool(VertexAttribBool {
|
||||
VertexAttribArrayEnabled = gl::VERTEX_ATTRIB_ARRAY_ENABLED,
|
||||
VertexAttribArrayNormalized = gl::VERTEX_ATTRIB_ARRAY_NORMALIZED,
|
||||
}),
|
||||
Int(VertexAttribInt {
|
||||
VertexAttribArraySize = gl::VERTEX_ATTRIB_ARRAY_SIZE,
|
||||
VertexAttribArrayStride = gl::VERTEX_ATTRIB_ARRAY_STRIDE,
|
||||
VertexAttribArrayType = gl::VERTEX_ATTRIB_ARRAY_TYPE,
|
||||
}),
|
||||
Float4(VertexAttribFloat4 {
|
||||
CurrentVertexAttrib = gl::CURRENT_VERTEX_ATTRIB,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue