Changeset 58102 in webkit


Ignore:
Timestamp:
Apr 22, 2010 9:54:00 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-04-22 Zhenyao Mo <zmo@google.com>

Reviewed by Dimitri Glazkov.

Emulate GL_IMPLEMENTATION_COLOR_READ_FORMAT/TYPE for glGet
https://bugs.webkit.org/show_bug.cgi?id=37281

  • fast/canvas/webgl/read-pixels-expected.txt: Add test case for the other supported format/type in readPixels (besides RGBA/UNSIGNED_BYTE); also, changed to a simpler test framework.
  • fast/canvas/webgl/read-pixels.html: Ditto.

2010-04-22 Zhenyao Mo <zmo@google.com>

Reviewed by Dimitri Glazkov.

Emulate GL_IMPLEMENTATION_COLOR_READ_FORMAT/TYPE for glGet
https://bugs.webkit.org/show_bug.cgi?id=37281

  • html/canvas/WebGLRenderingContext.cpp: (WebCore::WebGLRenderingContext::WebGLRenderingContext): Remove error check because two enums are supported now. (WebCore::WebGLRenderingContext::getParameter): Add two enums. (WebCore::WebGLRenderingContext::readPixels): Fix a tiny bug.
  • platform/graphics/mac/GraphicsContext3DMac.cpp: (WebCore::GraphicsContext3D::getIntegerv): Emulate two enums.

2010-04-22 Zhenyao Mo <zmo@google.com>

Reviewed by Dimitri Glazkov.

Emulate GL_IMPLEMENTATION_COLOR_READ_FORMAT/TYPE for glGet
https://bugs.webkit.org/show_bug.cgi?id=37281

  • src/WebGraphicsContext3DDefaultImpl.cpp: (WebKit::WebGraphicsContext3DDefaultImpl::getIntegerv): Emulate two enums.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r58099 r58102  
     12010-04-22  Zhenyao Mo  <zmo@google.com>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Emulate GL_IMPLEMENTATION_COLOR_READ_FORMAT/TYPE for glGet
     6        https://bugs.webkit.org/show_bug.cgi?id=37281
     7
     8        * fast/canvas/webgl/read-pixels-expected.txt: Add test case for the other supported format/type in readPixels (besides RGBA/UNSIGNED_BYTE); also, changed to a simpler test framework.
     9        * fast/canvas/webgl/read-pixels.html: Ditto.
     10
    1112010-04-22  Marcus Bulach  <bulach@chromium.org>
    212
  • trunk/LayoutTests/fast/canvas/webgl/read-pixels-expected.txt

    r57574 r58102  
    44
    55PASS gl = initWebGL('example', 'vshader', 'fshader', [ 'pos', 'colorIn' ], [ 0, 0, 0, 1 ], 1) is non-null.
     6Check supported pixel format/type besides RGBA/UNSIGNED_BYTE
     7PASS gl.getError() is gl.NO_ERROR
     8PASS gl.getError() is gl.NO_ERROR
     9PASS pixelFormat == gl.RGBA && pixelType == gl.UNSIGNED_BYTE is false
     10Testing format = RGBA and type = UNSIGNED_BYTE
    611Testing PACK_ALIGNMENT = 1, width = 1, height = 2
    7 PASS array.length is expectedSize
    8 PASS pixel is [ 255, 255, 0, 255]
     12PASS gl.getError() is gl.NO_ERROR
     13PASS gl.getError() is gl.NO_ERROR
     14PASS array.length is expectedSize
     15PASS 255,102,0,255 is non-null.
     16PASS pixel is expectedColor
    917Testing PACK_ALIGNMENT = 2, width = 1, height = 2
    10 PASS array.length is expectedSize
    11 PASS pixel is [ 255, 255, 0, 255]
     18PASS gl.getError() is gl.NO_ERROR
     19PASS gl.getError() is gl.NO_ERROR
     20PASS array.length is expectedSize
     21PASS 255,102,0,255 is non-null.
     22PASS pixel is expectedColor
    1223Testing PACK_ALIGNMENT = 4, width = 1, height = 2
    13 PASS array.length is expectedSize
    14 PASS pixel is [ 255, 255, 0, 255]
     24PASS gl.getError() is gl.NO_ERROR
     25PASS gl.getError() is gl.NO_ERROR
     26PASS array.length is expectedSize
     27PASS 255,102,0,255 is non-null.
     28PASS pixel is expectedColor
    1529Testing PACK_ALIGNMENT = 8, width = 1, height = 2
    16 PASS array.length is expectedSize
    17 PASS pixel is [ 255, 255, 0, 255]
     30PASS gl.getError() is gl.NO_ERROR
     31PASS gl.getError() is gl.NO_ERROR
     32PASS array.length is expectedSize
     33PASS 255,102,0,255 is non-null.
     34PASS pixel is expectedColor
    1835Testing PACK_ALIGNMENT = 4, width = 2, height = 2
    19 PASS array.length is expectedSize
    20 PASS pixel is [ 255, 255, 0, 255]
     36PASS gl.getError() is gl.NO_ERROR
     37PASS gl.getError() is gl.NO_ERROR
     38PASS array.length is expectedSize
     39PASS 255,102,0,255 is non-null.
     40PASS pixel is expectedColor
    2141Testing PACK_ALIGNMENT = 8, width = 2, height = 2
    22 PASS array.length is expectedSize
    23 PASS pixel is [ 255, 255, 0, 255]
     42PASS gl.getError() is gl.NO_ERROR
     43PASS gl.getError() is gl.NO_ERROR
     44PASS array.length is expectedSize
     45PASS 255,102,0,255 is non-null.
     46PASS pixel is expectedColor
    2447Testing PACK_ALIGNMENT = 4, width = 3, height = 2
    25 PASS array.length is expectedSize
    26 PASS pixel is [ 255, 255, 0, 255]
     48PASS gl.getError() is gl.NO_ERROR
     49PASS gl.getError() is gl.NO_ERROR
     50PASS array.length is expectedSize
     51PASS 255,102,0,255 is non-null.
     52PASS pixel is expectedColor
    2753Testing PACK_ALIGNMENT = 8, width = 3, height = 2
    28 PASS array.length is expectedSize
    29 PASS pixel is [ 255, 255, 0, 255]
     54PASS gl.getError() is gl.NO_ERROR
     55PASS gl.getError() is gl.NO_ERROR
     56PASS array.length is expectedSize
     57PASS 255,102,0,255 is non-null.
     58PASS pixel is expectedColor
    3059Testing PACK_ALIGNMENT = 4, width = 4, height = 2
    31 PASS array.length is expectedSize
    32 PASS pixel is [ 255, 255, 0, 255]
     60PASS gl.getError() is gl.NO_ERROR
     61PASS gl.getError() is gl.NO_ERROR
     62PASS array.length is expectedSize
     63PASS 255,102,0,255 is non-null.
     64PASS pixel is expectedColor
    3365Testing PACK_ALIGNMENT = 8, width = 4, height = 2
    34 PASS array.length is expectedSize
    35 PASS pixel is [ 255, 255, 0, 255]
     66PASS gl.getError() is gl.NO_ERROR
     67PASS gl.getError() is gl.NO_ERROR
     68PASS array.length is expectedSize
     69PASS 255,102,0,255 is non-null.
     70PASS pixel is expectedColor
    3671Testing PACK_ALIGNMENT = 8, width = 5, height = 1
    37 PASS array.length is expectedSize
    38 PASS pixel is [ 255, 255, 0, 255]
     72PASS gl.getError() is gl.NO_ERROR
     73PASS gl.getError() is gl.NO_ERROR
     74PASS array.length is expectedSize
     75PASS 255,102,0,255 is non-null.
     76PASS pixel is expectedColor
    3977Testing PACK_ALIGNMENT = 4, width = 5, height = 2
    40 PASS array.length is expectedSize
    41 PASS pixel is [ 255, 255, 0, 255]
     78PASS gl.getError() is gl.NO_ERROR
     79PASS gl.getError() is gl.NO_ERROR
     80PASS array.length is expectedSize
     81PASS 255,102,0,255 is non-null.
     82PASS pixel is expectedColor
    4283Testing PACK_ALIGNMENT = 8, width = 5, height = 2
    43 PASS array.length is expectedSize
    44 PASS pixel is [ 255, 255, 0, 255]
     84PASS gl.getError() is gl.NO_ERROR
     85PASS gl.getError() is gl.NO_ERROR
     86PASS array.length is expectedSize
     87PASS 255,102,0,255 is non-null.
     88PASS pixel is expectedColor
    4589Testing PACK_ALIGNMENT = 8, width = 6, height = 2
    46 PASS array.length is expectedSize
    47 PASS pixel is [ 255, 255, 0, 255]
     90PASS gl.getError() is gl.NO_ERROR
     91PASS gl.getError() is gl.NO_ERROR
     92PASS array.length is expectedSize
     93PASS 255,102,0,255 is non-null.
     94PASS pixel is expectedColor
    4895Testing PACK_ALIGNMENT = 8, width = 7, height = 2
    49 PASS array.length is expectedSize
    50 PASS pixel is [ 255, 255, 0, 255]
     96PASS gl.getError() is gl.NO_ERROR
     97PASS gl.getError() is gl.NO_ERROR
     98PASS array.length is expectedSize
     99PASS 255,102,0,255 is non-null.
     100PASS pixel is expectedColor
    51101Testing PACK_ALIGNMENT = 8, width = 8, height = 2
    52 PASS array.length is expectedSize
    53 PASS pixel is [ 255, 255, 0, 255]
     102PASS gl.getError() is gl.NO_ERROR
     103PASS gl.getError() is gl.NO_ERROR
     104PASS array.length is expectedSize
     105PASS 255,102,0,255 is non-null.
     106PASS pixel is expectedColor
     107Testing the other supported format/type combination
     108Testing PACK_ALIGNMENT = 1, width = 1, height = 2
     109PASS gl.getError() is gl.NO_ERROR
     110PASS gl.getError() is gl.NO_ERROR
     111PASS array.length is expectedSize
     112PASS 255,102,0,0 is non-null.
     113PASS pixel is expectedColor
     114Testing PACK_ALIGNMENT = 2, width = 1, height = 2
     115PASS gl.getError() is gl.NO_ERROR
     116PASS gl.getError() is gl.NO_ERROR
     117PASS array.length is expectedSize
     118PASS 255,102,0,0 is non-null.
     119PASS pixel is expectedColor
     120Testing PACK_ALIGNMENT = 4, width = 1, height = 2
     121PASS gl.getError() is gl.NO_ERROR
     122PASS gl.getError() is gl.NO_ERROR
     123PASS array.length is expectedSize
     124PASS 255,102,0,0 is non-null.
     125PASS pixel is expectedColor
     126Testing PACK_ALIGNMENT = 8, width = 1, height = 2
     127PASS gl.getError() is gl.NO_ERROR
     128PASS gl.getError() is gl.NO_ERROR
     129PASS array.length is expectedSize
     130PASS 255,102,0,0 is non-null.
     131PASS pixel is expectedColor
     132Testing PACK_ALIGNMENT = 4, width = 2, height = 2
     133PASS gl.getError() is gl.NO_ERROR
     134PASS gl.getError() is gl.NO_ERROR
     135PASS array.length is expectedSize
     136PASS 255,102,0,0 is non-null.
     137PASS pixel is expectedColor
     138Testing PACK_ALIGNMENT = 8, width = 2, height = 2
     139PASS gl.getError() is gl.NO_ERROR
     140PASS gl.getError() is gl.NO_ERROR
     141PASS array.length is expectedSize
     142PASS 255,102,0,0 is non-null.
     143PASS pixel is expectedColor
     144Testing PACK_ALIGNMENT = 4, width = 3, height = 2
     145PASS gl.getError() is gl.NO_ERROR
     146PASS gl.getError() is gl.NO_ERROR
     147PASS array.length is expectedSize
     148PASS 255,102,0,0 is non-null.
     149PASS pixel is expectedColor
     150Testing PACK_ALIGNMENT = 8, width = 3, height = 2
     151PASS gl.getError() is gl.NO_ERROR
     152PASS gl.getError() is gl.NO_ERROR
     153PASS array.length is expectedSize
     154PASS 255,102,0,0 is non-null.
     155PASS pixel is expectedColor
     156Testing PACK_ALIGNMENT = 4, width = 4, height = 2
     157PASS gl.getError() is gl.NO_ERROR
     158PASS gl.getError() is gl.NO_ERROR
     159PASS array.length is expectedSize
     160PASS 255,102,0,0 is non-null.
     161PASS pixel is expectedColor
     162Testing PACK_ALIGNMENT = 8, width = 4, height = 2
     163PASS gl.getError() is gl.NO_ERROR
     164PASS gl.getError() is gl.NO_ERROR
     165PASS array.length is expectedSize
     166PASS 255,102,0,0 is non-null.
     167PASS pixel is expectedColor
     168Testing PACK_ALIGNMENT = 8, width = 5, height = 1
     169PASS gl.getError() is gl.NO_ERROR
     170PASS gl.getError() is gl.NO_ERROR
     171PASS array.length is expectedSize
     172PASS 255,102,0,0 is non-null.
     173PASS pixel is expectedColor
     174Testing PACK_ALIGNMENT = 4, width = 5, height = 2
     175PASS gl.getError() is gl.NO_ERROR
     176PASS gl.getError() is gl.NO_ERROR
     177PASS array.length is expectedSize
     178PASS 255,102,0,0 is non-null.
     179PASS pixel is expectedColor
     180Testing PACK_ALIGNMENT = 8, width = 5, height = 2
     181PASS gl.getError() is gl.NO_ERROR
     182PASS gl.getError() is gl.NO_ERROR
     183PASS array.length is expectedSize
     184PASS 255,102,0,0 is non-null.
     185PASS pixel is expectedColor
     186Testing PACK_ALIGNMENT = 8, width = 6, height = 2
     187PASS gl.getError() is gl.NO_ERROR
     188PASS gl.getError() is gl.NO_ERROR
     189PASS array.length is expectedSize
     190PASS 255,102,0,0 is non-null.
     191PASS pixel is expectedColor
     192Testing PACK_ALIGNMENT = 8, width = 7, height = 2
     193PASS gl.getError() is gl.NO_ERROR
     194PASS gl.getError() is gl.NO_ERROR
     195PASS array.length is expectedSize
     196PASS 255,102,0,0 is non-null.
     197PASS pixel is expectedColor
     198Testing PACK_ALIGNMENT = 8, width = 8, height = 2
     199PASS gl.getError() is gl.NO_ERROR
     200PASS gl.getError() is gl.NO_ERROR
     201PASS array.length is expectedSize
     202PASS 255,102,0,0 is non-null.
     203PASS pixel is expectedColor
    54204PASS successfullyParsed is true
    55205
  • trunk/LayoutTests/fast/canvas/webgl/read-pixels.html

    r57574 r58102  
    2525}
    2626</script>
    27 
     27</head>
     28<body>
     29<canvas id="example" width="32px" height="32px"></canvas>
     30<div id="description"></div>
     31<div id="console"></div>
    2832<script>
    2933var successfullyParsed = false;
    3034
    31 // These four declarations need to be global for "shouldBe" to see them
     35// The below declarations need to be global for "shouldBe" to see them
    3236var gl = null;
    3337var array = null;
    3438var expectedSize = 0;
    35 var pixel = [ 0, 0, 0, 1 ];
    36 
    37 function init()
    38 {
    39     if (window.layoutTestController) {
    40         layoutTestController.overridePreference("WebKitWebGLEnabled", "1");
    41         layoutTestController.dumpAsText();
    42         layoutTestController.waitUntilDone();
    43     }
    44 
    45     description('Verify readPixels() works fine with various PACK_ALIGNMENT values.');
    46 
    47     runTest();
    48 }
    49 
    50 function runTestIteration(packAlignment, width, height, size)
     39var pixel = [ 0, 0, 0, 0 ];
     40var expectedColor = [ 0, 0, 0, 0 ];
     41var pixelFormat = 0;
     42var pixelType = 0;
     43
     44function calculatePixelBytes(format, type)
     45{
     46    var size = 0;
     47    switch (format) {
     48    case gl.ALPHA:
     49        size = 1;
     50        break;
     51    case gl.RGB:
     52        size = 3;
     53        break;
     54    case gl.RGBA:
     55        size = 4;
     56        break;
     57    default:
     58        return -1;
     59    }
     60    switch (type) {
     61    case gl.UNSIGNED_BYTE:
     62        break;
     63    case gl.UNSIGNED_SHORT_5_6_5:
     64        if (format != gl.RGB)
     65            return -1;
     66        size = 2;
     67        break;
     68    case gl.UNSIGNED_SHORT_4_4_4_4:
     69    case gl.UNSIGNED_SHORT_5_5_5_1:
     70        if (format != gl.RGBA)
     71            return -1;
     72        size = 2;
     73        break;
     74    default:
     75        return -1;
     76    }
     77    return size;
     78}
     79
     80function calculatePaddingBytes(bytesPerPixel, packAlignment, width)
     81{
     82    var padding = 0;
     83    switch (packAlignment) {
     84    case 1:
     85    case 2:
     86    case 4:
     87    case 8:
     88        padding = (bytesPerPixel * width) % packAlignment;
     89        if (padding > 0)
     90            padding = packAlignment - padding;
     91        break;
     92    default:
     93        return -1;
     94    }
     95    return padding;
     96}
     97
     98function packColor(format, type, r, g, b, a)
     99{
     100    // FIXME: not sure if the color packing is correct for UNSIGNED_SHORT_*.
     101    var color = [ 0, 0, 0, 0 ];
     102    switch (type) {
     103    case gl.UNSIGNED_BYTE:
     104        switch (format) {
     105        case gl.ALPHA:
     106            color[0] = a;
     107            break;
     108        case gl.RGB:
     109            color[0] = r;
     110            color[1] = g;
     111            color[2] = b;
     112            break;
     113        case gl.RGBA:
     114            color[0] = r;
     115            color[1] = g;
     116            color[2] = b;
     117            color[3] = a;
     118            break;
     119        default:
     120            return null;
     121        }
     122        break;
     123    case gl.UNSIGNED_SHORT_5_6_5:
     124        if (format != gl.RGB)
     125            return null;
     126        r >>= 3;
     127        g >>= 2;
     128        b >>= 3;
     129        color[0] = (r << 11) + (g << 5) + b;
     130        break;
     131    case gl.UNSIGNED_SHORT_4_4_4_4:
     132        if (format != gl.RGBA)
     133            return null;
     134        r >>= 4;
     135        g >>= 4;
     136        b >>= 4;
     137        a >>= 4;
     138        color[0] = (r << 12) + (g << 8) + (b << 4) + a;
     139        break;
     140    case gl.UNSIGNED_SHORT_5_5_5_1:
     141        if (format != gl.RGBA)
     142            return null;
     143        r >>= 3;
     144        g >>= 3;
     145        b >>= 3;
     146        a >>= 7;
     147        color[0] = (r << 11) + (g << 6) + (b << 1) + a;
     148        break;
     149    Default:
     150        return null;
     151    }
     152    return color;
     153}
     154
     155function runTestIteration(format, type, packAlignment, width, height)
    51156{
    52157    debug("Testing PACK_ALIGNMENT = " + packAlignment + ", width = " + width + ", height = " + height);
    53     gl.clearColor(1, 1, 0, 1);
     158    gl.clearColor(1, 0.4, 0, 1);
    54159    gl.clear(gl.COLOR_BUFFER_BIT);
    55160    gl.pixelStorei(gl.PACK_ALIGNMENT, packAlignment);
    56     array = gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE);
    57     expectedSize = size;
     161    shouldBe("gl.getError()", "gl.NO_ERROR");
     162    array = gl.readPixels(0, 0, width, height, format, type);
     163    shouldBe("gl.getError()", "gl.NO_ERROR");
     164    var bytesPerPixel = calculatePixelBytes(format, type);
     165    var padding = calculatePaddingBytes(bytesPerPixel, packAlignment, width);
     166    expectedSize = bytesPerPixel * width * height + padding * (height - 1);
     167    var isShort = false;
     168    switch (type) {
     169    case gl.UNSIGNED_SHORT_5_6_5:
     170    case gl.UNSIGNED_SHORT_4_4_4_4:
     171    case gl.UNSIGNED_SHORT_5_5_5_1:
     172        isShort = true;
     173    }
     174    if (isShort)
     175        expectedSize /= 2;
    58176    shouldBe("array.length", "expectedSize");
    59177    // Check the last pixel of the last row.
    60     var padding = 0;
    61     if (height > 1)
    62         padding = (size - width * height * 4) / (height - 1);
    63     var bytesPerRow = width * 4 + padding;
    64     var pos = bytesPerRow * (height - 1) + (width - 1) * 4;
    65     pixel[0] = array[pos];
    66     pixel[1] = array[pos + 1];
    67     pixel[2] = array[pos + 2];
    68     pixel[3] = array[pos + 3];
    69     shouldBe("pixel", "[ 255, 255, 0, 255]");
    70 }
    71 
    72 function runTest()
    73 {
    74     shouldBeNonNull("gl = initWebGL('example', 'vshader', 'fshader', [ 'pos', 'colorIn' ], [ 0, 0, 0, 1 ], 1)");
    75     gl.disable(gl.BLEND);
    76 
    77     runTestIteration(1, 1, 2, 8);
    78     runTestIteration(2, 1, 2, 8);
    79     runTestIteration(4, 1, 2, 8);
    80     runTestIteration(8, 1, 2, 12);
    81     runTestIteration(4, 2, 2, 16);
    82     runTestIteration(8, 2, 2, 16);
    83     runTestIteration(4, 3, 2, 24);
    84     runTestIteration(8, 3, 2, 28);
    85     runTestIteration(4, 4, 2, 32);
    86     runTestIteration(8, 4, 2, 32);
    87     runTestIteration(8, 5, 1, 20);
    88     runTestIteration(4, 5, 2, 40);
    89     runTestIteration(8, 5, 2, 44);
    90     runTestIteration(8, 6, 2, 48);
    91     runTestIteration(8, 7, 2, 60);
    92     runTestIteration(8, 8, 2, 64);
    93 
    94     successfullyParsed = true;
    95     var epilogue = document.createElement("script");
    96     epilogue.onload = finish;
    97     epilogue.src = "../../js/resources/js-test-post.js";
    98     document.body.appendChild(epilogue);
    99 }
    100 
    101 function finish() {
    102     if (window.layoutTestController) {
    103         layoutTestController.notifyDone();
    104     }
    105 }
     178    var bytesPerRow = width * bytesPerPixel + padding;
     179    var pos = bytesPerRow * (height - 1) + (width - 1) * bytesPerPixel;
     180    var numComponents = bytesPerPixel;
     181    if (isShort) {
     182        pos /= 2;
     183        numComponents /= 2;
     184    }
     185    for (var i = 0; i < numComponents; ++i)
     186        pixel[i] = array[pos + i];
     187    for (var i = numComponents; i < 4; ++i)
     188        pixel[i] = 0;
     189    expectedColor = packColor(format, type, 255, 102, 0, 255);
     190    shouldBeNonNull(expectedColor);
     191    shouldBe("pixel", "expectedColor");
     192}
     193
     194function checkSupportedPixelFormatAndType()
     195{
     196    debug("Check supported pixel format/type besides RGBA/UNSIGNED_BYTE");
     197    shouldBe("gl.getError()", "gl.NO_ERROR");
     198    pixelFormat = gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_FORMAT);
     199    pixelType = gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_TYPE);
     200    shouldBe("gl.getError()", "gl.NO_ERROR");
     201    shouldBeFalse("pixelFormat == gl.RGBA && pixelType == gl.UNSIGNED_BYTE");
     202}
     203
     204description('Verify readPixels() works fine with various PACK_ALIGNMENT values.');
     205
     206shouldBeNonNull("gl = initWebGL('example', 'vshader', 'fshader', [ 'pos', 'colorIn' ], [ 0, 0, 0, 1 ], 1)");
     207gl.disable(gl.BLEND);
     208
     209checkSupportedPixelFormatAndType();
     210
     211debug("Testing format = RGBA and type = UNSIGNED_BYTE");
     212runTestIteration(gl.RGBA, gl.UNSIGNED_BYTE, 1, 1, 2);
     213runTestIteration(gl.RGBA, gl.UNSIGNED_BYTE, 2, 1, 2);
     214runTestIteration(gl.RGBA, gl.UNSIGNED_BYTE, 4, 1, 2);
     215runTestIteration(gl.RGBA, gl.UNSIGNED_BYTE, 8, 1, 2);
     216runTestIteration(gl.RGBA, gl.UNSIGNED_BYTE, 4, 2, 2);
     217runTestIteration(gl.RGBA, gl.UNSIGNED_BYTE, 8, 2, 2);
     218runTestIteration(gl.RGBA, gl.UNSIGNED_BYTE, 4, 3, 2);
     219runTestIteration(gl.RGBA, gl.UNSIGNED_BYTE, 8, 3, 2);
     220runTestIteration(gl.RGBA, gl.UNSIGNED_BYTE, 4, 4, 2);
     221runTestIteration(gl.RGBA, gl.UNSIGNED_BYTE, 8, 4, 2);
     222runTestIteration(gl.RGBA, gl.UNSIGNED_BYTE, 8, 5, 1);
     223runTestIteration(gl.RGBA, gl.UNSIGNED_BYTE, 4, 5, 2);
     224runTestIteration(gl.RGBA, gl.UNSIGNED_BYTE, 8, 5, 2);
     225runTestIteration(gl.RGBA, gl.UNSIGNED_BYTE, 8, 6, 2);
     226runTestIteration(gl.RGBA, gl.UNSIGNED_BYTE, 8, 7, 2);
     227runTestIteration(gl.RGBA, gl.UNSIGNED_BYTE, 8, 8, 2);
     228
     229debug("Testing the other supported format/type combination");
     230runTestIteration(pixelFormat, pixelType, 1, 1, 2);
     231runTestIteration(pixelFormat, pixelType, 2, 1, 2);
     232runTestIteration(pixelFormat, pixelType, 4, 1, 2);
     233runTestIteration(pixelFormat, pixelType, 8, 1, 2);
     234runTestIteration(pixelFormat, pixelType, 4, 2, 2);
     235runTestIteration(pixelFormat, pixelType, 8, 2, 2);
     236runTestIteration(pixelFormat, pixelType, 4, 3, 2);
     237runTestIteration(pixelFormat, pixelType, 8, 3, 2);
     238runTestIteration(pixelFormat, pixelType, 4, 4, 2);
     239runTestIteration(pixelFormat, pixelType, 8, 4, 2);
     240runTestIteration(pixelFormat, pixelType, 8, 5, 1);
     241runTestIteration(pixelFormat, pixelType, 4, 5, 2);
     242runTestIteration(pixelFormat, pixelType, 8, 5, 2);
     243runTestIteration(pixelFormat, pixelType, 8, 6, 2);
     244runTestIteration(pixelFormat, pixelType, 8, 7, 2);
     245runTestIteration(pixelFormat, pixelType, 8, 8, 2);
     246
     247successfullyParsed = true;
    106248</script>
    107 </head>
    108 <body onload="init()">
    109 <canvas id="example" width="32px" height="32px"></canvas>
    110 <div id="description"></div>
    111 <div id="console"></div>
     249<script src="../../js/resources/js-test-post.js"></script>
    112250</body>
    113251</html>
  • trunk/WebCore/ChangeLog

    r58097 r58102  
     12010-04-22  Zhenyao Mo  <zmo@google.com>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Emulate GL_IMPLEMENTATION_COLOR_READ_FORMAT/TYPE for glGet
     6        https://bugs.webkit.org/show_bug.cgi?id=37281
     7
     8        * html/canvas/WebGLRenderingContext.cpp:
     9        (WebCore::WebGLRenderingContext::WebGLRenderingContext): Remove error check because two enums are supported now.
     10        (WebCore::WebGLRenderingContext::getParameter): Add two enums.
     11        (WebCore::WebGLRenderingContext::readPixels): Fix a tiny bug.
     12        * platform/graphics/mac/GraphicsContext3DMac.cpp:
     13        (WebCore::GraphicsContext3D::getIntegerv): Emulate two enums.
     14
    1152010-04-22  Diego Escalante Urrelo  <descalante@igalia.com>
    216
  • trunk/WebCore/html/canvas/WebGLRenderingContext.cpp

    r57747 r58102  
    102102    int implementationColorReadType = GraphicsContext3D::UNSIGNED_BYTE;
    103103    m_context->getIntegerv(GraphicsContext3D::IMPLEMENTATION_COLOR_READ_TYPE, &implementationColorReadType);
    104     // FIXME: remove the getError() when IMPLEMENTATION_COLOR_READ_FORMAT/TYPE are supported.
    105     m_context->getError();
    106104    m_implementationColorReadType = implementationColorReadType;
    107105    m_context->reshape(canvas()->width(), canvas()->height());
     
    10701068        return getUnsignedLongParameter(pname);
    10711069    case GraphicsContext3D::GREEN_BITS:
     1070        return getLongParameter(pname);
     1071    case GraphicsContext3D::IMPLEMENTATION_COLOR_READ_FORMAT:
     1072        return getLongParameter(pname);
     1073    case GraphicsContext3D::IMPLEMENTATION_COLOR_READ_TYPE:
    10721074        return getLongParameter(pname);
    10731075    case GraphicsContext3D::LINE_WIDTH:
     
    16401642        return 0;
    16411643    }
    1642     if (!(format == GraphicsContext3D::RGBA && type == GraphicsContext3D::UNSIGNED_BYTE || format == m_implementationColorReadFormat && type == m_implementationColorReadFormat)) {
     1644    if (!(format == GraphicsContext3D::RGBA && type == GraphicsContext3D::UNSIGNED_BYTE || format == m_implementationColorReadFormat && type == m_implementationColorReadType)) {
    16431645        m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
    16441646        return 0;
  • trunk/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp

    r57852 r58102  
    11421142void GraphicsContext3D::getIntegerv(unsigned long pname, int* value)
    11431143{
    1144     ensureContext(m_contextObj);
    1145     ::glGetIntegerv(pname, value);
     1144    // Need to emulate IMPLEMENTATION_COLOR_READ_FORMAT/TYPE for GL.  Any valid
     1145    // combination should work, but GL_RGB/GL_UNSIGNED_BYTE might be the most
     1146    // useful for desktop WebGL users.
     1147    ensureContext(m_contextObj);
     1148    switch (pname) {
     1149    case IMPLEMENTATION_COLOR_READ_FORMAT:
     1150        *value = GL_RGB;
     1151        break;
     1152    case IMPLEMENTATION_COLOR_READ_TYPE:
     1153        *value = GL_UNSIGNED_BYTE;
     1154        break;
     1155    default:
     1156        ::glGetIntegerv(pname, value);
     1157    }
    11461158}
    11471159
  • trunk/WebKit/chromium/ChangeLog

    r58072 r58102  
     12010-04-22  Zhenyao Mo  <zmo@google.com>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Emulate GL_IMPLEMENTATION_COLOR_READ_FORMAT/TYPE for glGet
     6        https://bugs.webkit.org/show_bug.cgi?id=37281
     7
     8        * src/WebGraphicsContext3DDefaultImpl.cpp:
     9        (WebKit::WebGraphicsContext3DDefaultImpl::getIntegerv): Emulate two  enums.
     10
    1112010-04-22  Adam Barth  <abarth@webkit.org>
    212
  • trunk/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp

    r57694 r58102  
    10511051}
    10521052
    1053 DELEGATE_TO_GL_2(getIntegerv, GetIntegerv, unsigned long, int*)
     1053void WebGraphicsContext3DDefaultImpl::getIntegerv(unsigned long pname, int* value)
     1054{
     1055    // Need to emulate IMPLEMENTATION_COLOR_READ_FORMAT/TYPE for GL.  Any valid
     1056    // combination should work, but GL_RGB/GL_UNSIGNED_BYTE might be the most
     1057    // useful for desktop WebGL users.
     1058    makeContextCurrent();
     1059    switch (pname) {
     1060    case 0x8B9B: // IMPLEMENTATION_COLOR_READ_FORMAT
     1061        *value = GL_RGB;
     1062        break;
     1063    case 0x8B9A: // IMPLEMENTATION_COLOR_READ_TYPE
     1064        *value = GL_UNSIGNED_BYTE;
     1065        break;
     1066    default:
     1067        glGetIntegerv(pname, value);
     1068    }
     1069}
    10541070
    10551071DELEGATE_TO_GL_3(getProgramiv, GetProgramiv, WebGLId, unsigned long, int*)
Note: See TracChangeset for help on using the changeset viewer.