diff options
author | Emilio Cobos Álvarez <me@emiliocobos.me> | 2016-06-12 00:16:27 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <me@emiliocobos.me> | 2016-06-25 00:03:15 +0200 |
commit | 46c14aced2f761c39f0f602962c660e362d98416 (patch) | |
tree | 668c13ee03202b095d352f67b533b8fdac86b889 /components/script/dom/webgl_validations/mod.rs | |
parent | 8d81ee77a877f07e2d4f2779aa252f5f3bb98c7c (diff) | |
download | servo-46c14aced2f761c39f0f602962c660e362d98416.tar.gz servo-46c14aced2f761c39f0f602962c660e362d98416.zip |
webgl: Refactor texture validations to take advantage of rust type system
This commit introduces the `WebGLValidator` trait, and uses it for multiple
validations in the texture-related WebGL code, to move that logic out of the
already bloated `webglrenderingcontext.rs` file.
It also creates a type-safe wrapper for some WebGL types, removing all the
`unreachable!`s there, and introduces a macro for generating them conveniently.
This partially addresses #10693, pending refactor more code to use this
infrastructure, and (possibly?) introducing an `AsGLError` trait for the errors
to make the error handling happen in `WebGLContext`.
Diffstat (limited to 'components/script/dom/webgl_validations/mod.rs')
-rw-r--r-- | components/script/dom/webgl_validations/mod.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/components/script/dom/webgl_validations/mod.rs b/components/script/dom/webgl_validations/mod.rs new file mode 100644 index 00000000000..2e070c6d6bc --- /dev/null +++ b/components/script/dom/webgl_validations/mod.rs @@ -0,0 +1,13 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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/. */ + +pub trait WebGLValidator { + type ValidatedOutput; + type Error: ::std::error::Error; + + fn validate(self) -> Result<Self::ValidatedOutput, Self::Error>; +} + +pub mod tex_image_2d; +pub mod types; |