mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Add initial support for WebGL compressed textures
This commit is contained in:
parent
a14b952fa3
commit
7f0b820d4e
16 changed files with 792 additions and 37 deletions
|
@ -17,6 +17,7 @@ use crate::dom::oestexturefloat::OESTextureFloat;
|
|||
use crate::dom::oestexturehalffloat::OESTextureHalfFloat;
|
||||
use crate::dom::webglcolorbufferfloat::WEBGLColorBufferFloat;
|
||||
use crate::dom::webglrenderingcontext::WebGLRenderingContext;
|
||||
use crate::dom::webgltexture::TexCompression;
|
||||
use canvas_traits::webgl::WebGLVersion;
|
||||
use fnv::{FnvHashMap, FnvHashSet};
|
||||
use gleam::gl::{self, GLenum};
|
||||
|
@ -82,6 +83,8 @@ struct WebGLExtensionFeatures {
|
|||
element_index_uint_enabled: bool,
|
||||
/// WebGL EXT_blend_minmax extension.
|
||||
blend_minmax_enabled: bool,
|
||||
/// WebGL supported texture compression formats enabled by extensions.
|
||||
tex_compression_formats: FnvHashMap<GLenum, TexCompression>,
|
||||
}
|
||||
|
||||
impl WebGLExtensionFeatures {
|
||||
|
@ -131,6 +134,7 @@ impl WebGLExtensionFeatures {
|
|||
disabled_get_vertex_attrib_names,
|
||||
element_index_uint_enabled,
|
||||
blend_minmax_enabled,
|
||||
tex_compression_formats: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -225,6 +229,13 @@ impl WebGLExtensions {
|
|||
.any(|name| features.gl_extensions.contains(*name))
|
||||
}
|
||||
|
||||
pub fn supports_all_gl_extension(&self, names: &[&str]) -> bool {
|
||||
let features = self.features.borrow();
|
||||
names
|
||||
.iter()
|
||||
.all(|name| features.gl_extensions.contains(*name))
|
||||
}
|
||||
|
||||
pub fn enable_tex_type(&self, data_type: GLenum) {
|
||||
self.features
|
||||
.borrow_mut()
|
||||
|
@ -335,6 +346,35 @@ impl WebGLExtensions {
|
|||
.contains(&name)
|
||||
}
|
||||
|
||||
pub fn add_tex_compression_formats(&self, formats: &[TexCompression]) {
|
||||
let formats: FnvHashMap<GLenum, TexCompression> = formats
|
||||
.iter()
|
||||
.map(|&compression| (compression.format.as_gl_constant(), compression))
|
||||
.collect();
|
||||
|
||||
self.features
|
||||
.borrow_mut()
|
||||
.tex_compression_formats
|
||||
.extend(formats.iter());
|
||||
}
|
||||
|
||||
pub fn get_tex_compression_format(&self, format_id: GLenum) -> Option<TexCompression> {
|
||||
self.features
|
||||
.borrow()
|
||||
.tex_compression_formats
|
||||
.get(&format_id)
|
||||
.cloned()
|
||||
}
|
||||
|
||||
pub fn get_tex_compression_ids(&self) -> Vec<GLenum> {
|
||||
self.features
|
||||
.borrow()
|
||||
.tex_compression_formats
|
||||
.keys()
|
||||
.map(|&k| k)
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn register_all_extensions(&self) {
|
||||
self.register::<ext::angleinstancedarrays::ANGLEInstancedArrays>();
|
||||
self.register::<ext::extblendminmax::EXTBlendMinmax>();
|
||||
|
@ -349,6 +389,8 @@ impl WebGLExtensions {
|
|||
self.register::<ext::oestexturehalffloatlinear::OESTextureHalfFloatLinear>();
|
||||
self.register::<ext::oesvertexarrayobject::OESVertexArrayObject>();
|
||||
self.register::<ext::webglcolorbufferfloat::WEBGLColorBufferFloat>();
|
||||
self.register::<ext::webglcompressedtextureetc1::WEBGLCompressedTextureETC1>();
|
||||
self.register::<ext::webglcompressedtextures3tc::WEBGLCompressedTextureS3TC>();
|
||||
}
|
||||
|
||||
pub fn enable_element_index_uint(&self) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue