Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Unified Diff: LayoutTests/fast/canvas/canvas-toDataURL-png-compression.html

Issue 290893002: [wip] Add canvas.toDataURL("image/png") compression control Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update after https://src.chromium.org/viewvc/blink?view=rev&revision=175387 Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/canvas/canvas-toDataURL-png-compression-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/canvas/canvas-toDataURL-png-compression.html
diff --git a/LayoutTests/fast/canvas/canvas-toDataURL-png-compression.html b/LayoutTests/fast/canvas/canvas-toDataURL-png-compression.html
new file mode 100644
index 0000000000000000000000000000000000000000..83fd7430c8bcecb0e7746d6383cfe6d478547095
--- /dev/null
+++ b/LayoutTests/fast/canvas/canvas-toDataURL-png-compression.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<body>
+<pre id="result"></pre>
+<canvas id="canvas" width="100" height="50"></canvas>
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+
+var canvas = document.getElementById('canvas');
+var ctx = canvas.getContext("2d");
+for (var i = 0; i < 30; i += 5) {
+ ctx.fillStyle = 'rgba(1, 3, 254, 1)';
+ ctx.fillRect( 0 + i, i, 25, 25);
+ ctx.fillStyle = 'rgba(8, 252, 248, 0.75)';
+ ctx.fillRect(25 + i, i, 25, 25);
+ ctx.fillStyle = 'rgba(6, 10, 250, 0.502)';
+ ctx.fillRect(50 - i, i, 25, 25);
+ ctx.fillRect(50 + i, i, 25, 25);
+ ctx.fillStyle = 'rgba(12, 16, 244, 0.25)';
+ ctx.fillRect(75 - i, i, 25, 25);
+ ctx.fillRect(75 + i, i, 25, 25);
+}
+
+function dataURLLength(compression) {
+ var length = canvas.toDataURL("image/png", compression).length;
+ result.textContent += compression.toFixed(1) + ' ';
+ result.textContent += 'toDataURL image/png length ' + length + '\n';
+ return length;
+}
+
+var length3 = dataURLLength(0.3);
+var length9 = dataURLLength(0.9);
+
+result.textContent += (length9 < length3 * 0.7) ? "\nPASS" : "\nFAIL";
+</script>
+</body>
+<html>
« no previous file with comments | « no previous file | LayoutTests/fast/canvas/canvas-toDataURL-png-compression-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698