зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #11426 - Implement IsBuffer, IsFramebuffer and IsRenderbuffer for WebGLRenderingContext (from DDEFISHER:master); r=emilio
- [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy --faster` does not report any errors - [X] These changes fix #11357 - [X] There are tests for these changes Source-Repo: https://github.com/servo/servo Source-Revision: b11648903bb07a31ec93f3030058ed41b3472b17
This commit is contained in:
Родитель
95f41e530d
Коммит
95d70551db
|
@ -95,6 +95,14 @@ impl WebGLBuffer {
|
|||
let _ = self.renderer.send(CanvasMsg::WebGL(WebGLCommand::DeleteBuffer(self.id)));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_deleted(&self) -> bool {
|
||||
self.is_deleted.get()
|
||||
}
|
||||
|
||||
pub fn target(&self) -> Option<u32> {
|
||||
self.target.get()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for WebGLBuffer {
|
||||
|
|
|
@ -17,6 +17,8 @@ use webrender_traits::{WebGLCommand, WebGLFramebufferBindingRequest};
|
|||
pub struct WebGLFramebuffer {
|
||||
webgl_object: WebGLObject,
|
||||
id: u32,
|
||||
/// target can only be gl::FRAMEBUFFER at the moment
|
||||
target: Cell<Option<u32>>,
|
||||
is_deleted: Cell<bool>,
|
||||
#[ignore_heap_size_of = "Defined in ipc-channel"]
|
||||
renderer: IpcSender<CanvasMsg>,
|
||||
|
@ -27,6 +29,7 @@ impl WebGLFramebuffer {
|
|||
WebGLFramebuffer {
|
||||
webgl_object: WebGLObject::new_inherited(),
|
||||
id: id,
|
||||
target: Cell::new(None),
|
||||
is_deleted: Cell::new(false),
|
||||
renderer: renderer,
|
||||
}
|
||||
|
@ -54,6 +57,7 @@ impl WebGLFramebuffer {
|
|||
}
|
||||
|
||||
pub fn bind(&self, target: u32) {
|
||||
self.target.set(Some(target));
|
||||
let cmd = WebGLCommand::BindFramebuffer(target, WebGLFramebufferBindingRequest::Explicit(self.id));
|
||||
self.renderer.send(CanvasMsg::WebGL(cmd)).unwrap();
|
||||
}
|
||||
|
@ -64,6 +68,14 @@ impl WebGLFramebuffer {
|
|||
let _ = self.renderer.send(CanvasMsg::WebGL(WebGLCommand::DeleteFramebuffer(self.id)));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_deleted(&self) -> bool {
|
||||
self.is_deleted.get()
|
||||
}
|
||||
|
||||
pub fn target(&self) -> Option<u32> {
|
||||
self.target.get()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for WebGLFramebuffer {
|
||||
|
|
|
@ -17,6 +17,7 @@ use webrender_traits::WebGLCommand;
|
|||
pub struct WebGLRenderbuffer {
|
||||
webgl_object: WebGLObject,
|
||||
id: u32,
|
||||
ever_bound: Cell<bool>,
|
||||
is_deleted: Cell<bool>,
|
||||
#[ignore_heap_size_of = "Defined in ipc-channel"]
|
||||
renderer: IpcSender<CanvasMsg>,
|
||||
|
@ -27,6 +28,7 @@ impl WebGLRenderbuffer {
|
|||
WebGLRenderbuffer {
|
||||
webgl_object: WebGLObject::new_inherited(),
|
||||
id: id,
|
||||
ever_bound: Cell::new(false),
|
||||
is_deleted: Cell::new(false),
|
||||
renderer: renderer,
|
||||
}
|
||||
|
@ -54,6 +56,7 @@ impl WebGLRenderbuffer {
|
|||
}
|
||||
|
||||
pub fn bind(&self, target: u32) {
|
||||
self.ever_bound.set(true);
|
||||
self.renderer.send(CanvasMsg::WebGL(WebGLCommand::BindRenderbuffer(target, self.id))).unwrap();
|
||||
}
|
||||
|
||||
|
@ -63,4 +66,12 @@ impl WebGLRenderbuffer {
|
|||
let _ = self.renderer.send(CanvasMsg::WebGL(WebGLCommand::DeleteRenderbuffer(self.id)));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_deleted(&self) -> bool {
|
||||
self.is_deleted.get()
|
||||
}
|
||||
|
||||
pub fn ever_bound(&self) -> bool {
|
||||
self.ever_bound.get()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1331,6 +1331,21 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
.unwrap()
|
||||
}
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
|
||||
fn IsBuffer(&self, buffer: Option<&WebGLBuffer>) -> bool {
|
||||
buffer.map_or(false, |buf| buf.target().is_some() && !buf.is_deleted())
|
||||
}
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6
|
||||
fn IsFramebuffer(&self, frame_buffer: Option<&WebGLFramebuffer>) -> bool {
|
||||
frame_buffer.map_or(false, |buf| buf.target().is_some() && !buf.is_deleted())
|
||||
}
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7
|
||||
fn IsRenderbuffer(&self, render_buffer: Option<&WebGLRenderbuffer>) -> bool {
|
||||
render_buffer.map_or(false, |buf| buf.ever_bound() && !buf.is_deleted())
|
||||
}
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||
fn IsShader(&self, shader: Option<&WebGLShader>) -> bool {
|
||||
shader.map_or(false, |s| !s.is_deleted() || s.is_attached())
|
||||
|
|
|
@ -602,11 +602,11 @@ interface WebGLRenderingContextBase
|
|||
//[WebGLHandlesContextLoss] GLsizeiptr getVertexAttribOffset(GLuint index, GLenum pname);
|
||||
|
||||
void hint(GLenum target, GLenum mode);
|
||||
//[WebGLHandlesContextLoss] GLboolean isBuffer(WebGLBuffer? buffer);
|
||||
[WebGLHandlesContextLoss] GLboolean isBuffer(WebGLBuffer? buffer);
|
||||
//[WebGLHandlesContextLoss] GLboolean isEnabled(GLenum cap);
|
||||
//[WebGLHandlesContextLoss] GLboolean isFramebuffer(WebGLFramebuffer? framebuffer);
|
||||
[WebGLHandlesContextLoss] GLboolean isFramebuffer(WebGLFramebuffer? framebuffer);
|
||||
//[WebGLHandlesContextLoss] GLboolean isProgram(WebGLProgram? program);
|
||||
//[WebGLHandlesContextLoss] GLboolean isRenderbuffer(WebGLRenderbuffer? renderbuffer);
|
||||
[WebGLHandlesContextLoss] GLboolean isRenderbuffer(WebGLRenderbuffer? renderbuffer);
|
||||
[WebGLHandlesContextLoss] GLboolean isShader(WebGLShader? shader);
|
||||
[WebGLHandlesContextLoss] GLboolean isTexture(WebGLTexture? texture);
|
||||
void lineWidth(GLfloat width);
|
||||
|
|
Загрузка…
Ссылка в новой задаче