mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Ensure putImageData() is unaffected by drawing state
This commit is contained in:
parent
2ac4544a81
commit
d3ca038b2c
Notes:
github-actions[bot]
2025-10-21 07:53:34 +00:00
Author: https://github.com/tcl3
Commit: d3ca038b2c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6518
Reviewed-by: https://github.com/gmta ✅
3 changed files with 50 additions and 1 deletions
|
|
@ -600,14 +600,18 @@ WebIDL::ExceptionOr<void> CanvasRenderingContext2D::put_pixels_from_an_image_dat
|
|||
// imageData data structure's bitmap, converted from imageData's colorSpace to the color space of bitmap using
|
||||
// 'relative-colorimetric' rendering intent.
|
||||
auto dst_rect = Gfx::FloatRect { dx + dirty_x, dy + dirty_y, dirty_width, dirty_height };
|
||||
painter.save();
|
||||
painter.set_transform({});
|
||||
painter.draw_bitmap(
|
||||
dst_rect,
|
||||
Gfx::ImmutableBitmap::create(image_data.bitmap(), Gfx::AlphaType::Unpremultiplied),
|
||||
Gfx::IntRect { dirty_x, dirty_y, dirty_width, dirty_height },
|
||||
Gfx::ScalingMode::NearestNeighbor,
|
||||
drawing_state().filter,
|
||||
{},
|
||||
1.0f,
|
||||
Gfx::CompositingAndBlendingOperator::SourceOver);
|
||||
painter.restore();
|
||||
|
||||
did_draw(dst_rect);
|
||||
|
||||
return {};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
Harness status: OK
|
||||
|
||||
Found 1 tests
|
||||
|
||||
1 Pass
|
||||
Pass putImageData() is not affected by context state
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
|
||||
<meta charset="UTF-8">
|
||||
<title>Canvas test: 2d.imageData.put.unaffected</title>
|
||||
<script src="../../../../resources/testharness.js"></script>
|
||||
<script src="../../../../resources/testharnessreport.js"></script>
|
||||
<script src="../../../../html/canvas/resources/canvas-tests.js"></script>
|
||||
<link rel="stylesheet" href="../../../../html/canvas/resources/canvas-tests.css">
|
||||
<body class="show_output">
|
||||
|
||||
<h1>2d.imageData.put.unaffected</h1>
|
||||
<p class="desc">putImageData() is not affected by context state</p>
|
||||
|
||||
|
||||
<p class="output">Actual output:</p>
|
||||
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
<p class="output expectedtext">Expected output:<p><img src="../../../../images/green-100x50.png" class="output expected" id="expected" alt="">
|
||||
<ul id="d"></ul>
|
||||
<script>
|
||||
var t = async_test("putImageData() is not affected by context state");
|
||||
_addTest(function(canvas, ctx) {
|
||||
|
||||
ctx.fillStyle = '#0f0';
|
||||
ctx.fillRect(0, 0, 100, 50)
|
||||
var imgdata = ctx.getImageData(0, 0, 100, 50);
|
||||
ctx.fillStyle = '#f00';
|
||||
ctx.fillRect(0, 0, 100, 50)
|
||||
ctx.globalAlpha = 0.1;
|
||||
ctx.globalCompositeOperation = 'destination-atop';
|
||||
ctx.shadowColor = '#f00';
|
||||
ctx.shadowBlur = 1;
|
||||
ctx.translate(100, 50);
|
||||
ctx.scale(0.1, 0.1);
|
||||
ctx.putImageData(imgdata, 0, 0);
|
||||
_assertPixelApprox(canvas, 50,25, 0,255,0,255, 2);
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue