fune/servo/components/script/dom/webgl_validations/mod.rs
Emilio Cobos Álvarez 3100c8274d servo: Merge #11724 - webgl: Refactor texture validations to take advantage of rust type system (from emilio:webgl-refactor); r=jdm
<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [x] These changes do not require tests because refactoring.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

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`.

r? @jdm

Source-Repo: https://github.com/servo/servo
Source-Revision: 80680764562bd4a46bd72a426b8157d59f6a6fd0
2016-06-25 15:16:48 -05:00

13 lines
406 B
Rust

/* 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;