Add USE_DRAW_POLYGON_FALLBACK build option for testing.

This new option, when enabled, forces the in-tree front ends
(Emcscripten, GTK, NestedVM, OS X, and Windows) to use the recently
introduced draw_polygon_fallback() in place of their native
draw_poly(). This will enable easy testing of this function in the
future.

This new option is off by default. To enable it, run CMake as:

$ cmake -DUSE_DRAW_POLYGON_FALLBACK=on

Note that I did _not_ update the Postscript frontend (ps.c) to use
this new option, as I don't think draw_polygon_fallback() would work
at all in Postscript, where the drawing units are no longer guaranteed
to be pixels. The envisioned use case for this option is a developer
testing changes to this function for sanity and/or performance, which
I only foresee happening on a standard GUI front end.
This commit is contained in:
Franklin Wei
2024-08-14 17:53:41 -04:00
committed by Simon Tatham
parent 989df5d2bf
commit a8b544d2aa
6 changed files with 25 additions and 0 deletions

View File

@ -9,6 +9,11 @@ set(build_icons FALSE)
set(need_c_icons FALSE) set(need_c_icons FALSE)
option(BUILD_SDL_PROGRAMS "build test programs requiring SDL" FALSE) option(BUILD_SDL_PROGRAMS "build test programs requiring SDL" FALSE)
option(USE_DRAW_POLYGON_FALLBACK "force frontend to use fallback software polygon rasterizer" off)
if(USE_DRAW_POLYGON_FALLBACK)
add_compile_definitions(USE_DRAW_POLYGON_FALLBACK)
endif()
# Don't disable assertions, even in release mode. Our assertions # Don't disable assertions, even in release mode. Our assertions
# generally aren't expensive and protect against more annoying crashes # generally aren't expensive and protect against more annoying crashes
# and memory corruption. # and memory corruption.

4
emcc.c
View File

@ -613,7 +613,11 @@ static const struct drawing_api js_drawing = {
js_draw_text, js_draw_text,
js_draw_rect, js_draw_rect,
js_draw_line, js_draw_line,
#ifdef USE_DRAW_POLYGON_FALLBACK
draw_polygon_fallback,
#else
js_draw_poly, js_draw_poly,
#endif
js_draw_circle, js_draw_circle,
js_draw_update, js_draw_update,
js_clip, js_clip,

4
gtk.c
View File

@ -1439,7 +1439,11 @@ static const struct drawing_api gtk_drawing = {
gtk_draw_text, gtk_draw_text,
gtk_draw_rect, gtk_draw_rect,
gtk_draw_line, gtk_draw_line,
#ifdef USE_DRAW_POLYGON_FALLBACK
draw_polygon_fallback,
#else
gtk_draw_poly, gtk_draw_poly,
#endif
gtk_draw_circle, gtk_draw_circle,
gtk_draw_update, gtk_draw_update,
gtk_clip, gtk_clip,

View File

@ -184,7 +184,11 @@ const struct drawing_api nestedvm_drawing = {
nestedvm_draw_text, nestedvm_draw_text,
nestedvm_draw_rect, nestedvm_draw_rect,
nestedvm_draw_line, nestedvm_draw_line,
#ifdef USE_DRAW_POLYGON_FALLBACK
draw_polygon_fallback,
#else
nestedvm_draw_poly, nestedvm_draw_poly,
#endif
nestedvm_draw_circle, nestedvm_draw_circle,
NULL, // draw_update, NULL, // draw_update,
nestedvm_clip, nestedvm_clip,

4
osx.m
View File

@ -1773,7 +1773,11 @@ const struct drawing_api osx_drawing = {
osx_draw_text, osx_draw_text,
osx_draw_rect, osx_draw_rect,
osx_draw_line, osx_draw_line,
#ifdef USE_DRAW_POLYGON_FALLBACK
draw_polygon_fallback,
#else
osx_draw_polygon, osx_draw_polygon,
#endif
osx_draw_circle, osx_draw_circle,
osx_draw_update, osx_draw_update,
osx_clip, osx_clip,

View File

@ -899,7 +899,11 @@ const struct drawing_api win_drawing = {
win_draw_text, win_draw_text,
win_draw_rect, win_draw_rect,
win_draw_line, win_draw_line,
#ifdef USE_DRAW_POLYGON_FALLBACK
draw_polygon_fallback,
#else
win_draw_polygon, win_draw_polygon,
#endif
win_draw_circle, win_draw_circle,
win_draw_update, win_draw_update,
win_clip, win_clip,