mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Auto merge of #20631 - brainlessdeveloper:add-webgl-get-renderbuffer-parameter, r=emilio
Implement WebGL GetRenderbufferParameter This needed a bump of gleam to version 0.4.33 for this https://github.com/servo/gleam/pull/162 <!-- Please describe your changes on the following line: --> I think my changes in test expectations are pretty naive and I have to wait for the PR to run on CI to see what the actual impact is. I'd like some guidance on this, too. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach build-geckolib` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #20514 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20631) <!-- Reviewable:end -->
This commit is contained in:
commit
f1a06e0d0c
8 changed files with 191 additions and 110 deletions
|
@ -754,6 +754,8 @@ impl WebGLImpl {
|
|||
Self::active_uniform(ctx.gl(), program_id, index, chan),
|
||||
WebGLCommand::GetAttribLocation(program_id, name, chan) =>
|
||||
Self::attrib_location(ctx.gl(), program_id, name, chan),
|
||||
WebGLCommand::GetRenderbufferParameter(target, pname, chan) =>
|
||||
Self::get_renderbuffer_parameter(ctx.gl(), target, pname, chan),
|
||||
WebGLCommand::GetFramebufferAttachmentParameter(target, attachment, pname, chan) =>
|
||||
Self::get_framebuffer_attachment_parameter(ctx.gl(), target, attachment, pname, chan),
|
||||
WebGLCommand::GetVertexAttrib(index, pname, chan) =>
|
||||
|
@ -1188,6 +1190,17 @@ impl WebGLImpl {
|
|||
chan.send(parameter).unwrap();
|
||||
}
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7
|
||||
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: &gl::Gl,
|
||||
program_id: WebGLProgramId,
|
||||
name: String,
|
||||
|
|
|
@ -220,6 +220,7 @@ pub enum WebGLCommand {
|
|||
GetShaderInfoLog(WebGLShaderId, WebGLSender<String>),
|
||||
GetProgramInfoLog(WebGLProgramId, WebGLSender<String>),
|
||||
GetFramebufferAttachmentParameter(u32, u32, u32, WebGLSender<i32>),
|
||||
GetRenderbufferParameter(u32, u32, WebGLSender<i32>),
|
||||
PolygonOffset(f32, f32),
|
||||
RenderbufferStorage(u32, u32, i32, i32),
|
||||
ReadPixels(i32, i32, i32, i32, u32, u32, WebGLSender<ByteBuf>),
|
||||
|
@ -494,6 +495,7 @@ impl fmt::Debug for WebGLCommand {
|
|||
GetVertexAttrib(..) => "GetVertexAttrib",
|
||||
GetVertexAttribOffset(..) => "GetVertexAttribOffset",
|
||||
GetFramebufferAttachmentParameter(..) => "GetFramebufferAttachmentParameter",
|
||||
GetRenderbufferParameter(..) => "GetRenderbufferParameter",
|
||||
PolygonOffset(..) => "PolygonOffset",
|
||||
ReadPixels(..) => "ReadPixels",
|
||||
RenderbufferStorage(..) => "RenderbufferStorage",
|
||||
|
|
|
@ -159,6 +159,17 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
self.base.GetFramebufferAttachmentParameter(cx, target, attachment, pname)
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7
|
||||
unsafe fn GetRenderbufferParameter(
|
||||
&self,
|
||||
cx: *mut JSContext,
|
||||
target: u32,
|
||||
pname: u32
|
||||
) -> JSVal {
|
||||
self.base.GetRenderbufferParameter(cx, target, pname)
|
||||
}
|
||||
|
||||
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||
fn ActiveTexture(&self, texture: u32) {
|
||||
self.base.ActiveTexture(texture)
|
||||
|
|
|
@ -2348,6 +2348,45 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
Int32Value(receiver.recv().unwrap())
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7
|
||||
unsafe fn GetRenderbufferParameter(
|
||||
&self,
|
||||
_cx: *mut JSContext,
|
||||
target: u32,
|
||||
pname: u32
|
||||
) -> JSVal {
|
||||
let target_matches = target == constants::RENDERBUFFER;
|
||||
|
||||
let pname_matches = match pname {
|
||||
constants::RENDERBUFFER_WIDTH |
|
||||
constants::RENDERBUFFER_HEIGHT |
|
||||
constants::RENDERBUFFER_INTERNAL_FORMAT |
|
||||
constants::RENDERBUFFER_RED_SIZE |
|
||||
constants::RENDERBUFFER_GREEN_SIZE |
|
||||
constants::RENDERBUFFER_BLUE_SIZE |
|
||||
constants::RENDERBUFFER_ALPHA_SIZE |
|
||||
constants::RENDERBUFFER_DEPTH_SIZE |
|
||||
constants::RENDERBUFFER_STENCIL_SIZE => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
if !target_matches || !pname_matches {
|
||||
self.webgl_error(InvalidEnum);
|
||||
return NullValue();
|
||||
}
|
||||
|
||||
if self.bound_renderbuffer.get().is_none() {
|
||||
self.webgl_error(InvalidOperation);
|
||||
return NullValue();
|
||||
}
|
||||
|
||||
let (sender, receiver) = webgl_channel().unwrap();
|
||||
self.send_command(WebGLCommand::GetRenderbufferParameter(target, pname, sender));
|
||||
|
||||
Int32Value(receiver.recv().unwrap())
|
||||
}
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||
fn GetProgramInfoLog(&self, program: &WebGLProgram) -> Option<DOMString> {
|
||||
match program.get_info_log() {
|
||||
|
|
|
@ -571,8 +571,7 @@ interface WebGLRenderingContextBase
|
|||
GLenum pname);
|
||||
any getProgramParameter(WebGLProgram program, GLenum pname);
|
||||
DOMString? getProgramInfoLog(WebGLProgram program);
|
||||
// FIXME: https://github.com/servo/servo/issues/20514
|
||||
// any getRenderbufferParameter(GLenum target, GLenum pname);
|
||||
any getRenderbufferParameter(GLenum target, GLenum pname);
|
||||
any getShaderParameter(WebGLShader shader, GLenum pname);
|
||||
WebGLShaderPrecisionFormat? getShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype);
|
||||
DOMString? getShaderInfoLog(WebGLShader shader);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue