]> O.S.I.I.S - jp/vkvg.git/commitdiff
wip
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 8 Nov 2022 12:09:00 +0000 (13:09 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 1 Mar 2023 17:56:44 +0000 (18:56 +0100)
src/vkvg_context_internal.c
src/vkvg_fonts.c
tests/bezier.c
tests/common/test.c
tests/common/test.h
tests/curve.c
tests/inverse_colinear.c

index d6b529b5919c361bd9d4633aa47fde61e6dbe0f7..1ee302802317cc03714a82e1e51d31a577e0e8d5 100644 (file)
@@ -929,12 +929,9 @@ void _release_context_ressources (VkvgContext ctx) {
 //populate vertice buff for stroke
 bool _build_vb_step(VkvgContext ctx, stroke_context_t* str, bool isCurve){
        Vertex v = {{0},ctx->curColor, {0,0,-1}};
-       vec2 pL = ctx->points[str->iL];
        vec2 p0 = ctx->points[str->cp];
-       vec2 pR = ctx->points[str->iR];
-
-       vec2 v0 = vec2_sub(p0, pL);
-       vec2 v1 = vec2_sub(pR, p0);
+       vec2 v0 = vec2_sub(p0, ctx->points[str->iL]);
+       vec2 v1 = vec2_sub(ctx->points[str->iR], p0);
        float length_v0 = vec2_length(v0);
        float length_v1 = vec2_length(v1);
        if (length_v0 < FLT_EPSILON || length_v1 < FLT_EPSILON) {
@@ -966,13 +963,9 @@ bool _build_vb_step(VkvgContext ctx, stroke_context_t* str, bool isCurve){
                return true;
        }
 
-
        vec2 bisec_n = vec2_norm(vec2_add(v0n,v1n));//bisec/bisec_perp are inverted names
-
-
        float alpha = acosf(dot);
 
-
        if (det<0)
                alpha = -alpha;
 
index 9c5f2c6ea78412239d825f5716cc96d128ee80ec..35858f3b79e6e39466375716f3cb2748bfd3ff4b 100644 (file)
@@ -75,7 +75,7 @@ void _fonts_cache_create (VkvgDevice dev){
 
        cache->uploadFence = vkh_fence_create((VkhDevice)dev);
 
-       uint32_t buffLength = FONT_PAGE_SIZE*FONT_PAGE_SIZE*cache->texPixelSize;
+       const uint32_t buffLength = FONT_PAGE_SIZE*FONT_PAGE_SIZE*cache->texPixelSize;
 
        vkh_buffer_init ((VkhDevice)dev,
                VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
@@ -85,7 +85,7 @@ void _fonts_cache_create (VkvgDevice dev){
        cache->cmd = vkh_cmd_buff_create((VkhDevice)dev,dev->cmdPool,VK_COMMAND_BUFFER_LEVEL_PRIMARY);
 
        //Set texture cache initial layout to shaderReadOnly to prevent error msg if cache is not fill
-       VkImageSubresourceRange subres          = {VK_IMAGE_ASPECT_COLOR_BIT,0,1,0,cache->texLength};
+       const VkImageSubresourceRange subres = {VK_IMAGE_ASPECT_COLOR_BIT,0,1,0,cache->texLength};
        vkh_cmd_begin (cache->cmd,VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);
        vkh_image_set_layout_subres(cache->cmd, cache->texture, subres,
                                                                VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
@@ -433,7 +433,7 @@ _vkvg_font_t* _find_or_create_font_size (VkvgContext ctx) {
        newSize.charLookup = (_char_ref**)calloc (newSize.face->num_glyphs, sizeof(_char_ref*));
 
        if (FT_IS_SCALABLE(newSize.face))
-               newSize.curLine.height = FT_MulFix(newSize.face->height, newSize.face->size->metrics.y_scale) >> 6;
+               newSize.curLine.height = newSize.face->size->metrics.height >> 6;
        else
                newSize.curLine.height = newSize.face->height >> 6;
 #else
index dafbbea7b9be2417a322eaeb0e7ea2dc67350260..756a3c7fc53a16a29e24745bfa57af9af9b97416 100644 (file)
@@ -54,7 +54,7 @@ void draw (){
                vkvg_fill_preserve (ctx);
        }
 
-       vkvg_set_source_rgba(ctx,1,0,0,1);
+       vkvg_set_source_rgba(ctx,1,0,0,0.3f);
 
        vkvg_stroke (ctx);
        vkvg_flush (ctx);
index 15c8d61d884290399cea6d36c5945fe0397cdea0..595f71a2b060f3c11fd536b5da126bd220f2e623 100644 (file)
@@ -321,17 +321,19 @@ void _parse_args (int argc, char* argv[]) {
                        _print_usage_and_exit();
        }
        if (printTestDetailsAndExit) {
-               #ifdef DEBUG
+#ifdef DEBUG
                printf("Debug build\n");
-               #else
+#else
                printf("Release build\n");
-               #endif
-               #ifdef VKVG_USE_RENDERDOC
+#endif
+#ifdef VKVG_USE_RENDERDOC
                printf("Render doc enabled\n");
-               #endif
-               #ifdef VKVG_USE_VALIDATION
-               printf("Validation enabled\n");
-               #endif
+#endif
+#ifdef VKVG_USE_VALIDATION
+               printf("Validation:\tenabled\n");
+#else
+               printf("Validation:\no\n");
+#endif
                printf("surf dims:\t%d x %d\n", test_width, test_height);
                printf("Samples:\t%d\n", samples);
                printf("Gpu type:\t");
@@ -426,6 +428,9 @@ void perform_test (void(*testfunc)(void), const char *testName, int argc, char*
        gettimeofday(&currentTime, NULL);
        srand((unsigned)currentTime.tv_usec);
 
+       if (iterations == 0)
+               iterations = 9999;
+
        if (single_test >= 0 && test_index != single_test) {
                test_index++;
                return;
@@ -463,8 +468,8 @@ void perform_test_offscreen (void(*testfunc)(void), const char *testName, int ar
                                                                   | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT
                                                                   , VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT
                                                                   | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT
-                                                                  | VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT
-                                                                  | VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT
+                                                                  //| VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT
+                                                                  //| VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT
                                                                   , NULL);
 #endif
        bool deferredResolve = false;
index e693071365896f7b41811cf5b9e6c95c58a35c50..d61858e48ef9c56c87e1d544d5bcdd6f65e86ad9 100644 (file)
 
 #define M_PIF               3.14159265359f /* float pi */
 #define M_PIF_MULT_2        6.28318530718f
+#ifndef M_PI
+# define M_PI          3.14159265358979323846  /* pi */
+#endif
+#ifndef M_PI_2
+# define M_PI_2                1.57079632679489661923  /* pi/2 */
+#endif
 
 #ifndef MIN
 # define MIN(a,b) (((a) < (b)) ? (a) : (b))
index 619019b02e856cc6b4dc6a16255475359a892213..ff78bc8b4e039916f63e21ad588d12200fc5abfa 100644 (file)
@@ -190,7 +190,7 @@ void long_curv_fill_stroke_eo () {
 int main(int argc, char *argv[]) {
        no_test_size = true;
        PERFORM_TEST(test3, argc, argv);
-       return 0;
+       //return 0;
        PERFORM_TEST(test, argc, argv);
        PERFORM_TEST(test2, argc, argv);
        PERFORM_TEST(curved_rect, argc, argv);
index 88de07596508aaedf071f2798865b35e15d32dc3..da4069f367bf27efe9db2299d6ec58d28b3bf5c4 100644 (file)
@@ -10,12 +10,13 @@ bool isClosed = false;
 bool startWithArc = false, endWithArc = false;
 
 int ptsCount = 4;
-int initPtsCount = 4;
+int initPtsCount = 5;
 vec2 pts[] = {
        {150,150},
        {200,300},
        {250,150},
        {280,350},
+       {300,100},
 };
 /*vec2 pts[] = {
        {150,150},
@@ -39,7 +40,7 @@ void draw (){
        vkvg_clear(ctx);
        if (dashCount > 0)
                vkvg_set_dash(ctx, dash, dashCount,0);
-       vkvg_set_source_rgba    (ctx,1,0,0,1);
+       vkvg_set_source_rgba    (ctx,1,0,0,0.3f);
        vkvg_set_line_width             (ctx,lineWidth);
        vkvg_set_line_join              (ctx, lineJoin);
        vkvg_set_line_cap               (ctx, lineCap);