mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:27:43 +00:00
LibWeb: Implement CRC2D.imageSmoothingEnabled
We now select between nearest neighbor and bilinear filtering when scaling images in CRC2D.drawImage(). This patch also adds CRC2D.imageSmoothingQuality but it's ignored for now as we don't have a bunch of different quality levels to map it to. Work towards #17993 (Ruffle Flash Player)
This commit is contained in:
parent
e4b71495f5
commit
e77552519e
7 changed files with 75 additions and 2 deletions
27
Userland/Libraries/LibWeb/HTML/Canvas/CanvasImageSmoothing.h
Normal file
27
Userland/Libraries/LibWeb/HTML/Canvas/CanvasImageSmoothing.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/HTML/ImageData.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/canvas.html#canvasimagesmoothing
|
||||
class CanvasImageSmoothing {
|
||||
public:
|
||||
virtual ~CanvasImageSmoothing() = default;
|
||||
|
||||
virtual bool image_smoothing_enabled() const = 0;
|
||||
virtual void set_image_smoothing_enabled(bool) = 0;
|
||||
virtual Bindings::ImageSmoothingQuality image_smoothing_quality() const = 0;
|
||||
virtual void set_image_smoothing_quality(Bindings::ImageSmoothingQuality) = 0;
|
||||
|
||||
protected:
|
||||
CanvasImageSmoothing() = default;
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
// https://html.spec.whatwg.org/multipage/canvas.html#canvasimagesmoothing
|
||||
interface mixin CanvasImageSmoothing {
|
||||
// image smoothing
|
||||
attribute boolean imageSmoothingEnabled; // (default true)
|
||||
attribute ImageSmoothingQuality imageSmoothingQuality; // (default low)
|
||||
};
|
|
@ -12,6 +12,7 @@
|
|||
#include <LibGfx/AffineTransform.h>
|
||||
#include <LibGfx/Color.h>
|
||||
#include <LibGfx/PaintStyle.h>
|
||||
#include <LibWeb/Bindings/CanvasRenderingContext2DPrototype.h>
|
||||
#include <LibWeb/HTML/CanvasGradient.h>
|
||||
#include <LibWeb/HTML/CanvasPattern.h>
|
||||
|
||||
|
@ -74,6 +75,8 @@ public:
|
|||
FillOrStrokeStyle fill_style { Gfx::Color::Black };
|
||||
FillOrStrokeStyle stroke_style { Gfx::Color::Black };
|
||||
float line_width { 1 };
|
||||
bool image_smoothing_enabled { true };
|
||||
Bindings::ImageSmoothingQuality image_smoothing_quality { Bindings::ImageSmoothingQuality::Low };
|
||||
};
|
||||
DrawingState& drawing_state() { return m_drawing_state; }
|
||||
DrawingState const& drawing_state() const { return m_drawing_state; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue