Auto merge of #21701 - servo:webgl, r=jdm

Yet another batch of arbitrary improvements to our WebGL stuff

<!-- 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/21701)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-09-13 16:05:04 -04:00 committed by GitHub
commit 93fbc1575f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 103 additions and 141 deletions

View file

@ -11,7 +11,7 @@ use azure::azure_hl::SurfacePattern;
use canvas_traits::canvas::*;
use cssparser::RGBA;
use euclid::{Transform2D, Point2D, Vector2D, Rect, Size2D};
use ipc_channel::ipc::IpcSender;
use ipc_channel::ipc::{IpcBytesSender, IpcSender};
use num_traits::ToPrimitive;
use serde_bytes::ByteBuf;
use std::mem;
@ -456,13 +456,9 @@ impl<'a> CanvasData<'a> {
&self,
dest_rect: Rect<i32>,
canvas_size: Size2D<f64>,
chan: IpcSender<ByteBuf>,
sender: IpcBytesSender,
) {
let mut dest_data = self.read_pixels(dest_rect, canvas_size);
// bgra -> rgba
byte_swap(&mut dest_data);
chan.send(dest_data.into()).unwrap();
sender.send(&self.read_pixels(dest_rect, canvas_size)).unwrap();
}
// https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata

View file

@ -4,7 +4,7 @@
use cssparser::RGBA;
use euclid::{Transform2D, Point2D, Vector2D, Rect, Size2D};
use ipc_channel::ipc::IpcSender;
use ipc_channel::ipc::{IpcBytesSender, IpcSender};
use serde_bytes::ByteBuf;
use std::default::Default;
use std::str::FromStr;
@ -51,7 +51,7 @@ pub enum Canvas2dMsg {
Fill,
FillText(String, f64, f64, Option<f64>),
FillRect(Rect<f32>),
GetImageData(Rect<i32>, Size2D<f64>, IpcSender<ByteBuf>),
GetImageData(Rect<i32>, Size2D<f64>, IpcBytesSender),
IsPointInPath(f64, f64, FillRule, IpcSender<bool>),
LineTo(Point2D<f32>),
MoveTo(Point2D<f32>),

View file

@ -32,7 +32,7 @@ use dom::imagedata::ImageData;
use dom::node::{Node, NodeDamage, window_from_node};
use dom_struct::dom_struct;
use euclid::{Transform2D, Point2D, Vector2D, Rect, Size2D, vec2};
use ipc_channel::ipc::IpcSender;
use ipc_channel::ipc::{self, IpcSender};
use net_traits::image::base::PixelFormat;
use net_traits::image_cache::CanRequestImages;
use net_traits::image_cache::ImageCache;
@ -41,7 +41,7 @@ use net_traits::image_cache::ImageResponse;
use net_traits::image_cache::ImageState;
use net_traits::image_cache::UsePlaceholder;
use num_traits::ToPrimitive;
use profile_traits::ipc;
use profile_traits::ipc as profiled_ipc;
use script_traits::ScriptMsg;
use servo_url::ServoUrl;
use std::{cmp, fmt, mem};
@ -130,7 +130,7 @@ impl CanvasRenderingContext2D {
size: Size2D<i32>)
-> CanvasRenderingContext2D {
debug!("Creating new canvas rendering context.");
let (sender, receiver) = ipc::channel(global.time_profiler_chan().clone()).unwrap();
let (sender, receiver) = profiled_ipc::channel(global.time_profiler_chan().clone()).unwrap();
let script_to_constellation_chan = global.script_to_constellation_chan();
debug!("Asking constellation to create new canvas thread.");
script_to_constellation_chan.send(ScriptMsg::CreateCanvasPaintThread(size, sender)).unwrap();
@ -790,7 +790,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
CanvasFillRule::Nonzero => FillRule::Nonzero,
CanvasFillRule::Evenodd => FillRule::Evenodd,
};
let (sender, receiver) = ipc::channel::<bool>(self.global().time_profiler_chan().clone()).unwrap();
let (sender, receiver) = profiled_ipc::channel::<bool>(self.global().time_profiler_chan().clone()).unwrap();
self.send_canvas_2d_msg(Canvas2dMsg::IsPointInPath(x, y, fill_rule, sender));
receiver.recv().unwrap()
}
@ -1107,7 +1107,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
let sh = cmp::max(1, sh.to_u32().unwrap());
let sw = cmp::max(1, sw.to_u32().unwrap());
let (sender, receiver) = ipc::channel(self.global().time_profiler_chan().clone()).unwrap();
let (sender, receiver) = ipc::bytes_channel().unwrap();
let dest_rect = Rect::new(Point2D::new(sx.to_i32().unwrap(), sy.to_i32().unwrap()),
Size2D::new(sw as i32, sh as i32));
let canvas_size = self.canvas.as_ref().map(|c| c.get_size()).unwrap_or(Size2D::zero());
@ -1115,12 +1115,12 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
self.send_canvas_2d_msg(Canvas2dMsg::GetImageData(dest_rect, canvas_size, sender));
let mut data = receiver.recv().unwrap();
// Un-premultiply alpha
// Byte swap and unmultiply alpha.
for chunk in data.chunks_mut(4) {
let alpha = chunk[3] as usize;
chunk[0] = UNPREMULTIPLY_TABLE[256 * alpha + chunk[0] as usize];
chunk[1] = UNPREMULTIPLY_TABLE[256 * alpha + chunk[1] as usize];
chunk[2] = UNPREMULTIPLY_TABLE[256 * alpha + chunk[2] as usize];
let (b, g, r, a) = (chunk[0], chunk[1], chunk[2], chunk[3]);
chunk[0] = UNPREMULTIPLY_TABLE[256 * (a as usize) + r as usize];
chunk[1] = UNPREMULTIPLY_TABLE[256 * (a as usize) + g as usize];
chunk[2] = UNPREMULTIPLY_TABLE[256 * (a as usize) + b as usize];
}
ImageData::new(&self.global(), sw, sh, Some(data.to_vec()))

View file

@ -1752,22 +1752,6 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
Err(_) => return,
};
let image_info = texture.image_info_for_target(&target, level);
// The color buffer components can be dropped during the conversion to
// the internal_format, but new components cannot be added.
//
// Note that this only applies if we're copying to an already
// initialized texture.
//
// GL_INVALID_OPERATION is generated if the color buffer cannot be
// converted to the internal_format.
if let Some(old_internal_format) = image_info.internal_format() {
if old_internal_format.components() > internal_format.components() {
return self.webgl_error(InvalidOperation);
}
}
// NB: TexImage2D depth is always equal to 1
handle_potential_webgl_error!(self, texture.initialize(target,
width as u32,

View file

@ -12085,7 +12085,9 @@
"conformance/glsl/misc/shader-uniform-packing-restrictions.html": [
[
"/_webgl/conformance/glsl/misc/shader-uniform-packing-restrictions.html",
{}
{
"timeout": "long"
}
]
],
"conformance/glsl/misc/shader-varying-packing-restrictions.html": [
@ -28644,7 +28646,7 @@
"testharness"
],
"conformance/glsl/misc/shader-uniform-packing-restrictions.html": [
"f6b879a8d8c531cb63392308f6d1c3b0e789e105",
"4d6f691246209793ec7fabfcfe1d143641135220",
"testharness"
],
"conformance/glsl/misc/shader-varying-packing-restrictions.html": [

View file

@ -1,3 +1,4 @@
[canvas-test.html]
bug: https://github.com/servo/servo/issues/21556
expected: ERROR

View file

@ -1,3 +1,4 @@
[draw-static-webgl-to-multiple-canvas-test.html]
bug: https://github.com/servo/servo/issues/21556
expected: ERROR

View file

@ -1,3 +1,4 @@
[draw-webgl-to-canvas-test.html]
bug: https://github.com/servo/servo/issues/21556
expected: ERROR

View file

@ -1,2 +1,3 @@
[drawingbuffer-static-canvas-test.html]
bug: https://github.com/servo/servo/issues/21556
expected: CRASH

View file

@ -1,4 +1,5 @@
[framebuffer-bindings-affected-by-to-data-url.html]
bug: https://github.com/servo/servo/issues/21132
[WebGL test #0: Unable to fetch WebGL rendering context for Canvas]
expected: FAIL

View file

@ -1,3 +1,3 @@
[rapid-resizing.html]
disabled: https://github.com/servo/servo/issues/21132
disabled: https://github.com/servo/servo/issues/16215

View file

@ -1,2 +1,3 @@
[to-data-url-test.html]
bug: https://github.com/servo/servo/issues/21132
expected: ERROR

View file

@ -1,2 +1,2 @@
[oes-texture-float-with-video.html]
disabled: flaky
disabled: https://github.com/servo/servo/issues/6711

View file

@ -1,2 +1,2 @@
[oes-texture-half-float-with-video.html]
disabled: flaky
disabled: https://github.com/servo/servo/issues/6711

View file

@ -1,4 +0,0 @@
[object-deletion-behaviour.html]
[WebGL test #76: getError expected: INVALID_OPERATION. Was NO_ERROR : after evaluating: gl.bindRenderbuffer(gl.RENDERBUFFER, rbo)]
expected: FAIL

View file

@ -1,3 +1,3 @@
[read-pixels-test.html]
bug: https://github.com/servo/servo/issues/14380
bug: https://github.com/servo/servo/issues/12859
expected: TIMEOUT

View file

@ -1,4 +1,5 @@
[framebuffer-state-restoration.html]
bug: https://github.com/servo/servo/issues/21132
[WebGL test #0: Unable to fetch WebGL rendering context for Canvas]
expected: FAIL

View file

@ -1,4 +0,0 @@
[gl-object-get-calls.html]
[WebGL test #121: getError expected: INVALID_OPERATION. Was NO_ERROR : ]
expected: FAIL

View file

@ -1,31 +1,4 @@
[copy-tex-image-2d-formats.html]
[WebGL test #23: getError expected: INVALID_OPERATION. Was NO_ERROR : should not be able to copyTexImage2D LUMINANCE_ALPHA from RGB]
expected: FAIL
[WebGL test #19: getError expected: INVALID_OPERATION. Was NO_ERROR : should not be able to copyTexImage2D ALPHA from RGB]
expected: FAIL
[WebGL test #27: getError expected: INVALID_OPERATION. Was NO_ERROR : should not be able to copyTexImage2D RGBA from RGB]
expected: FAIL
[WebGL test #18: Creating framebuffer from LUMINANCE_ALPHA texture succeeded even though it is not a renderable format]
expected: FAIL
[WebGL test #17: Creating framebuffer from LUMINANCE texture succeeded even though it is not a renderable format]
expected: FAIL
[WebGL test #48: getError expected: INVALID_OPERATION. Was NO_ERROR : should not be able to copyTexImage2D LUMINANCE_ALPHA from RGB]
expected: FAIL
[WebGL test #52: getError expected: INVALID_OPERATION. Was NO_ERROR : should not be able to copyTexImage2D RGBA from RGB]
expected: FAIL
[WebGL test #44: getError expected: INVALID_OPERATION. Was NO_ERROR : should not be able to copyTexImage2D ALPHA from RGB]
expected: FAIL
[WebGL test #16: Creating framebuffer from ALPHA texture succeeded even though it is not a renderable format]
expected: FAIL
[WebGL test #32: getError expected: INVALID_OPERATION. Was NO_ERROR : should not be able to copyTexImage2D ALPHA from RGB]
expected: FAIL

View file

@ -1,29 +1,65 @@
[framebuffer-test.html]
[WebGL test #1: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
[WebGL test #35: gl.getFramebufferAttachmentParameter(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE) should be 0 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #1: getError expected: INVALID_ENUM. Was INVALID_OPERATION : getFramebufferAttachmentParameter(COLOR_ATTACHMENT0) on the default framebuffer.]
expected: FAIL
[WebGL test #31: getError expected: NO_ERROR. Was INVALID_OPERATION : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING) on read/draw framebuffer.]
expected: FAIL
[WebGL test #30: getError expected: NO_ERROR. Was INVALID_ENUM : attach a texture to read/draw framebuffer binding point.]
expected: FAIL
[WebGL test #26: getError expected: NO_ERROR. Was INVALID_ENUM : attach a texture to read/draw framebuffer binding point.]
expected: FAIL
[WebGL test #44: getError expected: NO_ERROR. Was INVALID_OPERATION : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING) on read/draw framebuffer.]
expected: FAIL
[WebGL test #42: getError expected: NO_ERROR. Was INVALID_ENUM : detach a renderbuffer from a read/draw framebuffer.]
expected: FAIL
[WebGL test #38: getError expected: INVALID_OPERATION. Was INVALID_ENUM : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING) on draw framebuffer with no attachment.]
expected: FAIL
[WebGL test #52: getError expected: INVALID_OPERATION. Was INVALID_ENUM : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_RED_SIZE) on read framebuffer with no attachment.]
expected: FAIL
[WebGL test #21: getError expected: NO_ERROR. Was INVALID_VALUE : framebufferTexture2D with an appropriate mipmap level.]
expected: FAIL
[WebGL test #46: getError expected: NO_ERROR. Was INVALID_ENUM : detach a renderbuffer from a read/draw framebuffer.]
expected: FAIL
[WebGL test #29: getError expected: NO_ERROR. Was INVALID_ENUM : detach a texture from read/draw framebuffer.]
expected: FAIL
[WebGL test #33: getError expected: NO_ERROR. Was INVALID_ENUM : detach a texture from read/draw framebuffer.]
expected: FAIL
[WebGL test #40: getError expected: NO_ERROR. Was INVALID_OPERATION : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING) on read/draw framebuffer.]
expected: FAIL
[WebGL test #18: getError expected: INVALID_OPERATION. Was INVALID_ENUM : getFramebufferAttachmentParameter(GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING) with no attachment.]
expected: FAIL
[WebGL test #2: getError expected: NO_ERROR. Was INVALID_OPERATION : getFramebufferAttachmentParameter(BACK) on the default framebuffer.]
expected: FAIL
[WebGL test #9: getError expected: NO_ERROR. Was INVALID_ENUM : getFramebufferAttachmentParameter(READ_FRAMEBUFFER).]
expected: FAIL
[WebGL test #10: checkFramebufferStatus(READ_FRAMEBUFFER) should succeed.]
expected: FAIL
[WebGL test #11: getError expected: NO_ERROR. Was INVALID_ENUM : checkFramebufferStatus(READ_FRAMEBUFFER).]
expected: FAIL
[WebGL test #12: getError expected: NO_ERROR. Was INVALID_ENUM : bindFramebuffer(READ_FRAMEBUFFER).]
[WebGL test #10: checkFramebufferStatus(READ_FRAMEBUFFER) should succeed.]
expected: FAIL
[WebGL test #13: bindFramebuffer(READ_FRAMEBUFFER) should change READ_FRAMEBUFFER_BINDING.]
[WebGL test #27: getError expected: NO_ERROR. Was INVALID_OPERATION : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING) on read/draw framebuffer.]
expected: FAIL
[WebGL test #15: getError expected: NO_ERROR. Was INVALID_ENUM : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) with no attachment.]
[WebGL test #37: getError expected: NO_ERROR. Was INVALID_OPERATION : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING) on draw framebuffer.]
expected: FAIL
[WebGL test #36: getError expected: INVALID_OPERATION. Was INVALID_ENUM : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING) on read framebuffer with no attachment.]
expected: FAIL
[WebGL test #16: getError expected: NO_ERROR. Was INVALID_ENUM : framebufferTexImage2D(READ_FRAMEBUFFER).]
@ -32,69 +68,30 @@
[WebGL test #17: getError expected: NO_ERROR. Was INVALID_ENUM : framebufferRenderbuffer(READ_FRAMEBUFFER).]
expected: FAIL
[WebGL test #18: getError expected: INVALID_OPERATION. Was INVALID_ENUM : getFramebufferAttachmentParameter(GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING) with no attachment.]
expected: FAIL
[WebGL test #21: getError expected: NO_ERROR. Was INVALID_VALUE : framebufferTexture2D with an appropriate mipmap level.]
expected: FAIL
[WebGL test #26: getError expected: NO_ERROR. Was INVALID_ENUM : attach a texture to read/draw framebuffer binding point.]
expected: FAIL
[WebGL test #27: getError expected: NO_ERROR. Was INVALID_OPERATION : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING) on read/draw framebuffer.]
expected: FAIL
[WebGL test #29: getError expected: NO_ERROR. Was INVALID_ENUM : detach a texture from read/draw framebuffer.]
expected: FAIL
[WebGL test #30: getError expected: NO_ERROR. Was INVALID_ENUM : attach a texture to read/draw framebuffer binding point.]
expected: FAIL
[WebGL test #31: getError expected: NO_ERROR. Was INVALID_OPERATION : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING) on read/draw framebuffer.]
expected: FAIL
[WebGL test #33: getError expected: NO_ERROR. Was INVALID_ENUM : detach a texture from read/draw framebuffer.]
expected: FAIL
[WebGL test #35: gl.getFramebufferAttachmentParameter(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE) should be 0 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #36: getError expected: INVALID_OPERATION. Was INVALID_ENUM : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING) on read framebuffer with no attachment.]
expected: FAIL
[WebGL test #37: getError expected: NO_ERROR. Was INVALID_OPERATION : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING) on draw framebuffer.]
expected: FAIL
[WebGL test #38: getError expected: INVALID_OPERATION. Was INVALID_ENUM : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING) on draw framebuffer with no attachment.]
[WebGL test #15: getError expected: NO_ERROR. Was INVALID_ENUM : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) with no attachment.]
expected: FAIL
[WebGL test #39: getError expected: NO_ERROR. Was INVALID_ENUM : attaching a renderbuffer to a read/draw framebuffer.]
expected: FAIL
[WebGL test #40: getError expected: NO_ERROR. Was INVALID_OPERATION : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING) on read/draw framebuffer.]
expected: FAIL
[WebGL test #42: getError expected: NO_ERROR. Was INVALID_ENUM : detach a renderbuffer from a read/draw framebuffer.]
expected: FAIL
[WebGL test #43: getError expected: NO_ERROR. Was INVALID_ENUM : attaching a renderbuffer to a read/draw framebuffer.]
expected: FAIL
[WebGL test #44: getError expected: NO_ERROR. Was INVALID_OPERATION : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING) on read/draw framebuffer.]
expected: FAIL
[WebGL test #46: getError expected: NO_ERROR. Was INVALID_ENUM : detach a renderbuffer from a read/draw framebuffer.]
expected: FAIL
[WebGL test #49: getError expected: INVALID_OPERATION. Was INVALID_ENUM : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE) on read framebuffer without depth attachment.]
expected: FAIL
[WebGL test #52: getError expected: INVALID_OPERATION. Was INVALID_ENUM : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_RED_SIZE) on read framebuffer with no attachment.]
expected: FAIL
[WebGL test #55: getError expected: NO_ERROR. Was INVALID_ENUM : bind read framebuffer to default (null) framebuffer.]
expected: FAIL
[WebGL test #56: getError expected: NO_ERROR. Was INVALID_ENUM : bind draw framebuffer to default (null) framebuffer.]
expected: FAIL
[WebGL test #13: bindFramebuffer(READ_FRAMEBUFFER) should change READ_FRAMEBUFFER_BINDING.]
expected: FAIL
[WebGL test #12: getError expected: NO_ERROR. Was INVALID_ENUM : bindFramebuffer(READ_FRAMEBUFFER).]
expected: FAIL
[WebGL test #55: getError expected: NO_ERROR. Was INVALID_ENUM : bind read framebuffer to default (null) framebuffer.]
expected: FAIL
[WebGL test #49: getError expected: INVALID_OPERATION. Was INVALID_ENUM : getFramebufferAttachmentParameter(FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE) on read framebuffer without depth attachment.]
expected: FAIL
[WebGL test #9: getError expected: NO_ERROR. Was INVALID_ENUM : getFramebufferAttachmentParameter(READ_FRAMEBUFFER).]
expected: FAIL

View file

@ -29,6 +29,7 @@
<html>
<head>
<meta charset="utf-8">
<meta name="timeout" content="long">
<title>WebGL uniform packing restrctions Conformance Test</title>
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
<link rel="stylesheet" href="../../../resources/glsl-feature-tests.css"/>

View file

@ -94,3 +94,13 @@ index c1542f4fa9..b3ee786e0b 100644
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
--- i/conformance/glsl/misc/shader-uniform-packing-restrictions.html
+++ w/conformance/glsl/misc/shader-uniform-packing-restrictions.html
@@ -29,6 +29,7 @@
<html>
<head>
<meta charset="utf-8">
+<meta name="timeout" content="long">
<title>WebGL uniform packing restrctions Conformance Test</title>
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
<link rel="stylesheet" href="../../../resources/glsl-feature-tests.css"/>