Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draw background first in 2d.composite.canvas WPT tests #50259

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ <h1>2d.composite.canvas.clear</h1>
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'clear';
const canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
Expand All @@ -30,9 +33,6 @@ <h1>2d.composite.canvas.clear</h1>
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'clear';
ctx.drawImage(canvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 0,0,0,0, 5);

Expand Down
6 changes: 3 additions & 3 deletions html/canvas/element/compositing/2d.composite.canvas.copy.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ <h1>2d.composite.canvas.copy</h1>
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'copy';
const canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
Expand All @@ -30,9 +33,6 @@ <h1>2d.composite.canvas.copy</h1>
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'copy';
ctx.drawImage(canvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 255,255,0,191, 5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ <h1>2d.composite.canvas.destination-atop</h1>
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-atop';
const canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
Expand All @@ -30,9 +33,6 @@ <h1>2d.composite.canvas.destination-atop</h1>
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-atop';
ctx.drawImage(canvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 128,255,128,191, 5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ <h1>2d.composite.canvas.destination-in</h1>
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-in';
const canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
Expand All @@ -30,9 +33,6 @@ <h1>2d.composite.canvas.destination-in</h1>
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-in';
ctx.drawImage(canvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 0,255,255,96, 5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ <h1>2d.composite.canvas.destination-out</h1>
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-out';
const canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
Expand All @@ -30,9 +33,6 @@ <h1>2d.composite.canvas.destination-out</h1>
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-out';
ctx.drawImage(canvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 0,255,255,32, 5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ <h1>2d.composite.canvas.destination-over</h1>
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-over';
const canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
Expand All @@ -30,9 +33,6 @@ <h1>2d.composite.canvas.destination-over</h1>
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-over';
ctx.drawImage(canvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 109,255,146,223, 5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ <h1>2d.composite.canvas.lighter</h1>
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'lighter';
const canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
Expand All @@ -30,9 +33,6 @@ <h1>2d.composite.canvas.lighter</h1>
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'lighter';
ctx.drawImage(canvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 191,255,128,255, 5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ <h1>2d.composite.canvas.source-atop</h1>
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-atop';
const canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
Expand All @@ -30,9 +33,6 @@ <h1>2d.composite.canvas.source-atop</h1>
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-atop';
ctx.drawImage(canvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 191,255,64,128, 5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ <h1>2d.composite.canvas.source-in</h1>
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-in';
const canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
Expand All @@ -30,9 +33,6 @@ <h1>2d.composite.canvas.source-in</h1>
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-in';
ctx.drawImage(canvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 255,255,0,96, 5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ <h1>2d.composite.canvas.source-out</h1>
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-out';
const canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
Expand All @@ -30,9 +33,6 @@ <h1>2d.composite.canvas.source-out</h1>
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-out';
ctx.drawImage(canvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 255,255,0,96, 5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ <h1>2d.composite.canvas.source-over</h1>
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-over';
const canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
Expand All @@ -30,9 +33,6 @@ <h1>2d.composite.canvas.source-over</h1>
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'source-over';
ctx.drawImage(canvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 219,255,36,223, 5);

Expand Down
6 changes: 3 additions & 3 deletions html/canvas/element/compositing/2d.composite.canvas.xor.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ <h1>2d.composite.canvas.xor</h1>
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'xor';
const canvas2 = document.createElement('canvas');
canvas2.width = canvas.width;
canvas2.height = canvas.height;
Expand All @@ -30,9 +33,6 @@ <h1>2d.composite.canvas.xor</h1>
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'xor';
ctx.drawImage(canvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 191,255,64,128, 5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ <h1>2d.composite.canvas.clear</h1>
var canvas = new OffscreenCanvas(100, 50);
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'clear';
const offscreenCanvas2 = new OffscreenCanvas(canvas.width, canvas.height);
const ctx2 = offscreenCanvas2.getContext('2d');
const response = await fetch('/images/yellow75.png')
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'clear';
ctx.drawImage(offscreenCanvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 0,0,0,0, 5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ promise_test(async t => {
var canvas = new OffscreenCanvas(100, 50);
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'clear';
const offscreenCanvas2 = new OffscreenCanvas(canvas.width, canvas.height);
const ctx2 = offscreenCanvas2.getContext('2d');
const response = await fetch('/images/yellow75.png')
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'clear';
ctx.drawImage(offscreenCanvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 0,0,0,0, 5);
}, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ <h1>2d.composite.canvas.copy</h1>
var canvas = new OffscreenCanvas(100, 50);
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'copy';
const offscreenCanvas2 = new OffscreenCanvas(canvas.width, canvas.height);
const ctx2 = offscreenCanvas2.getContext('2d');
const response = await fetch('/images/yellow75.png')
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'copy';
ctx.drawImage(offscreenCanvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 255,255,0,191, 5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ promise_test(async t => {
var canvas = new OffscreenCanvas(100, 50);
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'copy';
const offscreenCanvas2 = new OffscreenCanvas(canvas.width, canvas.height);
const ctx2 = offscreenCanvas2.getContext('2d');
const response = await fetch('/images/yellow75.png')
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'copy';
ctx.drawImage(offscreenCanvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 255,255,0,191, 5);
}, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ <h1>2d.composite.canvas.destination-atop</h1>
var canvas = new OffscreenCanvas(100, 50);
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-atop';
const offscreenCanvas2 = new OffscreenCanvas(canvas.width, canvas.height);
const ctx2 = offscreenCanvas2.getContext('2d');
const response = await fetch('/images/yellow75.png')
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-atop';
ctx.drawImage(offscreenCanvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 128,255,128,191, 5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ promise_test(async t => {
var canvas = new OffscreenCanvas(100, 50);
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-atop';
const offscreenCanvas2 = new OffscreenCanvas(canvas.width, canvas.height);
const ctx2 = offscreenCanvas2.getContext('2d');
const response = await fetch('/images/yellow75.png')
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-atop';
ctx.drawImage(offscreenCanvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 128,255,128,191, 5);
}, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ <h1>2d.composite.canvas.destination-in</h1>
var canvas = new OffscreenCanvas(100, 50);
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-in';
const offscreenCanvas2 = new OffscreenCanvas(canvas.width, canvas.height);
const ctx2 = offscreenCanvas2.getContext('2d');
const response = await fetch('/images/yellow75.png')
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-in';
ctx.drawImage(offscreenCanvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 0,255,255,96, 5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ promise_test(async t => {
var canvas = new OffscreenCanvas(100, 50);
var ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-in';
const offscreenCanvas2 = new OffscreenCanvas(canvas.width, canvas.height);
const ctx2 = offscreenCanvas2.getContext('2d');
const response = await fetch('/images/yellow75.png')
const blob = await response.blob();
const bitmap = await createImageBitmap(blob);
ctx2.drawImage(bitmap, 0, 0);
ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
ctx.fillRect(0, 0, 100, 50);
ctx.globalCompositeOperation = 'destination-in';
ctx.drawImage(offscreenCanvas2, 0, 0);
_assertPixelApprox(canvas, 50,25, 0,255,255,96, 5);
}, "");
Expand Down
Loading
Loading