mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Make HTMLCanvasElement::get_size return a Size2D<u32>
The changes keep trickling down.
This commit is contained in:
parent
b8dbf2dddd
commit
a3392610c3
15 changed files with 126 additions and 101 deletions
|
@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue