• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// The size of the golden images (DMs)
2const CANVAS_WIDTH = 600;
3const CANVAS_HEIGHT = 600;
4
5function reportSurface(surface, testname, done) {
6    // In docker, the webgl canvas is blank, but the surface has the pixel
7    // data. So, we copy it out and draw it to a normal canvas to take a picture.
8    // To be consistent across CPU and GPU, we just do it for all configurations
9    // (even though the CPU canvas shows up after flush just fine).
10    let pixels = surface.getCanvas().readPixels(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
11    pixels = new Uint8ClampedArray(pixels.buffer);
12    const imageData = new ImageData(pixels, CANVAS_WIDTH, CANVAS_HEIGHT);
13
14    let reportingCanvas =  document.getElementById('report');
15    reportingCanvas.getContext('2d').putImageData(imageData, 0, 0);
16    reportCanvas(reportingCanvas, testname).then(() => {
17        done();
18    }).catch(reportError(done));
19}