mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-21 15:01:01 +01:00
[gpu] Add --bench option for automated benchmarking
Implies --demo and --type '30=f ' (zoom 30x, fullscreen, animate). Quits automatically after 3 fps reports. Uses a GOption parse callback so --demo is set early enough for the default font/text machinery. Assisted-by: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
6c1bd94816
commit
5d24cb5bf3
3 files changed
+33
No files matched your search
@@ -46,13 +46,30 @@ struct gpu_output_t
|
||||
hb_bool_t use_metal = false;
|
||||
hb_bool_t use_d3d11 = false;
|
||||
hb_bool_t demo = false;
|
||||
hb_bool_t bench = false;
|
||||
char *type_text = nullptr;
|
||||
|
||||
static gboolean
|
||||
parse_bench (const char *name G_GNUC_UNUSED,
|
||||
const char *arg G_GNUC_UNUSED,
|
||||
gpointer data,
|
||||
GError **error G_GNUC_UNUSED)
|
||||
{
|
||||
auto *self = (gpu_output_t *) data;
|
||||
self->demo = true;
|
||||
self->bench = true;
|
||||
if (!self->type_text)
|
||||
self->type_text = g_strdup ("30=f ");
|
||||
return true;
|
||||
}
|
||||
|
||||
void add_options (option_parser_t *parser)
|
||||
{
|
||||
GOptionEntry entries[] =
|
||||
{
|
||||
{"demo", 0, 0, G_OPTION_ARG_NONE, &this->demo, "Use built-in demo font and text", nullptr},
|
||||
{"bench", 0, G_OPTION_FLAG_NO_ARG,
|
||||
G_OPTION_ARG_CALLBACK, (gpointer) &parse_bench,"Demo in fullscreen benchmark mode", nullptr},
|
||||
{"type", 'T', 0, G_OPTION_ARG_STRING, &this->type_text, "Type these keystrokes on start", "keys"},
|
||||
#ifdef __APPLE__
|
||||
{"metal", 0, 0, G_OPTION_ARG_NONE, &this->use_metal, "Use Metal renderer", nullptr},
|
||||
@@ -248,6 +265,8 @@ struct gpu_output_t
|
||||
|
||||
if (type_text)
|
||||
demo_view_type (vu, type_text);
|
||||
if (bench)
|
||||
demo_view_set_fps_quit (vu, 3);
|
||||
|
||||
demo_view_display (vu, buf);
|
||||
glfwPollEvents ();
|
||||
|
||||
@@ -65,6 +65,7 @@ struct demo_view_t {
|
||||
bool has_fps_timer;
|
||||
double fps_timer_interval;
|
||||
double fps_timer_last;
|
||||
int fps_quit_after; /* quit after N fps prints; 0 = disabled */
|
||||
|
||||
/* Vim-style repeat count */
|
||||
unsigned int repeat_count;
|
||||
@@ -762,6 +763,10 @@ demo_view_display (demo_view_t *vu, demo_buffer_t *buffer)
|
||||
vu->num_frames = 0;
|
||||
vu->fps_start_time = now;
|
||||
vu->fps_timer_last = now;
|
||||
#ifndef HB_GPU_NO_GLFW
|
||||
if (vu->fps_quit_after && --vu->fps_quit_after == 0 && vu->window)
|
||||
glfwSetWindowShouldClose (vu->window, GLFW_TRUE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -826,6 +831,12 @@ demo_view_type (demo_view_t *vu, const char *keys)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
demo_view_set_fps_quit (demo_view_t *vu, int count)
|
||||
{
|
||||
vu->fps_quit_after = count;
|
||||
}
|
||||
|
||||
void
|
||||
demo_view_request_redraw (demo_view_t *vu)
|
||||
{
|
||||
|
||||
@@ -84,6 +84,9 @@ demo_view_setup (demo_view_t *vu);
|
||||
void
|
||||
demo_view_type (demo_view_t *vu, const char *keys);
|
||||
|
||||
void
|
||||
demo_view_set_fps_quit (demo_view_t *vu, int count);
|
||||
|
||||
void
|
||||
demo_view_request_redraw (demo_view_t *vu);
|
||||
|
||||
|
||||
Reference in new issue
Block a user