@@ -41,13 +41,15 @@ void DisplayListRecorder::add_mask(RefPtr<DisplayList> display_list, Gfx::IntRec
41
41
42
42
void DisplayListRecorder::fill_rect (Gfx::IntRect const & rect, Color color)
43
43
{
44
- if (rect.is_empty ())
44
+ if (rect.is_empty () || color. alpha () == 0 )
45
45
return ;
46
46
append (FillRect { rect, color });
47
47
}
48
48
49
49
void DisplayListRecorder::fill_path (FillPathUsingColorParams params)
50
50
{
51
+ if (params.color .alpha () == 0 )
52
+ return ;
51
53
auto aa_translation = params.translation .value_or (Gfx::FloatPoint {});
52
54
auto path_bounding_rect = params.path .bounding_box ().translated (aa_translation);
53
55
auto path_bounding_int_rect = enclosing_int_rect (path_bounding_rect);
@@ -81,6 +83,8 @@ void DisplayListRecorder::fill_path(FillPathUsingPaintStyleParams params)
81
83
82
84
void DisplayListRecorder::stroke_path (StrokePathUsingColorParams params)
83
85
{
86
+ if (params.color .alpha () == 0 )
87
+ return ;
84
88
auto aa_translation = params.translation .value_or (Gfx::FloatPoint {});
85
89
auto path_bounding_rect = params.path .bounding_box ().translated (aa_translation);
86
90
// Increase path bounding box by `thickness` to account for stroke.
@@ -128,7 +132,7 @@ void DisplayListRecorder::stroke_path(StrokePathUsingPaintStyleParams params)
128
132
129
133
void DisplayListRecorder::draw_ellipse (Gfx::IntRect const & a_rect, Color color, int thickness)
130
134
{
131
- if (a_rect.is_empty ())
135
+ if (a_rect.is_empty () || color. alpha () == 0 )
132
136
return ;
133
137
append (DrawEllipse {
134
138
.rect = a_rect,
@@ -139,7 +143,7 @@ void DisplayListRecorder::draw_ellipse(Gfx::IntRect const& a_rect, Color color,
139
143
140
144
void DisplayListRecorder::fill_ellipse (Gfx::IntRect const & a_rect, Color color)
141
145
{
142
- if (a_rect.is_empty ())
146
+ if (a_rect.is_empty () || color. alpha () == 0 )
143
147
return ;
144
148
append (FillEllipse { a_rect, color });
145
149
}
@@ -174,7 +178,7 @@ void DisplayListRecorder::fill_rect_with_radial_gradient(Gfx::IntRect const& rec
174
178
175
179
void DisplayListRecorder::draw_rect (Gfx::IntRect const & rect, Color color, bool rough)
176
180
{
177
- if (rect.is_empty ())
181
+ if (rect.is_empty () || color. alpha () == 0 )
178
182
return ;
179
183
append (DrawRect {
180
184
.rect = rect,
@@ -219,6 +223,8 @@ void DisplayListRecorder::draw_repeated_immutable_bitmap(Gfx::IntRect dst_rect,
219
223
220
224
void DisplayListRecorder::draw_line (Gfx::IntPoint from, Gfx::IntPoint to, Color color, int thickness, Gfx::LineStyle style, Color alternate_color)
221
225
{
226
+ if (color.alpha () == 0 )
227
+ return ;
222
228
append (DrawLine {
223
229
.color = color,
224
230
.from = from,
@@ -231,7 +237,7 @@ void DisplayListRecorder::draw_line(Gfx::IntPoint from, Gfx::IntPoint to, Color
231
237
232
238
void DisplayListRecorder::draw_text (Gfx::IntRect const & rect, String raw_text, Gfx::Font const & font, Gfx::TextAlignment alignment, Color color)
233
239
{
234
- if (rect.is_empty ())
240
+ if (rect.is_empty () || color. alpha () == 0 )
235
241
return ;
236
242
237
243
auto glyph_run = Gfx::shape_text ({}, 0 , raw_text.code_points (), font, Gfx::GlyphRun::TextType::Ltr, {});
@@ -253,6 +259,8 @@ void DisplayListRecorder::draw_text(Gfx::IntRect const& rect, String raw_text, G
253
259
254
260
void DisplayListRecorder::draw_text_run (Gfx::FloatPoint baseline_start, Gfx::GlyphRun const & glyph_run, Color color, Gfx::IntRect const & rect, double scale, Orientation orientation)
255
261
{
262
+ if (color.alpha () == 0 )
263
+ return ;
256
264
append (DrawGlyphRun {
257
265
.glyph_run = glyph_run,
258
266
.scale = scale,
@@ -377,14 +385,14 @@ void DisplayListRecorder::fill_rect_with_rounded_corners(Gfx::IntRect const& rec
377
385
378
386
void DisplayListRecorder::fill_rect_with_rounded_corners (Gfx::IntRect const & a_rect, Color color, int radius)
379
387
{
380
- if (a_rect.is_empty ())
388
+ if (a_rect.is_empty () || color. alpha () == 0 )
381
389
return ;
382
390
fill_rect_with_rounded_corners (a_rect, color, radius, radius, radius, radius);
383
391
}
384
392
385
393
void DisplayListRecorder::fill_rect_with_rounded_corners (Gfx::IntRect const & a_rect, Color color, int top_left_radius, int top_right_radius, int bottom_right_radius, int bottom_left_radius)
386
394
{
387
- if (a_rect.is_empty ())
395
+ if (a_rect.is_empty () || color. alpha () == 0 )
388
396
return ;
389
397
fill_rect_with_rounded_corners (a_rect, color,
390
398
{ top_left_radius, top_left_radius },
@@ -395,6 +403,8 @@ void DisplayListRecorder::fill_rect_with_rounded_corners(Gfx::IntRect const& a_r
395
403
396
404
void DisplayListRecorder::draw_triangle_wave (Gfx::IntPoint a_p1, Gfx::IntPoint a_p2, Color color, int amplitude, int thickness = 1 )
397
405
{
406
+ if (color.alpha () == 0 )
407
+ return ;
398
408
append (DrawTriangleWave {
399
409
.p1 = a_p1,
400
410
.p2 = a_p2,
0 commit comments