aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webgl_validations
diff options
context:
space:
mode:
authorImanol Fernandez <mortimergoro@gmail.com>2017-05-16 11:14:23 +0200
committerImanol Fernandez <mortimergoro@gmail.com>2017-05-18 18:44:07 +0200
commit32e23c4db4a80f8ebe01bead141c5ca04bc6b215 (patch)
tree3062608b9ac6441f73d6507ebe4d25100e2676d1 /components/script/dom/webgl_validations
parentac99a48aeaa184d3acdb39d249636a140c4b7393 (diff)
downloadservo-32e23c4db4a80f8ebe01bead141c5ca04bc6b215.tar.gz
servo-32e23c4db4a80f8ebe01bead141c5ca04bc6b215.zip
Implement WebGL extensions.
Diffstat (limited to 'components/script/dom/webgl_validations')
-rw-r--r--components/script/dom/webgl_validations/types.rs47
1 files changed, 27 insertions, 20 deletions
diff --git a/components/script/dom/webgl_validations/types.rs b/components/script/dom/webgl_validations/types.rs
index f42eb548efd..3920866b0ea 100644
--- a/components/script/dom/webgl_validations/types.rs
+++ b/components/script/dom/webgl_validations/types.rs
@@ -2,24 +2,25 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+use dom::bindings::codegen::Bindings::OESTextureHalfFloatBinding::OESTextureHalfFloatConstants;
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants;
/// This macro creates type-safe wrappers for WebGL types, associating variants
/// with gl constants.
macro_rules! type_safe_wrapper {
- ($name: ident, $($variant:ident => $constant:ident, )+) => {
+ ($name: ident, $($variant:ident => $mod:ident::$constant:ident, )+) => {
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, JSTraceable, HeapSizeOf)]
#[repr(u32)]
pub enum $name {
$(
- $variant = constants::$constant,
+ $variant = $mod::$constant,
)+
}
impl $name {
pub fn from_gl_constant(constant: u32) -> Option<Self> {
Some(match constant {
- $(constants::$constant => $name::$variant, )+
+ $($mod::$constant => $name::$variant, )+
_ => return None,
})
}
@@ -33,13 +34,13 @@ macro_rules! type_safe_wrapper {
}
type_safe_wrapper! { TexImageTarget,
- Texture2D => TEXTURE_2D,
- CubeMapPositiveX => TEXTURE_CUBE_MAP_POSITIVE_X,
- CubeMapNegativeX => TEXTURE_CUBE_MAP_NEGATIVE_X,
- CubeMapPositiveY => TEXTURE_CUBE_MAP_POSITIVE_Y,
- CubeMapNegativeY => TEXTURE_CUBE_MAP_NEGATIVE_Y,
- CubeMapPositiveZ => TEXTURE_CUBE_MAP_POSITIVE_Z,
- CubeMapNegativeZ => TEXTURE_CUBE_MAP_NEGATIVE_Z,
+ Texture2D => constants::TEXTURE_2D,
+ CubeMapPositiveX => constants::TEXTURE_CUBE_MAP_POSITIVE_X,
+ CubeMapNegativeX => constants::TEXTURE_CUBE_MAP_NEGATIVE_X,
+ CubeMapPositiveY => constants::TEXTURE_CUBE_MAP_POSITIVE_Y,
+ CubeMapNegativeY => constants::TEXTURE_CUBE_MAP_NEGATIVE_Y,
+ CubeMapPositiveZ => constants::TEXTURE_CUBE_MAP_POSITIVE_Z,
+ CubeMapNegativeZ => constants::TEXTURE_CUBE_MAP_NEGATIVE_Z,
}
impl TexImageTarget {
@@ -52,10 +53,12 @@ impl TexImageTarget {
}
type_safe_wrapper! { TexDataType,
- UnsignedByte => UNSIGNED_BYTE,
- UnsignedShort4444 => UNSIGNED_SHORT_4_4_4_4,
- UnsignedShort5551 => UNSIGNED_SHORT_5_5_5_1,
- UnsignedShort565 => UNSIGNED_SHORT_5_6_5,
+ UnsignedByte => constants::UNSIGNED_BYTE,
+ UnsignedShort4444 => constants::UNSIGNED_SHORT_4_4_4_4,
+ UnsignedShort5551 => constants::UNSIGNED_SHORT_5_5_5_1,
+ UnsignedShort565 => constants::UNSIGNED_SHORT_5_6_5,
+ Float => constants::FLOAT,
+ HalfFloat => OESTextureHalfFloatConstants::HALF_FLOAT_OES,
}
impl TexDataType {
@@ -67,6 +70,8 @@ impl TexDataType {
UnsignedShort4444 |
UnsignedShort5551 |
UnsignedShort565 => 2,
+ Float => 4,
+ HalfFloat => 2,
}
}
@@ -79,17 +84,19 @@ impl TexDataType {
UnsignedShort565 => 3,
UnsignedShort5551 => 4,
UnsignedShort4444 => 4,
+ Float => 1,
+ HalfFloat => 1,
}
}
}
type_safe_wrapper! { TexFormat,
- DepthComponent => DEPTH_COMPONENT,
- Alpha => ALPHA,
- RGB => RGB,
- RGBA => RGBA,
- Luminance => LUMINANCE,
- LuminanceAlpha => LUMINANCE_ALPHA,
+ DepthComponent => constants::DEPTH_COMPONENT,
+ Alpha => constants::ALPHA,
+ RGB => constants::RGB,
+ RGBA => constants::RGBA,
+ Luminance => constants::LUMINANCE,
+ LuminanceAlpha => constants::LUMINANCE_ALPHA,
}
impl TexFormat {