diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-10-03 06:00:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-03 06:00:50 -0400 |
commit | 74e7736720f457abc62ffe82cdda1db230320747 (patch) | |
tree | 6d4532f210773257b3db5a67e833f7d321fbfc83 /components/canvas/gl_context.rs | |
parent | 7fa2b2c879923a8b1f05be59ec9511ba8d5928c8 (diff) | |
parent | 5efbeea61ca619cbded91acb4b1b468aaa5e50b0 (diff) | |
download | servo-74e7736720f457abc62ffe82cdda1db230320747.tar.gz servo-74e7736720f457abc62ffe82cdda1db230320747.zip |
Auto merge of #21850 - servo:webgl, r=jdm
Don't use an intermediate PNG buffer in HTMLCanvasElement::ToDataURL
<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21850)
<!-- Reviewable:end -->
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()) } } } |