git log -n 1 --pretty=format:'%h %d %s%n%n' > $logfile
-echo "_____________________________________________________________________________________________________" >> $logfile
-echo "| Test File Name | Sub Test | Iter | SIZE | FPS | Average | Median | Sigma |" >> $logfile
-echo "|-----------------|---------------------------|------|------|---------|---------|---------|---------|" >> $logfile
+files=( test_* )
+./"${files[0]}" -p >> $logfile
+
+echo "__________________________________________________________________________________________________________" >> $logfile
+echo "| N° | Test File Name | Sub Test | Iter | Size | FPS | Average | Median | Sigma |" >> $logfile
+echo "|----|-----------------|---------------------------|------|------|---------|---------|---------|---------|" >> $logfile
for file in test_*
do
if [[ -x "$file" ]]
then
- ./"$file" $ITERATIONS $SIZE >> $logfile
+ printf "."
+ ./"$file" -i $ITERATIONS -s $SIZE -q >> $logfile
fi
done
-echo "_____________________________________________________________________________________________________" >> $logfile
+echo "__________________________________________________________________________________________________________" >> $logfile
+echo
+echo "results writen in $logfile"
_draw_stoke_cap (ctx, hw, p0, normal, dashOn);
dashOn ^= true;
-
- curDashOffset += ctx->dashes[curDash++];
- if (curDash == ctx->dashCount)
+ if (++curDash == ctx->dashCount)
curDash = 0;
+ curDashOffset += ctx->dashes[curDash];
}
curDashOffset -= segmentLength;
return segmentLength;
if (!dashOn){
//finishing last dash that is already started, draw end caps but not too close to start
//the default gap is the next void
- uint32_t prevDash = curDash-1;
+ int32_t prevDash = (int32_t)curDash-1;
if (prevDash < 0)
curDash = ctx->dashCount-1;
float m = fminf (ctx->dashes[prevDash] - curDashOffset, ctx->dashes[curDash]);
ctx->indCount+=3;
_check_index_cache_size(ctx);
- LOG(VKVG_LOG_INFO, "Triangle IDX: %d %d %d (count=%d)\n", i0,i1,i2,ctx->indCount);
+ LOG(VKVG_LOG_INFO, "Triangle IDX: %d %d %d (indCount=%d)\n", i0,i1,i2,ctx->indCount);
}
void _vao_add_rectangle (VkvgContext ctx, float x, float y, float width, float height){
Vertex v[4] =
#include "test.h"
-void test(){
+void test_name(){
VkvgContext ctx = vkvg_create(surf);
vkvg_destroy(ctx);
}
int main(int argc, char *argv[]) {
-
- perform_test (test, "custom test", 800, 600);
-
+ PERFORM_TEST (test_name, argc, argv);
return 0;
}
}
int main(int argc, char *argv[]) {
+ no_test_size = true;
PERFORM_TEST (sizes, argc, argv);
PERFORM_TEST (scaled_up, argc, argv);
- PERFORM_TEST (test, argc, argv);
+ PERFORM_TEST (test, argc, argv);
return 0;
}
}
int main(int argc, char *argv[]) {
+ no_test_size = true;
PERFORM_TEST (fill_and_stroke, argc, argv);
PERFORM_TEST (sizes, argc, argv);
PERFORM_TEST (scaled_up, argc, argv);
vkvg_destroy(ctx);
}
int main(int argc, char *argv[]) {
+ no_test_size = true;
PERFORM_TEST (clipped_paint_ec, argc, argv);
PERFORM_TEST (clipped_paint_eo, argc, argv);
PERFORM_TEST (clipped_transformed_ec, argc, argv);
}
int main(int argc, char *argv[]) {
-
+ no_test_size = true;
PERFORM_TEST (test, argc, argv);
return 0;
VkvgDevice device = NULL;
VkvgSurface surf = NULL;
-uint32_t test_size = 100; // items drawn in one run, or complexity
-uint32_t iterations = 1000;// repeat test n times
-uint32_t test_width = 1024;
-uint32_t test_height= 768;
-bool test_vsync = false;
+uint32_t test_size = 10; // items drawn in one run, or complexity
+uint32_t iterations = 100;// repeat test n times
+uint32_t test_width = 512;
+uint32_t test_height= 512;
+bool test_vsync = false;
+bool quiet = false;//if true, don't print details and head row
+bool first_test = true;//if multiple tests, dont print header row.
+bool no_test_size= false;//several test consist of a single draw sequence without looping 'size' times
+ //those test must be preceded by setting no_test_size to 'true'
+int test_index = 0;
+int single_test = -1; //if not < 0, contains the index of the single test to run
static bool paused = false;
-static VkSampleCountFlags samples = VK_SAMPLE_COUNT_8_BIT;
+static VkSampleCountFlags samples = VK_SAMPLE_COUNT_1_BIT;
static vk_engine_t* e;
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) {
#ifdef VKVG_TEST_DIRECT_DRAW
VkvgSurface* surfaces;
#endif
+_print_usage_and_exit () {
+ printf("\nUsage: test [options]\n\n");
+ printf("\t-i iterations:\tSpecify the repeat count for the test.\n");
+ printf("\t-s size:\tWhen applicable, specify the size of the test.\n");
+ printf("\t-w width:\tOutput surface width.\n");
+ printf("\t-h height:\tOutput surface height.\n");
+ printf("\t-n index:\tRun only a single test, zero based index.\n");
+ printf("\t-q:\t\tQuiet, don't print measures table head row, usefull for batch tests\n");
+ printf("\t-p:\t\tPrint test details and exit without performing test, usefull to print details in logs\n");
+ printf("\t-vsync:\t\tEnable VSync, disabled by default\n");
+ printf("\t-h:\t\tthis help message.\n");
+ printf("\n");
+ exit(-1);
+}
+void _parse_args (int argc, char* argv[]) {
+ for (int i = 1; i < argc; i++) {
+ if (strcmp (argv[i], "-help\0") == 0)
+ _print_usage_and_exit ();
+ if (strcmp (argv[i], "-p\0") == 0) {
+ #ifdef DEBUG
+ printf("Debug build\n");
+ #else
+ printf("Release build\n");
+ #endif
+ #ifdef VKVG_USE_RENDERDOC
+ printf("Render doc enabled\n");
+ #endif
+ #ifdef VKVG_USE_VALIDATION
+ printf("Validation enabled\n");
+ #endif
+ printf("surf dims:\t%d x %d\n", test_width, test_height);
+ printf("Samples:\t%d\n", samples);
+ #ifdef VKVG_TEST_OFFSCREEN
+ printf("Offscreen:\ttrue\n");
+ #else
+ printf("Offscreen:\ttrue\n");
+ #endif
+ printf("\n");
+ exit(0);
+ }
+ if (strcmp (argv[i], "-vsync\0") == 0)
+ test_vsync = true;
+ else if (strcmp (argv[i], "-q\0") == 0)
+ quiet = true;
+ else if (strcmp (argv[i], "-i\0") == 0) {
+ if (argc -1 < ++i)
+ _print_usage_and_exit();
+ iterations = atoi (argv[i]);
+ }else if (strcmp (argv[i], "-w\0") == 0) {
+ if (argc -1 < ++i)
+ _print_usage_and_exit();
+ test_width = atoi (argv[i]);
+ }else if (strcmp (argv[i], "-h\0") == 0) {
+ if (argc -1 < ++i)
+ _print_usage_and_exit();
+ test_height = atoi (argv[i]);
+ }else if (strcmp (argv[i], "-n\0") == 0) {
+ if (argc -1 < ++i)
+ _print_usage_and_exit();
+ single_test = atoi (argv[i]);
+ }else if (strcmp (argv[i], "-s\0") == 0) {
+ if (argc -1 < ++i)
+ _print_usage_and_exit();
+ test_size = atoi (argv[i]);
+ }
+ }
+}
+
+void _print_results (const char *testName, int argc, char* argv[], uint32_t i, double run_total, double* run_time_values) {
+ char* whoami;
+ (whoami = strrchr(argv[0], '/')) ? ++whoami : (whoami = argv[0]);
+
+ double avg_run_time = run_total / (double)i;
+ double med_run_time = median_run_time (run_time_values, i);
+ double standard_dev = standard_deviation (run_time_values, i, avg_run_time);
+ double avg_frames_per_second = (1.0 / avg_run_time);
+ avg_frames_per_second = (avg_frames_per_second<9999) ? avg_frames_per_second:9999;
+
+ if (!quiet && (test_index == 0 || test_index == single_test)) {
+ printf ("______________________________________________________________________________________________________\n");
+ printf ("| N° | Test File Name | Sub Test | Iter | Size | FPS | Average | Median | Sigma |\n");
+ printf ("|----|-----------------|---------------------------|------|------|---------|---------|---------|---------|\n");
+ }
+ printf ("| %2d | %-15s | %-25s | ", test_index, whoami + 5, testName);
+ if (no_test_size)
+ printf ("%4d | %4d | %7.2f | %6.5f | %6.5f | %6.5f |\n",
+ i, 1, avg_frames_per_second, avg_run_time, med_run_time, standard_dev);
+ else
+ printf ("%4d | %4d | %7.2f | %6.5f | %6.5f | %6.5f |\n",
+ i, test_size, avg_frames_per_second, avg_run_time, med_run_time, standard_dev);
+
+}
void perform_test_offscreen (void(*testfunc)(void), const char *testName, int argc, char* argv[]) {
//init random gen
srand((unsigned) currentTime.tv_usec);
//dumpLayerExts();
- if (argc > 1)
- iterations = atoi (argv[1]);
- if (argc > 2)
- test_size = atoi (argv[2]);
- if (iterations == 0 || test_size == 0) {
- printf("usage: test [iterations] [size]\n");
+
+ _parse_args (argc, argv);
+
+ if (single_test >= 0 && test_index != single_test){
+ test_index++;
return;
}
-
- char* whoami;
- (whoami = strrchr(argv[0], '/')) ? ++whoami : (whoami = argv[0]);
-
+
uint32_t enabledExtsCount = 0, phyCount = 0;
const char* enabledExts [10];
#ifdef VKVG_USE_RENDERDOC
i++;
}
- double avg_run_time = run_total / (double)i;
- double med_run_time = median_run_time (run_time_values, i);
- double standard_dev = standard_deviation (run_time_values, i, avg_run_time);
- double avg_frames_per_second = (1.0 / avg_run_time);
- avg_frames_per_second = (avg_frames_per_second<9999) ? avg_frames_per_second:9999;
-
- free (run_time_values);
-
- //printf ("size:%d iter:%d avgFps: %f avg: %4.2f%% med: %4.2f%% sd: %4.2f%% \n", test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev);
- printf ("| %-15s | %-25s | ",whoami + 5, testName);
- printf ("%4d | %4d | %7.2f | %6.5f | %6.5f | %6.5f |\n",
- test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev);
+ _print_results (testName, argc, argv, i, run_total, run_time_values);
- //printf ("%s size:%d iter:%d avgFps: %f avg: %4.2f%% med: %4.2f%% sd: %4.2f%% \n", whoami+5, test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev);
+ free (run_time_values);
vkDeviceWaitIdle(dev->dev);
vkh_device_destroy (dev);
vkh_app_destroy (app);
+
+ test_index++;
}
void perform_test (void(*testfunc)(void), const char *testName, int argc, char* argv[]) {
srand((unsigned) currentTime.tv_usec);
//dumpLayerExts();
- if (argc > 1)
- iterations = atoi (argv[1]);
- if (argc > 2)
- test_size = atoi (argv[2]);
- if (iterations == 0 || test_size == 0) {
- printf("usage: test [iterations] [size]\n");
+ _parse_args (argc, argv);
+
+ if (single_test >= 0 && test_index != single_test){
+ test_index++;
return;
}
- char* whoami;
- (whoami = strrchr(argv[0], '/')) ? ++whoami : (whoami = argv[0]);
-
if (test_vsync)
e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, test_width, test_height);
else
vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), test_width, test_height);
#endif
-
double start_time = 0.0, stop_time = 0.0, run_time = 0.0, run_total = 0.0, min_run_time = -1, max_run_time = 0.0;
double* run_time_values = (double*)malloc(iterations*sizeof(double));
i++;
}
- double avg_run_time = run_total / (double)i;
- double med_run_time = median_run_time (run_time_values, i);
- double standard_dev = standard_deviation (run_time_values, i, avg_run_time);
- double avg_frames_per_second = (1.0 / avg_run_time);
- avg_frames_per_second = (avg_frames_per_second<9999) ? avg_frames_per_second:9999;
+ _print_results (testName, argc, argv, i, run_total, run_time_values);
free (run_time_values);
-
- //printf ("size:%d iter:%d avgFps: %f avg: %4.2f%% med: %4.2f%% sd: %4.2f%% \n", test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev);
- printf ("| %-15s | %-25s | ",whoami + 5, testName);
- printf ("%4d | %4d | %7.2f | %6.5f | %6.5f | %6.5f |\n",
- test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev);
-
- //printf ("%s size:%d iter:%d avgFps: %f avg: %4.2f%% med: %4.2f%% sd: %4.2f%% \n", whoami+5, test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev);
-
vkDeviceWaitIdle(e->dev->dev);
#ifdef VKVG_TEST_DIRECT_DRAW
vkvg_device_destroy (device);
vkengine_destroy (e);
+
+ test_index++;
+}
+
+
+/* common context init for several tests */
+vkvg_fill_rule_t fill_rule = VKVG_FILL_RULE_NON_ZERO;
+vkvg_line_cap_t line_cap = VKVG_LINE_CAP_BUTT;
+vkvg_line_join_t line_join = VKVG_LINE_JOIN_MITER;
+float dashes[] = {20.0f, 10.0f};
+uint32_t dashes_count= 0;
+float dash_offset = 0;
+float line_width = 1.f;
+
+VkvgContext _initCtx() {
+ VkvgContext ctx = vkvg_create(surf);
+
+ vkvg_set_line_width (ctx,line_width);
+ vkvg_set_line_join (ctx, line_join);
+ vkvg_set_line_cap (ctx, line_cap);
+ vkvg_set_dash (ctx, dashes, dashes_count, dash_offset);
+ vkvg_set_fill_rule (ctx, fill_rule);
+
+ vkvg_clear (ctx);
+ return ctx;
}
+
+
const int star_points[11][2] = {
{ 0, 85 },
{ 75, 75 },
};
void randomize_color(VkvgContext ctx) {
vkvg_set_source_rgba(ctx,
- (float)rand() / RAND_MAX,
- (float)rand() / RAND_MAX,
- (float)rand() / RAND_MAX,
- (float)rand() / RAND_MAX
+ rndf(),
+ rndf(),
+ rndf(),
+ rndf()
);
}
void draw_random_shape (VkvgContext ctx, shape_t shape, float sizeFact) {
switch (shape) {
case SHAPE_LINE:
- x = (float)rand()/RAND_MAX * w;
- y = (float)rand()/RAND_MAX * h;
- z = (float)rand()/RAND_MAX * w;
- v = (float)rand()/RAND_MAX * h;
+ x = rndf() * w;
+ y = rndf() * h;
+ z = rndf() * w;
+ v = rndf() * h;
vkvg_move_to(ctx, x, y);
vkvg_line_to(ctx, z, v);
vkvg_stroke(ctx);
break;
case SHAPE_RECTANGLE:
- z = truncf((sizeFact*w*rand()/RAND_MAX)+1.f);
- v = truncf((sizeFact*h*rand()/RAND_MAX)+1.f);
- x = truncf((w-z)*rand()/RAND_MAX);
- y = truncf((h-v)*rand()/RAND_MAX);
+ z = truncf((sizeFact*w*rndf())+1.f);
+ v = truncf((sizeFact*h*rndf())+1.f);
+ x = truncf((w-z)*rndf());
+ y = truncf((h-v)*rndf());
vkvg_rectangle(ctx, x+1, y+1, z, v);
break;
case SHAPE_ROUNDED_RECTANGLE:
- z = truncf((sizeFact*w*rand()/RAND_MAX)+1.f);
- v = truncf((sizeFact*h*rand()/RAND_MAX)+1.f);
- x = truncf((w-z)*rand()/RAND_MAX);
- y = truncf((h-v)*rand()/RAND_MAX);
- r = truncf((0.2f*z*rand()/RAND_MAX)+1.f);
+ z = truncf((sizeFact*w*rndf())+1.f);
+ v = truncf((sizeFact*h*rndf())+1.f);
+ x = truncf((w-z)*rndf());
+ y = truncf((h-v)*rndf());
+ r = truncf((0.2f*z*rndf())+1.f);
if ((r > v / 2) || (r > z / 2))
r = MIN(v / 2, z / 2);
/*x = truncf((float)w * rnd()/RAND_MAX);
y = truncf((float)h * rnd()/RAND_MAX);
v = truncf((float)w * rnd()/RAND_MAX * 0.2f);*/
- x = (float)rand()/RAND_MAX * w;
- y = (float)rand()/RAND_MAX * h;
+ x = rndf() * w;
+ y = rndf() * h;
- r = truncf((sizeFact*MIN(w,h)*rand()/RAND_MAX)+1.f);
+ r = truncf((sizeFact*MIN(w,h)*rndf())+1.f);
/*float r = 0.5f*w*rand()/RAND_MAX;
float x = truncf(0.5f * w*rand()/RAND_MAX + r);
break;
case SHAPE_TRIANGLE:
case SHAPE_STAR:
- x = (float)rand()/RAND_MAX * w;
- y = (float)rand()/RAND_MAX * h;
- z = (float)rand()/RAND_MAX * sizeFact + 0.15f; //scale
+ x = rndf() * w;
+ y = rndf() * h;
+ z = rndf() * sizeFact + 0.15f; //scale
vkvg_move_to (ctx, x+star_points[0][0]*z, y+star_points[0][1]*z);
for (int s=1; s<11; s++)
vkvg_close_path (ctx);
break;
case SHAPE_RANDOM:
- draw_random_shape(ctx, 1 + rand()%4, sizeFact);
+ draw_random_shape(ctx, 1 + (rndf() * 4), sizeFact);
break;
}
}
+void draw_random_curve (VkvgContext ctx) {
+ float w = (float)test_width;
+ float h = (float)test_height;
+
+ float x2 = w*rndf();
+ float y2 = h*rndf();
+ float cp_x1 = w*rndf();
+ float cp_y1 = h*rndf();
+ float cp_x2 = w*rndf();
+ float cp_y2 = h*rndf();
+
+ vkvg_curve_to(ctx, cp_x1, cp_y1, cp_x2, cp_y2, x2, y2);
+}
/*void draw_random_shape (VkvgContext ctx, shape_t shape) {
float w = (float)test_width;
float h = (float)test_height;
float x = truncf((w-z)*rand()/RAND_MAX);
float y = truncf((h-v)*rand()/RAND_MAX);
vkvg_rectangle(ctx, x, y, z, v);
-}*/
+}*/
\ No newline at end of file
extern uint32_t iterations;
extern uint32_t test_width;
extern uint32_t test_height;
+extern bool no_test_size;
extern float panX;
extern float panY;
extern VkvgDevice device;
extern VkvgSurface surf;
+/* common context init for several tests */
+extern float dash_offset;
+extern float line_width;
+extern vkvg_fill_rule_t fill_rule;
+extern vkvg_line_cap_t line_cap;
+extern vkvg_line_join_t line_join;
+extern float dashes[];
+extern uint32_t dashes_count;
+
+VkvgContext _initCtx();
+/*******************************/
+
//run test in one step
void perform_test (void(*testfunc)(), const char* testName, int argc, char *argv[]);
void perform_test_offscreen (void(*testfunc)(void), const char *testName, int argc, char* argv[]);
void randomize_color (VkvgContext ctx);
void draw_random_shape (VkvgContext ctx, shape_t shape, float sizeFact);
+void draw_random_curve (VkvgContext ctx);
//run test in 3 step: init, run, clear.
void init_test (uint32_t width, uint32_t height);
}
int main(int argc, char *argv[]) {
+ no_test_size = true;
PERFORM_TEST (compositing, argc, argv);
return 0;
}
--- /dev/null
+#include "test.h"
+
+void create_destroy_multi(){
+ VkvgContext ctxs[test_size];
+ for (uint32_t i = 0; i < test_size; i++)
+ ctxs[i] = vkvg_create(surf);
+ for (uint32_t i = 0; i < test_size; i++)
+ vkvg_destroy(ctxs[i]);
+}
+
+void create_destroy_single(){
+ VkvgContext ctx = vkvg_create(surf);
+ vkvg_destroy(ctx);
+}
+
+int main(int argc, char *argv[]) {
+ PERFORM_TEST (create_destroy_multi, argc, argv);
+ no_test_size = true;
+ PERFORM_TEST (create_destroy_single, argc, argv);
+ return 0;
+}
vkvg_destroy(ctx);
}
-static float line_width = 1.f;
-static vkvg_line_cap_t line_cap = VKVG_LINE_CAP_ROUND;
-static vkvg_fill_rule_t fill_rule = VKVG_FILL_RULE_NON_ZERO;
-static float dashes[] = {30.0f, 10.0f};
-static uint32_t dashes_count = 0;
static bool fillAndStroke = true;
-void _rnd_curve (VkvgContext ctx) {
- float w = (float)test_width;
- float h = (float)test_height;
-
- float x2 = w*rand()/RAND_MAX;
- float y2 = h*rand()/RAND_MAX;
- float cp_x1 = w*rand()/RAND_MAX;
- float cp_y1 = h*rand()/RAND_MAX;
- float cp_x2 = w*rand()/RAND_MAX;
- float cp_y2 = h*rand()/RAND_MAX;
-
- vkvg_curve_to(ctx, cp_x1, cp_y1, cp_x2, cp_y2, x2, y2);
-}
-
-VkvgContext _initCtx() {
- VkvgContext ctx = vkvg_create(surf);
- vkvg_clear(ctx);
- vkvg_set_line_width (ctx,line_width);
- vkvg_set_line_cap(ctx, line_cap);
- vkvg_set_dash (ctx, dashes, dashes_count, 0);
- return ctx;
-}
-
-void random_curves () {
+void random_curves_stroke () {
float w = (float)test_width;
float h = (float)test_height;
float y1 = h*rand()/RAND_MAX;
vkvg_move_to (ctx, x1, y1);
- _rnd_curve(ctx);
+ draw_random_curve(ctx);
vkvg_stroke (ctx);
}
vkvg_destroy(ctx);
}
-void single_long_line_curved () {
+
+void _long_curv () {
float w = (float)test_width;
float h = (float)test_height;
vkvg_move_to (ctx, x1, y1);
for (uint32_t i=0; i<test_size; i++) {
- _rnd_curve(ctx);
+ draw_random_curve(ctx);
}
if (fillAndStroke) {
vkvg_destroy(ctx);
}
-int main(int argc, char *argv[]) {
- PERFORM_TEST(test, argc, argv);
- PERFORM_TEST(test2, argc, argv);
- PERFORM_TEST(curved_rect, argc, argv);
+
+void long_curv_fill_nz () {
fillAndStroke = false;
fill_rule = VKVG_FILL_RULE_NON_ZERO;
- PERFORM_TEST(single_long_line_curved, argc, argv);
+ _long_curv ();
+}
+void long_curv_fill_eo () {
+ fillAndStroke = false;
fill_rule = VKVG_FILL_RULE_EVEN_ODD;
- PERFORM_TEST(single_long_line_curved, argc, argv);
+ _long_curv ();
+}
+void long_curv_fill_stroke_nz () {
fillAndStroke = true;
fill_rule = VKVG_FILL_RULE_NON_ZERO;
- PERFORM_TEST(single_long_line_curved, argc, argv);
+ _long_curv ();
+}
+void long_curv_fill_stroke_eo () {
+ fillAndStroke = true;
fill_rule = VKVG_FILL_RULE_EVEN_ODD;
- PERFORM_TEST(single_long_line_curved, argc, argv);
-
- PERFORM_TEST(random_curves, argc, argv);
+ _long_curv ();
+}
+int main(int argc, char *argv[]) {
+ no_test_size = true;
+ PERFORM_TEST(test, argc, argv);
+ PERFORM_TEST(test2, argc, argv);
+ PERFORM_TEST(curved_rect, argc, argv);
+ //PERFORM_TEST(long_curv_fill_nz, argc, argv);
+ no_test_size = false;
+ PERFORM_TEST(long_curv_fill_eo, argc, argv);
+ //PERFORM_TEST(long_curv_fill_stroke_nz, argc, argv);
+ PERFORM_TEST(long_curv_fill_stroke_eo, argc, argv);
+ PERFORM_TEST(random_curves_stroke, argc, argv);
return 0;
}
#include "test.h"
-static float offset = 0;
+
void test(){
- offset += 0.1f;
+ dash_offset += 0.1f;
VkvgContext ctx = vkvg_create(surf);
vkvg_clear(ctx);
float dashes[] = {700.0f, 30};
//const float dashes[] = {50, 40};
vkvg_set_line_cap(ctx, VKVG_LINE_CAP_ROUND);
- vkvg_set_dash(ctx, dashes, 2, offset);
+ vkvg_set_dash(ctx, dashes, 2, dash_offset);
vkvg_set_line_width(ctx, 20);
vkvg_set_source_rgb(ctx, 0, 0, 1);
dashes[0] = 0;
dashes[1] = 30;
- vkvg_set_dash(ctx, dashes, 2, offset);
+ vkvg_set_dash(ctx, dashes, 2, dash_offset);
vkvg_set_source_rgb(ctx, 0, 1, 0);
vkvg_destroy(ctx);
}
-void test2() {
- VkvgContext ctx = vkvg_create(surf);
- const float dashes[] = { 0, 8 };
- vkvg_set_line_cap(ctx, VKVG_LINE_CAP_ROUND);
- vkvg_set_dash(ctx, dashes, 2, 0);
- vkvg_set_line_width(ctx, 4);
+void _long_curve () {
+ float w = (float)test_width;
+ float h = (float)test_height;
- vkvg_move_to(ctx, 100, 400);
- vkvg_curve_to(ctx, 100, 100, 600, 700, 600, 400);
- vkvg_curve_to(ctx, 1000, 100, 100, 800, 1000, 800);
- vkvg_curve_to(ctx, 1000, 500, 700, 500, 700, 100);
- //vkvg_close_path(ctx);
+ VkvgContext ctx = _initCtx();
- //vkvg_set_source_rgba (ctx, 0.5,0.0,1.0,0.5);
- //vkvg_fill_preserve(ctx);
+ randomize_color(ctx);
+ float x1 = w*rand()/RAND_MAX;
+ float y1 = h*rand()/RAND_MAX;
+ vkvg_move_to (ctx, x1, y1);
- vkvg_set_source_rgba(ctx, 1, 0, 0, 1);
- vkvg_stroke(ctx);
+ for (uint32_t i=0; i<test_size; i++)
+ draw_random_curve(ctx);
+ vkvg_stroke (ctx);
vkvg_destroy(ctx);
+
+}
+void _long_path() {
+ float w = (float)test_width-10;
+ float h = (float)test_height-10;
+
+ VkvgContext ctx = _initCtx();
+
+ randomize_color(ctx);
+ float x1 = w*rndf();
+ float y1 = h*rndf();
+ vkvg_move_to (ctx, x1, y1);
+ for (uint32_t i=0; i<test_size; i++) {
+ x1 = w*rndf();
+ y1 = h*rndf();
+ vkvg_line_to (ctx, x1, y1);
+ }
+ vkvg_stroke (ctx);
+ vkvg_destroy(ctx);
+}
+
+void path () {
+ _long_path ();
+}
+void curve () {
+ _long_curve ();
}
-int main(int argc, char *argv[]) {
- PERFORM_TEST(test, argc, argv);
- PERFORM_TEST(test2, argc, argv);
+
+int main(int argc, char *argv[]) {
+ //PERFORM_TEST(test, argc, argv);
+ //vkvg_log_level = VKVG_LOG_ERR|VKVG_LOG_DEBUG|VKVG_LOG_INFO|VKVG_LOG_INFO_PATH|VKVG_LOG_DBG_ARRAYS|VKVG_LOG_FULL;
+ dashes_count = 1;
+ dashes[0] = 50;
+ dashes[1] = 60;
+ line_width = 10;
+ line_cap = VKVG_LINE_CAP_ROUND;
+ PERFORM_TEST(path, argc, argv);
+ PERFORM_TEST(curve, argc, argv);
return 0;
}
}
int main(int argc, char *argv[]) {
+ no_test_size = true;
PERFORM_TEST (test, argc, argv);
return 0;
}
}
int main(int argc, char *argv[]) {
+ no_test_size = true;
PERFORM_TEST (test, argc, argv);
return 0;
}
}
int main(int argc, char *argv[]) {
+ no_test_size = true;
PERFORM_TEST(paint, argc, argv);
PERFORM_TEST(paint_repeat, argc, argv);
PERFORM_TEST(gradient_transform, argc, argv);
vkvg_surface_destroy(imgSurf);
vkvg_destroy(ctx);
}
-void paint_pattern_repeat () {
+void paint_patt_repeat () {
VkvgContext ctx = vkvg_create(surf);
VkvgSurface imgSurf = vkvg_surface_create_from_image(device, "data/miroir.jpg");
VkvgPattern pat = vkvg_pattern_create_for_surface(imgSurf);
vkvg_surface_destroy(imgSurf);
vkvg_destroy(ctx);
}
-void paint_pattern_repeat_scalled () {
+void paint_patt_repeat_scalled () {
VkvgContext ctx = vkvg_create(surf);
vkvg_scale (ctx, 0.2f,0.2f);
VkvgSurface imgSurf = vkvg_surface_create_from_image(device, "data/miroir.jpg");
vkvg_surface_destroy(imgSurf);
vkvg_destroy(ctx);
}
-void paint_pattern_pad () {
+void paint_patt_pad () {
VkvgContext ctx = vkvg_create(surf);
VkvgSurface imgSurf = vkvg_surface_create_from_image(device, "data/miroir.jpg");
VkvgPattern pat = vkvg_pattern_create_for_surface(imgSurf);
}
int main(int argc, char *argv[]) {
+ no_test_size = true;
PERFORM_TEST (paint, argc, argv);
PERFORM_TEST (paint_offset, argc, argv);
PERFORM_TEST (paint_with_scale, argc, argv);
PERFORM_TEST (paint_pattern, argc, argv);
- PERFORM_TEST (paint_pattern_repeat, argc, argv);
- PERFORM_TEST (paint_pattern_repeat_scalled, argc, argv);
- PERFORM_TEST (paint_pattern_pad, argc, argv);
+ PERFORM_TEST (paint_patt_repeat, argc, argv);
+ PERFORM_TEST (paint_patt_repeat_scalled, argc, argv);
+ PERFORM_TEST (paint_patt_pad, argc, argv);
PERFORM_TEST (test, argc, argv);
return 0;
}
int main(int argc, char *argv[]) {
+ no_test_size = true;
PERFORM_TEST (test, argc, argv);
return 0;
}
int main(int argc, char *argv[]) {
+ no_test_size = true;
PERFORM_TEST(test, argc, argv);
PERFORM_TEST(test2, argc, argv);
PERFORM_TEST(test3, argc, argv);
#include "test.h"
-static float line_width = 1.f;
-static vkvg_line_cap_t line_cap = VKVG_LINE_CAP_ROUND;
-static float dashes[] = {1.0f, 5.0f};
-static uint32_t dashes_count = 0;
-
-VkvgContext _initCtx() {
- VkvgContext ctx = vkvg_create(surf);
- vkvg_clear(ctx);
- vkvg_set_line_width (ctx,line_width);
- vkvg_set_line_cap(ctx, line_cap);
- vkvg_set_dash (ctx, dashes, dashes_count, 0);
- return ctx;
-}
-
void horizontal() {
float w = (float)test_width;
float h = (float)test_height;
for (uint32_t i=0; i<test_size; i++) {
randomize_color(ctx);
- float x1 = w*rand()/RAND_MAX;
- float y1 = h*rand()/RAND_MAX;
- float v = 500.f*rand()/RAND_MAX;
+ float x1 = w*rndf();
+ float y1 = h*rndf();
+ float v = 500.f*rndf();
vkvg_move_to (ctx, x1, y1);
vkvg_line_to (ctx, x1 + v, y1);
for (uint32_t i=0; i<test_size; i++) {
randomize_color(ctx);
- float x1 = w*rand()/RAND_MAX;
- float y1 = h*rand()/RAND_MAX;
- float v = 500.f*rand()/RAND_MAX;
+ float x1 = w*rndf();
+ float y1 = h*rndf();
+ float v = 500.f*rndf();
vkvg_move_to (ctx, x1, y1);
vkvg_line_to (ctx, x1, y1 + v);
for (uint32_t i=0; i<test_size; i++) {
randomize_color(ctx);
- float x1 = w*rand()/RAND_MAX;
- float y1 = h*rand()/RAND_MAX;
- float x2 = (w*rand()/RAND_MAX) + 1;
- float y2 = (h*rand()/RAND_MAX) + 1;
+ float x1 = w*rndf();
+ float y1 = h*rndf();
+ float x2 = (w*rndf()) + 1;
+ float y2 = (h*rndf()) + 1;
vkvg_move_to (ctx, x1, y1);
vkvg_line_to (ctx, x2, y2);
for (uint32_t i=0; i<test_size; i++) {
- float x1 = w*rand()/RAND_MAX;
- float y1 = h*rand()/RAND_MAX;
- float x2 = (w*rand()/RAND_MAX) + 1;
- float y2 = (h*rand()/RAND_MAX) + 1;
+ float x1 = w*rndf();
+ float y1 = h*rndf();
+ float x2 = (w*rndf()) + 1;
+ float y2 = (h*rndf()) + 1;
vkvg_move_to (ctx, x1, y1);
vkvg_line_to (ctx, x2, y2);
VkvgContext ctx = _initCtx();
randomize_color(ctx);
- float x1 = w*rand()/RAND_MAX;
- float y1 = h*rand()/RAND_MAX;
+ float x1 = w*rndf();
+ float y1 = h*rndf();
vkvg_move_to (ctx, x1, y1);
for (uint32_t i=0; i<test_size; i++) {
- x1 = w*rand()/RAND_MAX;
- y1 = h*rand()/RAND_MAX;
+ x1 = w*rndf();
+ y1 = h*rndf();
vkvg_line_to (ctx, x1, y1);
}
vkvg_stroke (ctx);
vkvg_destroy(ctx);
}
int main(int argc, char *argv[]) {
+ no_test_size = true;
PERFORM_TEST (paint, argc, argv);
PERFORM_TEST (paint_with_offset, argc, argv);
PERFORM_TEST (paint_multiple, argc, argv);
vkvg_rectangle(ctx, x, y, z, v);
}*/
-static vkvg_fill_rule_t fill_rule = VKVG_FILL_RULE_EVEN_ODD;
-static vkvg_line_cap_t line_cap = VKVG_LINE_CAP_BUTT;
-static vkvg_line_join_t line_join = VKVG_LINE_JOIN_MITER;
-static float line_width = 1.f;
static float shape_size = 0.2f;
-static float dashes[] = {3.0f, 10.0f};
-static uint32_t dashes_count = 0;
-
void _shape_fill(shape_t shape){
- VkvgContext ctx = vkvg_create(surf);
- vkvg_clear(ctx);
- vkvg_set_fill_rule(ctx, fill_rule);
+ VkvgContext ctx = _initCtx ();
for (uint32_t i=0; i<test_size; i++) {
draw_random_shape(ctx, shape, shape_size);
vkvg_fill(ctx);
vkvg_destroy(ctx);
}
void _shape_stroke(shape_t shape){
- VkvgContext ctx = vkvg_create(surf);
- vkvg_clear(ctx);
- vkvg_set_line_width (ctx, line_width);
- vkvg_set_line_cap(ctx, line_cap);
- vkvg_set_line_join (ctx, line_join);
- vkvg_set_dash (ctx, dashes, dashes_count, 0);
- vkvg_set_fill_rule(ctx, fill_rule);
+ VkvgContext ctx = _initCtx ();
for (uint32_t i=0; i<test_size; i++) {
draw_random_shape(ctx, shape, shape_size);
vkvg_stroke (ctx);
vkvg_destroy(ctx);
}
void _shape_fill_stroke(shape_t shape){
- VkvgContext ctx = vkvg_create(surf);
- vkvg_clear(ctx);
- vkvg_set_line_width (ctx, line_width);
- vkvg_set_line_cap(ctx, line_cap);
- vkvg_set_line_join (ctx, line_join);
+ VkvgContext ctx = _initCtx ();
- vkvg_set_dash (ctx, dashes, dashes_count, 0);
- vkvg_set_fill_rule(ctx, fill_rule);
for (uint32_t i=0; i<test_size; i++) {
draw_random_shape(ctx, shape, shape_size);
vkvg_fill_preserve(ctx);
}
int main(int argc, char *argv[]) {
- srand(0);
+ //vkvg_log_level = VKVG_LOG_ERR|VKVG_LOG_DEBUG|VKVG_LOG_INFO|VKVG_LOG_INFO_PATH|VKVG_LOG_DBG_ARRAYS|VKVG_LOG_FULL;
PERFORM_TEST (rectangles_fill, argc, argv);
PERFORM_TEST (rectangles_stroke, argc, argv);
vkvg_destroy(ctx);
}
int main(int argc, char *argv[]) {
-
+ no_test_size = true;
PERFORM_TEST (test, argc, argv);
PERFORM_TEST (test_evenodd, argc, argv);
return 0;
}
int main(int argc, char *argv[]) {
+ no_test_size = true;
PERFORM_TEST (test, argc, argv);
return 0;
}
vkvg_destroy(ctx);
}
int main(int argc, char *argv[]) {
+ no_test_size = true;
PERFORM_TEST (paint, argc, argv);
PERFORM_TEST (paint_with_rotation, argc, argv);
PERFORM_TEST (paint_with_scale, argc, argv);
}
int main(int argc, char *argv[]) {
+ no_test_size = true;
PERFORM_TEST (test, argc, argv);
return 0;
}
--- /dev/null
+#include "test.h"
+
+void create_destroy_multi_512(){
+ VkvgSurface surfs[test_size];
+ for (uint32_t i = 0; i < test_size; i++)
+ surfs[i] = vkvg_surface_create (device, 512, 512);
+ for (uint32_t i = 0; i < test_size; i++)
+ vkvg_surface_destroy(surfs[i]);
+}
+
+void create_destroy_single_512(){
+ VkvgSurface s = vkvg_surface_create (device, 512, 512);
+ vkvg_surface_destroy (s);
+}
+
+int main(int argc, char *argv[]) {
+ PERFORM_TEST (create_destroy_multi_512, argc, argv);
+ no_test_size = true;
+ PERFORM_TEST (create_destroy_single_512, argc, argv);
+ return 0;
+}
}
int main(int argc, char *argv[]) {
+ no_test_size = true;
PERFORM_TEST (test_nsvg, argc, argv);
return 0;
}
int main(int argc, char *argv[]) {
+ no_test_size = true;
PERFORM_TEST (cairo_tests, argc, argv);
return 0;
}
vkvg_destroy(ctx);
}
int main(int argc, char *argv[]) {
-
+ no_test_size = true;
//vkvg_log_level = VKVG_LOG_INFO;
PERFORM_TEST (random_text, argc, argv);
PERFORM_TEST (test, argc, argv);