mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibWeb+LibGfx: Refactor CSS filters into LibGfx
CSS filters work similarly to canvas filters, so it makes sense to have Gfx::Filter that can be used by both libraries in an analogous way as Gfx::Color.
This commit is contained in:
committed by
Alexander Kalenik
parent
bc971a4ccc
commit
9fd1223992
@@ -92,19 +92,19 @@ String FilterValueListStyleValue::to_string(SerializationMode) const
|
||||
builder.appendff("{}(",
|
||||
[&] {
|
||||
switch (color.operation) {
|
||||
case FilterOperation::Color::Type::Brightness:
|
||||
case Gfx::ColorFilter::Type::Brightness:
|
||||
return "brightness"sv;
|
||||
case FilterOperation::Color::Type::Contrast:
|
||||
case Gfx::ColorFilter::Type::Contrast:
|
||||
return "contrast"sv;
|
||||
case FilterOperation::Color::Type::Grayscale:
|
||||
case Gfx::ColorFilter::Type::Grayscale:
|
||||
return "grayscale"sv;
|
||||
case FilterOperation::Color::Type::Invert:
|
||||
case Gfx::ColorFilter::Type::Invert:
|
||||
return "invert"sv;
|
||||
case FilterOperation::Color::Type::Opacity:
|
||||
case Gfx::ColorFilter::Type::Opacity:
|
||||
return "opacity"sv;
|
||||
case FilterOperation::Color::Type::Saturate:
|
||||
case Gfx::ColorFilter::Type::Saturate:
|
||||
return "saturate"sv;
|
||||
case FilterOperation::Color::Type::Sepia:
|
||||
case Gfx::ColorFilter::Type::Sepia:
|
||||
return "sepia"sv;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibGfx/Filter.h>
|
||||
#include <LibWeb/CSS/Angle.h>
|
||||
#include <LibWeb/CSS/CalculatedOr.h>
|
||||
#include <LibWeb/CSS/Length.h>
|
||||
@@ -44,15 +45,7 @@ struct HueRotate {
|
||||
};
|
||||
|
||||
struct Color {
|
||||
enum class Type {
|
||||
Brightness,
|
||||
Contrast,
|
||||
Grayscale,
|
||||
Invert,
|
||||
Opacity,
|
||||
Saturate,
|
||||
Sepia
|
||||
} operation;
|
||||
Gfx::ColorFilter::Type operation;
|
||||
Optional<NumberPercentage> amount {};
|
||||
float resolved_amount() const;
|
||||
bool operator==(Color const&) const = default;
|
||||
|
||||
Reference in New Issue
Block a user