]> O.S.I.I.S - jp/vkvg.git/commitdiff
split select font face/path, preferedPhysicalDeviceType in test.c
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 14 Jun 2021 07:51:44 +0000 (09:51 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 14 Jun 2021 07:51:44 +0000 (09:51 +0200)
appveyor.yml
include/vkvg.h
src/vkvg_context.c
src/vkvg_context_internal.c
src/vkvg_context_internal.h
src/vkvg_fonts.c
src/vkvg_fonts.h
tests/common/test.c

index cf6d16f8355bd9f44b700b2eb0c35f93ed67145d..79edab00c0197823d67f95621694b3f9e8c0f2fd 100644 (file)
@@ -13,7 +13,7 @@ for:
         VCPKG_DEFAULT_TRIPLET: x64-windows
         VULKAN_SDK: C:/VulkanSDK/1.1.130.0
         APPVEYOR_SAVE_CACHE_ON_ERROR: true
-        APPVEYOR_CACHE_SKIP_RESTORE: true
+        APPVEYOR_CACHE_SKIP_RESTORE: false
     cache:
         - VulkanSDK.exe
         - c:\tools\vcpkg\installed\
index 156c148b4e2f2b91cb9271aca496e2b98ef80d89..1846c17ca0daa43f3d9f2a941350ddfef2071e8b 100644 (file)
@@ -1237,22 +1237,29 @@ void vkvg_set_matrix (VkvgContext ctx, const vkvg_matrix_t* matrix);
 vkvg_public
 void vkvg_get_matrix (VkvgContext ctx, const vkvg_matrix_t* matrix);
 /**
- * @brief
+ * @brief Reset the current transformation matrix of the provided context to the identity matrix.
  *
  * @param ctx a valid vkvg #context
  */
 vkvg_public
 void vkvg_identity_matrix (VkvgContext ctx);
 
-//text
 /**
- * @brief
+ * @brief Try find font with the specified name using the FontConfig library.
  *
  * @param ctx a valid vkvg #context
- * @param name
+ * @param name A name to be recognized by the FontConfig library
  */
 vkvg_public
 void vkvg_select_font_face (VkvgContext ctx, const char* name);
+/**
+ * @brief Select a new font by providing its file path.
+ *
+ * @param ctx a valid vkvg #context
+ * @param name A valid font file path.
+ */
+vkvg_public
+void vkvg_select_font_path (VkvgContext ctx, const char* path);
 /**
  * @brief
  *
index e9df71e928df60c94c74a88c92f11fdf01f02076..33e4c4b58f95117aa565e2ed9837003b0afbc9ba 100644 (file)
@@ -896,6 +896,9 @@ VkvgPattern vkvg_get_source (VkvgContext ctx){
 void vkvg_select_font_face (VkvgContext ctx, const char* name){
        _select_font_face (ctx, name);
 }
+void vkvg_select_font_path (VkvgContext ctx, const char* path){
+       _select_font_path (ctx, path);
+}
 void vkvg_set_font_size (VkvgContext ctx, uint32_t size){
        _set_font_size (ctx,size);
 }
index d3df56b500b785ef25daee77ece5067d0eb6893c..025b63eca326ab630defc6e409737803fcf1dc31 100644 (file)
@@ -1056,7 +1056,7 @@ void _poly_fill (VkvgContext ctx){
                        _end_render_pass(ctx);
                        _flush_vertices_caches(ctx);
                        vkh_cmd_end(ctx->cmd);
-                       _wait_and_submit_cmd(ctx);
+                       _wait_and_submit_cmd(ctx);//the extra wait here is not useful.
                        if (ctx->vertCount + ctx->pointCount > ctx->sizeVBO){
                                //_resize_vertex_cache(ctx, ctx->vertCount + ctx->pointCount);
                                _resize_vbo(ctx, ctx->vertCount + ctx->pointCount);
index 4f658685d4453526ccf6b7da134472db2134e34b..1b302ba7faf784f45afcd1a910f0ebe44919b2eb 100644 (file)
@@ -127,7 +127,7 @@ typedef struct _vkvg_context_t {
 
        //vk buffers, holds data until flush
        vkvg_buff       indices;        //index buffer with persistent map memory
-       uint32_t        sizeIBO;        //size of vk ibo size
+       uint32_t        sizeIBO;        //size of vk ibo
        uint32_t        sizeIndices;    //reserved size
        uint32_t        indCount;       //current indice count
 
index 2255754f0a3820a75b29059471e2066a189f867f..3cd9cf1e33ceddf1a393488a6d88a75fad9dc8b3 100644 (file)
@@ -220,7 +220,7 @@ void _dump_glyphs (FT_Face face){
 //flush font stagging buffer to cache texture array
 void _flush_chars_to_tex (VkvgDevice dev, _vkvg_font_t* f) {
        _font_cache_t* cache = dev->fontCache;
-       if (cache->stagingX == 0)
+       if (cache->stagingX == 0)//no char in stagging buff to flush
                return;
 
        LOG(VKVG_LOG_INFO, "_flush_chars_to_tex pen(%d, %d)\n",f->curLine.penX, f->curLine.penY);
@@ -321,6 +321,12 @@ void _set_font_size (VkvgContext ctx, uint32_t size){
        ctx->selectedFont.charSize = size << 6;
        ctx->currentFont = NULL;
 }
+
+void _select_font_path (VkvgContext ctx, const char* fontFile){
+       memset (ctx->selectedFont.fontFile, 0, FONT_FILE_NAME_MAX_SIZE);
+       memcpy (ctx->selectedFont.fontFile, fontFile, FONT_FILE_NAME_MAX_SIZE);
+       ctx->currentFont =  NULL;
+}
 //select current font for context
 void _select_font_face (VkvgContext ctx, const char* name){
        _font_cache_t*  cache = (_font_cache_t*)ctx->pSurf->dev->fontCache;
@@ -336,16 +342,13 @@ void _select_font_face (VkvgContext ctx, const char* name){
        FcPattern* font = FcFontMatch(cache->config, pat, &result);
        if (font)
        {
-               if (FcPatternGetString(font, FC_FILE, 0, (FcChar8 **)&fontFile) == FcResultMatch){
-                       memset (ctx->selectedFont.fontFile, 0, FONT_FILE_NAME_MAX_SIZE);
-                       memcpy (ctx->selectedFont.fontFile, fontFile, FONT_FILE_NAME_MAX_SIZE);
-               }
+               if (FcPatternGetString(font, FC_FILE, 0, (FcChar8 **)&fontFile) == FcResultMatch)
+                       _select_font_path (ctx, fontFile);
        }
        FcPatternDestroy(pat);
        FcPatternDestroy(font);
-
-       ctx->currentFont =  NULL;
 }
+
 //try to find font in cache with same font file path and font size as selected in context.
 _vkvg_font_t* _tryFindVkvgFont (VkvgContext ctx){
        _font_cache_t*  cache = (_font_cache_t*)ctx->pSurf->dev->fontCache;
index d6bd37edad75d6a870d3e49af242c0533c7f1830..4f5211daab534825c20aa5e30ce1ef59f45314d9 100644 (file)
@@ -116,6 +116,7 @@ void _init_fonts_cache      (VkvgDevice dev);
 void _destroy_font_cache       (VkvgDevice dev);
 //Select current font for context from font name, create new font entry in cache if required
 void _select_font_face         (VkvgContext ctx, const char* name);
+void _select_font_path         (VkvgContext ctx, const char* fontFile);
 //Set current font size for context
 void _set_font_size         (VkvgContext ctx, uint32_t size);
 //Draw text
index c64f002444ba922f4f344425dc652d0f11b80308..0bec4d94aea0a3027f0cf1dcd280f1bbc00ef6e4 100644 (file)
@@ -48,6 +48,7 @@ int           single_test = -1;       //if not < 0, contains the index of the single test to ru
 
 static bool paused = false;
 static VkSampleCountFlags samples = VK_SAMPLE_COUNT_1_BIT;
+static VkPhysicalDeviceType preferedPhysicalDeviceType = VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU;
 static vk_engine_t* e;
 
 static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) {
@@ -136,9 +137,9 @@ double standard_deviation (const double data[], int n, double mean)
 
 void init_test (uint32_t width, uint32_t height){
        if (test_vsync)
-               e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, width, height);
+               e = vkengine_create (preferedPhysicalDeviceType, VK_PRESENT_MODE_FIFO_KHR, width, height);
        else
-               e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_MAILBOX_KHR, width, height);
+               e = vkengine_create (preferedPhysicalDeviceType, VK_PRESENT_MODE_MAILBOX_KHR, width, height);
 
        VkhPresenter r = e->renderer;
        vkengine_set_key_callback (e, key_callback);
@@ -416,9 +417,9 @@ void perform_test (void(*testfunc)(void), const char *testName, int argc, char*
        }
 
        if (test_vsync)
-               e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, test_width, test_height);
+               e = vkengine_create (preferedPhysicalDeviceType, VK_PRESENT_MODE_FIFO_KHR, test_width, test_height);
        else
-               e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_MAILBOX_KHR, test_width, test_height);
+               e = vkengine_create (preferedPhysicalDeviceType, VK_PRESENT_MODE_MAILBOX_KHR, test_width, test_height);
 
        VkhPresenter r = e->renderer;
        vkengine_set_key_callback (e, key_callback);