Changeset 95482 in webkit
- Timestamp:
- Sep 19, 2011 3:23:28 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r95478 r95482 1 2011-09-19 John Bauman <jbauman@chromium.org> 2 3 Fix nonpremultiplied webgl toDataURL to jpeg 4 https://bugs.webkit.org/show_bug.cgi?id=68366 5 6 Update the premultiplyalpha-test from the WebGL conformance tests. 7 8 Reviewed by Kenneth Russell. 9 10 * fast/canvas/webgl/premultiplyalpha-test-expected.txt: 11 * fast/canvas/webgl/premultiplyalpha-test.html: 12 1 13 2011-09-19 Ryosuke Niwa <rniwa@webkit.org> 2 14 -
trunk/LayoutTests/fast/canvas/webgl/premultiplyalpha-test-expected.txt
r81213 r95482 4 4 5 5 6 testing: premultipliedAlpha: true toDataURL: true6 testing: premultipliedAlpha: true imageFormat: image/png 7 7 PASS gl.getContextAttributes().premultipledAlpha is premultipledAlpha 8 PASS gl.getContextAttributes().preserveDrawingBuffer is true 8 9 PASS getError was expected value: NO_ERROR : Should be no errors from setup. 9 10 PASS getError was expected value: NO_ERROR : Should be no errors from drawing. … … 12 13 PASS should draw with 64,128,255,128 13 14 14 testing: premultipliedAlpha: true toDataURL: false15 testing: premultipliedAlpha: true imageFormat: undefined 15 16 PASS gl.getContextAttributes().premultipledAlpha is premultipledAlpha 17 PASS gl.getContextAttributes().preserveDrawingBuffer is true 16 18 PASS getError was expected value: NO_ERROR : Should be no errors from setup. 17 19 PASS getError was expected value: NO_ERROR : Should be no errors from drawing. … … 20 22 PASS should draw with 64,128,255,128 21 23 22 testing: premultipliedAlpha: false toDataURL: true24 testing: premultipliedAlpha: false imageFormat: image/png 23 25 PASS gl.getContextAttributes().premultipledAlpha is premultipledAlpha 26 PASS gl.getContextAttributes().preserveDrawingBuffer is true 24 27 PASS getError was expected value: NO_ERROR : Should be no errors from setup. 25 28 PASS getError was expected value: NO_ERROR : Should be no errors from drawing. … … 28 31 PASS should draw with 255,192,128,1 29 32 30 testing: premultipliedAlpha: false toDataURL: false33 testing: premultipliedAlpha: false imageFormat: undefined 31 34 PASS gl.getContextAttributes().premultipledAlpha is premultipledAlpha 35 PASS gl.getContextAttributes().preserveDrawingBuffer is true 32 36 PASS getError was expected value: NO_ERROR : Should be no errors from setup. 33 37 PASS getError was expected value: NO_ERROR : Should be no errors from drawing. … … 36 40 PASS should draw with 255,192,128,1 37 41 42 testing: premultipliedAlpha: false imageFormat: image/jpeg 43 PASS gl.getContextAttributes().premultipledAlpha is premultipledAlpha 44 PASS gl.getContextAttributes().preserveDrawingBuffer is true 45 PASS getError was expected value: NO_ERROR : Should be no errors from setup. 46 PASS getError was expected value: NO_ERROR : Should be no errors from drawing. 47 PASS getError was expected value: NO_ERROR : Should be no errors from creating copy. 48 PASS getError was expected value: NO_ERROR : Should be no errors from 2nd drawing. 49 PASS should draw with 128,128,128,255 50 51 testing: premultipliedAlpha: true imageFormat: image/jpeg 52 PASS gl.getContextAttributes().premultipledAlpha is premultipledAlpha 53 PASS gl.getContextAttributes().preserveDrawingBuffer is true 54 PASS getError was expected value: NO_ERROR : Should be no errors from setup. 55 PASS getError was expected value: NO_ERROR : Should be no errors from drawing. 56 PASS getError was expected value: NO_ERROR : Should be no errors from creating copy. 57 PASS getError was expected value: NO_ERROR : Should be no errors from 2nd drawing. 58 PASS should draw with 128,128,128,255 59 -
trunk/LayoutTests/fast/canvas/webgl/premultiplyalpha-test.html
r81213 r95482 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 2 "http://www.w3.org/TR/html4/loose.dtd"> 1 <!DOCTYPE html> 3 2 <html> 4 3 <head> 4 <meta charset="utf-8"> 5 5 <title>Test the WebGL premultipledAlpha context creation flag.</title> 6 6 <link rel="stylesheet" href="../../js/resources/js-test-style.css"/> … … 22 22 expectedColor: [64, 128, 255, 128], 23 23 errorRange: 2, 24 useToDataURL: true,24 imageFormat: "image/png" 25 25 }, 26 26 // If premultipledAlpha is true then … … 31 31 expectedColor: [64, 128, 255, 128], 32 32 errorRange: 2, 33 useToDataURL: false,34 33 }, 35 34 // If premultipledAlpha is false then … … 40 39 expectedColor: [255, 192, 128, 1], 41 40 errorRange: 0, 42 useToDataURL: true,41 imageFormat: "image/png" 43 42 }, 44 43 // If premultipledAlpha is false then … … 49 48 expectedColor: [255, 192, 128, 1], 50 49 errorRange: 0, 51 useToDataURL: false, 50 }, 51 // If premultipledAlpha is false then 52 // [texture] [canvas] [dataURL] 53 // 255, 255, 255, 128 -> 255, 255, 255, 128 -> 128, 128, 128, 255 54 { creationAttributes: {premultipliedAlpha: false}, 55 sentColor: [255, 255, 255, 128], 56 expectedColor: [128, 128, 128, 255], 57 errorRange: 2, 58 imageFormat: "image/jpeg" 59 }, 60 // If premultipledAlpha is true then 61 // [texture] [canvas] [dataURL] 62 // 128, 128, 128, 128 -> 255, 255, 255, 128 -> 128, 128, 128, 255 63 { creationAttributes: {}, 64 sentColor: [128, 128, 128, 128], 65 expectedColor: [128, 128, 128, 255], 66 errorRange: 2, 67 imageFormat: "image/jpeg" 52 68 } 53 69 ]; … … 69 85 var test = tests[g_count++]; 70 86 canvas = document.createElement("canvas"); 87 // Need to preserve drawing buffer to load it in a callback 88 test.creationAttributes.preserveDrawingBuffer = true; 71 89 gl = wtu.create3DContext(canvas, test.creationAttributes); 72 90 var premultipliedAlpha = test.creationAttributes.premultipliedAlpha != false; 73 91 debug("") 74 debug("testing: premultipliedAlpha: " + premultipliedAlpha + " toDataURL: " + test.useToDataURL);92 debug("testing: premultipliedAlpha: " + premultipliedAlpha + " imageFormat: " + test.imageFormat); 75 93 76 94 shouldBe('gl.getContextAttributes().premultipledAlpha', 'premultipledAlpha'); 95 shouldBeTrue('gl.getContextAttributes().preserveDrawingBuffer'); 77 96 78 97 var program = wtu.setupTexturedQuad(gl); … … 97 116 gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, false); 98 117 gl.bindTexture(gl.TEXTURE_2D, pngTex); 99 if (test. useToDataURL) {118 if (test.imageFormat) { 100 119 // create texture from image 101 120 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this); … … 118 137 } 119 138 120 if (test. useToDataURL) {139 if (test.imageFormat) { 121 140 // Load canvas into string using toDataURL 122 var png = canvas.toDataURL(); 123 // Load string into the texture 124 var input = document.createElement("img"); 125 input.onload = loadTexture; 126 input.src = png; 141 var imageUrl = canvas.toDataURL(test.imageFormat); 142 if (test.imageFormat != "image/png" && 143 (imageUrl.indexOf("data:image/png,") == 0 || 144 imageUrl.indexOf("data:image/png;") == 0)) { 145 debug("Image format " + test.imageFormat + " not supported; skipping"); 146 setTimeout(doNextTest, 0); 147 } else { 148 // Load string into the texture 149 var input = document.createElement("img"); 150 input.onload = loadTexture; 151 input.src = imageUrl; 152 } 127 153 } else { 128 154 // Load canvas into the texture asynchronously (to prevent unbounded stack consumption) … … 139 165 </script> 140 166 141 <script>142 </script>143 144 167 </body> 145 168 </html> -
trunk/Source/WebCore/ChangeLog
r95479 r95482 1 2011-09-19 John Bauman <jbauman@chromium.org> 2 3 Fix nonpremultiplied webgl toDataURL to jpeg 4 https://bugs.webkit.org/show_bug.cgi?id=68366 5 6 The canvas spec says that toDataURL to formats without an alpha must 7 be "composited onto a solid black background using the source-over 8 operator." Do that. 9 10 Reviewed by Kenneth Russell. 11 12 * platform/image-encoders/skia/JPEGImageEncoder.cpp: 13 (WebCore::RGBAtoRGB): 14 1 15 2011-09-19 Chris Marrin <cmarrin@apple.com> 2 16 -
trunk/Source/WebCore/platform/image-encoders/skia/JPEGImageEncoder.cpp
r94591 r95482 93 93 { 94 94 for (; pixelCount-- > 0; pixels += 4) { 95 *output++ = pixels[0]; 96 *output++ = pixels[1]; 97 *output++ = pixels[2]; 95 // Do source-over composition on black. 96 *output++ = pixels[0] * pixels[3] / 255; 97 *output++ = pixels[1] * pixels[3] / 255; 98 *output++ = pixels[2] * pixels[3] / 255; 98 99 } 99 100 }
Note: See TracChangeset
for help on using the changeset viewer.