aboutsummaryrefslogtreecommitdiffstats
path: root/components/canvas_traits/lib.rs
diff options
context:
space:
mode:
authorecoal95 <ecoal95@gmail.com>2015-06-14 22:55:50 +0200
committerecoal95 <ecoal95@gmail.com>2015-07-06 19:54:05 +0200
commitb1765c68821d12a21cd304f7dffaa3bdc8f101e4 (patch)
treed98d8aa769e2894c5ffee3e8597ed93945d4bbed /components/canvas_traits/lib.rs
parentc0222628264423a67bf98775be83dcf2f85211ab (diff)
downloadservo-b1765c68821d12a21cd304f7dffaa3bdc8f101e4.tar.gz
servo-b1765c68821d12a21cd304f7dffaa3bdc8f101e4.zip
webgl: Refactor implementation to move logic inside the DOM interfaces
This improves the encapsulation and consistency in our WebGL implementation. Also allows to implement new methods such as `getShaderSource()`. It will also allow us to use `delete()` in the destructors of them (note that we will want to keep track of them from the context).
Diffstat (limited to 'components/canvas_traits/lib.rs')
-rw-r--r--components/canvas_traits/lib.rs24
1 files changed, 21 insertions, 3 deletions
diff --git a/components/canvas_traits/lib.rs b/components/canvas_traits/lib.rs
index 0fee050d78d..51c9a1dafb2 100644
--- a/components/canvas_traits/lib.rs
+++ b/components/canvas_traits/lib.rs
@@ -107,9 +107,9 @@ pub enum CanvasWebGLMsg {
BindTexture(u32, u32),
DrawArrays(u32, i32, i32),
EnableVertexAttribArray(u32),
- GetAttribLocation(u32, String, Sender<i32>),
- GetShaderInfoLog(u32, Sender<String>),
- GetShaderParameter(u32, u32, Sender<i32>),
+ GetShaderInfoLog(u32, Sender<Option<String>>),
+ GetShaderParameter(u32, u32, Sender<WebGLShaderParameter>),
+ GetAttribLocation(u32, String, Sender<Option<i32>>),
GetUniformLocation(u32, String, Sender<Option<i32>>),
LinkProgram(u32),
ShaderSource(u32, String),
@@ -122,6 +122,24 @@ pub enum CanvasWebGLMsg {
}
#[derive(Clone)]
+pub enum WebGLError {
+ InvalidEnum,
+ InvalidOperation,
+ InvalidValue,
+ OutOfMemory,
+ ContextLost,
+}
+
+pub type WebGLResult<T> = Result<T, WebGLError>;
+
+#[derive(Clone)]
+pub enum WebGLShaderParameter {
+ Int(i32),
+ Bool(bool),
+ Invalid,
+}
+
+#[derive(Clone)]
pub enum CanvasCommonMsg {
Close,
Recreate(Size2D<i32>),