mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 05:37:44 +00:00
Everywhere: Use ReadonlySpan<T> instead of Span<T const>
This commit is contained in:
parent
1c92e6ee9d
commit
63b11030f0
102 changed files with 206 additions and 206 deletions
|
@ -25,7 +25,7 @@ Bitmap const* Emoji::emoji_for_code_point(u32 code_point)
|
|||
return emoji_for_code_points(Array { code_point });
|
||||
}
|
||||
|
||||
Bitmap const* Emoji::emoji_for_code_points(Span<u32 const> const& code_points)
|
||||
Bitmap const* Emoji::emoji_for_code_points(ReadonlySpan<u32> const& code_points)
|
||||
{
|
||||
// FIXME: This function is definitely not fast.
|
||||
auto basename = DeprecatedString::join('_', code_points, "U+{:X}"sv);
|
||||
|
|
|
@ -17,7 +17,7 @@ class Bitmap;
|
|||
class Emoji {
|
||||
public:
|
||||
static Gfx::Bitmap const* emoji_for_code_point(u32 code_point);
|
||||
static Gfx::Bitmap const* emoji_for_code_points(Span<u32 const> const&);
|
||||
static Gfx::Bitmap const* emoji_for_code_points(ReadonlySpan<u32> const&);
|
||||
static Gfx::Bitmap const* emoji_for_code_point_iterator(Utf8CodePointIterator&);
|
||||
};
|
||||
|
||||
|
|
|
@ -274,7 +274,7 @@ Optional<i16> Kern::read_glyph_kerning_format0(ReadonlyBytes slice, u16 left_gly
|
|||
return {};
|
||||
|
||||
// FIXME: implement a possibly slightly more efficient binary search using the parameters above
|
||||
Span<Format0Pair const> pairs { bit_cast<Format0Pair const*>(slice.slice(sizeof(Format0)).data()), number_of_pairs };
|
||||
ReadonlySpan<Format0Pair> pairs { bit_cast<Format0Pair const*>(slice.slice(sizeof(Format0)).data()), number_of_pairs };
|
||||
|
||||
// The left and right halves of the kerning pair make an unsigned 32-bit number, which is then used to order the kerning pairs numerically.
|
||||
auto needle = (static_cast<u32>(left_glyph_id) << 16u) | static_cast<u32>(right_glyph_id);
|
||||
|
|
|
@ -52,7 +52,7 @@ enum class UsePremultipliedAlpha {
|
|||
|
||||
class GradientLine {
|
||||
public:
|
||||
GradientLine(int gradient_length, Span<ColorStop const> color_stops, Optional<float> repeat_length, UsePremultipliedAlpha use_premultiplied_alpha = UsePremultipliedAlpha::Yes)
|
||||
GradientLine(int gradient_length, ReadonlySpan<ColorStop> color_stops, Optional<float> repeat_length, UsePremultipliedAlpha use_premultiplied_alpha = UsePremultipliedAlpha::Yes)
|
||||
: m_repeating(repeat_length.has_value())
|
||||
, m_start_offset(round_to<int>((m_repeating ? color_stops.first().position : 0.0f) * gradient_length))
|
||||
, m_color_stops(color_stops)
|
||||
|
@ -133,7 +133,7 @@ private:
|
|||
bool m_repeating { false };
|
||||
int m_start_offset { 0 };
|
||||
float m_sample_scale { 1 };
|
||||
Span<ColorStop const> m_color_stops {};
|
||||
ReadonlySpan<ColorStop> m_color_stops {};
|
||||
UsePremultipliedAlpha m_use_premultiplied_alpha { UsePremultipliedAlpha::Yes };
|
||||
|
||||
Vector<Color, 1024> m_gradient_line_colors;
|
||||
|
@ -165,7 +165,7 @@ private:
|
|||
TransformFunction m_transform_function;
|
||||
};
|
||||
|
||||
static auto create_linear_gradient(IntRect const& physical_rect, Span<ColorStop const> color_stops, float angle, Optional<float> repeat_length)
|
||||
static auto create_linear_gradient(IntRect const& physical_rect, ReadonlySpan<ColorStop> color_stops, float angle, Optional<float> repeat_length)
|
||||
{
|
||||
float normalized_angle = normalized_gradient_angle_radians(angle);
|
||||
float sin_angle, cos_angle;
|
||||
|
@ -188,7 +188,7 @@ static auto create_linear_gradient(IntRect const& physical_rect, Span<ColorStop
|
|||
};
|
||||
}
|
||||
|
||||
static auto create_conic_gradient(Span<ColorStop const> color_stops, FloatPoint center_point, float start_angle, Optional<float> repeat_length, UsePremultipliedAlpha use_premultiplied_alpha = UsePremultipliedAlpha::Yes)
|
||||
static auto create_conic_gradient(ReadonlySpan<ColorStop> color_stops, FloatPoint center_point, float start_angle, Optional<float> repeat_length, UsePremultipliedAlpha use_premultiplied_alpha = UsePremultipliedAlpha::Yes)
|
||||
{
|
||||
// FIXME: Do we need/want sub-degree accuracy for the gradient line?
|
||||
GradientLine gradient_line(360, color_stops, repeat_length, use_premultiplied_alpha);
|
||||
|
@ -213,7 +213,7 @@ static auto create_conic_gradient(Span<ColorStop const> color_stops, FloatPoint
|
|||
};
|
||||
}
|
||||
|
||||
static auto create_radial_gradient(IntRect const& physical_rect, Span<ColorStop const> color_stops, IntPoint center, IntSize size, Optional<float> repeat_length)
|
||||
static auto create_radial_gradient(IntRect const& physical_rect, ReadonlySpan<ColorStop> color_stops, IntPoint center, IntSize size, Optional<float> repeat_length)
|
||||
{
|
||||
// A conservative guesstimate on how many colors we need to generate:
|
||||
auto max_dimension = max(physical_rect.width(), physical_rect.height());
|
||||
|
@ -232,7 +232,7 @@ static auto create_radial_gradient(IntRect const& physical_rect, Span<ColorStop
|
|||
};
|
||||
}
|
||||
|
||||
void Painter::fill_rect_with_linear_gradient(IntRect const& rect, Span<ColorStop const> color_stops, float angle, Optional<float> repeat_length)
|
||||
void Painter::fill_rect_with_linear_gradient(IntRect const& rect, ReadonlySpan<ColorStop> color_stops, float angle, Optional<float> repeat_length)
|
||||
{
|
||||
auto a_rect = to_physical(rect);
|
||||
if (a_rect.intersected(clip_rect() * scale()).is_empty())
|
||||
|
@ -246,7 +246,7 @@ static FloatPoint pixel_center(IntPoint point)
|
|||
return point.to_type<float>().translated(0.5f, 0.5f);
|
||||
}
|
||||
|
||||
void Painter::fill_rect_with_conic_gradient(IntRect const& rect, Span<ColorStop const> color_stops, IntPoint center, float start_angle, Optional<float> repeat_length)
|
||||
void Painter::fill_rect_with_conic_gradient(IntRect const& rect, ReadonlySpan<ColorStop> color_stops, IntPoint center, float start_angle, Optional<float> repeat_length)
|
||||
{
|
||||
auto a_rect = to_physical(rect);
|
||||
if (a_rect.intersected(clip_rect() * scale()).is_empty())
|
||||
|
@ -257,7 +257,7 @@ void Painter::fill_rect_with_conic_gradient(IntRect const& rect, Span<ColorStop
|
|||
conic_gradient.paint(*this, a_rect);
|
||||
}
|
||||
|
||||
void Painter::fill_rect_with_radial_gradient(IntRect const& rect, Span<ColorStop const> color_stops, IntPoint center, IntSize size, Optional<float> repeat_length)
|
||||
void Painter::fill_rect_with_radial_gradient(IntRect const& rect, ReadonlySpan<ColorStop> color_stops, IntPoint center, IntSize size, Optional<float> repeat_length)
|
||||
{
|
||||
auto a_rect = to_physical(rect);
|
||||
if (a_rect.intersected(clip_rect() * scale()).is_empty())
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
m_repeat_length = repeat_length;
|
||||
}
|
||||
|
||||
Span<ColorStop const> color_stops() const { return m_color_stops; }
|
||||
ReadonlySpan<ColorStop> color_stops() const { return m_color_stops; }
|
||||
Optional<float> repeat_length() const { return m_repeat_length; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -704,7 +704,7 @@ void Painter::draw_bitmap(IntPoint p, GlyphBitmap const& bitmap, Color color)
|
|||
}
|
||||
}
|
||||
|
||||
void Painter::draw_triangle(IntPoint offset, Span<IntPoint const> control_points, Color color)
|
||||
void Painter::draw_triangle(IntPoint offset, ReadonlySpan<IntPoint> control_points, Color color)
|
||||
{
|
||||
VERIFY(control_points.size() == 3);
|
||||
draw_triangle(control_points[0] + offset, control_points[1] + offset, control_points[2] + offset, color);
|
||||
|
|
|
@ -53,9 +53,9 @@ public:
|
|||
void fill_rect_with_checkerboard(IntRect const&, IntSize, Color color_dark, Color color_light);
|
||||
void fill_rect_with_gradient(Orientation, IntRect const&, Color gradient_start, Color gradient_end);
|
||||
void fill_rect_with_gradient(IntRect const&, Color gradient_start, Color gradient_end);
|
||||
void fill_rect_with_linear_gradient(IntRect const&, Span<ColorStop const>, float angle, Optional<float> repeat_length = {});
|
||||
void fill_rect_with_conic_gradient(IntRect const&, Span<ColorStop const>, IntPoint center, float start_angle, Optional<float> repeat_length = {});
|
||||
void fill_rect_with_radial_gradient(IntRect const&, Span<ColorStop const>, IntPoint center, IntSize size, Optional<float> repeat_length = {});
|
||||
void fill_rect_with_linear_gradient(IntRect const&, ReadonlySpan<ColorStop>, float angle, Optional<float> repeat_length = {});
|
||||
void fill_rect_with_conic_gradient(IntRect const&, ReadonlySpan<ColorStop>, IntPoint center, float start_angle, Optional<float> repeat_length = {});
|
||||
void fill_rect_with_radial_gradient(IntRect const&, ReadonlySpan<ColorStop>, IntPoint center, IntSize size, Optional<float> repeat_length = {});
|
||||
void fill_rect_with_rounded_corners(IntRect const&, Color, int radius);
|
||||
void fill_rect_with_rounded_corners(IntRect const&, Color, int top_left_radius, int top_right_radius, int bottom_right_radius, int bottom_left_radius);
|
||||
void fill_ellipse(IntRect const&, Color);
|
||||
|
@ -68,7 +68,7 @@ public:
|
|||
void draw_scaled_bitmap(IntRect const& dst_rect, Gfx::Bitmap const&, FloatRect const& src_rect, float opacity = 1.0f, ScalingMode = ScalingMode::NearestNeighbor);
|
||||
void draw_scaled_bitmap_with_transform(IntRect const& dst_rect, Gfx::Bitmap const&, FloatRect const& src_rect, Gfx::AffineTransform const&, float opacity = 1.0f, ScalingMode = ScalingMode::NearestNeighbor);
|
||||
void draw_triangle(IntPoint, IntPoint, IntPoint, Color);
|
||||
void draw_triangle(IntPoint offset, Span<IntPoint const>, Color);
|
||||
void draw_triangle(IntPoint offset, ReadonlySpan<IntPoint>, Color);
|
||||
void draw_ellipse_intersecting(IntRect const&, Color, int thickness = 1);
|
||||
void set_pixel(IntPoint, Color, bool blend = false);
|
||||
void set_pixel(int x, int y, Color color, bool blend = false) { set_pixel({ x, y }, color, blend); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue