From c7c6f33536a6e5cc7470cab6dea7b4ed78d16fad Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Sun, 7 Mar 2021 11:58:01 +0900 Subject: [PATCH 01/16] Update README.md updated svg part. --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b907c58..0a12d7f 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,15 @@ This path drawing result shows like this.

-Next, this code snippet shows you how to draw SVG image. +## SVG (Scalable Vector Graphics) + +ThorVG supports SVG rendering through its own SVG interpreter. It basically aims to satisfy with [SVG Tiny Specification](https://www.w3.org/TR/SVGTiny12/) for the lightweight system such as embeded. Most cases ThorVG supports the SVG spec fully but some partial SVG features were not supported officially yet. Next list shows the unsupported features by ThorVG. + + - CSS Styles + - Filters + - Images + +Next code snippet shows you how to draw SVG image using ThorVG. ```cpp auto picture = tvg::Picture::gen(); //generate a picture -- 2.7.4 From a4bc97646ef3c3455124c3af470d0eff71287ade Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Sun, 7 Mar 2021 12:05:58 +0900 Subject: [PATCH 02/16] Update README.md --- README.md | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 0a12d7f..7b2a73b 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ Basically your program could use this library functions by calling slick and nea - [Building ThorVG](#building-thorvg) - [Meson Build](#meson-build) - [Quick Start](#quick-start) +- [SVG](#svg) - [Examples](#examples) - [Tools](#tools) - [ThorVG Viewer](#thorvg-viewer) @@ -141,9 +142,26 @@ This path drawing result shows like this.

-## SVG (Scalable Vector Graphics) +Now begin rendering & finish it at a particular time. -ThorVG supports SVG rendering through its own SVG interpreter. It basically aims to satisfy with [SVG Tiny Specification](https://www.w3.org/TR/SVGTiny12/) for the lightweight system such as embeded. Most cases ThorVG supports the SVG spec fully but some partial SVG features were not supported officially yet. Next list shows the unsupported features by ThorVG. +```cpp +canvas->draw(); +canvas->sync(); +``` + +Then you can acquire the rendered image from the buffer memory. + +Lastly, terminate the engine after usage. + +```cpp +tvg::Initializer::term(tvg::CanvasEngine::Sw); +``` +[Back to contents](#contents) +
+
+## SVG + +ThorVG supports SVG(Scalable Vector Graphics) rendering through its own SVG interpreter. It basically aims to satisfy with [SVG Tiny Specification](https://www.w3.org/TR/SVGTiny12/) for the lightweight system such as embeded. Most cases ThorVG supports the SVG spec fully but some partial SVG features were not supported officially yet. Next list shows the unsupported features by ThorVG. - CSS Styles - Filters @@ -163,20 +181,6 @@ And here is the result.

-Begin rendering & finish it at a particular time. - -```cpp -canvas->draw(); -canvas->sync(); -``` - -Now you can acquire the rendered image from the buffer memory. - -Lastly, terminate the engine after usage. - -```cpp -tvg::Initializer::term(tvg::CanvasEngine::Sw); -``` [Back to contents](#contents)

-- 2.7.4 From b196b4a82b5dc7c68ca0b61113ff770dba8f9c0a Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 9 Mar 2021 14:26:50 +0900 Subject: [PATCH 03/16] bump up version. Change-Id: I664ef791eef4afac8ce5b8ecc9dec7166a6f6c52 --- packaging/thorvg.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/thorvg.spec b/packaging/thorvg.spec index 8b7f6f5..b9e3aa6 100644 --- a/packaging/thorvg.spec +++ b/packaging/thorvg.spec @@ -1,6 +1,6 @@ Name: thorvg Summary: Thor Vector Graphics Library -Version: 0.0.1 +Version: 0.0.2 Release: 1 Group: Graphics System/Rendering Engine License: MIT -- 2.7.4 From bc19096c61aab13906ee0af0a20b41293e1ed3ba Mon Sep 17 00:00:00 2001 From: Patryk Kaczmarek Date: Mon, 8 Mar 2021 02:22:42 +0100 Subject: [PATCH 04/16] example: AnimateMask images change Change-Id: Iacd407c3e186f1f91c2bcbd9099f0b83a9dba264 --- meson_options.txt | 2 +- packaging/thorvg.spec | 2 +- src/examples/AnimateMasking.cpp | 10 +- src/examples/Svg.cpp | 4 +- src/examples/images/bones.svg | 198 ---------------------------------------- src/examples/images/human.svg | 112 ----------------------- 6 files changed, 10 insertions(+), 318 deletions(-) delete mode 100644 src/examples/images/bones.svg delete mode 100644 src/examples/images/human.svg diff --git a/meson_options.txt b/meson_options.txt index 4a18785..5c7251a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -30,7 +30,7 @@ option('tools', option('examples', type: 'boolean', - value: false, + value: true, description: 'Enable building examples') option('test', diff --git a/packaging/thorvg.spec b/packaging/thorvg.spec index b9e3aa6..f48e297 100644 --- a/packaging/thorvg.spec +++ b/packaging/thorvg.spec @@ -9,7 +9,7 @@ Source0: %{name}-%{version}.tar.gz BuildRequires: pkgconfig BuildRequires: pkgconfig(glesv2) - +BuildRequires: pkgconfig(elementary) BuildRequires: meson BuildRequires: ninja Requires(post): /sbin/ldconfig diff --git a/src/examples/AnimateMasking.cpp b/src/examples/AnimateMasking.cpp index 7b12497..dbfd65f 100644 --- a/src/examples/AnimateMasking.cpp +++ b/src/examples/AnimateMasking.cpp @@ -20,15 +20,17 @@ void tvgDrawCmds(tvg::Canvas* canvas) // image auto picture1 = tvg::Picture::gen(); - picture1->load(EXAMPLE_DIR"/human.svg"); + picture1->load(EXAMPLE_DIR"/cartman.svg"); + picture1->size(400, 400); auto picture2 = tvg::Picture::gen(); - picture2->load(EXAMPLE_DIR"/bones.svg"); + picture2->load(EXAMPLE_DIR"/samsung-7.svg"); + picture2->size(400, 400); canvas->push(move(picture1)); //mask auto maskShape = tvg::Shape::gen(); pMaskShape = maskShape.get(); - maskShape->appendCircle(180, 180, 125, 125); + maskShape->appendCircle(180, 180, 75, 75); maskShape->fill(0, 0, 0, 125); maskShape->stroke(25, 25, 25, 255); maskShape->stroke(tvg::StrokeJoin::Round); @@ -37,7 +39,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) auto mask = tvg::Shape::gen(); pMask = mask.get(); - mask->appendCircle(180, 180, 125, 125); + mask->appendCircle(180, 180, 75, 75); mask->fill(255, 0, 0, 255); picture2->composite(move(mask), tvg::CompositeMethod::AlphaMask); diff --git a/src/examples/Svg.cpp b/src/examples/Svg.cpp index 392e5c7..2dc89a3 100644 --- a/src/examples/Svg.cpp +++ b/src/examples/Svg.cpp @@ -6,7 +6,7 @@ /************************************************************************/ #define NUM_PER_LINE 5 -#define SIZE 160 +#define SIZE 320 static int count = 0; @@ -46,7 +46,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) if (canvas->push(move(shape)) != tvg::Result::Success) return; - eina_file_dir_list(EXAMPLE_DIR, EINA_TRUE, svgDirCallback, canvas); + eina_file_dir_list("/tmp", EINA_TRUE, svgDirCallback, canvas); /* This showcase shows you asynchrounous loading of svg. For this, pushing pictures at a certian sync time. diff --git a/src/examples/images/bones.svg b/src/examples/images/bones.svg deleted file mode 100644 index ef7f7e1..0000000 --- a/src/examples/images/bones.svg +++ /dev/null @@ -1,198 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/examples/images/human.svg b/src/examples/images/human.svg deleted file mode 100644 index 6beb9d9..0000000 --- a/src/examples/images/human.svg +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- 2.7.4 From c7736aaecb1854232f75fb0714c9097c0471ccc8 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Sun, 7 Mar 2021 12:01:32 +0100 Subject: [PATCH 05/16] sw_engine shape/image: substituting logical 'and' with 'or' In the case when the height or width of the bounding box is 0 it is not necessary to calculate Rle. Change-Id: Ib5351cf43d68530b83efd71d4c2dd71caf67c904 --- src/lib/sw_engine/tvgSwImage.cpp | 2 +- src/lib/sw_engine/tvgSwShape.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/sw_engine/tvgSwImage.cpp b/src/lib/sw_engine/tvgSwImage.cpp index 5a58443..0c25b5b 100644 --- a/src/lib/sw_engine/tvgSwImage.cpp +++ b/src/lib/sw_engine/tvgSwImage.cpp @@ -68,7 +68,7 @@ static bool _updateBBox(const SwOutline* outline, SwBBox& bbox, const SwSize& cl bbox.max.x = min(bbox.max.x, clip.w); bbox.max.y = min(bbox.max.y, clip.h); - if (xMax - xMin < 1 && yMax - yMin < 1) return false; + if (xMax - xMin < 1 || yMax - yMin < 1) return false; return true; } diff --git a/src/lib/sw_engine/tvgSwShape.cpp b/src/lib/sw_engine/tvgSwShape.cpp index 02284ff..e749aac 100644 --- a/src/lib/sw_engine/tvgSwShape.cpp +++ b/src/lib/sw_engine/tvgSwShape.cpp @@ -193,7 +193,7 @@ static bool _updateBBox(const SwOutline* outline, SwBBox& bbox) bbox.min.y = yMin >> 6; bbox.max.y = (yMax + 63) >> 6; - if (xMax - xMin < 1 && yMax - yMin < 1) return false; + if (xMax - xMin < 1 || yMax - yMin < 1) return false; return true; } -- 2.7.4 From aa855f93c6551500184c047ccc9944066fc47376 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Mon, 22 Feb 2021 22:18:34 +0100 Subject: [PATCH 06/16] sw_engine raster: functions optimization in the image block The alpha value calculation pulled out outside the inner loop to reduce the number of unnecessary operations. Added local variables to reduce the number of costly multiplications performed in a loop. Change-Id: Ib7f68cb05d1ec8fd05df751d933ce7c2c09da484 --- src/lib/sw_engine/tvgSwRaster.cpp | 69 +++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/src/lib/sw_engine/tvgSwRaster.cpp b/src/lib/sw_engine/tvgSwRaster.cpp index 22ecdc8..408c82d 100644 --- a/src/lib/sw_engine/tvgSwRaster.cpp +++ b/src/lib/sw_engine/tvgSwRaster.cpp @@ -333,8 +333,8 @@ static bool _rasterTranslucentImageRle(SwSurface* surface, const SwRleData* rle, for (uint32_t i = 0; i < rle->size; ++i, ++span) { auto dst = &surface->buffer[span->y * surface->stride + span->x]; auto src = img + span->x + span->y * w; //TODO: need to use image's stride + auto alpha = ALPHA_MULTIPLY(span->coverage, opacity); for (uint32_t x = 0; x < span->len; ++x, ++dst, ++src) { - auto alpha = ALPHA_MULTIPLY(span->coverage, opacity); *src = ALPHA_BLEND(*src, alpha); *dst = *src + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(*src)); } @@ -347,19 +347,18 @@ static bool _rasterTranslucentImageRle(SwSurface* surface, const SwRleData* rle, { auto span = rle->spans; - for (uint32_t i = 0; i < rle->size; ++i) { + for (uint32_t i = 0; i < rle->size; ++i, ++span) { auto ey1 = span->y * invTransform->e12 + invTransform->e13; auto ey2 = span->y * invTransform->e22 + invTransform->e23; auto dst = &surface->buffer[span->y * surface->stride + span->x]; + auto alpha = ALPHA_MULTIPLY(span->coverage, opacity); for (uint32_t x = 0; x < span->len; ++x, ++dst) { auto rX = static_cast(roundf((span->x + x) * invTransform->e11 + ey1)); auto rY = static_cast(roundf((span->x + x) * invTransform->e21 + ey2)); if (rX >= w || rY >= h) continue; - auto alpha = ALPHA_MULTIPLY(span->coverage, opacity); auto src = ALPHA_BLEND(img[rY * w + rX], alpha); //TODO: need to use image's stride *dst = src + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(src)); } - ++span; } return true; } @@ -385,7 +384,7 @@ static bool _rasterImageRle(SwSurface* surface, SwRleData* rle, uint32_t *img, u { auto span = rle->spans; - for (uint32_t i = 0; i < rle->size; ++i) { + for (uint32_t i = 0; i < rle->size; ++i, ++span) { auto ey1 = span->y * invTransform->e12 + invTransform->e13; auto ey2 = span->y * invTransform->e22 + invTransform->e23; auto dst = &surface->buffer[span->y * surface->stride + span->x]; @@ -396,7 +395,6 @@ static bool _rasterImageRle(SwSurface* surface, SwRleData* rle, uint32_t *img, u auto src = ALPHA_BLEND(img[rY * w + rX], span->coverage); //TODO: need to use image's stride *dst = src + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(src)); } - ++span; } return true; } @@ -404,8 +402,10 @@ static bool _rasterImageRle(SwSurface* surface, SwRleData* rle, uint32_t *img, u static bool _translucentImage(SwSurface* surface, const uint32_t *img, uint32_t w, TVG_UNUSED uint32_t h, uint32_t opacity, const SwBBox& region, const Matrix* invTransform) { + auto dbuffer = &surface->buffer[region.min.y * surface->stride + region.min.x]; + for (auto y = region.min.y; y < region.max.y; ++y) { - auto dst = &surface->buffer[y * surface->stride + region.min.x]; + auto dst = dbuffer; auto ey1 = y * invTransform->e12 + invTransform->e13; auto ey2 = y * invTransform->e22 + invTransform->e23; for (auto x = region.min.x; x < region.max.x; ++x, ++dst) { @@ -415,6 +415,7 @@ static bool _translucentImage(SwSurface* surface, const uint32_t *img, uint32_t auto src = ALPHA_BLEND(img[rX + (rY * w)], opacity); //TODO: need to use image's stride *dst = src + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(src)); } + dbuffer += surface->stride; } return true; } @@ -425,9 +426,12 @@ static bool _translucentImageAlphaMask(SwSurface* surface, const uint32_t *img, #ifdef THORVG_LOG_ENABLED cout <<"SW_ENGINE: Transformed Image Alpha Mask Composition" << endl; #endif + auto dbuffer = &surface->buffer[region.min.y * surface->stride + region.min.x]; + auto cbuffer = &surface->compositor->image.data[region.min.y * surface->stride + region.min.x]; + for (auto y = region.min.y; y < region.max.y; ++y) { - auto dst = &surface->buffer[y * surface->stride + region.min.x]; - auto cmp = &surface->compositor->image.data[y * surface->stride + region.min.x]; + auto dst = dbuffer; + auto cmp = cbuffer; float ey1 = y * invTransform->e12 + invTransform->e13; float ey2 = y * invTransform->e22 + invTransform->e23; for (auto x = region.min.x; x < region.max.x; ++x, ++dst, ++cmp) { @@ -437,6 +441,8 @@ static bool _translucentImageAlphaMask(SwSurface* surface, const uint32_t *img, auto tmp = ALPHA_BLEND(img[rX + (rY * w)], ALPHA_MULTIPLY(opacity, surface->blender.alpha(*cmp))); //TODO: need to use image's stride *dst = tmp + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(tmp)); } + dbuffer += surface->stride; + cbuffer += surface->stride; } return true; } @@ -446,9 +452,12 @@ static bool _translucentImageInvAlphaMask(SwSurface* surface, const uint32_t *im #ifdef THORVG_LOG_ENABLED cout <<"SW_ENGINE: Transformed Image Inverse Alpha Mask Composition" << endl; #endif + auto dbuffer = &surface->buffer[region.min.y * surface->stride + region.min.x]; + auto cbuffer = &surface->compositor->image.data[region.min.y * surface->stride + region.min.x]; + for (auto y = region.min.y; y < region.max.y; ++y) { - auto dst = &surface->buffer[y * surface->stride + region.min.x]; - auto cmp = &surface->compositor->image.data[y * surface->stride + region.min.x]; + auto dst = dbuffer; + auto cmp = cbuffer; float ey1 = y * invTransform->e12 + invTransform->e13; float ey2 = y * invTransform->e22 + invTransform->e23; for (auto x = region.min.x; x < region.max.x; ++x, ++dst, ++cmp) { @@ -459,6 +468,8 @@ static bool _translucentImageInvAlphaMask(SwSurface* surface, const uint32_t *im auto tmp = ALPHA_BLEND(img[rX + (rY * w)], ALPHA_MULTIPLY(opacity, ialpha)); //TODO: need to use image's stride *dst = tmp + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(tmp)); } + dbuffer += surface->stride; + cbuffer += surface->stride; } return true; } @@ -479,13 +490,18 @@ static bool _rasterTranslucentImage(SwSurface* surface, const uint32_t *img, uin static bool _translucentImage(SwSurface* surface, uint32_t *img, uint32_t w, uint32_t h, uint32_t opacity, const SwBBox& region) { + auto dbuffer = &surface->buffer[region.min.y * surface->stride + region.min.x]; + auto sbuffer = img + region.min.x + region.min.y * w; //TODO: need to use image's stride + for (auto y = region.min.y; y < region.max.y; ++y) { - auto dst = &surface->buffer[y * surface->stride + region.min.x]; - auto src = img + region.min.x + (y * w); //TODO: need to use image's stride + auto dst = dbuffer; + auto src = sbuffer; for (auto x = region.min.x; x < region.max.x; ++x, ++dst, ++src) { auto p = ALPHA_BLEND(*src, opacity); *dst = p + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(p)); } + dbuffer += surface->stride; + sbuffer += w; //TODO: need to use image's stride } return true; } @@ -505,13 +521,16 @@ static bool _translucentImageAlphaMask(SwSurface* surface, uint32_t *img, uint32 auto cbuffer = surface->compositor->image.data + (region.min.y * surface->stride) + region.min.x; //compositor buffer for (uint32_t y = 0; y < h2; ++y) { - auto dst = &buffer[y * surface->stride]; - auto cmp = &cbuffer[y * surface->stride]; - auto src = &sbuffer[y * w]; //TODO: need to use image's stride + auto dst = buffer; + auto cmp = cbuffer; + auto src = sbuffer; for (uint32_t x = 0; x < w2; ++x, ++dst, ++src, ++cmp) { auto tmp = ALPHA_BLEND(*src, ALPHA_MULTIPLY(opacity, surface->blender.alpha(*cmp))); *dst = tmp + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(tmp)); } + buffer += surface->stride; + cbuffer += surface->stride; + sbuffer += w; //TODO: need to use image's stride } return true; } @@ -531,14 +550,17 @@ static bool _translucentImageInvAlphaMask(SwSurface* surface, uint32_t *img, uin auto cbuffer = surface->compositor->image.data + (region.min.y * surface->stride) + region.min.x; //compositor buffer for (uint32_t y = 0; y < h2; ++y) { - auto dst = &buffer[y * surface->stride]; - auto cmp = &cbuffer[y * surface->stride]; - auto src = &sbuffer[y * w]; //TODO: need to use image's stride + auto dst = buffer; + auto cmp = cbuffer; + auto src = sbuffer; for (uint32_t x = 0; x < w2; ++x, ++dst, ++src, ++cmp) { auto ialpha = 255 - surface->blender.alpha(*cmp); auto tmp = ALPHA_BLEND(*src, ALPHA_MULTIPLY(opacity, ialpha)); *dst = tmp + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(tmp)); } + buffer += surface->stride; + cbuffer += surface->stride; + sbuffer += w; //TODO: need to use image's stride } return true; } @@ -559,12 +581,17 @@ static bool _rasterTranslucentImage(SwSurface* surface, uint32_t *img, uint32_t static bool _rasterImage(SwSurface* surface, uint32_t *img, uint32_t w, TVG_UNUSED uint32_t h, const SwBBox& region) { + auto dbuffer = &surface->buffer[region.min.y * surface->stride + region.min.x]; + auto sbuffer = img + region.min.x + region.min.y * w; //TODO: need to use image's stride + for (auto y = region.min.y; y < region.max.y; ++y) { - auto dst = &surface->buffer[y * surface->stride + region.min.x]; - auto src = img + region.min.x + (y * w); //TODO: need to use image's stride + auto dst = dbuffer; + auto src = sbuffer; for (auto x = region.min.x; x < region.max.x; x++, dst++, src++) { *dst = *src + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(*src)); } + dbuffer += surface->stride; + sbuffer += w; //TODO: need to use image's stride } return true; } -- 2.7.4 From a942dcbc14c6180c4f3e678230eaf6f048877920 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 9 Mar 2021 20:13:44 +0900 Subject: [PATCH 07/16] Revert "sw_engine shape/image: substituting logical 'and' with 'or'" This reverts commit 74b27c74af220e30fef274e07f8ad4f19430d217. This patch breaks Stroke example. 1 line drawings... There is a possibility that less 1 (i.e: 0.5) width axis-aligned line drawings... So logically "&&" is correct. Change-Id: Ia98622d7df464f55a255a35ccb37fc9664ed6954 --- src/lib/sw_engine/tvgSwImage.cpp | 2 +- src/lib/sw_engine/tvgSwShape.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/sw_engine/tvgSwImage.cpp b/src/lib/sw_engine/tvgSwImage.cpp index 0c25b5b..5a58443 100644 --- a/src/lib/sw_engine/tvgSwImage.cpp +++ b/src/lib/sw_engine/tvgSwImage.cpp @@ -68,7 +68,7 @@ static bool _updateBBox(const SwOutline* outline, SwBBox& bbox, const SwSize& cl bbox.max.x = min(bbox.max.x, clip.w); bbox.max.y = min(bbox.max.y, clip.h); - if (xMax - xMin < 1 || yMax - yMin < 1) return false; + if (xMax - xMin < 1 && yMax - yMin < 1) return false; return true; } diff --git a/src/lib/sw_engine/tvgSwShape.cpp b/src/lib/sw_engine/tvgSwShape.cpp index e749aac..02284ff 100644 --- a/src/lib/sw_engine/tvgSwShape.cpp +++ b/src/lib/sw_engine/tvgSwShape.cpp @@ -193,7 +193,7 @@ static bool _updateBBox(const SwOutline* outline, SwBBox& bbox) bbox.min.y = yMin >> 6; bbox.max.y = (yMax + 63) >> 6; - if (xMax - xMin < 1 || yMax - yMin < 1) return false; + if (xMax - xMin < 1 && yMax - yMin < 1) return false; return true; } -- 2.7.4 From 4aca50cb909436e77b4fceebc826d8ebeacf1a0e Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 9 Mar 2021 20:20:43 +0900 Subject: [PATCH 08/16] updated AUTHORS Change-Id: I43defd73b85b000aea191f017c5be30f8e195d93 --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 88b6064..0bd7b80 100644 --- a/AUTHORS +++ b/AUTHORS @@ -10,3 +10,4 @@ Shinwoo Kim Piotr Kalota Vincent Torri Pankaj Kumar +Patryk Kaczmarek -- 2.7.4 From 43face7079fc8b5d0727b584365eeb76b85b233a Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Tue, 9 Mar 2021 21:00:08 +0100 Subject: [PATCH 09/16] example: Duplicate.cpp modified Duplication of the Picture with a raw image is added Change-Id: I8d069e2e829a4f869e477a6aa5076175335a6751 --- src/examples/Duplicate.cpp | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/examples/Duplicate.cpp b/src/examples/Duplicate.cpp index 2c94642..5c6a397 100644 --- a/src/examples/Duplicate.cpp +++ b/src/examples/Duplicate.cpp @@ -1,4 +1,5 @@ #include "Common.h" +#include /************************************************************************/ /* Drawing Commands */ @@ -71,21 +72,44 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Duplicate Scene1 auto scene2 = unique_ptr(static_cast(scene1->duplicate())); - scene2->translate(600, 200); + scene2->translate(600, 0); canvas->push(move(scene1)); canvas->push(move(scene2)); } - //Duplicate Picture + //Duplicate Picture - svg { auto picture1 = tvg::Picture::gen(); picture1->load(EXAMPLE_DIR"/tiger.svg"); - picture1->translate(370, 370); + picture1->translate(350, 200); picture1->scale(0.25); auto picture2 = unique_ptr(static_cast(picture1->duplicate())); - picture2->translate(550, 550); + picture2->translate(550, 250); + + canvas->push(move(picture1)); + canvas->push(move(picture2)); + } + + //Duplicate Picture - raw + { + string path(EXAMPLE_DIR"/rawimage_200x300.raw"); + ifstream file(path); + if (!file.is_open()) return ; + uint32_t* data = (uint32_t*)malloc(sizeof(uint32_t) * 200 * 300); + file.read(reinterpret_cast(data), sizeof(uint32_t) * 200 * 300); + file.close(); + + auto picture1 = tvg::Picture::gen(); + if (picture1->load(data, 200, 300, true) != tvg::Result::Success) return; + picture1->scale(0.8); + picture1->translate(400, 450); + + auto picture2 = unique_ptr(static_cast(picture1->duplicate())); + picture2->translate(600, 550); + picture2->scale(0.7); + picture2->rotate(8); canvas->push(move(picture1)); canvas->push(move(picture2)); -- 2.7.4 From b6aad5b3b03007a6daca0bf1c37fdd2671e5c1c8 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Thu, 11 Mar 2021 19:05:18 +0900 Subject: [PATCH 10/16] revert unintended code changes while upstream code sync. Change-Id: I5c95954a470d5a1f330f3044e254b896d445426c --- meson_options.txt | 2 +- packaging/thorvg.spec | 1 - src/examples/Svg.cpp | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/meson_options.txt b/meson_options.txt index 5c7251a..4a18785 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -30,7 +30,7 @@ option('tools', option('examples', type: 'boolean', - value: true, + value: false, description: 'Enable building examples') option('test', diff --git a/packaging/thorvg.spec b/packaging/thorvg.spec index f48e297..c3e7652 100644 --- a/packaging/thorvg.spec +++ b/packaging/thorvg.spec @@ -9,7 +9,6 @@ Source0: %{name}-%{version}.tar.gz BuildRequires: pkgconfig BuildRequires: pkgconfig(glesv2) -BuildRequires: pkgconfig(elementary) BuildRequires: meson BuildRequires: ninja Requires(post): /sbin/ldconfig diff --git a/src/examples/Svg.cpp b/src/examples/Svg.cpp index 2dc89a3..392e5c7 100644 --- a/src/examples/Svg.cpp +++ b/src/examples/Svg.cpp @@ -6,7 +6,7 @@ /************************************************************************/ #define NUM_PER_LINE 5 -#define SIZE 320 +#define SIZE 160 static int count = 0; @@ -46,7 +46,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) if (canvas->push(move(shape)) != tvg::Result::Success) return; - eina_file_dir_list("/tmp", EINA_TRUE, svgDirCallback, canvas); + eina_file_dir_list(EXAMPLE_DIR, EINA_TRUE, svgDirCallback, canvas); /* This showcase shows you asynchrounous loading of svg. For this, pushing pictures at a certian sync time. -- 2.7.4 From 90e49422bf73c8db02827c473f5fc304bbf7b8fc Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Thu, 11 Mar 2021 20:10:11 +0900 Subject: [PATCH 11/16] sw_engine fill: correct value loss by data conversion. --- src/lib/sw_engine/tvgSwFill.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/sw_engine/tvgSwFill.cpp b/src/lib/sw_engine/tvgSwFill.cpp index 676cd6e..79ae1ae 100644 --- a/src/lib/sw_engine/tvgSwFill.cpp +++ b/src/lib/sw_engine/tvgSwFill.cpp @@ -248,8 +248,8 @@ void fillFetchLinear(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x, //we can use fixed point math if (v < vMax && v > vMin) { - auto t2 = static_cast(t * FIXPT_SIZE); - auto inc2 = static_cast(inc * FIXPT_SIZE); + auto t2 = static_cast(t * FIXPT_SIZE); + auto inc2 = static_cast(inc * FIXPT_SIZE); for (uint32_t j = 0; j < len; ++j) { *dst = _fixedPixel(fill, t2); ++dst; -- 2.7.4 From c633999048c1baf7edf54b2ab6341713fdbe0366 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Sun, 7 Mar 2021 16:02:04 +0100 Subject: [PATCH 12/16] svg_loader: limiting the ploted area of svg to viewBox The 'viewBox' element given in the svg file determines the coordinates of the plotted area. ClipPath used in Svg loader. Change-Id: Idddcbce7cddfe46e2049d6741379c747e76482ed --- src/loaders/svg/tvgSvgSceneBuilder.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/loaders/svg/tvgSvgSceneBuilder.cpp b/src/loaders/svg/tvgSvgSceneBuilder.cpp index 38b3b6e..25f85ea 100644 --- a/src/loaders/svg/tvgSvgSceneBuilder.cpp +++ b/src/loaders/svg/tvgSvgSceneBuilder.cpp @@ -363,7 +363,14 @@ unique_ptr _sceneBuildHelper(const SvgNode* node, float vx, float vy, flo scene->push(_sceneBuildHelper(*child, vx, vy, vw, vh)); } else { auto shape = _shapeBuildHelper(*child, vx, vy, vw, vh); - if (shape) scene->push(move(shape)); + // clipping the viewBox + if (shape) { + auto viewBoxClip = Shape::gen(); + viewBoxClip->appendRect(vx, vy, vw, vh, 0, 0); + viewBoxClip->fill(0, 0, 0, 255); + shape->composite(move(viewBoxClip), tvg::CompositeMethod::ClipPath); + scene->push(move(shape)); + } } } //Apply composite node -- 2.7.4 From e98ef8365b9baed3e16b8e6b7105f7f35f6b952b Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Fri, 12 Mar 2021 11:50:46 +0900 Subject: [PATCH 13/16] common canvas: initialize member variable. to shutdown the static code analizer report. Change-Id: Id32127ab3caf64f1b8e34e5f3abf6780ac0d3b71 --- src/lib/tvgCanvasImpl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/tvgCanvasImpl.h b/src/lib/tvgCanvasImpl.h index 98dd4b9..0f417bc 100644 --- a/src/lib/tvgCanvasImpl.h +++ b/src/lib/tvgCanvasImpl.h @@ -32,7 +32,7 @@ struct Canvas::Impl { Array paints; RenderMethod* renderer; - bool refresh; //if all paints should be updated by force. + bool refresh = false; //if all paints should be updated by force. Impl(RenderMethod* pRenderer):renderer(pRenderer) { -- 2.7.4 From 74712522de6151e9f96b4877fa2f0aa322feed05 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Fri, 12 Mar 2021 18:09:19 +0900 Subject: [PATCH 14/16] This is too untable.... Stress in example is crashed by this. Revert "svg_loader: limiting the ploted area of svg to viewBox" This reverts commit 2bb108b2f13432ac140d9be08daae189fe9c61c5. Change-Id: Iec82290d6ca080d868471275bc83663adbaf4b56 --- src/loaders/svg/tvgSvgSceneBuilder.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/loaders/svg/tvgSvgSceneBuilder.cpp b/src/loaders/svg/tvgSvgSceneBuilder.cpp index 25f85ea..38b3b6e 100644 --- a/src/loaders/svg/tvgSvgSceneBuilder.cpp +++ b/src/loaders/svg/tvgSvgSceneBuilder.cpp @@ -363,14 +363,7 @@ unique_ptr _sceneBuildHelper(const SvgNode* node, float vx, float vy, flo scene->push(_sceneBuildHelper(*child, vx, vy, vw, vh)); } else { auto shape = _shapeBuildHelper(*child, vx, vy, vw, vh); - // clipping the viewBox - if (shape) { - auto viewBoxClip = Shape::gen(); - viewBoxClip->appendRect(vx, vy, vw, vh, 0, 0); - viewBoxClip->fill(0, 0, 0, 255); - shape->composite(move(viewBoxClip), tvg::CompositeMethod::ClipPath); - scene->push(move(shape)); - } + if (shape) scene->push(move(shape)); } } //Apply composite node -- 2.7.4 From 9ac4590059d243638628656a588381ef5be728e3 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Fri, 12 Mar 2021 18:00:47 +0900 Subject: [PATCH 15/16] common shape: revise Shape::reset() api. reset Path is useful rather than reset all properties. Change-Id: Ic62eaecf9e4129f2ada790ebef6745e7be85db4c --- src/lib/tvgShape.cpp | 3 ++- src/lib/tvgShapeImpl.h | 18 ------------------ 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/src/lib/tvgShape.cpp b/src/lib/tvgShape.cpp index e4cfb9e..40b80ee 100644 --- a/src/lib/tvgShape.cpp +++ b/src/lib/tvgShape.cpp @@ -52,7 +52,8 @@ unique_ptr Shape::gen() noexcept Result Shape::reset() noexcept { - pImpl->reset(); + pImpl->path.reset(); + pImpl->flag = RenderUpdateFlag::Path; return Result::Success; } diff --git a/src/lib/tvgShapeImpl.h b/src/lib/tvgShapeImpl.h index 2281ea0..4bc5f61 100644 --- a/src/lib/tvgShapeImpl.h +++ b/src/lib/tvgShapeImpl.h @@ -352,24 +352,6 @@ struct Shape::Impl return true; } - void reset() - { - path.reset(); - - if (fill) { - delete(fill); - fill = nullptr; - } - if (stroke) { - delete(stroke); - stroke = nullptr; - } - - color[0] = color[1] = color[2] = color[3] = 0; - - flag = RenderUpdateFlag::All; - } - Paint* duplicate() { auto ret = Shape::gen(); -- 2.7.4 From 32ad795f1bd224bb7f5fab923eb72d9420d358dd Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 15 Mar 2021 14:50:29 +0900 Subject: [PATCH 16/16] bump up version. Change-Id: I33545ca3d2e437d43471b080cc60a39e52a28bf6 --- packaging/thorvg.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/thorvg.spec b/packaging/thorvg.spec index c3e7652..59dfb16 100644 --- a/packaging/thorvg.spec +++ b/packaging/thorvg.spec @@ -1,6 +1,6 @@ Name: thorvg Summary: Thor Vector Graphics Library -Version: 0.0.2 +Version: 0.0.3 Release: 1 Group: Graphics System/Rendering Engine License: MIT -- 2.7.4