mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
LibWeb/HTML: Add spec comment to CRC2D::put_image_data()
Also rename imagedata -> imageData, as done here:
6a3787f6cf
This commit is contained in:
parent
54d41cfea3
commit
03bccb5ff1
Notes:
github-actions[bot]
2025-02-22 15:00:45 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/03bccb5ff16 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3647 Reviewed-by: https://github.com/tcl3 ✅
2 changed files with 9 additions and 4 deletions
|
@ -3,10 +3,10 @@
|
|||
// https://html.spec.whatwg.org/multipage/canvas.html#canvasimagedata
|
||||
interface mixin CanvasImageData {
|
||||
ImageData createImageData([EnforceRange] long sw, [EnforceRange] long sh, optional ImageDataSettings settings = {});
|
||||
ImageData createImageData(ImageData imagedata);
|
||||
ImageData createImageData(ImageData imageData);
|
||||
|
||||
ImageData getImageData([EnforceRange] long sx, [EnforceRange] long sy, [EnforceRange] long sw, [EnforceRange] long sh, optional ImageDataSettings settings = {});
|
||||
|
||||
undefined putImageData(ImageData imagedata, [EnforceRange] long dx, [EnforceRange] long dy);
|
||||
[FIXME] undefined putImageData(ImageData imagedata, [EnforceRange] long dx, [EnforceRange] long dy, [EnforceRange] long dirtyX, [EnforceRange] long dirtyY, [EnforceRange] long dirtyWidth, [EnforceRange] long dirtyHeight);
|
||||
undefined putImageData(ImageData imageData, [EnforceRange] long dx, [EnforceRange] long dy);
|
||||
[FIXME] undefined putImageData(ImageData imageData, [EnforceRange] long dx, [EnforceRange] long dy, [EnforceRange] long dirtyX, [EnforceRange] long dirtyY, [EnforceRange] long dirtyWidth, [EnforceRange] long dirtyHeight);
|
||||
};
|
||||
|
|
|
@ -379,7 +379,7 @@ WebIDL::ExceptionOr<GC::Ref<ImageData>> CanvasRenderingContext2D::create_image_d
|
|||
WebIDL::ExceptionOr<GC::Ref<ImageData>> CanvasRenderingContext2D::create_image_data(ImageData const& image_data) const
|
||||
{
|
||||
// 1. Let newImageData be a new ImageData object.
|
||||
// 2. Initialize newImageData given the value of imagedata's width attribute, the value of imagedata's height attribute, and defaultColorSpace set to the value of imagedata's colorSpace attribute.
|
||||
// 2. Initialize newImageData given the value of imageData's width attribute, the value of imageData's height attribute, and defaultColorSpace set to the value of imageData's colorSpace attribute.
|
||||
// FIXME: Set defaultColorSpace to the value of image_data's colorSpace attribute
|
||||
// 3. Initialize the image data of newImageData to transparent black.
|
||||
// NOTE: No-op, already done during creation.
|
||||
|
@ -440,8 +440,13 @@ WebIDL::ExceptionOr<GC::Ptr<ImageData>> CanvasRenderingContext2D::get_image_data
|
|||
return image_data;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-putimagedata-short
|
||||
void CanvasRenderingContext2D::put_image_data(ImageData const& image_data, float x, float y)
|
||||
{
|
||||
// The putImageData(imageData, dx, dy) method steps are to put pixels from an ImageData onto a bitmap,
|
||||
// given imageData, this's output bitmap, dx, dy, 0, 0, imageData's width, and imageData's height.
|
||||
// FIXME: "put pixels from an ImageData onto a bitmap" is a spec algorithm.
|
||||
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context2d-putimagedata-common
|
||||
if (auto* painter = this->painter()) {
|
||||
auto dst_rect = Gfx::FloatRect(x, y, image_data.width(), image_data.height());
|
||||
painter->draw_bitmap(dst_rect, Gfx::ImmutableBitmap::create(image_data.bitmap()), image_data.bitmap().rect(), Gfx::ScalingMode::NearestNeighbor, drawing_state().filters, 1.0f, Gfx::CompositingAndBlendingOperator::SourceOver);
|
||||
|
|
Loading…
Add table
Reference in a new issue