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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/imagebitmap/bitmaprenderer-as-imagesource.html

Issue 2496013002: Make a bitmaprenderer canvas an ImageSource (Closed)
Patch Set: remove the expected.txt because the test is passing Created 4 years, 1 month 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 | third_party/WebKit/LayoutTests/imported/wpt/imagebitmap-renderingcontext/bitmaprenderer-as-imagesource-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/canvas/imagebitmap/bitmaprenderer-as-imagesource.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/imagebitmap/bitmaprenderer-as-imagesource.html b/third_party/WebKit/LayoutTests/fast/canvas/imagebitmap/bitmaprenderer-as-imagesource.html
new file mode 100644
index 0000000000000000000000000000000000000000..4a22799ca0dde50fb43a51629889664746a03a41
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/imagebitmap/bitmaprenderer-as-imagesource.html
@@ -0,0 +1,114 @@
+<!DOCTYPE html>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script>
+var width = 10;
+var height = 10;
+
+function testCanvas(ctx, x, y, r, g, b, a)
+{
+ var color = ctx.getImageData(x, y, 1, 1).data;
+ assert_array_equals(color, [r, g, b, a]);
+}
+
+
+function consumeImageBitmap(image, t)
+{
+ var myCanvas = document.createElement('canvas');
+ myCanvas.width = myCanvas.height = 20;
+ var myCtx = myCanvas.getContext('bitmaprenderer');
+ myCtx.transferFromImageBitmap(image);
+
+ var dstCanvas = document.createElement('canvas');
+ dstCanvas.width = dstCanvas.height = 20;
+ var dstCtx = dstCanvas.getContext('2d');
+ dstCtx.clearRect(0, 0, 20, 20);
+ dstCtx.drawImage(myCanvas, 0, 0);
+ testCanvas(dstCtx, 5, 5, 0, 255, 0, 255);
+ testCanvas(dstCtx, 15, 15, 0, 0, 0, 0);
+ t.done();
+}
+
+function consumeImageBitmapByCreateImageBitmap(image, t)
+{
+ var myCanvas = document.createElement('canvas');
+ myCanvas.width = myCanvas.height = 20;
+ var myCtx = myCanvas.getContext('bitmaprenderer');
+ myCtx.transferFromImageBitmap(image);
+
+ createImageBitmap(myCanvas).then(t.step_func_done(function(imageBitmap) {
+ assert_equals(imageBitmap.width, width);
+ assert_equals(imageBitmap.height, height);
+
+ var dstCanvas = document.createElement('canvas');
+ dstCanvas.width = dstCanvas.height = 20;
+ var dstCtx = dstCanvas.getContext('2d');
+ dstCtx.clearRect(0, 0, 20, 20);
+ dstCtx.drawImage(imageBitmap, 0, 0);
+ testCanvas(dstCtx, 5, 5, 0, 255, 0, 255);
+ testCanvas(dstCtx, 15, 15, 0, 0, 0, 0);
+ }));
+}
+
+async_test(function(t) {
+ var canvas = document.createElement("canvas");
+ canvas.width = width;
+ canvas.height = height;
+ var ctx = canvas.getContext('2d');
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, width, height);
+ createImageBitmap(canvas).then(t.step_func(function(image) {
+ consumeImageBitmap(image, t);
+ }));
+}, 'Test that drawImage from a bitmaprenderer canvas produces correct result');
+
+async_test(function(t) {
+ var canvas = document.createElement("canvas");
+ canvas.width = width;
+ canvas.height = height;
+ var ctx = canvas.getContext('2d');
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, width, height);
+ createImageBitmap(canvas).then(t.step_func(function(image) {
+ consumeImageBitmapByCreateImageBitmap(image, t);
+ }));
+}, 'Test that createImageBitmap from a bitmaprenderer canvas produces correct result');
+
+async_test(function(t) {
+ var canvas = document.createElement("canvas");
+ canvas.width = width;
+ canvas.height = height;
+ var ctx = canvas.getContext('bitmaprenderer');
+ createImageBitmap(canvas).then(t.step_func_done(function(image) {
+ assert_equals(image.width, width);
+ assert_equals(image.height, height);
+
+ var dstCanvas = document.createElement('canvas');
+ dstCanvas.width = width;
+ dstCanvas.height = height;
+ var dstCtx = dstCanvas.getContext('2d');
+ dstCtx.drawImage(canvas, 0, 0);
+ testCanvas(dstCtx, 5, 5, 0, 0, 0, 0);
+ }));
+}, 'Test that createImageBitmap on a bitmaprenderer canvas that never consumes any source produces correct result');
+
+
+async_test(function(t) {
+ var canvas = document.createElement("canvas");
+ canvas.width = width;
+ canvas.height = height;
+ var ctx = canvas.getContext('bitmaprenderer');
+ ctx.transferFromImageBitmap(null);
+ createImageBitmap(canvas).then(t.step_func_done(function(image) {
+ assert_equals(image.width, width);
+ assert_equals(image.height, height);
+
+ var dstCanvas = document.createElement('canvas');
+ dstCanvas.width = width;
+ dstCanvas.height = height;
+ var dstCtx = dstCanvas.getContext('2d');
+ dstCtx.drawImage(canvas, 0, 0);
+ testCanvas(dstCtx, 5, 5, 0, 0, 0, 0);
+ }));
+}, 'Test that createImageBitmap on a bitmaprenderer canvas that consumes null produces correct result');
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/imported/wpt/imagebitmap-renderingcontext/bitmaprenderer-as-imagesource-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698