mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:37:35 +00:00
LibGfx: Sprinkle some FLATTEN/hot attributes in the path rasterizer
This seems to actually improve performance to the tune of about +5 fps.
This commit is contained in:
parent
e2152a5b3d
commit
ec93973158
2 changed files with 4 additions and 4 deletions
|
@ -167,7 +167,7 @@ void EdgeFlagPathRasterizer<SamplesPerPixel>::fill_internal(Painter& painter, Pa
|
||||||
auto for_each_sample = [&](Detail::Edge& edge, int start_subpixel_y, int end_subpixel_y, EdgeExtent& edge_extent, auto callback) {
|
auto for_each_sample = [&](Detail::Edge& edge, int start_subpixel_y, int end_subpixel_y, EdgeExtent& edge_extent, auto callback) {
|
||||||
for (int y = start_subpixel_y; y < end_subpixel_y; y++) {
|
for (int y = start_subpixel_y; y < end_subpixel_y; y++) {
|
||||||
auto xi = static_cast<int>(edge.x + SubpixelSample::nrooks_subpixel_offsets[y]);
|
auto xi = static_cast<int>(edge.x + SubpixelSample::nrooks_subpixel_offsets[y]);
|
||||||
if (xi < 0 || size_t(xi) >= m_scanline.size()) {
|
if (xi < 0 || size_t(xi) >= m_scanline.size()) [[unlikely]] {
|
||||||
// FIXME: For very low dxdy values, floating point error can push the sample outside the scanline.
|
// FIXME: For very low dxdy values, floating point error can push the sample outside the scanline.
|
||||||
// This does not seem to make a visible difference most of the time (and is more likely from generated
|
// This does not seem to make a visible difference most of the time (and is more likely from generated
|
||||||
// paths, such as this 3D canvas demo: https://www.kevs3d.co.uk/dev/html5logo/).
|
// paths, such as this 3D canvas demo: https://www.kevs3d.co.uk/dev/html5logo/).
|
||||||
|
@ -241,7 +241,7 @@ Color EdgeFlagPathRasterizer<SamplesPerPixel>::scanline_color(int scanline, int
|
||||||
}
|
}
|
||||||
|
|
||||||
template<unsigned SamplesPerPixel>
|
template<unsigned SamplesPerPixel>
|
||||||
Detail::Edge* EdgeFlagPathRasterizer<SamplesPerPixel>::plot_edges_for_scanline(int scanline, auto plot_edge, EdgeExtent& edge_extent, Detail::Edge* active_edges)
|
__attribute__((hot)) Detail::Edge* EdgeFlagPathRasterizer<SamplesPerPixel>::plot_edges_for_scanline(int scanline, auto plot_edge, EdgeExtent& edge_extent, Detail::Edge* active_edges)
|
||||||
{
|
{
|
||||||
auto y_subpixel = [](int y) {
|
auto y_subpixel = [](int y) {
|
||||||
return y & (SamplesPerPixel - 1);
|
return y & (SamplesPerPixel - 1);
|
||||||
|
@ -368,7 +368,7 @@ void EdgeFlagPathRasterizer<SamplesPerPixel>::fast_fill_solid_color_span(ARGB32*
|
||||||
|
|
||||||
template<unsigned SamplesPerPixel>
|
template<unsigned SamplesPerPixel>
|
||||||
template<Painter::WindingRule WindingRule>
|
template<Painter::WindingRule WindingRule>
|
||||||
void EdgeFlagPathRasterizer<SamplesPerPixel>::write_scanline(Painter& painter, int scanline, EdgeExtent edge_extent, auto& color_or_function)
|
FLATTEN __attribute__((hot)) void EdgeFlagPathRasterizer<SamplesPerPixel>::write_scanline(Painter& painter, int scanline, EdgeExtent edge_extent, auto& color_or_function)
|
||||||
{
|
{
|
||||||
// Handle scanline clipping.
|
// Handle scanline clipping.
|
||||||
auto left_clip = m_clip.left() - m_blit_origin.x();
|
auto left_clip = m_clip.left() - m_blit_origin.x();
|
||||||
|
|
|
@ -176,7 +176,7 @@ private:
|
||||||
Detail::Edge* plot_edges_for_scanline(int scanline, auto plot_edge, EdgeExtent&, Detail::Edge* active_edges = nullptr);
|
Detail::Edge* plot_edges_for_scanline(int scanline, auto plot_edge, EdgeExtent&, Detail::Edge* active_edges = nullptr);
|
||||||
|
|
||||||
template<Painter::WindingRule>
|
template<Painter::WindingRule>
|
||||||
void write_scanline(Painter&, int scanline, EdgeExtent, auto& color_or_function);
|
FLATTEN void write_scanline(Painter&, int scanline, EdgeExtent, auto& color_or_function);
|
||||||
Color scanline_color(int scanline, int offset, u8 alpha, auto& color_or_function);
|
Color scanline_color(int scanline, int offset, u8 alpha, auto& color_or_function);
|
||||||
void write_pixel(BitmapFormat format, ARGB32* scanline_ptr, int scanline, int offset, SampleType sample, auto& color_or_function);
|
void write_pixel(BitmapFormat format, ARGB32* scanline_ptr, int scanline, int offset, SampleType sample, auto& color_or_function);
|
||||||
void fast_fill_solid_color_span(ARGB32* scanline_ptr, int start, int end, Color color);
|
void fast_fill_solid_color_span(ARGB32* scanline_ptr, int start, int end, Color color);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue