OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 Copyright (C) 2012 Opera Software ASA. All rights reserved. |
| 3 |
| 4 Redistribution and use in source and binary forms, with or without |
| 5 modification, are permitted provided that the following conditions |
| 6 are met: |
| 7 1. Redistributions of source code must retain the above copyright |
| 8 notice, this list of conditions and the following disclaimer. |
| 9 2. Redistributions in binary form must reproduce the above copyright |
| 10 notice, this list of conditions and the following disclaimer in the |
| 11 documentation and/or other materials provided with the distribution. |
| 12 |
| 13 THIS SOFTWARE IS PROVIDED BY OPERA SOFTWARE ASA. ''AS IS'' AND ANY |
| 14 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 --> |
| 25 <!DOCTYPE html> |
| 26 <html> |
| 27 <head> |
| 28 <meta charset="utf-8"> |
| 29 <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
| 30 <script src="../../resources/js-test-pre.js"></script> |
| 31 <script src="../resources/webgl-test.js"></script> |
| 32 <style> |
| 33 canvas { |
| 34 width:50px; |
| 35 height:50px; |
| 36 } |
| 37 .square { |
| 38 display:inline-block; |
| 39 width:50px; |
| 40 height:50px; |
| 41 background-color:red; |
| 42 } |
| 43 </style> |
| 44 <script> |
| 45 function checkResult(ctx1, ctx2, preserve) { |
| 46 var imgData1 = ctx1.getImageData(0,0,1,1); |
| 47 var imgData2 = ctx2.getImageData(0,0,1,1); |
| 48 var correct1 = [255,0,0,255]; |
| 49 var correct2 = preserve ? [255,0,0,255] : [0,0,0,255]; |
| 50 var ok1 = true; |
| 51 var ok2 = true; |
| 52 for (var p = 0; p < 4; ++p) { |
| 53 if (imgData1.data[p] != correct1[p]) |
| 54 ok1 = false; |
| 55 if (imgData2.data[p] != correct2[p]) |
| 56 ok2 = false; |
| 57 } |
| 58 if (ok1 && ok2) |
| 59 testPassed('Rendered ok with preserveDrawingBuffer ' + prese
rve +'.'); |
| 60 else |
| 61 testFailed('Did not render ok with preserveDrawingBuffer ' +
preserve + '.'); |
| 62 if (preserve) { |
| 63 debug('<br /><span class="pass">TEST COMPLETE</span>'); |
| 64 notifyFinishedToHarness() |
| 65 } else { |
| 66 runTest(true); |
| 67 } |
| 68 } |
| 69 |
| 70 function runTest(preserve) { |
| 71 var c1 = document.getElementById('c' + (preserve * 3 + 1)); |
| 72 var c2 = document.getElementById('c' + (preserve * 3 + 2)); |
| 73 var c3 = document.getElementById('c' + (preserve * 3 + 3)); |
| 74 var ctx1 = c1.getContext('2d'); |
| 75 var ctx2 = c2.getContext('2d'); |
| 76 var gl = c3.getContext('experimental-webgl', { alpha:false, pres
erveDrawingBuffer:preserve }); |
| 77 gl.clearColor(1, 0, 0, 1); |
| 78 gl.clear(gl.COLOR_BUFFER_BIT); |
| 79 ctx1.drawImage(c3, 0, 0); |
| 80 setTimeout(function() { ctx2.drawImage(c3, 0, 0); checkResult(ct
x1, ctx2, preserve); }, 100); |
| 81 |
| 82 } |
| 83 </script> |
| 84 </head> |
| 85 <body> |
| 86 <div> |
| 87 <canvas id='c1'></canvas> |
| 88 <canvas id='c2'></canvas> |
| 89 <canvas id='c3'></canvas> |
| 90 <span>should look as right pattern</span> |
| 91 <div class='square'></div> |
| 92 <div class='square' style='background-color:black'></div> |
| 93 <div class='square'></div> |
| 94 </div> |
| 95 <div> |
| 96 <canvas id='c4'></canvas> |
| 97 <canvas id='c5'></canvas> |
| 98 <canvas id='c6'></canvas> |
| 99 <span>should look as right pattern</span> |
| 100 <div class='square'></div> |
| 101 <div class='square'></div> |
| 102 <div class='square'></div> |
| 103 </div> |
| 104 <div id="description"></div> |
| 105 <div id="console"></div> |
| 106 <script> |
| 107 description('Verify that preserveDrawingBuffer attribute is honored.
'); |
| 108 runTest(false); |
| 109 successfullyParsed = true; |
| 110 shouldBeTrue("successfullyParsed"); |
| 111 </script> |
| 112 </body> |
| 113 </html> |
OLD | NEW |