Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import re | 5 import re |
| 6 | 6 |
| 7 | 7 |
| 8 def result_contains_repaint_rects(text): | 8 def result_contains_repaint_rects(text): |
| 9 return isinstance(text, str) and re.search(r'"paintInvalidations": \[$', tex t, re.MULTILINE) is not None | 9 return isinstance(text, str) and re.search(r'"paintInvalidations": \[$', tex t, re.MULTILINE) is not None |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 } | 59 } |
| 60 #actual { | 60 #actual { |
| 61 display: none; | 61 display: none; |
| 62 } | 62 } |
| 63 </style> | 63 </style> |
| 64 </head> | 64 </head> |
| 65 <body> | 65 <body> |
| 66 <label><input id="show-test" type="checkbox" checked onchange="toggle_test(this. checked)">Show test</label> | 66 <label><input id="show-test" type="checkbox" checked onchange="toggle_test(this. checked)">Show test</label> |
| 67 <label><input id="use-solid-colors" type="checkbox" onchange="toggle_solid_color (this.checked)">Use solid colors</label> | 67 <label><input id="use-solid-colors" type="checkbox" onchange="toggle_solid_color (this.checked)">Use solid colors</label> |
| 68 <br> | 68 <br> |
| 69 <button title="See fast/repaint/resources/text-based-repaint.js for how this wor ks" onclick="highlight_under_repaint()"> | |
| 70 Highlight under-repaint | |
| 71 </button> | |
| 72 <br> | |
| 73 <span id='type'>Expected Invalidations</span> | 69 <span id='type'>Expected Invalidations</span> |
| 74 <div id=overlay> | 70 <div id=overlay> |
| 75 <canvas id='expected' width='2000' height='2000'></canvas> | 71 <canvas id='expected' width='2000' height='2000'></canvas> |
| 76 <canvas id='actual' width='2000' height='2000'></canvas> | 72 <canvas id='actual' width='2000' height='2000'></canvas> |
| 77 </div> | 73 </div> |
| 78 <script> | 74 <script> |
| 79 var overlay_opacity = 0.25; | 75 var overlay_opacity = 0.25; |
| 80 | 76 |
| 81 function toggle_test(show_test) { | 77 function toggle_test(show_test) { |
| 82 iframe.style.display = show_test ? 'block' : 'none'; | 78 iframe.style.display = show_test ? 'block' : 'none'; |
| 83 } | 79 } |
| 84 | 80 |
| 85 function toggle_solid_color(use_solid_color) { | 81 function toggle_solid_color(use_solid_color) { |
| 86 overlay_opacity = use_solid_color ? 1 : 0.25; | 82 overlay_opacity = use_solid_color ? 1 : 0.25; |
| 87 draw_repaint_rects(); | 83 draw_repaint_rects(); |
| 88 } | 84 } |
| 89 | 85 |
| 90 function highlight_under_repaint() { | |
| 91 document.getElementById('show-test').checked = false; | |
| 92 toggle_test(false); | |
| 93 document.getElementById('use-solid-colors').checked = true; | |
| 94 toggle_solid_color(true); | |
| 95 } | |
|
Xianzhu
2016/10/12 20:13:22
The above code has been no use since we removed th
| |
| 96 | |
| 97 var expected = %(expected)s; | 86 var expected = %(expected)s; |
| 98 var actual = %(actual)s; | 87 var actual = %(actual)s; |
| 99 | 88 |
| 100 function rectsEqual(rect1, rect2) { | 89 function rectsEqual(rect1, rect2) { |
| 101 return rect1[0] == rect2[0] && rect1[1] == rect2[1] && rect1[2] == rect2[2] && rect1[3] == rect2[3]; | 90 return rect1[0] == rect2[0] && rect1[1] == rect2[1] && rect1[2] == rect2[2] && rect1[3] == rect2[3]; |
| 102 } | 91 } |
| 103 | 92 |
| 104 function draw_rects(context, rects) { | 93 function draw_rects(context, rects) { |
| 105 for (var i = 0; i < rects.length; ++i) { | 94 for (var i = 0; i < rects.length; ++i) { |
| 106 var rect = rects[i]; | 95 var rect = rects[i]; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 120 context.translate(-origin[0], -origin[1]); | 109 context.translate(-origin[0], -origin[1]); |
| 121 } | 110 } |
| 122 if (result.paintInvalidations) { | 111 if (result.paintInvalidations) { |
| 123 var rects = []; | 112 var rects = []; |
| 124 for (var i = 0; i < result.paintInvalidations.length; ++i) { | 113 for (var i = 0; i < result.paintInvalidations.length; ++i) { |
| 125 if (result.paintInvalidations[i].rect) | 114 if (result.paintInvalidations[i].rect) |
| 126 rects.push(result.paintInvalidations[i].rect); | 115 rects.push(result.paintInvalidations[i].rect); |
| 127 } | 116 } |
| 128 draw_rects(context, rects); | 117 draw_rects(context, rects); |
| 129 } | 118 } |
| 130 if (result.children) { | 119 context.restore(); |
| 131 for (var i = 0; i < result.children.length; ++i) | 120 } |
| 132 draw_layer_rects(context, result.children[i]); | 121 |
| 122 function draw_result_rects(context, result) { | |
| 123 if (result.layers) { | |
| 124 for (var i = 0; i < result.layers.length; ++i) | |
| 125 draw_layer_rects(context, result.layers[i]); | |
| 133 } | 126 } |
| 134 context.restore(); | |
| 135 } | 127 } |
| 136 | 128 |
| 137 var expected_canvas = document.getElementById('expected'); | 129 var expected_canvas = document.getElementById('expected'); |
| 138 var actual_canvas = document.getElementById('actual'); | 130 var actual_canvas = document.getElementById('actual'); |
| 139 | 131 |
| 140 function draw_repaint_rects() { | 132 function draw_repaint_rects() { |
| 141 var expected_ctx = expected_canvas.getContext("2d"); | 133 var expected_ctx = expected_canvas.getContext("2d"); |
| 142 expected_ctx.clearRect(0, 0, 2000, 2000); | 134 expected_ctx.clearRect(0, 0, 2000, 2000); |
| 143 expected_ctx.fillStyle = 'rgba(255, 0, 0, ' + overlay_opacity + ')'; | 135 expected_ctx.fillStyle = 'rgba(255, 0, 0, ' + overlay_opacity + ')'; |
| 144 draw_layer_rects(expected_ctx, expected); | 136 draw_result_rects(expected_ctx, expected); |
| 145 | 137 |
| 146 var actual_ctx = actual_canvas.getContext("2d"); | 138 var actual_ctx = actual_canvas.getContext("2d"); |
| 147 actual_ctx.clearRect(0, 0, 2000, 2000); | 139 actual_ctx.clearRect(0, 0, 2000, 2000); |
| 148 actual_ctx.fillStyle = 'rgba(0, 255, 0, ' + overlay_opacity + ')'; | 140 actual_ctx.fillStyle = 'rgba(0, 255, 0, ' + overlay_opacity + ')'; |
| 149 draw_layer_rects(actual_ctx, actual); | 141 draw_result_rects(actual_ctx, actual); |
| 150 } | 142 } |
| 151 | 143 |
| 152 draw_repaint_rects(); | 144 draw_repaint_rects(); |
| 153 | 145 |
| 154 var path = decodeURIComponent(location.search).substr(1); | 146 var path = decodeURIComponent(location.search).substr(1); |
| 155 var iframe = document.createElement('iframe'); | 147 var iframe = document.createElement('iframe'); |
| 156 iframe.id = 'test-frame'; | 148 iframe.id = 'test-frame'; |
| 157 iframe.width = 800; | 149 iframe.width = 800; |
| 158 iframe.height = 600; | 150 iframe.height = 600; |
| 159 iframe.src = path; | 151 iframe.src = path; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 177 } | 169 } |
| 178 setInterval(flip, 3000); | 170 setInterval(flip, 3000); |
| 179 </script> | 171 </script> |
| 180 </body> | 172 </body> |
| 181 </html> | 173 </html> |
| 182 """ % { | 174 """ % { |
| 183 'title': test_name, | 175 'title': test_name, |
| 184 'expected': expected_layer_tree, | 176 'expected': expected_layer_tree, |
| 185 'actual': actual_layer_tree, | 177 'actual': actual_layer_tree, |
| 186 } | 178 } |
| OLD | NEW |