mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-27 19:59:03 +00:00
LibWeb: Remove stacking context painting failure handling
CommandResult was needed by LibGfx display list player that could have failed to allocate a temporary bitmap for painting a stacking context with CSS transforms. This is no longer an issue with Skia painter, so we can delete CommandResult::SkipStackingContext handling path.
This commit is contained in:
parent
70e053bbf4
commit
6ae9b54f11
Notes:
github-actions[bot]
2024-07-24 12:58:18 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 6ae9b54f11
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/807
4 changed files with 94 additions and 153 deletions
|
@ -141,13 +141,12 @@ void DisplayList::execute(DisplayListPlayer& executor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HANDLE_COMMAND(command_type, executor_method) \
|
#define HANDLE_COMMAND(command_type, executor_method) \
|
||||||
if (command.has<command_type>()) { \
|
if (command.has<command_type>()) { \
|
||||||
result = executor.executor_method(command.get<command_type>()); \
|
executor.executor_method(command.get<command_type>()); \
|
||||||
}
|
}
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
CommandResult result;
|
|
||||||
HANDLE_COMMAND(DrawGlyphRun, draw_glyph_run)
|
HANDLE_COMMAND(DrawGlyphRun, draw_glyph_run)
|
||||||
else HANDLE_COMMAND(FillRect, fill_rect)
|
else HANDLE_COMMAND(FillRect, fill_rect)
|
||||||
else HANDLE_COMMAND(DrawScaledBitmap, draw_scaled_bitmap)
|
else HANDLE_COMMAND(DrawScaledBitmap, draw_scaled_bitmap)
|
||||||
|
@ -179,22 +178,6 @@ void DisplayList::execute(DisplayListPlayer& executor)
|
||||||
else HANDLE_COMMAND(BlitCornerClipping, blit_corner_clipping)
|
else HANDLE_COMMAND(BlitCornerClipping, blit_corner_clipping)
|
||||||
else VERIFY_NOT_REACHED();
|
else VERIFY_NOT_REACHED();
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
if (result == CommandResult::SkipStackingContext) {
|
|
||||||
auto stacking_context_nesting_level = 1;
|
|
||||||
while (next_command_index < m_commands.size()) {
|
|
||||||
if (m_commands[next_command_index].command.has<PushStackingContext>()) {
|
|
||||||
stacking_context_nesting_level++;
|
|
||||||
} else if (m_commands[next_command_index].command.has<PopStackingContext>()) {
|
|
||||||
stacking_context_nesting_level--;
|
|
||||||
}
|
|
||||||
|
|
||||||
next_command_index++;
|
|
||||||
|
|
||||||
if (stacking_context_nesting_level == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,44 +32,39 @@
|
||||||
|
|
||||||
namespace Web::Painting {
|
namespace Web::Painting {
|
||||||
|
|
||||||
enum class CommandResult {
|
|
||||||
Continue,
|
|
||||||
SkipStackingContext,
|
|
||||||
};
|
|
||||||
|
|
||||||
class DisplayListPlayer {
|
class DisplayListPlayer {
|
||||||
public:
|
public:
|
||||||
virtual ~DisplayListPlayer() = default;
|
virtual ~DisplayListPlayer() = default;
|
||||||
|
|
||||||
virtual CommandResult draw_glyph_run(DrawGlyphRun const&) = 0;
|
virtual void draw_glyph_run(DrawGlyphRun const&) = 0;
|
||||||
virtual CommandResult fill_rect(FillRect const&) = 0;
|
virtual void fill_rect(FillRect const&) = 0;
|
||||||
virtual CommandResult draw_scaled_bitmap(DrawScaledBitmap const&) = 0;
|
virtual void draw_scaled_bitmap(DrawScaledBitmap const&) = 0;
|
||||||
virtual CommandResult draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const&) = 0;
|
virtual void draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const&) = 0;
|
||||||
virtual CommandResult draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const&) = 0;
|
virtual void draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const&) = 0;
|
||||||
virtual CommandResult save(Save const&) = 0;
|
virtual void save(Save const&) = 0;
|
||||||
virtual CommandResult restore(Restore const&) = 0;
|
virtual void restore(Restore const&) = 0;
|
||||||
virtual CommandResult add_clip_rect(AddClipRect const&) = 0;
|
virtual void add_clip_rect(AddClipRect const&) = 0;
|
||||||
virtual CommandResult push_stacking_context(PushStackingContext const&) = 0;
|
virtual void push_stacking_context(PushStackingContext const&) = 0;
|
||||||
virtual CommandResult pop_stacking_context(PopStackingContext const&) = 0;
|
virtual void pop_stacking_context(PopStackingContext const&) = 0;
|
||||||
virtual CommandResult paint_linear_gradient(PaintLinearGradient const&) = 0;
|
virtual void paint_linear_gradient(PaintLinearGradient const&) = 0;
|
||||||
virtual CommandResult paint_radial_gradient(PaintRadialGradient const&) = 0;
|
virtual void paint_radial_gradient(PaintRadialGradient const&) = 0;
|
||||||
virtual CommandResult paint_conic_gradient(PaintConicGradient const&) = 0;
|
virtual void paint_conic_gradient(PaintConicGradient const&) = 0;
|
||||||
virtual CommandResult paint_outer_box_shadow(PaintOuterBoxShadow const&) = 0;
|
virtual void paint_outer_box_shadow(PaintOuterBoxShadow const&) = 0;
|
||||||
virtual CommandResult paint_inner_box_shadow(PaintInnerBoxShadow const&) = 0;
|
virtual void paint_inner_box_shadow(PaintInnerBoxShadow const&) = 0;
|
||||||
virtual CommandResult paint_text_shadow(PaintTextShadow const&) = 0;
|
virtual void paint_text_shadow(PaintTextShadow const&) = 0;
|
||||||
virtual CommandResult fill_rect_with_rounded_corners(FillRectWithRoundedCorners const&) = 0;
|
virtual void fill_rect_with_rounded_corners(FillRectWithRoundedCorners const&) = 0;
|
||||||
virtual CommandResult fill_path_using_color(FillPathUsingColor const&) = 0;
|
virtual void fill_path_using_color(FillPathUsingColor const&) = 0;
|
||||||
virtual CommandResult fill_path_using_paint_style(FillPathUsingPaintStyle const&) = 0;
|
virtual void fill_path_using_paint_style(FillPathUsingPaintStyle const&) = 0;
|
||||||
virtual CommandResult stroke_path_using_color(StrokePathUsingColor const&) = 0;
|
virtual void stroke_path_using_color(StrokePathUsingColor const&) = 0;
|
||||||
virtual CommandResult stroke_path_using_paint_style(StrokePathUsingPaintStyle const&) = 0;
|
virtual void stroke_path_using_paint_style(StrokePathUsingPaintStyle const&) = 0;
|
||||||
virtual CommandResult draw_ellipse(DrawEllipse const&) = 0;
|
virtual void draw_ellipse(DrawEllipse const&) = 0;
|
||||||
virtual CommandResult fill_ellipse(FillEllipse const&) = 0;
|
virtual void fill_ellipse(FillEllipse const&) = 0;
|
||||||
virtual CommandResult draw_line(DrawLine const&) = 0;
|
virtual void draw_line(DrawLine const&) = 0;
|
||||||
virtual CommandResult apply_backdrop_filter(ApplyBackdropFilter const&) = 0;
|
virtual void apply_backdrop_filter(ApplyBackdropFilter const&) = 0;
|
||||||
virtual CommandResult draw_rect(DrawRect const&) = 0;
|
virtual void draw_rect(DrawRect const&) = 0;
|
||||||
virtual CommandResult draw_triangle_wave(DrawTriangleWave const&) = 0;
|
virtual void draw_triangle_wave(DrawTriangleWave const&) = 0;
|
||||||
virtual CommandResult sample_under_corners(SampleUnderCorners const&) = 0;
|
virtual void sample_under_corners(SampleUnderCorners const&) = 0;
|
||||||
virtual CommandResult blit_corner_clipping(BlitCornerClipping const&) = 0;
|
virtual void blit_corner_clipping(BlitCornerClipping const&) = 0;
|
||||||
virtual bool would_be_fully_clipped_by_painter(Gfx::IntRect) const = 0;
|
virtual bool would_be_fully_clipped_by_painter(Gfx::IntRect) const = 0;
|
||||||
virtual bool needs_prepare_glyphs_texture() const { return false; }
|
virtual bool needs_prepare_glyphs_texture() const { return false; }
|
||||||
virtual void prepare_glyph_texture(HashMap<Gfx::Font const*, HashTable<u32>> const& unique_glyphs) = 0;
|
virtual void prepare_glyph_texture(HashMap<Gfx::Font const*, HashTable<u32>> const& unique_glyphs) = 0;
|
||||||
|
|
|
@ -386,7 +386,7 @@ DisplayListPlayerSkia::SkiaSurface& DisplayListPlayerSkia::surface() const
|
||||||
return static_cast<SkiaSurface&>(*m_surface);
|
return static_cast<SkiaSurface&>(*m_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::draw_glyph_run(DrawGlyphRun const& command)
|
void DisplayListPlayerSkia::draw_glyph_run(DrawGlyphRun const& command)
|
||||||
{
|
{
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
|
@ -418,10 +418,9 @@ CommandResult DisplayListPlayerSkia::draw_glyph_run(DrawGlyphRun const& command)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::fill_rect(FillRect const& command)
|
void DisplayListPlayerSkia::fill_rect(FillRect const& command)
|
||||||
{
|
{
|
||||||
APPLY_PATH_CLIP_IF_NEEDED
|
APPLY_PATH_CLIP_IF_NEEDED
|
||||||
|
|
||||||
|
@ -430,10 +429,9 @@ CommandResult DisplayListPlayerSkia::fill_rect(FillRect const& command)
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setColor(to_skia_color(command.color));
|
paint.setColor(to_skia_color(command.color));
|
||||||
canvas.drawRect(to_skia_rect(rect), paint);
|
canvas.drawRect(to_skia_rect(rect), paint);
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::draw_scaled_bitmap(DrawScaledBitmap const& command)
|
void DisplayListPlayerSkia::draw_scaled_bitmap(DrawScaledBitmap const& command)
|
||||||
{
|
{
|
||||||
auto src_rect = to_skia_rect(command.src_rect);
|
auto src_rect = to_skia_rect(command.src_rect);
|
||||||
auto dst_rect = to_skia_rect(command.dst_rect);
|
auto dst_rect = to_skia_rect(command.dst_rect);
|
||||||
|
@ -442,10 +440,9 @@ CommandResult DisplayListPlayerSkia::draw_scaled_bitmap(DrawScaledBitmap const&
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
canvas.drawImageRect(image, src_rect, dst_rect, to_skia_sampling_options(command.scaling_mode), &paint, SkCanvas::kStrict_SrcRectConstraint);
|
canvas.drawImageRect(image, src_rect, dst_rect, to_skia_sampling_options(command.scaling_mode), &paint, SkCanvas::kStrict_SrcRectConstraint);
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const& command)
|
void DisplayListPlayerSkia::draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const& command)
|
||||||
{
|
{
|
||||||
APPLY_PATH_CLIP_IF_NEEDED
|
APPLY_PATH_CLIP_IF_NEEDED
|
||||||
|
|
||||||
|
@ -456,10 +453,9 @@ CommandResult DisplayListPlayerSkia::draw_scaled_immutable_bitmap(DrawScaledImmu
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
canvas.drawImageRect(image, src_rect, dst_rect, to_skia_sampling_options(command.scaling_mode), &paint, SkCanvas::kStrict_SrcRectConstraint);
|
canvas.drawImageRect(image, src_rect, dst_rect, to_skia_sampling_options(command.scaling_mode), &paint, SkCanvas::kStrict_SrcRectConstraint);
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const& command)
|
void DisplayListPlayerSkia::draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const& command)
|
||||||
{
|
{
|
||||||
APPLY_PATH_CLIP_IF_NEEDED
|
APPLY_PATH_CLIP_IF_NEEDED
|
||||||
|
|
||||||
|
@ -481,29 +477,25 @@ CommandResult DisplayListPlayerSkia::draw_repeated_immutable_bitmap(DrawRepeated
|
||||||
paint.setShader(shader);
|
paint.setShader(shader);
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
canvas.drawPaint(paint);
|
canvas.drawPaint(paint);
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::add_clip_rect(AddClipRect const& command)
|
void DisplayListPlayerSkia::add_clip_rect(AddClipRect const& command)
|
||||||
{
|
{
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
auto const& rect = command.rect;
|
auto const& rect = command.rect;
|
||||||
canvas.clipRect(to_skia_rect(rect));
|
canvas.clipRect(to_skia_rect(rect));
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::save(Save const&)
|
void DisplayListPlayerSkia::save(Save const&)
|
||||||
{
|
{
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
canvas.save();
|
canvas.save();
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::restore(Restore const&)
|
void DisplayListPlayerSkia::restore(Restore const&)
|
||||||
{
|
{
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static SkBitmap alpha_mask_from_bitmap(Gfx::Bitmap const& bitmap, Gfx::Bitmap::MaskKind kind)
|
static SkBitmap alpha_mask_from_bitmap(Gfx::Bitmap const& bitmap, Gfx::Bitmap::MaskKind kind)
|
||||||
|
@ -525,7 +517,7 @@ static SkBitmap alpha_mask_from_bitmap(Gfx::Bitmap const& bitmap, Gfx::Bitmap::M
|
||||||
return alpha_mask;
|
return alpha_mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::push_stacking_context(PushStackingContext const& command)
|
void DisplayListPlayerSkia::push_stacking_context(PushStackingContext const& command)
|
||||||
{
|
{
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
|
|
||||||
|
@ -560,14 +552,11 @@ CommandResult DisplayListPlayerSkia::push_stacking_context(PushStackingContext c
|
||||||
canvas.resetMatrix();
|
canvas.resetMatrix();
|
||||||
}
|
}
|
||||||
canvas.concat(matrix);
|
canvas.concat(matrix);
|
||||||
|
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::pop_stacking_context(PopStackingContext const&)
|
void DisplayListPlayerSkia::pop_stacking_context(PopStackingContext const&)
|
||||||
{
|
{
|
||||||
surface().canvas().restore();
|
surface().canvas().restore();
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ColorStopList replace_transition_hints_with_normal_color_stops(ColorStopList const& color_stop_list)
|
static ColorStopList replace_transition_hints_with_normal_color_stops(ColorStopList const& color_stop_list)
|
||||||
|
@ -664,7 +653,7 @@ static ColorStopList expand_repeat_length(ColorStopList const& color_stop_list,
|
||||||
return color_stop_list_with_expanded_repeat;
|
return color_stop_list_with_expanded_repeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::paint_linear_gradient(PaintLinearGradient const& command)
|
void DisplayListPlayerSkia::paint_linear_gradient(PaintLinearGradient const& command)
|
||||||
{
|
{
|
||||||
APPLY_PATH_CLIP_IF_NEEDED
|
APPLY_PATH_CLIP_IF_NEEDED
|
||||||
|
|
||||||
|
@ -709,8 +698,6 @@ CommandResult DisplayListPlayerSkia::paint_linear_gradient(PaintLinearGradient c
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setShader(shader);
|
paint.setShader(shader);
|
||||||
surface().canvas().drawRect(to_skia_rect(rect), paint);
|
surface().canvas().drawRect(to_skia_rect(rect), paint);
|
||||||
|
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_spread_distance_to_border_radius(int& border_radius, int spread_distance)
|
static void add_spread_distance_to_border_radius(int& border_radius, int spread_distance)
|
||||||
|
@ -734,7 +721,7 @@ static void add_spread_distance_to_border_radius(int& border_radius, int spread_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::paint_outer_box_shadow(PaintOuterBoxShadow const& command)
|
void DisplayListPlayerSkia::paint_outer_box_shadow(PaintOuterBoxShadow const& command)
|
||||||
{
|
{
|
||||||
auto const& outer_box_shadow_params = command.box_shadow_params;
|
auto const& outer_box_shadow_params = command.box_shadow_params;
|
||||||
auto const& color = outer_box_shadow_params.color;
|
auto const& color = outer_box_shadow_params.color;
|
||||||
|
@ -770,11 +757,9 @@ CommandResult DisplayListPlayerSkia::paint_outer_box_shadow(PaintOuterBoxShadow
|
||||||
auto shadow_rounded_rect = to_skia_rrect(shadow_rect, corner_radii);
|
auto shadow_rounded_rect = to_skia_rrect(shadow_rect, corner_radii);
|
||||||
canvas.drawRRect(shadow_rounded_rect, paint);
|
canvas.drawRRect(shadow_rounded_rect, paint);
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
|
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::paint_inner_box_shadow(PaintInnerBoxShadow const& command)
|
void DisplayListPlayerSkia::paint_inner_box_shadow(PaintInnerBoxShadow const& command)
|
||||||
{
|
{
|
||||||
auto const& outer_box_shadow_params = command.box_shadow_params;
|
auto const& outer_box_shadow_params = command.box_shadow_params;
|
||||||
auto color = outer_box_shadow_params.color;
|
auto color = outer_box_shadow_params.color;
|
||||||
|
@ -827,11 +812,9 @@ CommandResult DisplayListPlayerSkia::paint_inner_box_shadow(PaintInnerBoxShadow
|
||||||
canvas.clipRRect(to_skia_rrect(device_content_rect, corner_radii), true);
|
canvas.clipRRect(to_skia_rrect(device_content_rect, corner_radii), true);
|
||||||
canvas.drawPath(result_path, path_paint);
|
canvas.drawPath(result_path, path_paint);
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
|
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::paint_text_shadow(PaintTextShadow const& command)
|
void DisplayListPlayerSkia::paint_text_shadow(PaintTextShadow const& command)
|
||||||
{
|
{
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
auto blur_image_filter = SkImageFilters::Blur(command.blur_radius / 2, command.blur_radius / 2, nullptr);
|
auto blur_image_filter = SkImageFilters::Blur(command.blur_radius / 2, command.blur_radius / 2, nullptr);
|
||||||
|
@ -846,10 +829,9 @@ CommandResult DisplayListPlayerSkia::paint_text_shadow(PaintTextShadow const& co
|
||||||
.scale = command.glyph_run_scale,
|
.scale = command.glyph_run_scale,
|
||||||
});
|
});
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::fill_rect_with_rounded_corners(FillRectWithRoundedCorners const& command)
|
void DisplayListPlayerSkia::fill_rect_with_rounded_corners(FillRectWithRoundedCorners const& command)
|
||||||
{
|
{
|
||||||
APPLY_PATH_CLIP_IF_NEEDED
|
APPLY_PATH_CLIP_IF_NEEDED
|
||||||
|
|
||||||
|
@ -862,11 +844,9 @@ CommandResult DisplayListPlayerSkia::fill_rect_with_rounded_corners(FillRectWith
|
||||||
|
|
||||||
auto rounded_rect = to_skia_rrect(rect, command.corner_radii);
|
auto rounded_rect = to_skia_rrect(rect, command.corner_radii);
|
||||||
canvas.drawRRect(rounded_rect, paint);
|
canvas.drawRRect(rounded_rect, paint);
|
||||||
|
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::fill_path_using_color(FillPathUsingColor const& command)
|
void DisplayListPlayerSkia::fill_path_using_color(FillPathUsingColor const& command)
|
||||||
{
|
{
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
|
@ -876,7 +856,6 @@ CommandResult DisplayListPlayerSkia::fill_path_using_color(FillPathUsingColor co
|
||||||
path.setFillType(to_skia_path_fill_type(command.winding_rule));
|
path.setFillType(to_skia_path_fill_type(command.winding_rule));
|
||||||
path.offset(command.aa_translation.x(), command.aa_translation.y());
|
path.offset(command.aa_translation.x(), command.aa_translation.y());
|
||||||
canvas.drawPath(path, paint);
|
canvas.drawPath(path, paint);
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static SkTileMode to_skia_tile_mode(SVGLinearGradientPaintStyle::SpreadMethod spread_method)
|
static SkTileMode to_skia_tile_mode(SVGLinearGradientPaintStyle::SpreadMethod spread_method)
|
||||||
|
@ -950,7 +929,7 @@ static SkPaint paint_style_to_skia_paint(Painting::SVGGradientPaintStyle const&
|
||||||
return paint;
|
return paint;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::fill_path_using_paint_style(FillPathUsingPaintStyle const& command)
|
void DisplayListPlayerSkia::fill_path_using_paint_style(FillPathUsingPaintStyle const& command)
|
||||||
{
|
{
|
||||||
auto path = to_skia_path(command.path);
|
auto path = to_skia_path(command.path);
|
||||||
path.offset(command.aa_translation.x(), command.aa_translation.y());
|
path.offset(command.aa_translation.x(), command.aa_translation.y());
|
||||||
|
@ -959,14 +938,13 @@ CommandResult DisplayListPlayerSkia::fill_path_using_paint_style(FillPathUsingPa
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
paint.setAlphaf(command.opacity);
|
paint.setAlphaf(command.opacity);
|
||||||
surface().canvas().drawPath(path, paint);
|
surface().canvas().drawPath(path, paint);
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::stroke_path_using_color(StrokePathUsingColor const& command)
|
void DisplayListPlayerSkia::stroke_path_using_color(StrokePathUsingColor const& command)
|
||||||
{
|
{
|
||||||
// Skia treats zero thickness as a special case and will draw a hairline, while we want to draw nothing.
|
// Skia treats zero thickness as a special case and will draw a hairline, while we want to draw nothing.
|
||||||
if (!command.thickness)
|
if (!command.thickness)
|
||||||
return CommandResult::Continue;
|
return;
|
||||||
|
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
|
@ -977,14 +955,13 @@ CommandResult DisplayListPlayerSkia::stroke_path_using_color(StrokePathUsingColo
|
||||||
auto path = to_skia_path(command.path);
|
auto path = to_skia_path(command.path);
|
||||||
path.offset(command.aa_translation.x(), command.aa_translation.y());
|
path.offset(command.aa_translation.x(), command.aa_translation.y());
|
||||||
canvas.drawPath(path, paint);
|
canvas.drawPath(path, paint);
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::stroke_path_using_paint_style(StrokePathUsingPaintStyle const& command)
|
void DisplayListPlayerSkia::stroke_path_using_paint_style(StrokePathUsingPaintStyle const& command)
|
||||||
{
|
{
|
||||||
// Skia treats zero thickness as a special case and will draw a hairline, while we want to draw nothing.
|
// Skia treats zero thickness as a special case and will draw a hairline, while we want to draw nothing.
|
||||||
if (!command.thickness)
|
if (!command.thickness)
|
||||||
return CommandResult::Continue;
|
return;
|
||||||
|
|
||||||
auto path = to_skia_path(command.path);
|
auto path = to_skia_path(command.path);
|
||||||
path.offset(command.aa_translation.x(), command.aa_translation.y());
|
path.offset(command.aa_translation.x(), command.aa_translation.y());
|
||||||
|
@ -994,14 +971,13 @@ CommandResult DisplayListPlayerSkia::stroke_path_using_paint_style(StrokePathUsi
|
||||||
paint.setStyle(SkPaint::Style::kStroke_Style);
|
paint.setStyle(SkPaint::Style::kStroke_Style);
|
||||||
paint.setStrokeWidth(command.thickness);
|
paint.setStrokeWidth(command.thickness);
|
||||||
surface().canvas().drawPath(path, paint);
|
surface().canvas().drawPath(path, paint);
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::draw_ellipse(DrawEllipse const& command)
|
void DisplayListPlayerSkia::draw_ellipse(DrawEllipse const& command)
|
||||||
{
|
{
|
||||||
// Skia treats zero thickness as a special case and will draw a hairline, while we want to draw nothing.
|
// Skia treats zero thickness as a special case and will draw a hairline, while we want to draw nothing.
|
||||||
if (!command.thickness)
|
if (!command.thickness)
|
||||||
return CommandResult::Continue;
|
return;
|
||||||
|
|
||||||
auto const& rect = command.rect;
|
auto const& rect = command.rect;
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
|
@ -1011,10 +987,9 @@ CommandResult DisplayListPlayerSkia::draw_ellipse(DrawEllipse const& command)
|
||||||
paint.setStrokeWidth(command.thickness);
|
paint.setStrokeWidth(command.thickness);
|
||||||
paint.setColor(to_skia_color(command.color));
|
paint.setColor(to_skia_color(command.color));
|
||||||
canvas.drawOval(to_skia_rect(rect), paint);
|
canvas.drawOval(to_skia_rect(rect), paint);
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::fill_ellipse(FillEllipse const& command)
|
void DisplayListPlayerSkia::fill_ellipse(FillEllipse const& command)
|
||||||
{
|
{
|
||||||
auto const& rect = command.rect;
|
auto const& rect = command.rect;
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
|
@ -1022,14 +997,13 @@ CommandResult DisplayListPlayerSkia::fill_ellipse(FillEllipse const& command)
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
paint.setColor(to_skia_color(command.color));
|
paint.setColor(to_skia_color(command.color));
|
||||||
canvas.drawOval(to_skia_rect(rect), paint);
|
canvas.drawOval(to_skia_rect(rect), paint);
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::draw_line(DrawLine const& command)
|
void DisplayListPlayerSkia::draw_line(DrawLine const& command)
|
||||||
{
|
{
|
||||||
// Skia treats zero thickness as a special case and will draw a hairline, while we want to draw nothing.
|
// Skia treats zero thickness as a special case and will draw a hairline, while we want to draw nothing.
|
||||||
if (!command.thickness)
|
if (!command.thickness)
|
||||||
return CommandResult::Continue;
|
return;
|
||||||
|
|
||||||
auto from = to_skia_point(command.from);
|
auto from = to_skia_point(command.from);
|
||||||
auto to = to_skia_point(command.to);
|
auto to = to_skia_point(command.to);
|
||||||
|
@ -1074,10 +1048,9 @@ CommandResult DisplayListPlayerSkia::draw_line(DrawLine const& command)
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas.drawLine(from, to, paint);
|
canvas.drawLine(from, to, paint);
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::apply_backdrop_filter(ApplyBackdropFilter const& command)
|
void DisplayListPlayerSkia::apply_backdrop_filter(ApplyBackdropFilter const& command)
|
||||||
{
|
{
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
|
|
||||||
|
@ -1211,11 +1184,9 @@ CommandResult DisplayListPlayerSkia::apply_backdrop_filter(ApplyBackdropFilter c
|
||||||
dbgln("TODO: Implement drop-shadow() filter function!");
|
dbgln("TODO: Implement drop-shadow() filter function!");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::draw_rect(DrawRect const& command)
|
void DisplayListPlayerSkia::draw_rect(DrawRect const& command)
|
||||||
{
|
{
|
||||||
auto const& rect = command.rect;
|
auto const& rect = command.rect;
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
|
@ -1225,10 +1196,9 @@ CommandResult DisplayListPlayerSkia::draw_rect(DrawRect const& command)
|
||||||
paint.setStrokeWidth(1);
|
paint.setStrokeWidth(1);
|
||||||
paint.setColor(to_skia_color(command.color));
|
paint.setColor(to_skia_color(command.color));
|
||||||
canvas.drawRect(to_skia_rect(rect), paint);
|
canvas.drawRect(to_skia_rect(rect), paint);
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::paint_radial_gradient(PaintRadialGradient const& command)
|
void DisplayListPlayerSkia::paint_radial_gradient(PaintRadialGradient const& command)
|
||||||
{
|
{
|
||||||
APPLY_PATH_CLIP_IF_NEEDED
|
APPLY_PATH_CLIP_IF_NEEDED
|
||||||
|
|
||||||
|
@ -1275,11 +1245,9 @@ CommandResult DisplayListPlayerSkia::paint_radial_gradient(PaintRadialGradient c
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
paint.setShader(shader);
|
paint.setShader(shader);
|
||||||
surface().canvas().drawRect(to_skia_rect(rect), paint);
|
surface().canvas().drawRect(to_skia_rect(rect), paint);
|
||||||
|
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::paint_conic_gradient(PaintConicGradient const& command)
|
void DisplayListPlayerSkia::paint_conic_gradient(PaintConicGradient const& command)
|
||||||
{
|
{
|
||||||
APPLY_PATH_CLIP_IF_NEEDED
|
APPLY_PATH_CLIP_IF_NEEDED
|
||||||
|
|
||||||
|
@ -1318,34 +1286,29 @@ CommandResult DisplayListPlayerSkia::paint_conic_gradient(PaintConicGradient con
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
paint.setShader(shader);
|
paint.setShader(shader);
|
||||||
surface().canvas().drawRect(to_skia_rect(rect), paint);
|
surface().canvas().drawRect(to_skia_rect(rect), paint);
|
||||||
|
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::draw_triangle_wave(DrawTriangleWave const&)
|
void DisplayListPlayerSkia::draw_triangle_wave(DrawTriangleWave const&)
|
||||||
{
|
{
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayListPlayerSkia::prepare_to_execute(size_t)
|
void DisplayListPlayerSkia::prepare_to_execute(size_t)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::sample_under_corners(SampleUnderCorners const& command)
|
void DisplayListPlayerSkia::sample_under_corners(SampleUnderCorners const& command)
|
||||||
{
|
{
|
||||||
auto rounded_rect = to_skia_rrect(command.border_rect, command.corner_radii);
|
auto rounded_rect = to_skia_rrect(command.border_rect, command.corner_radii);
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
canvas.save();
|
canvas.save();
|
||||||
auto clip_op = command.corner_clip == CornerClip::Inside ? SkClipOp::kDifference : SkClipOp::kIntersect;
|
auto clip_op = command.corner_clip == CornerClip::Inside ? SkClipOp::kDifference : SkClipOp::kIntersect;
|
||||||
canvas.clipRRect(rounded_rect, clip_op, true);
|
canvas.clipRRect(rounded_rect, clip_op, true);
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult DisplayListPlayerSkia::blit_corner_clipping(BlitCornerClipping const&)
|
void DisplayListPlayerSkia::blit_corner_clipping(BlitCornerClipping const&)
|
||||||
{
|
{
|
||||||
auto& canvas = surface().canvas();
|
auto& canvas = surface().canvas();
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
return CommandResult::Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DisplayListPlayerSkia::would_be_fully_clipped_by_painter(Gfx::IntRect rect) const
|
bool DisplayListPlayerSkia::would_be_fully_clipped_by_painter(Gfx::IntRect rect) const
|
||||||
|
|
|
@ -33,35 +33,35 @@ public:
|
||||||
|
|
||||||
class DisplayListPlayerSkia : public DisplayListPlayer {
|
class DisplayListPlayerSkia : public DisplayListPlayer {
|
||||||
public:
|
public:
|
||||||
CommandResult draw_glyph_run(DrawGlyphRun const&) override;
|
void draw_glyph_run(DrawGlyphRun const&) override;
|
||||||
CommandResult fill_rect(FillRect const&) override;
|
void fill_rect(FillRect const&) override;
|
||||||
CommandResult draw_scaled_bitmap(DrawScaledBitmap const&) override;
|
void draw_scaled_bitmap(DrawScaledBitmap const&) override;
|
||||||
CommandResult draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const&) override;
|
void draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const&) override;
|
||||||
CommandResult draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const&) override;
|
void draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const&) override;
|
||||||
CommandResult add_clip_rect(AddClipRect const&) override;
|
void add_clip_rect(AddClipRect const&) override;
|
||||||
CommandResult save(Save const&) override;
|
void save(Save const&) override;
|
||||||
CommandResult restore(Restore const&) override;
|
void restore(Restore const&) override;
|
||||||
CommandResult push_stacking_context(PushStackingContext const&) override;
|
void push_stacking_context(PushStackingContext const&) override;
|
||||||
CommandResult pop_stacking_context(PopStackingContext const&) override;
|
void pop_stacking_context(PopStackingContext const&) override;
|
||||||
CommandResult paint_linear_gradient(PaintLinearGradient const&) override;
|
void paint_linear_gradient(PaintLinearGradient const&) override;
|
||||||
CommandResult paint_outer_box_shadow(PaintOuterBoxShadow const&) override;
|
void paint_outer_box_shadow(PaintOuterBoxShadow const&) override;
|
||||||
CommandResult paint_inner_box_shadow(PaintInnerBoxShadow const&) override;
|
void paint_inner_box_shadow(PaintInnerBoxShadow const&) override;
|
||||||
CommandResult paint_text_shadow(PaintTextShadow const&) override;
|
void paint_text_shadow(PaintTextShadow const&) override;
|
||||||
CommandResult fill_rect_with_rounded_corners(FillRectWithRoundedCorners const&) override;
|
void fill_rect_with_rounded_corners(FillRectWithRoundedCorners const&) override;
|
||||||
CommandResult fill_path_using_color(FillPathUsingColor const&) override;
|
void fill_path_using_color(FillPathUsingColor const&) override;
|
||||||
CommandResult fill_path_using_paint_style(FillPathUsingPaintStyle const&) override;
|
void fill_path_using_paint_style(FillPathUsingPaintStyle const&) override;
|
||||||
CommandResult stroke_path_using_color(StrokePathUsingColor const&) override;
|
void stroke_path_using_color(StrokePathUsingColor const&) override;
|
||||||
CommandResult stroke_path_using_paint_style(StrokePathUsingPaintStyle const&) override;
|
void stroke_path_using_paint_style(StrokePathUsingPaintStyle const&) override;
|
||||||
CommandResult draw_ellipse(DrawEllipse const&) override;
|
void draw_ellipse(DrawEllipse const&) override;
|
||||||
CommandResult fill_ellipse(FillEllipse const&) override;
|
void fill_ellipse(FillEllipse const&) override;
|
||||||
CommandResult draw_line(DrawLine const&) override;
|
void draw_line(DrawLine const&) override;
|
||||||
CommandResult apply_backdrop_filter(ApplyBackdropFilter const&) override;
|
void apply_backdrop_filter(ApplyBackdropFilter const&) override;
|
||||||
CommandResult draw_rect(DrawRect const&) override;
|
void draw_rect(DrawRect const&) override;
|
||||||
CommandResult paint_radial_gradient(PaintRadialGradient const&) override;
|
void paint_radial_gradient(PaintRadialGradient const&) override;
|
||||||
CommandResult paint_conic_gradient(PaintConicGradient const&) override;
|
void paint_conic_gradient(PaintConicGradient const&) override;
|
||||||
CommandResult draw_triangle_wave(DrawTriangleWave const&) override;
|
void draw_triangle_wave(DrawTriangleWave const&) override;
|
||||||
CommandResult sample_under_corners(SampleUnderCorners const&) override;
|
void sample_under_corners(SampleUnderCorners const&) override;
|
||||||
CommandResult blit_corner_clipping(BlitCornerClipping const&) override;
|
void blit_corner_clipping(BlitCornerClipping const&) override;
|
||||||
|
|
||||||
bool would_be_fully_clipped_by_painter(Gfx::IntRect) const override;
|
bool would_be_fully_clipped_by_painter(Gfx::IntRect) const override;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue