]> O.S.I.I.S - jp/vkvg.git/commitdiff
Fontconfig init check, sample startup simplified, code docs and clean
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 4 May 2020 11:40:57 +0000 (13:40 +0200)
committerj-p <jp_bruyere@hotmail.com>
Tue, 5 May 2020 20:14:27 +0000 (22:14 +0200)
43 files changed:
src/vkvg_context.c
src/vkvg_context_internal.c
src/vkvg_context_internal.h
src/vkvg_fonts.c
src/vkvg_fonts.h
template.c
tests/arcs.c
tests/circles.c
tests/clip.c
tests/colinear.c
tests/common/test.c
tests/common/test.h
tests/common/vkengine.c
tests/common/vkengine.h
tests/compositing.c
tests/curve.c
tests/curve2.c
tests/curved_rect.c
tests/dashes.c
tests/dashes2.c
tests/fill.c
tests/fill_and_stroke.c
tests/gradient.c
tests/gradient_transform.c
tests/hlines.c
tests/img_surf.c
tests/line_caps.c
tests/line_join.c
tests/line_join_2.c
tests/line_join_3.c
tests/lines.c
tests/multilines.c
tests/random_cirles.c
tests/random_rects.c
tests/rect_fill.c
tests/save_restore.c
tests/simple_paint.c
tests/stroke.c
tests/svg.c
tests/test1.c
tests/text.c
tests/vlines.c
vkh

index b6a405260db13b8adf596121ec13419e6e7087bc..4a985a3573ed32fc039f6474075ae2b1c681d2ee 100644 (file)
@@ -41,7 +41,7 @@ static VkClearValue clearValues[3] = {
 
 /**
  * @brief create new context for surface
- * @param drawing operation output surface
+ * @param drawing operations output surface
  * @return newly created context pointer
  */
 VkvgContext vkvg_create(VkvgSurface surf)
@@ -229,6 +229,7 @@ void vkvg_destroy (VkvgContext ctx)
     free(ctx->vertexCache);
     free(ctx->indexCache);
 
+    //TODO:check this for source counter
     //vkh_image_destroy   (ctx->source);
 
     free(ctx->selectedFont.fontFile);
@@ -301,10 +302,6 @@ void vkvg_new_sub_path (VkvgContext ctx){
 void vkvg_new_path (VkvgContext ctx){
     _clear_path(ctx);
 }
-//path closing is done by setting the endpoint of the path to the same index
-//as the start point.
-//I'll test if closing by adding a new point with the same x,y as the start point
-//would not make more sense.
 /**
  * @brief Close current path if at least 3 points are present
  * @param context pointer
@@ -356,7 +353,7 @@ void vkvg_line_to (VkvgContext ctx, float x, float y)
     _add_point(ctx,x,y);
 }
 /**
- * @brief Draw arc
+ * @brief Draw arc in clockwise order following angles of the trigonometric circle.
  * @param context pointer
  * @param center x coordinate
  * @param center y coordinate
@@ -408,6 +405,15 @@ void vkvg_arc (VkvgContext ctx, float xc, float yc, float radius, float a1, floa
         _add_point (ctx, v.x, v.y);
     _set_curve_end(ctx);
 }
+/**
+ * @brief Draw arc in counter clockwise order following angles of the trigonometric circle.
+ * @param context pointer
+ * @param center x coordinate
+ * @param center y coordinate
+ * @param radius
+ * @param start angle of arc
+ * @param end angle of arc
+ */
 void vkvg_arc_negative (VkvgContext ctx, float xc, float yc, float radius, float a1, float a2) {
     while (a2 > a1)
         a2 -= 2.f*M_PIF;
@@ -450,6 +456,12 @@ void vkvg_arc_negative (VkvgContext ctx, float xc, float yc, float radius, float
         _add_point (ctx, v.x, v.y);
     _set_curve_end(ctx);
 }
+/**
+ * @brief move pen relative to the current point.
+ * @param ctx
+ * @param delta in the horizontal direction
+ * @param delta in the vertical direction
+ */
 void vkvg_rel_move_to (VkvgContext ctx, float x, float y)
 {
     if (_current_path_is_empty(ctx)){
@@ -459,11 +471,18 @@ void vkvg_rel_move_to (VkvgContext ctx, float x, float y)
     vec2 cp = _get_current_position(ctx);
     vkvg_move_to(ctx, cp.x + x, cp.y + y);
 }
+/**
+ * @brief move pen to the position given in argument
+ * @param ctx
+ * @param new x position of the pen
+ * @param new y position of the pen
+ */
 void vkvg_move_to (VkvgContext ctx, float x, float y)
 {
     _finish_path(ctx);
     _start_sub_path(ctx, x, y);
 }
+
 void vkvg_curve_to (VkvgContext ctx, float x1, float y1, float x2, float y2, float x3, float y3) {
     if (_current_path_is_empty(ctx))
         vkvg_move_to(ctx, x1, y1);
index 423ba0527309b67acf5696ef40f1b7c16427188f..e8ff1dd4464c9d5a14f18a734856013fbf098f9f 100644 (file)
@@ -99,7 +99,7 @@ void _set_curve_start (VkvgContext ctx) {
     ctx->pathes[ctx->pathPtr+ctx->curvePtr+1] = (ctx->pointCount - 1);
     ctx->pathes[ctx->pathPtr-1] |= PATH_HAS_CURVES_BIT;
 }
-//set curve end point and set path has curve bit
+//set curve end point and set path is curve bit
 void _set_curve_end (VkvgContext ctx) {
     ctx->pathes[ctx->pathPtr+ctx->curvePtr+2] = (ctx->pointCount - 1)|PATH_IS_CURVE_BIT;
     ctx->curvePtr+=2;
@@ -1017,10 +1017,10 @@ void _poly_fill (VkvgContext ctx){
             continue;
         }
         //close path
-        ctx->pathes[ptrPath] |= PATH_CLOSED_BIT;// ctx->pathes[ptrPath];//close path by setting start and end equal
+        ctx->pathes[ptrPath] |= PATH_CLOSED_BIT;
 
         uint32_t firstPtIdx = ctx->pathes [ptrPath] & PATH_ELT_MASK;
-        uint32_t lastPtIdx  = ctx->pathes [ptrPath+1] & PATH_ELT_MASK;//_get_last_point_of_closed_path (ctx, ptrPath);
+        uint32_t lastPtIdx  = ctx->pathes [ptrPath+1] & PATH_ELT_MASK;
         uint32_t pathPointCount = lastPtIdx - firstPtIdx + 1;
 
         VKVG_IBO_INDEX_TYPE firstVertIdx = ctx->vertCount;
index 052813bf6eefa7a2cf1048057be2d6f7d0281a59..3e3472287b225b6b0af7924cbfa9253b22821785 100644 (file)
@@ -123,8 +123,6 @@ typedef struct _vkvg_context_t {
 
     //pathes array is a list of couple (start,end) point idx refering to point array
     //it split points list in subpathes and tell if path is closed.
-    //if path is closed, end index is the same as start.
-    //(TODO: I should use a boolean or smthg else instead to keep last point in array)
     uint32_t   pathPtr;        //pointer in the path array, even=start point;odd=end point
     uint32_t*  pathes;
     size_t             sizePathes;
index 6fa7af1122418d62e2f50d73d9c3686b8a57380e..c38c303a68fb44b81f34cf30a09ac3bac8c1a674 100644 (file)
@@ -33,6 +33,11 @@ void _init_fonts_cache (VkvgDevice dev){
     _font_cache_t* cache = (_font_cache_t*)calloc(1, sizeof(_font_cache_t));
 
     cache->config = FcInitLoadConfigAndFonts();
+    if (!cache->config) {
+        fprintf(stderr, "Font config initialisation failed, consider using 'FONTCONFIG_PATH' and 'FONTCONFIG_FILE' environmane\
+                       variables to point to 'fonts.conf' needed for FontConfig startup");
+        assert(cache->config);
+    }
 
     FT_CHECK_RESULT(FT_Init_FreeType(&cache->library));
 
index 02c1c1492a12bfca6085fef2fe5ce51f0979bb0e..d925545f1bcba01c841616752264fbd6152d50fb 100644 (file)
@@ -43,7 +43,7 @@
     FT_Error res = (f);                                                                                                                                                                        \
     if (res != 0)                                                                                                                                                              \
     {                                                                                                                                                                                                  \
-        printf("Fatal : FreeType error is %d in %s at line %d\n", res,  __FILE__, __LINE__); \
+        fprintf(stderr,"Fatal : FreeType error is %d in %s at line %d\n", res,  __FILE__, __LINE__); \
         assert(res == 0);                                                                                                                                              \
     }                                                                                                                                                                                                  \
 }
index 3cb99af9a3f72e236dfbe801cb21c212b178d713..a222a844ce581b7a8e2588ef4b792625a8d1a594 100644 (file)
@@ -1,3 +1,7 @@
+/*
+ * test template
+ */
+
 #include "test.h"
 
 void test(){
@@ -8,7 +12,7 @@ void test(){
 
 int main(int argc, char *argv[]) {
 
-       perform_test (test, 600, 800);
+       perform_test (test, "custom test", 800, 600);
 
        return 0;
 }
index 88a6066544aafa353b194ac9b4ed19e42e76e900..6a3c56c25ce8fc883dbec364d9257920d503da42 100644 (file)
@@ -1,13 +1,79 @@
 #include "test.h"
 
+void draw_growing_circles (VkvgContext ctx, float y, int count) {
+    float x = 2;
+    for (int i=1; i<count; i++) {
+        x += 0.5*i;
+        //vkvg_set_source_rgb   (ctx, 1,0,1);
+        vkvg_arc(ctx, x + 2, y, 0.5 * i, 0, M_PI*1.5);
+        //vkvg_set_source_rgb   (ctx, 0,1,1);
+        //vkvg_arc_negative(ctx, x + 2, y, 0.5 * i, M_PI/2,0);
+        x += 0.5*i + 5;
+    }
+}
+
+void scaled_up() {
+    VkvgContext ctx = vkvg_create(surf);
+
+    vkvg_set_source_rgb   (ctx, 1,1,1);
+    vkvg_paint(ctx);
+    vkvg_set_source_rgb   (ctx, 0,0,0);
+
+    vkvg_scale(ctx,100,100);
+    vkvg_arc(ctx, 2, 2, 0.5, 0, M_PI/2);
+    vkvg_stroke(ctx);
+
+    vkvg_destroy(ctx);
+}
+void sizes() {
+    VkvgContext ctx = vkvg_create(surf);
+
+    vkvg_set_source_rgb   (ctx, 1,1,1);
+    vkvg_paint(ctx);
+    vkvg_set_source_rgb   (ctx, 0,0,0);
+
+    draw_growing_circles (ctx, 100, 40);
+    vkvg_stroke(ctx);
+
+    vkvg_destroy(ctx);
+}
 void test(){
     VkvgContext ctx = vkvg_create(surf);
 
-    vkvg_set_line_width(ctx, 0.5);
     vkvg_set_source_rgb   (ctx, 1,1,1);
     vkvg_paint(ctx);
     vkvg_set_source_rgb   (ctx, 0,0,0);
 
+    vkvg_set_source_rgb   (ctx, 1,0,1);
+    vkvg_set_line_width(ctx, 5.0);
+    vkvg_arc(ctx, 100, 100, 20, 0, M_PI/2);
+    vkvg_stroke(ctx);
+
+    vkvg_set_source_rgb   (ctx, 0,1,1);
+    vkvg_arc_negative(ctx, 100, 100, 20, 0, M_PI/2);
+    vkvg_stroke(ctx);
+
+    vkvg_set_source_rgb   (ctx, 1,0,1);
+    vkvg_arc(ctx, 100, 200, 20, M_PI/2, 0);
+    vkvg_stroke(ctx);
+
+    vkvg_set_source_rgb   (ctx, 0,1,1);
+    vkvg_arc_negative(ctx, 100, 200, 20, M_PI/2, 0);
+    vkvg_stroke(ctx);
+
+    vkvg_set_source_rgb   (ctx, 0,0,1);
+    vkvg_set_line_width(ctx, 10.0);
+    vkvg_arc(ctx, 350, 100, 40, 0, M_PI*2);
+    vkvg_stroke(ctx);
+
+    vkvg_set_source_rgb   (ctx, 0,1,0);
+    vkvg_set_line_width(ctx, 1.0);
+    vkvg_arc(ctx, 150, 100, 3.5, 0, M_PI*2);
+    vkvg_stroke(ctx);
+    vkvg_arc(ctx, 200, 200, 10, 0, M_PI*2);
+    vkvg_fill(ctx);
+
+    vkvg_set_source_rgb   (ctx, 1,0,0);
     vkvg_scale(ctx,3,3);
     vkvg_arc(ctx, 150, 100, 3.5, 0, M_PI*2);
     vkvg_stroke(ctx);
@@ -18,8 +84,8 @@ void test(){
 }
 
 int main() {
-
-    perform_test (test, 1024, 768);
-
+    PERFORM_TEST (sizes);
+    PERFORM_TEST (scaled_up);
+    PERFORM_TEST (test);
     return 0;
 }
index 42af4d9e5b1b0a825a47845efb1b53c14d4073e3..6cf60b300431a63b4c7753cdf9be7d7bd500d3ae 100644 (file)
@@ -1,34 +1,51 @@
 #include "test.h"
 
-void test(){
+void draw_growing_circles (VkvgContext ctx, float y, int count) {
+    float x = 2;
+    for (int i=1; i<count; i++) {
+        x += 0.5*i;
+        vkvg_arc(ctx, x + 2, y, 0.5 * i, 0, M_PI*2);
+        x += 0.5*i + 5;
+    }
+}
+
+void scaled_up() {
     VkvgContext ctx = vkvg_create(surf);
 
+    vkvg_set_source_rgb   (ctx, 1,1,1);
+    vkvg_paint(ctx);
+    vkvg_set_source_rgb   (ctx, 0,0,0);
+
+    vkvg_scale(ctx,100,100);
+    vkvg_arc(ctx, 2, 2, 0.5, 0, M_PI*2);
+    vkvg_stroke(ctx);
+
+    vkvg_destroy(ctx);
+}
+void sizes() {
+    VkvgContext ctx = vkvg_create(surf);
 
-    vkvg_set_line_width(ctx, 1);
     vkvg_set_source_rgb   (ctx, 1,1,1);
     vkvg_paint(ctx);
     vkvg_set_source_rgb   (ctx, 0,0,0);
 
-    vkvg_scale(ctx,10.0f,10.0f);
-    //vkvg_scale(ctx,2.0f,2.0f);
+    draw_growing_circles (ctx, 100, 40);
+    vkvg_fill (ctx);
 
-    float x = 10;
-    float r = 1;
-    while (x < 600){
-        vkvg_arc(ctx, x+0.5f, 10.5f,   r, 0, M_PI*2);
-        x += r;
-        r ++;
-        x += r + 5;
-    }
+    draw_growing_circles (ctx, 200, 40);
+    vkvg_stroke(ctx);
 
+    vkvg_set_source_rgba  (ctx, 0,0,1,0.4);
+    draw_growing_circles (ctx, 300, 40);
+    vkvg_fill_preserve (ctx);
+    vkvg_set_line_width(ctx,5);
     vkvg_stroke(ctx);
 
     vkvg_destroy(ctx);
 }
 
 int main() {
-
-    perform_test (test, 1024, 768);
-
+    PERFORM_TEST (sizes);
+    PERFORM_TEST (scaled_up);
     return 0;
 }
index e6189749e6d88b3cea7ccbf9fdae81196d339d29..1418adfab7b9aa9769f0145216efe42d0905a2cb 100644 (file)
@@ -75,8 +75,7 @@ void test_clip2(){
     vkvg_destroy(ctx);
 }
 int main(int argc, char *argv[]) {
-
-    perform_test (test_clip2, 1024, 768);
-
+    PERFORM_TEST (test_clip);
+    PERFORM_TEST (test_clip2);
     return 0;
 }
index 7f426adc15392bdee946079278219976fc000afb..991af6b9a2b6b71d0e99f358c9a4573ee4e8a9d5 100644 (file)
@@ -19,7 +19,7 @@ void test(){
 
 int main(int argc, char *argv[]) {
 
-    perform_test (test, 1024, 768);
+    PERFORM_TEST (test);
 
     return 0;
 }
index 07be05748ed827549c6a2c49b18f4bcf72a8c904..85c9df027569bb896784cf55b741c91d23acdde9 100644 (file)
@@ -210,7 +210,7 @@ void clear_test () {
 VkvgSurface* surfaces;
 #endif
 
-void perform_test (void(*testfunc)(void),uint32_t width, uint32_t height) {
+void perform_test (void(*testfunc)(void), const char *testName, uint32_t width, uint32_t height) {
     //dumpLayerExts();
 
     e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_MAILBOX_KHR, width, height);
@@ -241,6 +241,8 @@ void perform_test (void(*testfunc)(void),uint32_t width, uint32_t height) {
 
     int i = 0;
 
+    vkengine_set_title(e, testName);
+
     while (!vkengine_should_close (e) && i < iterations) {
         glfwPollEvents();
 
index 74c867a9123df1c95e95741912fc110057a27efe..6606b12459cffe10dfe58c666a9ab38b1d2202de 100644 (file)
@@ -21,6 +21,7 @@
 # define MAX(a,b) (((a) > (b)) ? (a) : (b))
 #endif
 
+#define PERFORM_TEST(testName) perform_test(testName, #testName, 1024, 768);
 #if defined(_WIN32) || defined(_WIN64)
     #define WIN32_LEAN_AND_MEAN
     #define NOMINMAX
@@ -73,10 +74,10 @@ extern VkvgDevice device;
 extern VkvgSurface surf;
 
 //run test in one step
-void perform_test (void(*testfunc)(void),uint32_t width, uint32_t height);
+void perform_test (void(*testfunc)(void), const char* testName, uint32_t width, uint32_t height);
 void randomize_color (VkvgContext ctx);
 
 //run test in 3 step: init, run, clear.
 void init_test (uint32_t width, uint32_t height);
-void run_test_func (void(*testfunc)(void),uint32_t width, uint32_t height);
+void run_test_func (void(*testfunc)(void), uint32_t width, uint32_t height);
 void clear_test ();
index a090177f69268a44a95e734c3a39de03fda578dc..c9cf9f30471be2ad8a8811e23e8aa74e1ef7d26c 100644 (file)
@@ -258,7 +258,9 @@ void vkengine_blitter_run (VkEngine e, VkImage img, uint32_t width, uint32_t hei
 inline bool vkengine_should_close (VkEngine e) {
     return glfwWindowShouldClose (e->window);
 }
-
+void vkengine_set_title (VkEngine e, const char* title) {
+    glfwSetWindowTitle(e->window, title);
+}
 VkDevice vkengine_get_device (VkEngine e){
     return e->dev->dev;
 }
index 056be08bc8fd615ebb9b8921c528890e35c9c273..9a83aba69cedcd7d12bdab05f5f6742c8a2f047e 100644 (file)
@@ -51,6 +51,7 @@ void vkengine_destroy       (VkEngine e);
 bool vkengine_should_close  (VkEngine e);
 void vkengine_close         (VkEngine e);
 void vkengine_dump_Infos    (VkEngine e);
+void vkengine_set_title     (VkEngine e, const char* title);
 VkDevice            vkengine_get_device         (VkEngine e);
 VkPhysicalDevice    vkengine_get_physical_device(VkEngine e);
 VkQueue             vkengine_get_queue          (VkEngine e);
index 56e3d45baed809e38f18416c528dc5178f941c44..f485f92825cad6ce77153b29d6798aac71cfaab8 100644 (file)
@@ -1,6 +1,6 @@
 #include "test.h"
 
-void test(){
+void compositing(){
     vkvg_surface_clear(surf);
 
     VkvgContext ctx = vkvg_create(surf);
@@ -17,8 +17,6 @@ void test(){
 }
 
 int main(int argc, char *argv[]) {
-
-    perform_test (test, 600, 800);
-
+    PERFORM_TEST (compositing);
     return 0;
 }
index 38c4620639ef23cd3e4f0f5454113d61f4395915..d6e35204adaa043dab2859def187e80208e0150f 100644 (file)
@@ -56,8 +56,6 @@ void test(){
 }
 
 int main(int argc, char *argv[]) {
-
-    perform_test (test, 1024, 768);
-
+    PERFORM_TEST (test);
     return 0;
 }
index 683c29bcc65ecd9f38c5a87859f1dfd1003e6dc7..dd8e1d9febd2ab07016018aab6618fea726dc4ca 100644 (file)
@@ -20,8 +20,6 @@ void test(){
 }
 
 int main(int argc, char *argv[]) {
-
-    perform_test (test, 1024, 768);
-
+    PERFORM_TEST (test);
     return 0;
 }
index 34e739f46470489fc715412d29ad4328d702388a..ceebfb0b729904edccb9e2701852d699bf07081b 100644 (file)
@@ -33,8 +33,6 @@ void test(){
 }
 
 int main(int argc, char *argv[]) {
-
-    perform_test (test, 1024, 768);
-
+    PERFORM_TEST (test);
     return 0;
 }
index a0acdb15ce42c6a82c7aeeb983b5f9ad96a62c09..f0fb73a38bf5baf8aa77a1448ba6320c9c72b205 100644 (file)
@@ -41,8 +41,6 @@ void test(){
 }
 
 int main() {
-
-    perform_test (test, 1024, 768);
-
+    PERFORM_TEST (test);
     return 0;
 }
index 8c1b26af99f8502028e5a0e15e4a3de73cc34b44..fe14a7603cad1680bdabd191ec19d86853c6a5a9 100644 (file)
@@ -24,8 +24,6 @@ void test(){
 }
 
 int main(int argc, char *argv[]) {
-
-    perform_test (test, 1024, 768);
-
+    PERFORM_TEST (test);
     return 0;
 }
index 8813e262d63cf74b013b3869e2bc41992011ca32..eb3ed28db6ba23eb1c46d8b369575727a3bcd0b6 100644 (file)
@@ -21,8 +21,6 @@ void test(){
 }
 
 int main(int argc, char *argv[]) {
-
-    perform_test (test, 1024, 768);
-
+    PERFORM_TEST (test);
     return 0;
 }
index 791d3919bb9f4504998e5d110749e2c7b6a6c202..a9dd8d4fb8902298a40f53113a4d5d5e91ad6aa9 100644 (file)
@@ -24,8 +24,6 @@ void test(){
 }
 
 int main(int argc, char *argv[]) {
-
-    perform_test (test, 1024, 768);
-
+    PERFORM_TEST (test);
     return 0;
 }
index c11a6dc8a95b02fb2db6a3e2653a4f181cdd94a8..a474ae8249d8b4d317505ad5ec0561c363b95d6b 100644 (file)
@@ -1,15 +1,40 @@
 #include "test.h"
 
-void test(){
-    VkvgContext ctx = vkvg_create(surf);
-
-    VkvgPattern pat = vkvg_pattern_create_linear(0,0,300,300);
-    vkvg_set_line_width(ctx, 20);
+VkvgPattern create_grad (VkvgContext ctx) {
+    VkvgPattern pat = vkvg_pattern_create_linear(0,0,300,0);
     vkvg_pattern_add_color_stop(pat, 0, 1, 0, 0, 1);
     vkvg_pattern_add_color_stop(pat, 0.5, 0, 1, 0, 1);
     vkvg_pattern_add_color_stop(pat, 1, 0, 0, 1, 1);
+    return pat;
+}
+
+void paint(){
+    VkvgContext ctx = vkvg_create(surf);
+    VkvgPattern pat = create_grad(ctx);
+    vkvg_pattern_set_extend(pat,VKVG_EXTEND_NONE);
+    vkvg_set_source (ctx, pat);
+    vkvg_paint(ctx);
+
+    vkvg_pattern_destroy (pat);
+    vkvg_destroy(ctx);
+}
+void paint_repeat(){
+    VkvgContext ctx = vkvg_create(surf);
+    VkvgPattern pat = create_grad(ctx);
+    vkvg_pattern_set_extend(pat,VKVG_EXTEND_REPEAT);
+    vkvg_set_source (ctx, pat);
+    vkvg_paint(ctx);
+
+    vkvg_pattern_destroy (pat);
+    vkvg_destroy(ctx);
+}
+
+void test(){
+    VkvgContext ctx = vkvg_create(surf);
+    VkvgPattern pat = create_grad(ctx);
     vkvg_set_source (ctx, pat);
     vkvg_rectangle(ctx,100,100,200,200);
+    vkvg_set_line_width(ctx, 20);
     //vkvg_fill (ctx);
     //vkvg_paint(ctx);
     vkvg_stroke (ctx);
@@ -36,8 +61,7 @@ void test2(){
     vkvg_destroy(ctx);
 }
 int main(int argc, char *argv[]) {
-
-    perform_test (test, 1024, 768);
-
+    PERFORM_TEST(paint);
+    PERFORM_TEST(paint_repeat);
     return 0;
 }
index 6012648bd917b7c5c0b83d081f8b2e597f6bc429..ad7dadd7fb1098a60ca576580e4e6879a27100e7 100644 (file)
@@ -26,8 +26,6 @@ void test(){
 }
 
 int main(int argc, char *argv[]) {
-
-    perform_test (test, 1024, 768);
-
+    PERFORM_TEST (test);
     return 0;
 }
index 5c2e3f576cbf388707518e0cd25e31947305a30d..73837b66ae250bb26b6113d9d29a33917f62278b 100644 (file)
@@ -29,7 +29,7 @@ void test(){
 
 int main(int argc, char *argv[]) {
 
-       perform_test (test, 1024, 768);
+    PERFORM_TEST (test);
 
        return 0;
 }
index 42c4797c781be1c045e69894e96d9cb576a9ebfd..a915f2cd30bb66bbbdf765b3a845fe497bbb48f5 100644 (file)
@@ -1,4 +1,56 @@
 #include "test.h"
+void paint () {
+    VkvgContext ctx = vkvg_create(surf);
+    VkvgSurface imgSurf = vkvg_surface_create_from_image(device, "data/miroir.jpg");
+
+    vkvg_set_source_surface(ctx, imgSurf, 00, 00);
+    vkvg_paint(ctx);
+
+    vkvg_surface_destroy(imgSurf);
+    vkvg_destroy(ctx);
+}
+void paint_offset () {
+    VkvgContext ctx = vkvg_create(surf);
+    VkvgSurface imgSurf = vkvg_surface_create_from_image(device, "data/miroir.jpg");
+
+    vkvg_set_source_surface(ctx, imgSurf, 100, 100);
+    vkvg_paint(ctx);
+
+    vkvg_surface_destroy(imgSurf);
+    vkvg_destroy(ctx);
+}
+void paint_pattern () {
+    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_set_source(ctx, pat);
+    vkvg_paint(ctx);
+    vkvg_pattern_destroy(pat);
+    vkvg_surface_destroy(imgSurf);
+    vkvg_destroy(ctx);
+}
+void paint_pattern_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_pattern_set_extend(pat,VKVG_EXTEND_REPEAT);
+    vkvg_set_source(ctx, pat);
+    vkvg_paint(ctx);
+    vkvg_pattern_destroy(pat);
+    vkvg_surface_destroy(imgSurf);
+    vkvg_destroy(ctx);
+}
+void paint_pattern_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);
+    vkvg_pattern_set_extend(pat,VKVG_EXTEND_PAD);
+    vkvg_set_source(ctx, pat);
+    vkvg_paint(ctx);
+    vkvg_pattern_destroy(pat);
+    vkvg_surface_destroy(imgSurf);
+    vkvg_destroy(ctx);
+}
 
 void test(){
     VkvgContext ctx = vkvg_create(surf);
@@ -26,8 +78,12 @@ void test(){
 }
 
 int main(int argc, char *argv[]) {
-
-    perform_test (test, 1024, 768);
+    PERFORM_TEST (paint);
+    PERFORM_TEST (paint_offset);
+    PERFORM_TEST (paint_pattern);
+    PERFORM_TEST (paint_pattern_repeat);
+    PERFORM_TEST (paint_pattern_pad);
+    PERFORM_TEST (test);
 
     return 0;
 }
index 674ebb3fde7d094c1216f64be745dea0ccfdd4f9..5629be15fe29f430f95192d4a626252d9b8c60e4 100644 (file)
@@ -52,8 +52,6 @@ void test(){
 }
 
 int main(int argc, char *argv[]) {
-
-    perform_test (test, 1024, 768);
-
+    PERFORM_TEST (test);
     return 0;
 }
index 5dd2149812e4e594c91cc581951c9e49125441d5..1ef3f511a188b4d6e9a86275456db6621b9b5a45 100644 (file)
@@ -72,8 +72,6 @@ void test(){
 }
 
 int main(int argc, char *argv[]) {
-
-    perform_test (test, 1024, 768);
-
+    PERFORM_TEST (test);
     return 0;
 }
index a6e0ea7971267c8888f6567b93566189724c0a9a..9cf011c5680ef2e67a9ba54b01fc5e4a0c923b6d 100644 (file)
@@ -51,8 +51,6 @@ void test(){
 }
 
 int main(int argc, char *argv[]) {
-
-    perform_test (test, 1024, 768);
-
+    PERFORM_TEST (test);
     return 0;
 }
index 5e0e48bb3894465f11630b8218d1b4065f792a4a..9c417148bc1a10390cd13008f61b87c98db50bc4 100644 (file)
@@ -51,8 +51,6 @@ void test(){
 }
 
 int main(int argc, char *argv[]) {
-
-    perform_test (test, 1024, 768);
-
+    PERFORM_TEST(test);
     return 0;
 }
index 28927e2862fcb4e3413f30eb7f893e2ba7beb144..66d493f7a4d0755bea8e26486299c5435191da55 100644 (file)
@@ -34,8 +34,6 @@ void test(){
 }
 
 int main(int argc, char *argv[]) {
-
-    perform_test (test, 1024, 768);
-
+    PERFORM_TEST(test);
     return 0;
 }
index b4616c3047c67f76236dec691f83103e652ed219..cecd24bc83ac19619e40e4f4f8b925157ec47de1 100644 (file)
@@ -34,8 +34,6 @@ void test(){
 }
 
 int main(int argc, char *argv[]) {
-
-    perform_test (test, 1024, 768);
-
+    PERFORM_TEST (test);
     return 0;
 }
index c98cb02cf2ba11ec7e1edd4d5c2f6a0864a89b2f..f52dc235da19a3d5bec0cb2f294753d494a4a31a 100644 (file)
@@ -28,8 +28,6 @@ void test(){
 }
 
 int main(int argc, char *argv[]) {
-
-    perform_test (test, 1024, 768);
-
+    PERFORM_TEST(test);
     return 0;
 }
index c6d2402e801364d3ac8973258bdd5352d10b32f1..0befc38c99c782b02119f425ab47cc9f87ec5a87 100644 (file)
@@ -28,7 +28,7 @@ void test(){
 
 int main(int argc, char *argv[]) {
 
-       perform_test (test, 800, 600);
+    PERFORM_TEST (test);
 
        return 0;
 }
index 98ba1c35d1fec690aef39bb9d0812ebb62b63ffe..8b14c3da7584adf7a0def95ce5b467310ef42b82 100644 (file)
@@ -5,7 +5,7 @@ void test(){
 
     VkvgContext ctx = vkvg_create(surf);
 
-    //vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD);
+    vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO);
 
     vkvg_set_source_rgba(ctx,0,0,1,0.5);
     vkvg_rectangle(ctx,100,100,200,200);
@@ -17,10 +17,26 @@ void test(){
 
     vkvg_destroy(ctx);
 }
+void test_evenodd(){
+    vkvg_surface_clear(surf);
 
-int main(int argc, char *argv[]) {
+    VkvgContext ctx = vkvg_create(surf);
+
+    vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD);
+
+    vkvg_set_source_rgba(ctx,0,0,1,0.5);
+    vkvg_rectangle(ctx,100,100,200,200);
+    vkvg_fill(ctx);
 
-    perform_test (test, 1024, 768);
+    vkvg_rectangle(ctx,200,200,200,200);
+    vkvg_set_source_rgba(ctx,1,0,0,0.5);
+    vkvg_fill(ctx);
+
+    vkvg_destroy(ctx);
+}
+int main(int argc, char *argv[]) {
 
+    PERFORM_TEST (test);
+    PERFORM_TEST (test_evenodd);
     return 0;
 }
index 2024fef0083a8eafdd1131de361b831d8fcf6543..01afe48d966751de74c5d0e72947dfc3d7217434 100644 (file)
@@ -29,7 +29,7 @@ void test(){
 
 int main(int argc, char *argv[]) {
 
-    perform_test (test, 600, 800);
+    PERFORM_TEST (test);
 
     return 0;
 }
index 9ea7aae142bd31c33afa270eb6cda40968651f12..78c27c900562b29ac635862e0c3774c477b62566 100644 (file)
@@ -1,17 +1,59 @@
 #include "test.h"
 
-void test(){
+void paint(){
     VkvgContext ctx = vkvg_create(surf);
     vkvg_set_source_rgba(ctx,1,0,0,1);
     vkvg_paint(ctx);
     vkvg_destroy(ctx);
 }
-
+void paint_with_rotation(){
+    VkvgContext ctx = vkvg_create(surf);
+    vkvg_rotate(ctx, 45);
+    vkvg_set_source_rgba(ctx,1,0,0,1);
+    vkvg_paint(ctx);
+    vkvg_destroy(ctx);
+}
+void paint_with_scale(){
+    VkvgContext ctx = vkvg_create(surf);
+    vkvg_scale (ctx, 0.2,0.2);
+    vkvg_set_source_rgba(ctx,1,0,0,1);
+    vkvg_paint(ctx);
+    vkvg_destroy(ctx);
+}
+void paint_rect(){
+    VkvgContext ctx = vkvg_create(surf);
+    vkvg_set_source_rgba(ctx,1,0,0,1);
+    vkvg_rectangle(ctx,100,100,300,200);
+    vkvg_paint(ctx);
+    vkvg_destroy(ctx);
+}
+//TODO:test failed: full screen paint instead of rotated rect
+void paint_rect_with_rotation(){
+    VkvgContext ctx = vkvg_create(surf);
+    vkvg_rotate(ctx, 45);
+    vkvg_set_source_rgba(ctx,1,0,0,1);
+    vkvg_rectangle(ctx,100,100,300,200);
+    vkvg_paint(ctx);
+    vkvg_destroy(ctx);
+}
+void paint_rect_with_scale(){
+    VkvgContext ctx = vkvg_create(surf);
+    vkvg_scale (ctx, 0.2,0.2);
+    vkvg_set_source_rgba(ctx,1,0,0,1);
+    vkvg_rectangle(ctx,100,100,300,200);
+    vkvg_paint(ctx);
+    vkvg_destroy(ctx);
+}
 int main(int argc, char *argv[]) {
 
     vkengine_dump_available_layers();
 
-    perform_test (test, 1024, 768);
+    PERFORM_TEST (paint);
+    PERFORM_TEST (paint_with_rotation);
+    PERFORM_TEST (paint_with_scale);
+    PERFORM_TEST (paint_rect);
+    PERFORM_TEST (paint_rect_with_rotation);
+    PERFORM_TEST (paint_rect_with_scale);
 
     return 0;
 }
index 028e9bc61e63153e4d0c6e3eeeb04d2671b63216..a26dce7c8f46b0b3526b5682158708247c63db6b 100644 (file)
@@ -55,7 +55,7 @@ void test(){
 
 int main(int argc, char *argv[]) {
 
-    perform_test (test, 1024, 768);
+    PERFORM_TEST (test);
 
     return 0;
 }
index 7d148179f688ed85bbe772af2b5a08896c0e85e0..24235aee2802dcd66ed45419b1eda81e3d9966b5 100644 (file)
@@ -43,7 +43,6 @@ void test_nsvg() {
 }
 
 int main(int argc, char *argv[]) {
-
-    perform_test (test_nsvg, 1024, 800);
+    PERFORM_TEST (test_nsvg);
     return 0;
 }
index 07ca3b0d2b6ea08a7a4d1abb4edcb4a497f72a0c..faf278cc70754e9eea66a5496b8629d1eed5499c 100644 (file)
@@ -372,7 +372,6 @@ void cairo_tests () {
 
 
 int main(int argc, char *argv[]) {
-
-    perform_test (cairo_tests, 1024, 768);
+    PERFORM_TEST (cairo_tests);
     return 0;
 }
index a7b46e53925ddc7add2b1a27c9e3abbfced6e6bc..7db0a26b925f00a82a9c5e2f38412ca9da9a0e91 100644 (file)
@@ -154,9 +154,9 @@ void test(){
 
 int main(int argc, char *argv[]) {
 
-    perform_test (test2, 1024, 768);
-    perform_test (test1, 1024, 768);
-    perform_test (test, 1024, 768);
+    PERFORM_TEST (test);
+    PERFORM_TEST (test1);
+    PERFORM_TEST (test2);
 
     return 0;
 }
index 5ae3be4ffd253b2897afc4169d96a244e9b559b6..5c128c756d9bc327f8791b5e7520946d212f7bbd 100644 (file)
@@ -29,8 +29,6 @@ void test(){
 }
 
 int main(int argc, char *argv[]) {
-
-    perform_test (test, 1024, 768);
-
+    PERFORM_TEST (test);
     return 0;
 }
diff --git a/vkh b/vkh
index d13ee198a63102ae2ec6feb3397a65a503dcc25e..97cd46b439c22abca509fd971cbe4405f8801524 160000 (submodule)
--- a/vkh
+++ b/vkh
@@ -1 +1 @@
-Subproject commit d13ee198a63102ae2ec6feb3397a65a503dcc25e
+Subproject commit 97cd46b439c22abca509fd971cbe4405f8801524