KhronosGroup/WebGL

texture-corner-cases-video tests Context2D pixels in wrong colour space

Opened this issue · 4 comments

texture-corner-cases-video tests Context2D pixels in wrong colour space

The video pixel values are (say) 255, ... but the video is not in sRGB.
When drawn to Context2D, the values should be converted to sRGB.

The test should assert the sRGB values, not the original video values

Related but orthogonal discussion in #2165

I'm not sure follow the results of the other discussion but....

My understand is WebGL has 2 modes.

UNPACK_COLORSPACE_CONVERSION_WEBGL = true (default)
UNPACK_COLORSPACE_CONVERSION_WEBGL = false

When UNPACK_COLORSPACE_CONVERSION_WEBGL = true there ZERO guarantee of anything whatsoever. The browser stuffs whatever data it has into the texture as is. Some browsers might have applied color space, they might have applied a display profile, they might have applied anything. They may or may not support the various ways of specifying a color space in the file itself. That's undefined just like it's undefined what formats a browser supports (gif? jpg? webp? animated png? jpeg2000? tiff? not sure if Safari still supports tiff but it did at one time and no other browser did) it's also undefined what details of a file format a browser supports. For example it might ignore png color spaces just like many browsers ignored animated png files for a long time.

UNPACK_COLORSPACE_CONVERSION_WEBGL = false = you get the raw data from the file. No color space interpretation is allowed by the browser and color space data in the file itself is ignored(assuming that's possible). The purpose of this is to be able to load images as binary data, in particular PNG files but even not PNG, in general the data might not be an image, it might be a normal map or height data or anything so applying color spaces to it would destroy the raw data and the author's intent.

So, it seems like If you want a test here you first need to change the spec?

My understand is WebGL has 2 modes.

This particular issue is not reporting an issue in WebGL.

It is reporting an issue of misuse of Canvas Context2D in WebGL conformance test suite.

    function runCanvas2DTest(videoElement, topColor, bottomColor)
    {
        debug('Testing with 2D canvas');

        var canvas = c2d.canvas;

        // Draw the video to the 2D canvas context.
        c2d.drawImage(videoElement, 0, 0, canvas.width, canvas.height);

        // Check a few pixels near the top and bottom and make sure they have
        // the right color.
        // Origin is upper left in 2D canvas context.
        var tolerance = currentTolerance;
        debug("Checking lower left corner");
        wtu.checkCanvasRect(c2d, 4, canvas.height - 8, 2, 2, bottomColor,
                            "shouldBe " + bottomColor, tolerance);
        debug("Checking upper left corner");
        wtu.checkCanvasRect(c2d, 4, 4, 2, 2, topColor,
                            "shouldBe " + topColor, tolerance);
    }