mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Store Option<ImageInfo> instead of making fields optional
This commit is contained in:
parent
48d918dcde
commit
a4fa36f9fb
4 changed files with 47 additions and 69 deletions
|
@ -438,13 +438,12 @@ impl WebGLRenderingContext {
|
|||
}
|
||||
|
||||
let target = TexImageTarget::Texture2D;
|
||||
let info = texture.image_info_for_target(&target, 0);
|
||||
if info.is_initialized() {
|
||||
if let Some(info) = texture.image_info_for_target(&target, 0) {
|
||||
self.validate_filterable_texture(
|
||||
&texture,
|
||||
target,
|
||||
0,
|
||||
info.internal_format().unwrap_or(TexFormat::RGBA),
|
||||
info.internal_format(),
|
||||
Size2D::new(info.width(), info.height()),
|
||||
info.data_type().unwrap_or(TexDataType::UnsignedByte),
|
||||
);
|
||||
|
@ -746,7 +745,10 @@ impl WebGLRenderingContext {
|
|||
pixels: TexPixels,
|
||||
) {
|
||||
// We have already validated level
|
||||
let image_info = texture.image_info_for_target(&target, level);
|
||||
let image_info = match texture.image_info_for_target(&target, level) {
|
||||
Some(info) => info,
|
||||
None => return self.webgl_error(InvalidOperation),
|
||||
};
|
||||
|
||||
// GL_INVALID_VALUE is generated if:
|
||||
// - xoffset or yoffset is less than 0
|
||||
|
@ -761,9 +763,7 @@ impl WebGLRenderingContext {
|
|||
}
|
||||
|
||||
// NB: format and internal_format must match.
|
||||
if format != image_info.internal_format().unwrap() ||
|
||||
data_type != image_info.data_type().unwrap()
|
||||
{
|
||||
if format != image_info.internal_format() || data_type != image_info.data_type().unwrap() {
|
||||
return self.webgl_error(InvalidOperation);
|
||||
}
|
||||
|
||||
|
@ -1921,9 +1921,9 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
Some(WebGLFramebufferAttachmentRoot::Renderbuffer(rb)) => {
|
||||
TexFormat::from_gl_constant(rb.internal_format())
|
||||
},
|
||||
Some(WebGLFramebufferAttachmentRoot::Texture(texture)) => {
|
||||
texture.image_info_for_target(&target, 0).internal_format()
|
||||
},
|
||||
Some(WebGLFramebufferAttachmentRoot::Texture(texture)) => texture
|
||||
.image_info_for_target(&target, 0)
|
||||
.map(|info| info.internal_format()),
|
||||
None => None,
|
||||
},
|
||||
None => {
|
||||
|
@ -2022,7 +2022,10 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
Err(_) => return,
|
||||
};
|
||||
|
||||
let image_info = texture.image_info_for_target(&target, level);
|
||||
let image_info = match texture.image_info_for_target(&target, level) {
|
||||
Some(info) => info,
|
||||
None => return self.webgl_error(InvalidOperation),
|
||||
};
|
||||
|
||||
// GL_INVALID_VALUE is generated if:
|
||||
// - xoffset or yoffset is less than 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue