2021-04-04 16:10:54 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Oleg Sikorskiy <olegsik@gmail.com>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-04-04 16:10:54 +03:00
|
|
|
*/
|
|
|
|
|
2021-04-25 08:53:23 +03:00
|
|
|
#include <LibTest/TestCase.h>
|
2021-04-04 16:10:54 +03:00
|
|
|
|
|
|
|
#include <LibGfx/Bitmap.h>
|
2022-04-09 10:28:38 +03:00
|
|
|
#include <LibGfx/Font/FontDatabase.h>
|
2021-04-04 16:10:54 +03:00
|
|
|
#include <LibGfx/Painter.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
BENCHMARK_CASE(diagonal_lines)
|
|
|
|
{
|
2022-04-01 20:58:27 +03:00
|
|
|
int const run_count = 50;
|
|
|
|
int const bitmap_size = 2000;
|
2021-04-04 16:10:54 +03:00
|
|
|
|
2024-02-07 23:42:43 +03:00
|
|
|
auto bitmap = TRY_OR_FAIL(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { bitmap_size, bitmap_size }));
|
2021-11-06 21:30:59 +03:00
|
|
|
Gfx::Painter painter(bitmap);
|
2021-04-04 16:10:54 +03:00
|
|
|
|
|
|
|
for (int run = 0; run < run_count; run++) {
|
|
|
|
for (int i = 0; i < bitmap_size; i++) {
|
|
|
|
painter.draw_line({ 0, 0 }, { i, bitmap_size - 1 }, Color::Blue);
|
|
|
|
painter.draw_line({ 0, 0 }, { bitmap_size - 1, i }, Color::Blue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BENCHMARK_CASE(fill)
|
|
|
|
{
|
2022-04-01 20:58:27 +03:00
|
|
|
int const run_count = 1000;
|
|
|
|
int const bitmap_size = 2000;
|
2021-04-04 16:10:54 +03:00
|
|
|
|
2024-02-07 23:42:43 +03:00
|
|
|
auto bitmap = TRY_OR_FAIL(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { bitmap_size, bitmap_size }));
|
2021-11-06 21:30:59 +03:00
|
|
|
Gfx::Painter painter(bitmap);
|
2021-04-04 16:10:54 +03:00
|
|
|
|
|
|
|
for (int run = 0; run < run_count; run++) {
|
|
|
|
painter.fill_rect(bitmap->rect(), Color::Blue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BENCHMARK_CASE(fill_with_gradient)
|
|
|
|
{
|
2022-04-01 20:58:27 +03:00
|
|
|
int const run_count = 50;
|
|
|
|
int const bitmap_size = 2000;
|
2021-04-04 16:10:54 +03:00
|
|
|
|
2024-02-07 23:42:43 +03:00
|
|
|
auto bitmap = TRY_OR_FAIL(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { bitmap_size, bitmap_size }));
|
2021-11-06 21:30:59 +03:00
|
|
|
Gfx::Painter painter(bitmap);
|
2021-04-04 16:10:54 +03:00
|
|
|
|
|
|
|
for (int run = 0; run < run_count; run++) {
|
|
|
|
painter.fill_rect_with_gradient(bitmap->rect(), Color::Blue, Color::Red);
|
|
|
|
}
|
|
|
|
}
|