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