gecko-dev/testing/web-platform/tests/css/css-paint-api/parse-input-arguments-018.https.html
Xida Chen 8c67a630b7 Bug 1602807 [wpt PR 20705] - [OT-PW] Make it work with OOP-R, a=testonly
Automatic update from web-platform-tests
[OT-PW] Make it work with OOP-R

This CL makes off-thread paint worklet work with OOP-R. OOP-R serialize
an PaintOp and stores the serialized buffer in a shared memory. GPU
then reads the memory and de-serialize it.

For off-thread paint worklet, we are producing a DrawImageRectOp. Note
that this DrawImageRectOp is different than a normal one. It is a
DrawImageRectOp that contains a DrawRecord that contains multiple
PaintOps in it. So this CL adds a special code path to serialize it,
for paint worklet DrawImageRectOp only. The way to serialize it is to
iterate over all the PaintOps inside the DrawRecord. In this way, we
do not need to change anything on the GPU de-serialize code.

We also changed the layout tests. We changed some tests, now using
fillRect instead of strokeRect.
The problem with strokeRect is that using GPU rasterization could
easily result in subpixel difference on different platforms. Using
fillRect will avoid that.

Bug: 1020238
Change-Id: Ie0aadfe217e462547cc16a273d09ec8a64f055a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1957012
Reviewed-by: Yi Gu <yigu@chromium.org>
Reviewed-by: Khushal <khushalsagar@chromium.org>
Commit-Queue: Xida Chen <xidachen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#725554}

--

wpt-commits: 15e4f2b5a97b2fcd14c592f2de16cc62a82c645d
wpt-pr: 20705
2019-12-23 11:14:49 +00:00

68 lines
2.3 KiB
HTML

<!DOCTYPE html>
<html class="reftest-wait">
<link rel="help" href="https://drafts.css-houdini.org/css-paint-api/">
<link rel="match" href="parse-input-arguments-018-ref.html">
<style>
.container {
width: 100px;
height: 100px;
}
#canvas-geometry {
background-image: paint(failureIndicator), paint(geometry);
}
</style>
<script src="/common/reftest-wait.js"></script>
<script src="/common/worklet-reftest.js"></script>
<body>
<p>This test result should show a green rect. The registerPaint('failureIndicator')
will be called twice and the inputArguments will return two different strings,
which will throw an exception and the paint function with 'failureIndicator'
should never be called. In other words, there should be no red painted in the result.</p>
<div id="canvas-geometry" class="container"></div>
<script id="code" type="text/worklet">
function generateRandString(length) {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < length; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
try {
registerPaint('failureIndicator', class {
static get inputArguments() {
// This test is testing the case where an exception should be thrown
// when two paint definitions with different properties are registered
// to the same paint worklet. In order to do that, we randomly generate
// the input properties here. We make the string length 100 to make sure
// that it is veryyyyyyyyyyyy unlikely that two strings will be the same
// when running this test.
var current_str = generateRandString(100);
return [current_str];
}
// The paint function here should never be called because the inputArguments
// will generate two different properties, and that should throw an
// exception.
paint(ctx, geom) {
ctx.fillStyle = 'red';
ctx.fillRect(0, 0, 50, 50);
}
});
} catch(ex) {
}
registerPaint('geometry', class {
paint(ctx, geom) {
ctx.fillStyle = 'green';
ctx.fillRect(50, 50, 50, 50);
}
});
</script>
<script>
importWorkletAndTerminateTestAfterAsyncPaint(CSS.paintWorklet, document.getElementById('code').textContent);
</script>
</body>
</html>