Add support for filtering WebGL extensions based on WebGL version

This commit is contained in:
Imanol Fernandez 2017-10-27 17:06:53 +02:00
parent d21657a9e5
commit f2f5817f56
13 changed files with 87 additions and 25 deletions

View file

@ -9,7 +9,7 @@ use dom::bindings::trace::JSTraceable;
use dom::webglrenderingcontext::WebGLRenderingContext;
use malloc_size_of::MallocSizeOf;
use std::any::Any;
use super::{WebGLExtension, WebGLExtensions};
use super::{WebGLExtension, WebGLExtensions, WebGLExtensionSpec};
/// Trait used internally by WebGLExtensions to store and
/// handle the different WebGL extensions in a common list.
@ -18,6 +18,7 @@ pub trait WebGLExtensionWrapper: JSTraceable + MallocSizeOf {
ctx: &WebGLRenderingContext,
ext: &WebGLExtensions)
-> NonNullJSObjectPtr;
fn spec(&self) -> WebGLExtensionSpec;
fn is_supported(&self, &WebGLExtensions) -> bool;
fn is_enabled(&self) -> bool;
fn enable(&self, ext: &WebGLExtensions);
@ -61,6 +62,10 @@ impl<T> WebGLExtensionWrapper for TypedWebGLExtensionWrapper<T>
}
}
fn spec(&self) -> WebGLExtensionSpec {
T::spec()
}
fn is_supported(&self, ext: &WebGLExtensions) -> bool {
self.is_enabled() || T::is_supported(ext)
}