diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2018-10-02 13:25:45 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2018-10-02 14:21:06 +0200 |
commit | a3392610c3414a86a2294073bdc59c78c237bfda (patch) | |
tree | 549cc165a6a48da00ac9a6e4f715f3978112f79f /components/canvas/gl_context.rs | |
parent | b8dbf2dddd88516f85370c49015133435750003d (diff) | |
download | servo-a3392610c3414a86a2294073bdc59c78c237bfda.tar.gz servo-a3392610c3414a86a2294073bdc59c78c237bfda.zip |
Make HTMLCanvasElement::get_size return a Size2D<u32>
The changes keep trickling down.
Diffstat (limited to 'components/canvas/gl_context.rs')
-rw-r--r-- | components/canvas/gl_context.rs | 92 |
1 files changed, 51 insertions, 41 deletions
diff --git a/components/canvas/gl_context.rs b/components/canvas/gl_context.rs index c90ecec9cca..77cbc20e55b 100644 --- a/components/canvas/gl_context.rs +++ b/components/canvas/gl_context.rs @@ -47,63 +47,71 @@ impl GLContextFactory { pub fn new_shared_context( &self, webgl_version: WebGLVersion, - size: Size2D<i32>, + size: Size2D<u32>, attributes: GLContextAttributes ) -> Result<GLContextWrapper, &'static str> { - match *self { + Ok(match *self { GLContextFactory::Native(ref handle, ref dispatcher) => { let dispatcher = dispatcher.as_ref().map(|d| Box::new(d.clone()) as Box<_>); - let ctx = GLContext::<NativeGLContext>::new_shared_with_dispatcher(size, - attributes, - ColorAttachmentType::Texture, - gl::GlType::default(), - Self::gl_version(webgl_version), - Some(handle), - dispatcher); - ctx.map(GLContextWrapper::Native) + GLContextWrapper::Native(GLContext::new_shared_with_dispatcher( + // FIXME(nox): Why are those i32 values? + size.to_i32(), + attributes, + ColorAttachmentType::Texture, + gl::GlType::default(), + Self::gl_version(webgl_version), + Some(handle), + dispatcher, + )?) } GLContextFactory::OSMesa(ref handle) => { - let ctx = GLContext::<OSMesaContext>::new_shared_with_dispatcher(size.to_untyped(), - attributes, - ColorAttachmentType::Texture, - gl::GlType::default(), - Self::gl_version(webgl_version), - Some(handle), - None); - ctx.map(GLContextWrapper::OSMesa) + GLContextWrapper::OSMesa(GLContext::new_shared_with_dispatcher( + // FIXME(nox): Why are those i32 values? + size.to_i32(), + attributes, + ColorAttachmentType::Texture, + gl::GlType::default(), + Self::gl_version(webgl_version), + Some(handle), + None, + )?) } - } + }) } /// Creates a new non-shared GLContext pub fn new_context( &self, webgl_version: WebGLVersion, - size: Size2D<i32>, + size: Size2D<u32>, attributes: GLContextAttributes ) -> Result<GLContextWrapper, &'static str> { - match *self { + Ok(match *self { GLContextFactory::Native(..) => { - let ctx = GLContext::<NativeGLContext>::new_shared_with_dispatcher(size, - attributes, - ColorAttachmentType::Texture, - gl::GlType::default(), - Self::gl_version(webgl_version), - None, - None); - ctx.map(GLContextWrapper::Native) + GLContextWrapper::Native(GLContext::new_shared_with_dispatcher( + // FIXME(nox): Why are those i32 values? + size.to_i32(), + attributes, + ColorAttachmentType::Texture, + gl::GlType::default(), + Self::gl_version(webgl_version), + None, + None, + )?) } GLContextFactory::OSMesa(_) => { - let ctx = GLContext::<OSMesaContext>::new_shared_with_dispatcher(size.to_untyped(), - attributes, - ColorAttachmentType::Texture, - gl::GlType::default(), - Self::gl_version(webgl_version), - None, - None); - ctx.map(GLContextWrapper::OSMesa) + GLContextWrapper::OSMesa(GLContext::new_shared_with_dispatcher( + // FIXME(nox): Why are those i32 values? + size.to_i32(), + attributes, + ColorAttachmentType::Texture, + gl::GlType::default(), + Self::gl_version(webgl_version), + None, + None, + )?) } - } + }) } fn gl_version(webgl_version: WebGLVersion) -> GLVersion { @@ -196,13 +204,15 @@ impl GLContextWrapper { } } - pub fn resize(&mut self, size: Size2D<i32>) -> Result<(), &'static str> { + pub fn resize(&mut self, size: Size2D<u32>) -> Result<(), &'static str> { match *self { GLContextWrapper::Native(ref mut ctx) => { - ctx.resize(size) + // FIXME(nox): Why are those i32 values? + ctx.resize(size.to_i32()) } GLContextWrapper::OSMesa(ref mut ctx) => { - ctx.resize(size) + // FIXME(nox): Why are those i32 values? + ctx.resize(size.to_i32()) } } } |