1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:37:45 +00:00

LibPDF: Use Variant<Color, PaintStyle> instead of Color for ColorSpaces

This is in anticipation of Pattern color space support which does not
yield a simple color.
This commit is contained in:
Kyle Pereira 2023-12-05 12:51:42 +00:00 committed by Andreas Kling
parent e4b8d68039
commit 082a4197b6
6 changed files with 116 additions and 55 deletions

View file

@ -74,8 +74,8 @@ struct GraphicsState {
ClippingPaths clipping_paths;
RefPtr<ColorSpace> stroke_color_space { DeviceGrayColorSpace::the() };
RefPtr<ColorSpace> paint_color_space { DeviceGrayColorSpace::the() };
Gfx::Color stroke_color { Gfx::Color::NamedColor::Black };
Gfx::Color paint_color { Gfx::Color::NamedColor::Black };
ColorOrStyle stroke_style { Color::Black };
ColorOrStyle paint_style { Color::Black };
DeprecatedString color_rendering_intent { "RelativeColorimetric"sv };
float flatness_tolerance { 0.0f };
float line_width { 1.0f };
@ -286,8 +286,16 @@ struct Formatter<PDF::GraphicsState> : Formatter<StringView> {
StringBuilder builder;
builder.append("GraphicsState {\n"sv);
builder.appendff(" ctm={}\n", state.ctm);
builder.appendff(" stroke_color={}\n", state.stroke_color);
builder.appendff(" paint_color={}\n", state.paint_color);
if (state.stroke_style.has<Color>()) {
builder.appendff(" stroke_style={}\n", state.stroke_style.get<Color>());
} else {
builder.appendff(" stroke_style={}\n", state.stroke_style.get<NonnullRefPtr<Gfx::PaintStyle>>());
}
if (state.paint_style.has<Color>()) {
builder.appendff(" paint_style={}\n", state.paint_style.get<Color>());
} else {
builder.appendff(" paint_style={}\n", state.paint_style.get<NonnullRefPtr<Gfx::PaintStyle>>());
}
builder.appendff(" color_rendering_intent={}\n", state.color_rendering_intent);
builder.appendff(" flatness_tolerance={}\n", state.flatness_tolerance);
builder.appendff(" line_width={}\n", state.line_width);