mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:07:45 +00:00
LibWeb/Painting: Do not paint paths not visible in viewport
Painting optimization to do less unnecessary work
This commit is contained in:
parent
708574d373
commit
3fb2b008a2
2 changed files with 20 additions and 0 deletions
|
@ -87,6 +87,8 @@ CommandResult DrawTextRun::execute(CommandExecutionState& state) const
|
||||||
|
|
||||||
CommandResult FillPathUsingColor::execute(CommandExecutionState& state) const
|
CommandResult FillPathUsingColor::execute(CommandExecutionState& state) const
|
||||||
{
|
{
|
||||||
|
if (state.would_be_fully_clipped_by_painter(bounding_rect))
|
||||||
|
return CommandResult::Continue;
|
||||||
auto& painter = state.painter();
|
auto& painter = state.painter();
|
||||||
Gfx::AntiAliasingPainter aa_painter(painter);
|
Gfx::AntiAliasingPainter aa_painter(painter);
|
||||||
if (aa_translation.has_value())
|
if (aa_translation.has_value())
|
||||||
|
@ -97,6 +99,8 @@ CommandResult FillPathUsingColor::execute(CommandExecutionState& state) const
|
||||||
|
|
||||||
CommandResult FillPathUsingPaintStyle::execute(CommandExecutionState& state) const
|
CommandResult FillPathUsingPaintStyle::execute(CommandExecutionState& state) const
|
||||||
{
|
{
|
||||||
|
if (state.would_be_fully_clipped_by_painter(bounding_rect))
|
||||||
|
return CommandResult::Continue;
|
||||||
auto& painter = state.painter();
|
auto& painter = state.painter();
|
||||||
Gfx::AntiAliasingPainter aa_painter(painter);
|
Gfx::AntiAliasingPainter aa_painter(painter);
|
||||||
if (aa_translation.has_value())
|
if (aa_translation.has_value())
|
||||||
|
@ -107,6 +111,8 @@ CommandResult FillPathUsingPaintStyle::execute(CommandExecutionState& state) con
|
||||||
|
|
||||||
CommandResult StrokePathUsingColor::execute(CommandExecutionState& state) const
|
CommandResult StrokePathUsingColor::execute(CommandExecutionState& state) const
|
||||||
{
|
{
|
||||||
|
if (state.would_be_fully_clipped_by_painter(bounding_rect))
|
||||||
|
return CommandResult::Continue;
|
||||||
auto& painter = state.painter();
|
auto& painter = state.painter();
|
||||||
Gfx::AntiAliasingPainter aa_painter(painter);
|
Gfx::AntiAliasingPainter aa_painter(painter);
|
||||||
if (aa_translation.has_value())
|
if (aa_translation.has_value())
|
||||||
|
@ -117,6 +123,8 @@ CommandResult StrokePathUsingColor::execute(CommandExecutionState& state) const
|
||||||
|
|
||||||
CommandResult StrokePathUsingPaintStyle::execute(CommandExecutionState& state) const
|
CommandResult StrokePathUsingPaintStyle::execute(CommandExecutionState& state) const
|
||||||
{
|
{
|
||||||
|
if (state.would_be_fully_clipped_by_painter(bounding_rect))
|
||||||
|
return CommandResult::Continue;
|
||||||
auto& painter = state.painter();
|
auto& painter = state.painter();
|
||||||
Gfx::AntiAliasingPainter aa_painter(painter);
|
Gfx::AntiAliasingPainter aa_painter(painter);
|
||||||
if (aa_translation.has_value())
|
if (aa_translation.has_value())
|
||||||
|
@ -526,7 +534,9 @@ void RecordingPainter::fill_rect(Gfx::IntRect const& rect, Color color)
|
||||||
|
|
||||||
void RecordingPainter::fill_path(FillPathUsingColorParams params)
|
void RecordingPainter::fill_path(FillPathUsingColorParams params)
|
||||||
{
|
{
|
||||||
|
auto bounding_rect = params.path.bounding_box().translated(params.translation.value_or({})).to_type<int>();
|
||||||
push_command(FillPathUsingColor {
|
push_command(FillPathUsingColor {
|
||||||
|
.bounding_rect = bounding_rect,
|
||||||
.path = params.path,
|
.path = params.path,
|
||||||
.color = params.color,
|
.color = params.color,
|
||||||
.winding_rule = params.winding_rule,
|
.winding_rule = params.winding_rule,
|
||||||
|
@ -536,7 +546,9 @@ void RecordingPainter::fill_path(FillPathUsingColorParams params)
|
||||||
|
|
||||||
void RecordingPainter::fill_path(FillPathUsingPaintStyleParams params)
|
void RecordingPainter::fill_path(FillPathUsingPaintStyleParams params)
|
||||||
{
|
{
|
||||||
|
auto bounding_rect = params.path.bounding_box().translated(params.translation.value_or({})).to_type<int>();
|
||||||
push_command(FillPathUsingPaintStyle {
|
push_command(FillPathUsingPaintStyle {
|
||||||
|
.bounding_rect = bounding_rect,
|
||||||
.path = params.path,
|
.path = params.path,
|
||||||
.paint_style = params.paint_style,
|
.paint_style = params.paint_style,
|
||||||
.winding_rule = params.winding_rule,
|
.winding_rule = params.winding_rule,
|
||||||
|
@ -547,7 +559,9 @@ void RecordingPainter::fill_path(FillPathUsingPaintStyleParams params)
|
||||||
|
|
||||||
void RecordingPainter::stroke_path(StrokePathUsingColorParams params)
|
void RecordingPainter::stroke_path(StrokePathUsingColorParams params)
|
||||||
{
|
{
|
||||||
|
auto bounding_rect = params.path.bounding_box().translated(params.translation.value_or({})).to_type<int>();
|
||||||
push_command(StrokePathUsingColor {
|
push_command(StrokePathUsingColor {
|
||||||
|
.bounding_rect = bounding_rect,
|
||||||
.path = params.path,
|
.path = params.path,
|
||||||
.color = params.color,
|
.color = params.color,
|
||||||
.thickness = params.thickness,
|
.thickness = params.thickness,
|
||||||
|
@ -557,7 +571,9 @@ void RecordingPainter::stroke_path(StrokePathUsingColorParams params)
|
||||||
|
|
||||||
void RecordingPainter::stroke_path(StrokePathUsingPaintStyleParams params)
|
void RecordingPainter::stroke_path(StrokePathUsingPaintStyleParams params)
|
||||||
{
|
{
|
||||||
|
auto bounding_rect = params.path.bounding_box().translated(params.translation.value_or({})).to_type<int>();
|
||||||
push_command(StrokePathUsingPaintStyle {
|
push_command(StrokePathUsingPaintStyle {
|
||||||
|
.bounding_rect = bounding_rect,
|
||||||
.path = params.path,
|
.path = params.path,
|
||||||
.paint_style = params.paint_style,
|
.paint_style = params.paint_style,
|
||||||
.thickness = params.thickness,
|
.thickness = params.thickness,
|
||||||
|
|
|
@ -194,6 +194,7 @@ struct FillRectWithRoundedCorners {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FillPathUsingColor {
|
struct FillPathUsingColor {
|
||||||
|
Gfx::IntRect bounding_rect;
|
||||||
Gfx::Path path;
|
Gfx::Path path;
|
||||||
Color color;
|
Color color;
|
||||||
Gfx::Painter::WindingRule winding_rule;
|
Gfx::Painter::WindingRule winding_rule;
|
||||||
|
@ -203,6 +204,7 @@ struct FillPathUsingColor {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FillPathUsingPaintStyle {
|
struct FillPathUsingPaintStyle {
|
||||||
|
Gfx::IntRect bounding_rect;
|
||||||
Gfx::Path path;
|
Gfx::Path path;
|
||||||
NonnullRefPtr<Gfx::PaintStyle> paint_style;
|
NonnullRefPtr<Gfx::PaintStyle> paint_style;
|
||||||
Gfx::Painter::WindingRule winding_rule;
|
Gfx::Painter::WindingRule winding_rule;
|
||||||
|
@ -213,6 +215,7 @@ struct FillPathUsingPaintStyle {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StrokePathUsingColor {
|
struct StrokePathUsingColor {
|
||||||
|
Gfx::IntRect bounding_rect;
|
||||||
Gfx::Path path;
|
Gfx::Path path;
|
||||||
Color color;
|
Color color;
|
||||||
float thickness;
|
float thickness;
|
||||||
|
@ -222,6 +225,7 @@ struct StrokePathUsingColor {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StrokePathUsingPaintStyle {
|
struct StrokePathUsingPaintStyle {
|
||||||
|
Gfx::IntRect bounding_rect;
|
||||||
Gfx::Path path;
|
Gfx::Path path;
|
||||||
NonnullRefPtr<Gfx::PaintStyle> paint_style;
|
NonnullRefPtr<Gfx::PaintStyle> paint_style;
|
||||||
float thickness;
|
float thickness;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue