mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibWeb: Delete DisplayListPlayerCPU
No longer used after switching to Skia as a default.
This commit is contained in:
parent
3627329bed
commit
f3b3b3f5b9
Notes:
github-actions[bot]
2024-07-21 11:27:06 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/f3b3b3f5b92 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/736 Reviewed-by: https://github.com/jamierocks
8 changed files with 0 additions and 574 deletions
|
@ -16,7 +16,6 @@ source_set("Painting") {
|
|||
"ClippableAndScrollable.cpp",
|
||||
"Command.cpp",
|
||||
"DisplayList.cpp",
|
||||
"DisplayListPlayerCPU.cpp",
|
||||
"DisplayListRecorder.cpp",
|
||||
"FilterPainting.cpp",
|
||||
"GradientPainting.cpp",
|
||||
|
|
|
@ -549,7 +549,6 @@ set(SOURCES
|
|||
Painting/CheckBoxPaintable.cpp
|
||||
Painting/ClippableAndScrollable.cpp
|
||||
Painting/DisplayList.cpp
|
||||
Painting/DisplayListPlayerCPU.cpp
|
||||
Painting/DisplayListPlayerSkia.cpp
|
||||
Painting/DisplayListRecorder.cpp
|
||||
Painting/GradientPainting.cpp
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include <LibWeb/HTML/TraversableNavigable.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/Painting/DisplayListPlayerCPU.h>
|
||||
#include <LibWeb/Platform/EventLoopPlugin.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -1233,11 +1232,6 @@ void TraversableNavigable::paint(DevicePixelRect const& content_rect, Painting::
|
|||
display_list.execute(player);
|
||||
break;
|
||||
}
|
||||
case DisplayListPlayerType::CPU: {
|
||||
Painting::DisplayListPlayerCPU player(target.bitmap());
|
||||
display_list.execute(player);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
|
|
@ -277,7 +277,6 @@ struct PaintOptions {
|
|||
};
|
||||
|
||||
enum class DisplayListPlayerType {
|
||||
CPU,
|
||||
SkiaGPUIfAvailable,
|
||||
SkiaCPU,
|
||||
};
|
||||
|
|
|
@ -1,480 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibGfx/Filters/StackBlurFilter.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibWeb/CSS/ComputedValues.h>
|
||||
#include <LibWeb/Painting/BorderRadiusCornerClipper.h>
|
||||
#include <LibWeb/Painting/DisplayListPlayerCPU.h>
|
||||
#include <LibWeb/Painting/DisplayListRecorder.h>
|
||||
#include <LibWeb/Painting/FilterPainting.h>
|
||||
#include <LibWeb/Painting/ShadowPainting.h>
|
||||
|
||||
namespace Web::Painting {
|
||||
|
||||
DisplayListPlayerCPU::DisplayListPlayerCPU(Gfx::Bitmap& bitmap)
|
||||
: m_target_bitmap(bitmap)
|
||||
{
|
||||
stacking_contexts.append({ .painter = AK::make<Gfx::Painter>(bitmap),
|
||||
.opacity = 1.0f,
|
||||
.destination = {},
|
||||
.scaling_mode = {} });
|
||||
}
|
||||
|
||||
DisplayListPlayerCPU::~DisplayListPlayerCPU() = default;
|
||||
|
||||
CommandResult DisplayListPlayerCPU::draw_glyph_run(DrawGlyphRun const& command)
|
||||
{
|
||||
auto& painter = this->painter();
|
||||
auto const& glyphs = command.glyph_run->glyphs();
|
||||
auto const& font = command.glyph_run->font();
|
||||
auto scaled_font = font.with_size(font.point_size() * static_cast<float>(command.scale));
|
||||
for (auto const& glyph_or_emoji : glyphs) {
|
||||
auto transformed_glyph = glyph_or_emoji;
|
||||
transformed_glyph.visit([&](auto& glyph) {
|
||||
glyph.position = glyph.position.scaled(command.scale).translated(command.translation);
|
||||
});
|
||||
if (glyph_or_emoji.has<Gfx::DrawGlyph>()) {
|
||||
auto& glyph = transformed_glyph.get<Gfx::DrawGlyph>();
|
||||
painter.draw_glyph(glyph.position, glyph.code_point, *scaled_font, command.color);
|
||||
} else {
|
||||
auto& emoji = transformed_glyph.get<Gfx::DrawEmoji>();
|
||||
painter.draw_emoji(emoji.position.to_type<int>(), *emoji.emoji, *scaled_font);
|
||||
}
|
||||
}
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
template<typename Callback>
|
||||
void apply_clip_paths_to_painter(Gfx::IntRect const& rect, Callback callback, Vector<Gfx::Path> const& clip_paths, Gfx::Painter& target_painter)
|
||||
{
|
||||
// Setup a painter for a background canvas that we will paint to first.
|
||||
auto background_canvas = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, rect.size()).release_value_but_fixme_should_propagate_errors();
|
||||
Gfx::Painter painter(*background_canvas);
|
||||
|
||||
// Offset the painter to paint in the correct location.
|
||||
painter.translate(-rect.location());
|
||||
|
||||
// Paint the background canvas.
|
||||
callback(painter);
|
||||
|
||||
// Apply the clip path to the target painter.
|
||||
Gfx::AntiAliasingPainter aa_painter(target_painter);
|
||||
for (auto const& clip_path : clip_paths) {
|
||||
auto fill_offset = clip_path.bounding_box().location().to_type<int>() - rect.location();
|
||||
auto paint_style = Gfx::BitmapPaintStyle::create(*background_canvas, fill_offset).release_value_but_fixme_should_propagate_errors();
|
||||
aa_painter.fill_path(clip_path, paint_style);
|
||||
}
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::fill_rect(FillRect const& command)
|
||||
{
|
||||
auto paint_op = [&](Gfx::Painter& painter) {
|
||||
painter.fill_rect(command.rect, command.color);
|
||||
};
|
||||
if (command.clip_paths.is_empty()) {
|
||||
paint_op(painter());
|
||||
} else {
|
||||
apply_clip_paths_to_painter(command.rect, paint_op, command.clip_paths, painter());
|
||||
}
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::draw_scaled_bitmap(DrawScaledBitmap const& command)
|
||||
{
|
||||
auto& painter = this->painter();
|
||||
painter.draw_scaled_bitmap(command.dst_rect, command.bitmap, command.src_rect, 1, command.scaling_mode);
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const& command)
|
||||
{
|
||||
auto paint_op = [&](Gfx::Painter& painter) {
|
||||
painter.draw_scaled_bitmap(command.dst_rect, command.bitmap->bitmap(), command.src_rect, 1, command.scaling_mode);
|
||||
};
|
||||
if (command.clip_paths.is_empty()) {
|
||||
paint_op(painter());
|
||||
} else {
|
||||
apply_clip_paths_to_painter(command.dst_rect, paint_op, command.clip_paths, painter());
|
||||
}
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::save(Save const&)
|
||||
{
|
||||
painter().save();
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::restore(Restore const&)
|
||||
{
|
||||
painter().restore();
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::add_clip_rect(AddClipRect const& command)
|
||||
{
|
||||
painter().add_clip_rect(command.rect);
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::push_stacking_context(PushStackingContext const& command)
|
||||
{
|
||||
// FIXME: This extracts the affine 2D part of the full transformation matrix.
|
||||
// Use the whole matrix when we get better transformation support in LibGfx or use LibGL for drawing the bitmap
|
||||
auto affine_transform = Gfx::extract_2d_affine_transform(command.transform.matrix);
|
||||
|
||||
painter().save();
|
||||
if (command.is_fixed_position)
|
||||
painter().translate(-painter().translation());
|
||||
|
||||
if (command.mask.has_value()) {
|
||||
// TODO: Support masks and other stacking context features at the same time.
|
||||
// Note: Currently only SVG masking is implemented (which does not use CSS transforms anyway).
|
||||
auto bitmap_or_error = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, command.mask->mask_bitmap->size());
|
||||
if (bitmap_or_error.is_error())
|
||||
return CommandResult::Continue;
|
||||
auto bitmap = bitmap_or_error.release_value();
|
||||
stacking_contexts.append(StackingContext {
|
||||
.painter = AK::make<Gfx::Painter>(bitmap),
|
||||
.opacity = 1,
|
||||
.destination = command.source_paintable_rect.translated(command.post_transform_translation),
|
||||
.scaling_mode = Gfx::ScalingMode::None,
|
||||
.mask = command.mask });
|
||||
painter().translate(-command.source_paintable_rect.location());
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
if (command.opacity == 1.0f && affine_transform.is_identity_or_translation()) {
|
||||
// OPTIMIZATION: This is a simple translation use previous stacking context's painter.
|
||||
painter().translate(affine_transform.translation().to_rounded<int>() + command.post_transform_translation);
|
||||
stacking_contexts.append(StackingContext {
|
||||
.painter = MaybeOwned(painter()),
|
||||
.opacity = 1,
|
||||
.destination = {},
|
||||
.scaling_mode = {} });
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
auto& current_painter = this->painter();
|
||||
auto source_rect = command.source_paintable_rect.to_type<float>().translated(-command.transform.origin);
|
||||
auto transformed_destination_rect = affine_transform.map(source_rect).translated(command.transform.origin);
|
||||
auto destination_rect = transformed_destination_rect.to_rounded<int>();
|
||||
|
||||
// FIXME: We should find a way to scale the paintable, rather than paint into a separate bitmap,
|
||||
// then scale it. This snippet now copies the background at the destination, then scales it down/up
|
||||
// to the size of the source (which could add some artefacts, though just scaling the bitmap already does that).
|
||||
// We need to copy the background at the destination because a bunch of our rendering effects now rely on
|
||||
// being able to sample the painter (see border radii, shadows, filters, etc).
|
||||
Gfx::FloatPoint destination_clipped_fixup {};
|
||||
auto try_get_scaled_destination_bitmap = [&]() -> ErrorOr<NonnullRefPtr<Gfx::Bitmap>> {
|
||||
Gfx::IntRect actual_destination_rect;
|
||||
auto bitmap = TRY(current_painter.get_region_bitmap(destination_rect, Gfx::BitmapFormat::BGRA8888, actual_destination_rect));
|
||||
// get_region_bitmap() may clip to a smaller region if the requested rect goes outside the painter, so we need to account for that.
|
||||
destination_clipped_fixup = Gfx::FloatPoint { destination_rect.location() - actual_destination_rect.location() };
|
||||
destination_rect = actual_destination_rect;
|
||||
if (source_rect.size() != transformed_destination_rect.size()) {
|
||||
auto sx = static_cast<float>(source_rect.width()) / transformed_destination_rect.width();
|
||||
auto sy = static_cast<float>(source_rect.height()) / transformed_destination_rect.height();
|
||||
bitmap = TRY(bitmap->scaled(sx, sy));
|
||||
destination_clipped_fixup.scale_by(sx, sy);
|
||||
}
|
||||
return bitmap;
|
||||
};
|
||||
|
||||
auto bitmap_or_error = try_get_scaled_destination_bitmap();
|
||||
if (bitmap_or_error.is_error()) {
|
||||
// NOTE: If the creation of the bitmap fails, we need to skip all painting commands that belong to this stacking context.
|
||||
// We don't interrupt the execution of painting commands because get_region_bitmap() returns an error if the requested
|
||||
// region is outside of the viewport (mmap fails to allocate a zero-size region), which means we can safely proceed
|
||||
// with execution of commands outside of this stacking context.
|
||||
// FIXME: Change the get_region_bitmap() API to return ErrorOr<Optional<Bitmap>> and exit the execution of commands here
|
||||
// if we run out of memory.
|
||||
painter().restore();
|
||||
return CommandResult::SkipStackingContext;
|
||||
}
|
||||
|
||||
auto bitmap = bitmap_or_error.release_value();
|
||||
stacking_contexts.append(StackingContext {
|
||||
.painter = AK::make<Gfx::Painter>(bitmap),
|
||||
.opacity = command.opacity,
|
||||
.destination = destination_rect.translated(command.post_transform_translation),
|
||||
.scaling_mode = CSS::to_gfx_scaling_mode(command.image_rendering, destination_rect, destination_rect) });
|
||||
painter().translate(-command.source_paintable_rect.location() + destination_clipped_fixup.to_type<int>());
|
||||
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::pop_stacking_context(PopStackingContext const&)
|
||||
{
|
||||
ScopeGuard restore_painter = [&] {
|
||||
painter().restore();
|
||||
};
|
||||
auto stacking_context = stacking_contexts.take_last();
|
||||
// Stacking contexts that don't own their painter are simple translations, and don't need to blit anything back.
|
||||
if (stacking_context.painter.is_owned()) {
|
||||
auto& bitmap = stacking_context.painter->target();
|
||||
if (stacking_context.mask.has_value())
|
||||
bitmap.apply_mask(*stacking_context.mask->mask_bitmap, stacking_context.mask->mask_kind);
|
||||
auto destination_rect = stacking_context.destination;
|
||||
if (destination_rect.size() == bitmap.size()) {
|
||||
painter().blit(destination_rect.location(), bitmap, bitmap.rect(), stacking_context.opacity);
|
||||
} else {
|
||||
painter().draw_scaled_bitmap(destination_rect, bitmap, bitmap.rect(), stacking_context.opacity, stacking_context.scaling_mode);
|
||||
}
|
||||
}
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::paint_linear_gradient(PaintLinearGradient const& command)
|
||||
{
|
||||
auto const& linear_gradient_data = command.linear_gradient_data;
|
||||
auto paint_op = [&](Gfx::Painter& painter) {
|
||||
painter.fill_rect_with_linear_gradient(
|
||||
command.gradient_rect, linear_gradient_data.color_stops.list,
|
||||
linear_gradient_data.gradient_angle, linear_gradient_data.color_stops.repeat_length);
|
||||
};
|
||||
if (command.clip_paths.is_empty()) {
|
||||
paint_op(painter());
|
||||
} else {
|
||||
apply_clip_paths_to_painter(command.gradient_rect, paint_op, command.clip_paths, painter());
|
||||
}
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::paint_outer_box_shadow(PaintOuterBoxShadow const& command)
|
||||
{
|
||||
auto& painter = this->painter();
|
||||
Web::Painting::paint_outer_box_shadow(painter, command.box_shadow_params);
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::paint_inner_box_shadow(PaintInnerBoxShadow const& command)
|
||||
{
|
||||
auto& painter = this->painter();
|
||||
Web::Painting::paint_inner_box_shadow(painter, command.box_shadow_params);
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::paint_text_shadow(PaintTextShadow const& command)
|
||||
{
|
||||
// FIXME: Figure out the maximum bitmap size for all shadows and then allocate it once and reuse it?
|
||||
auto maybe_shadow_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, command.shadow_bounding_rect.size());
|
||||
if (maybe_shadow_bitmap.is_error()) {
|
||||
dbgln("Unable to allocate temporary bitmap {} for text-shadow rendering: {}", command.shadow_bounding_rect.size(), maybe_shadow_bitmap.error());
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
auto shadow_bitmap = maybe_shadow_bitmap.release_value();
|
||||
|
||||
Gfx::Painter shadow_painter { *shadow_bitmap };
|
||||
// FIXME: "Spread" the shadow somehow.
|
||||
Gfx::IntPoint const baseline_start(command.text_rect.x(), command.text_rect.y());
|
||||
shadow_painter.translate(baseline_start);
|
||||
auto const& glyphs = command.glyph_run->glyphs();
|
||||
auto const& font = command.glyph_run->font();
|
||||
auto scaled_font = font.with_size(font.point_size() * static_cast<float>(command.glyph_run_scale));
|
||||
for (auto const& glyph_or_emoji : glyphs) {
|
||||
auto transformed_glyph = glyph_or_emoji;
|
||||
transformed_glyph.visit([&](auto& glyph) {
|
||||
glyph.position = glyph.position.scaled(command.glyph_run_scale);
|
||||
});
|
||||
if (glyph_or_emoji.has<Gfx::DrawGlyph>()) {
|
||||
auto& glyph = transformed_glyph.get<Gfx::DrawGlyph>();
|
||||
shadow_painter.draw_glyph(glyph.position, glyph.code_point, *scaled_font, command.color);
|
||||
} else {
|
||||
auto& emoji = transformed_glyph.get<Gfx::DrawEmoji>();
|
||||
shadow_painter.draw_emoji(emoji.position.to_type<int>(), *emoji.emoji, *scaled_font);
|
||||
}
|
||||
}
|
||||
|
||||
// Blur
|
||||
Gfx::StackBlurFilter filter(*shadow_bitmap);
|
||||
filter.process_rgba(command.blur_radius, command.color);
|
||||
|
||||
painter().blit(command.draw_location, *shadow_bitmap, command.shadow_bounding_rect);
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::fill_rect_with_rounded_corners(FillRectWithRoundedCorners const& command)
|
||||
{
|
||||
auto paint_op = [&](Gfx::Painter& painter) {
|
||||
Gfx::AntiAliasingPainter aa_painter(painter);
|
||||
aa_painter.fill_rect_with_rounded_corners(
|
||||
command.rect,
|
||||
command.color,
|
||||
command.corner_radii.top_left,
|
||||
command.corner_radii.top_right,
|
||||
command.corner_radii.bottom_right,
|
||||
command.corner_radii.bottom_left);
|
||||
};
|
||||
if (command.clip_paths.is_empty()) {
|
||||
paint_op(painter());
|
||||
} else {
|
||||
apply_clip_paths_to_painter(command.rect, paint_op, command.clip_paths, painter());
|
||||
}
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::fill_path_using_color(FillPathUsingColor const& command)
|
||||
{
|
||||
Gfx::AntiAliasingPainter aa_painter(painter());
|
||||
aa_painter.translate(command.aa_translation);
|
||||
aa_painter.fill_path(command.path, command.color, command.winding_rule);
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::fill_path_using_paint_style(FillPathUsingPaintStyle const& command)
|
||||
{
|
||||
Gfx::AntiAliasingPainter aa_painter(painter());
|
||||
auto gfx_paint_style = command.paint_style->create_gfx_paint_style();
|
||||
aa_painter.translate(command.aa_translation);
|
||||
aa_painter.fill_path(command.path, gfx_paint_style, command.opacity, command.winding_rule);
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::stroke_path_using_color(StrokePathUsingColor const& command)
|
||||
{
|
||||
Gfx::AntiAliasingPainter aa_painter(painter());
|
||||
aa_painter.translate(command.aa_translation);
|
||||
aa_painter.stroke_path(command.path, command.color, command.thickness);
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::stroke_path_using_paint_style(StrokePathUsingPaintStyle const& command)
|
||||
{
|
||||
Gfx::AntiAliasingPainter aa_painter(painter());
|
||||
auto gfx_paint_style = command.paint_style->create_gfx_paint_style();
|
||||
aa_painter.translate(command.aa_translation);
|
||||
aa_painter.stroke_path(command.path, gfx_paint_style, command.thickness, command.opacity);
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::draw_ellipse(DrawEllipse const& command)
|
||||
{
|
||||
Gfx::AntiAliasingPainter aa_painter(painter());
|
||||
aa_painter.draw_ellipse(command.rect, command.color, command.thickness);
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::fill_ellipse(FillEllipse const& command)
|
||||
{
|
||||
Gfx::AntiAliasingPainter aa_painter(painter());
|
||||
aa_painter.fill_ellipse(command.rect, command.color);
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::draw_line(DrawLine const& command)
|
||||
{
|
||||
if (command.style == Gfx::LineStyle::Dotted) {
|
||||
Gfx::AntiAliasingPainter aa_painter(painter());
|
||||
aa_painter.draw_line(command.from, command.to, command.color, command.thickness, command.style, command.alternate_color);
|
||||
} else {
|
||||
painter().draw_line(command.from, command.to, command.color, command.thickness, command.style, command.alternate_color);
|
||||
}
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::apply_backdrop_filter(ApplyBackdropFilter const& command)
|
||||
{
|
||||
auto& painter = this->painter();
|
||||
|
||||
// This performs the backdrop filter operation: https://drafts.fxtf.org/filter-effects-2/#backdrop-filter-operation
|
||||
|
||||
// Note: The region bitmap can be smaller than the backdrop_region if it's at the edge of canvas.
|
||||
// Note: This is in DevicePixels, but we use an IntRect because `get_region_bitmap()` below writes to it.
|
||||
|
||||
// FIXME: Go through the steps to find the "Backdrop Root Image"
|
||||
// https://drafts.fxtf.org/filter-effects-2/#BackdropRoot
|
||||
|
||||
// 1. Copy the Backdrop Root Image into a temporary buffer, such as a raster image. Call this buffer T’.
|
||||
Gfx::IntRect actual_region {};
|
||||
auto maybe_backdrop_bitmap = painter.get_region_bitmap(command.backdrop_region, Gfx::BitmapFormat::BGRA8888, actual_region);
|
||||
if (actual_region.is_empty())
|
||||
return CommandResult::Continue;
|
||||
if (maybe_backdrop_bitmap.is_error()) {
|
||||
dbgln("Failed get region bitmap for backdrop-filter");
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
auto backdrop_bitmap = maybe_backdrop_bitmap.release_value();
|
||||
|
||||
// 2. Apply the backdrop-filter’s filter operations to the entire contents of T'.
|
||||
apply_filter_list(*backdrop_bitmap, command.backdrop_filter.filters);
|
||||
|
||||
// FIXME: 3. If element B has any transforms (between B and the Backdrop Root), apply the inverse of those transforms to the contents of T’.
|
||||
|
||||
// 4. Apply a clip to the contents of T’, using the border box of element B, including border-radius if specified. Note that the children of B are not considered for the sizing or location of this clip.
|
||||
// FIXME: 5. Draw all of element B, including its background, border, and any children elements, into T’.
|
||||
// FXIME: 6. If element B has any transforms, effects, or clips, apply those to T’.
|
||||
|
||||
// 7. Composite the contents of T’ into element B’s parent, using source-over compositing.
|
||||
painter.blit(actual_region.location(), *backdrop_bitmap, backdrop_bitmap->rect());
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::draw_rect(DrawRect const& command)
|
||||
{
|
||||
painter().draw_rect(command.rect, command.color, command.rough);
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::paint_radial_gradient(PaintRadialGradient const& command)
|
||||
{
|
||||
auto paint_op = [&](Gfx::Painter& painter) {
|
||||
painter.fill_rect_with_radial_gradient(command.rect, command.radial_gradient_data.color_stops.list, command.center, command.size, command.radial_gradient_data.color_stops.repeat_length);
|
||||
};
|
||||
if (command.clip_paths.is_empty()) {
|
||||
paint_op(painter());
|
||||
} else {
|
||||
apply_clip_paths_to_painter(command.rect, paint_op, command.clip_paths, painter());
|
||||
}
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::paint_conic_gradient(PaintConicGradient const& command)
|
||||
{
|
||||
auto paint_op = [&](Gfx::Painter& painter) {
|
||||
painter.fill_rect_with_conic_gradient(command.rect, command.conic_gradient_data.color_stops.list, command.position, command.conic_gradient_data.start_angle, command.conic_gradient_data.color_stops.repeat_length);
|
||||
};
|
||||
if (command.clip_paths.is_empty()) {
|
||||
paint_op(painter());
|
||||
} else {
|
||||
apply_clip_paths_to_painter(command.rect, paint_op, command.clip_paths, painter());
|
||||
}
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::draw_triangle_wave(DrawTriangleWave const& command)
|
||||
{
|
||||
painter().draw_triangle_wave(command.p1, command.p2, command.color, command.amplitude, command.thickness);
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
void DisplayListPlayerCPU::prepare_to_execute(size_t corner_clip_max_depth)
|
||||
{
|
||||
m_corner_clippers_stack.ensure_capacity(corner_clip_max_depth);
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::sample_under_corners(SampleUnderCorners const& command)
|
||||
{
|
||||
auto clipper = BorderRadiusCornerClipper::create(command.corner_radii, command.border_rect.to_type<DevicePixels>(), command.corner_clip).release_value();
|
||||
clipper->sample_under_corners(painter());
|
||||
m_corner_clippers_stack.append(clipper);
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
CommandResult DisplayListPlayerCPU::blit_corner_clipping(BlitCornerClipping const&)
|
||||
{
|
||||
auto clipper = m_corner_clippers_stack.take_last();
|
||||
clipper->blit_corner_clipping(painter());
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
bool DisplayListPlayerCPU::would_be_fully_clipped_by_painter(Gfx::IntRect rect) const
|
||||
{
|
||||
return !painter().clip_rect().intersects(rect.translated(painter().translation()));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/MaybeOwned.h>
|
||||
#include <LibGfx/ScalingMode.h>
|
||||
#include <LibWeb/Painting/DisplayListRecorder.h>
|
||||
|
||||
namespace Web::Painting {
|
||||
|
||||
class DisplayListPlayerCPU : public DisplayListPlayer {
|
||||
public:
|
||||
CommandResult draw_glyph_run(DrawGlyphRun const&) override;
|
||||
CommandResult fill_rect(FillRect const&) override;
|
||||
CommandResult draw_scaled_bitmap(DrawScaledBitmap const&) override;
|
||||
CommandResult draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const&) override;
|
||||
CommandResult save(Save const&) override;
|
||||
CommandResult restore(Restore const&) override;
|
||||
CommandResult add_clip_rect(AddClipRect const&) override;
|
||||
CommandResult push_stacking_context(PushStackingContext const&) override;
|
||||
CommandResult pop_stacking_context(PopStackingContext const&) override;
|
||||
CommandResult paint_linear_gradient(PaintLinearGradient const&) override;
|
||||
CommandResult paint_outer_box_shadow(PaintOuterBoxShadow const&) override;
|
||||
CommandResult paint_inner_box_shadow(PaintInnerBoxShadow const&) override;
|
||||
CommandResult paint_text_shadow(PaintTextShadow const&) override;
|
||||
CommandResult fill_rect_with_rounded_corners(FillRectWithRoundedCorners const&) override;
|
||||
CommandResult fill_path_using_color(FillPathUsingColor const&) override;
|
||||
CommandResult fill_path_using_paint_style(FillPathUsingPaintStyle const&) override;
|
||||
CommandResult stroke_path_using_color(StrokePathUsingColor const&) override;
|
||||
CommandResult stroke_path_using_paint_style(StrokePathUsingPaintStyle const&) override;
|
||||
CommandResult draw_ellipse(DrawEllipse const&) override;
|
||||
CommandResult fill_ellipse(FillEllipse const&) override;
|
||||
CommandResult draw_line(DrawLine const&) override;
|
||||
CommandResult apply_backdrop_filter(ApplyBackdropFilter const&) override;
|
||||
CommandResult draw_rect(DrawRect const&) override;
|
||||
CommandResult paint_radial_gradient(PaintRadialGradient const&) override;
|
||||
CommandResult paint_conic_gradient(PaintConicGradient const&) override;
|
||||
CommandResult draw_triangle_wave(DrawTriangleWave const&) override;
|
||||
CommandResult sample_under_corners(SampleUnderCorners const&) override;
|
||||
CommandResult blit_corner_clipping(BlitCornerClipping const&) override;
|
||||
|
||||
bool would_be_fully_clipped_by_painter(Gfx::IntRect) const override;
|
||||
|
||||
bool needs_prepare_glyphs_texture() const override { return false; }
|
||||
void prepare_glyph_texture(HashMap<Gfx::Font const*, HashTable<u32>> const&) override {};
|
||||
|
||||
virtual void prepare_to_execute(size_t corner_clip_max_depth) override;
|
||||
|
||||
bool needs_update_immutable_bitmap_texture_cache() const override { return false; }
|
||||
void update_immutable_bitmap_texture_cache(HashMap<u32, Gfx::ImmutableBitmap const*>&) override {};
|
||||
|
||||
DisplayListPlayerCPU(Gfx::Bitmap& bitmap);
|
||||
~DisplayListPlayerCPU();
|
||||
|
||||
private:
|
||||
Gfx::Bitmap& m_target_bitmap;
|
||||
|
||||
Vector<RefPtr<BorderRadiusCornerClipper>> m_corner_clippers_stack;
|
||||
|
||||
struct StackingContext {
|
||||
MaybeOwned<Gfx::Painter> painter;
|
||||
float opacity;
|
||||
Gfx::IntRect destination;
|
||||
Gfx::ScalingMode scaling_mode;
|
||||
Optional<StackingContextMask> mask = {};
|
||||
};
|
||||
|
||||
[[nodiscard]] Gfx::Painter const& painter() const { return *stacking_contexts.last().painter; }
|
||||
[[nodiscard]] Gfx::Painter& painter() { return *stacking_contexts.last().painter; }
|
||||
|
||||
Vector<StackingContext> stacking_contexts;
|
||||
};
|
||||
|
||||
}
|
|
@ -7,7 +7,6 @@
|
|||
#include <LibWeb/Layout/ImageBox.h>
|
||||
#include <LibWeb/Layout/SVGClipBox.h>
|
||||
#include <LibWeb/Layout/SVGMaskBox.h>
|
||||
#include <LibWeb/Painting/DisplayListPlayerCPU.h>
|
||||
#include <LibWeb/Painting/DisplayListPlayerSkia.h>
|
||||
#include <LibWeb/Painting/SVGClipPaintable.h>
|
||||
#include <LibWeb/Painting/SVGGraphicsPaintable.h>
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include <LibWeb/HTML/TraversableNavigable.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/Painting/DisplayListPlayerCPU.h>
|
||||
#include <LibWeb/Painting/DisplayListPlayerSkia.h>
|
||||
#include <LibWeb/Painting/PaintContext.h>
|
||||
#include <LibWeb/Painting/ViewportPaintable.h>
|
||||
|
@ -100,11 +99,6 @@ RefPtr<Gfx::Bitmap> SVGDecodedImageData::render(Gfx::IntSize size) const
|
|||
|
||||
auto painting_command_executor_type = m_page_client->display_list_player_type();
|
||||
switch (painting_command_executor_type) {
|
||||
case DisplayListPlayerType::CPU: {
|
||||
Painting::DisplayListPlayerCPU executor { *bitmap };
|
||||
display_list.execute(executor);
|
||||
break;
|
||||
}
|
||||
case DisplayListPlayerType::SkiaGPUIfAvailable:
|
||||
case DisplayListPlayerType::SkiaCPU: {
|
||||
Painting::DisplayListPlayerSkia executor { *bitmap };
|
||||
|
|
Loading…
Reference in a new issue