aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webglrenderingcontext.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-11-01 20:13:59 -0400
committerGitHub <noreply@github.com>2019-11-01 20:13:59 -0400
commit56537fad5801143d70d923a612720a4606abcd75 (patch)
tree72775c3a86c1c5544f1aba71837a8d3ad5453bb5 /components/script/dom/webglrenderingcontext.rs
parent8b7e872ba75376efe3ed170b674a3dfd9a3fcdbb (diff)
parenta4fa36f9fb540357b8c9452598b729fba6688c46 (diff)
downloadservo-56537fad5801143d70d923a612720a4606abcd75.tar.gz
servo-56537fad5801143d70d923a612720a4606abcd75.zip
Auto merge of #24616 - teapotd:imageinfo-option-refactoring, r=jdm
Store Option<ImageInfo> instead of making fields of ImageInfo optional Fixes #24582 --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #24582 - [X] These changes do not require tests
Diffstat (limited to 'components/script/dom/webglrenderingcontext.rs')
-rw-r--r--components/script/dom/webglrenderingcontext.rs25
1 files changed, 14 insertions, 11 deletions
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs
index 7315d2516ab..b5faecc7371 100644
--- a/components/script/dom/webglrenderingcontext.rs
+++ b/components/script/dom/webglrenderingcontext.rs
@@ -443,13 +443,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),
);
@@ -751,7 +750,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
@@ -766,9 +768,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);
}
@@ -1919,9 +1919,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 => {
@@ -2020,7 +2020,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