From a7765823672abd3638d4c179b2693d4fb14d3c3a Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 2 Dec 2015 21:43:29 +0100 Subject: [PATCH] [DEV] correct color integration --- .travis.yml | 72 ++++++++++++++++++++++++++++++------------ README.md | 54 +++++++++++++++++++++++++++++-- esvg/Renderer.cpp | 25 ++++++++------- lutin_esvg-test.py | 4 ++- test/testColor.cpp | 60 +++++++++++++++++++++++++++++++++++ test/testRectangle.cpp | 22 ------------- test/testStyle.cpp | 0 7 files changed, 181 insertions(+), 56 deletions(-) create mode 100644 test/testColor.cpp create mode 100644 test/testStyle.cpp diff --git a/.travis.yml b/.travis.yml index 7a7731b..bad6ee4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,7 @@ -language: - - cpp +language: cpp sudo: false -os: - - linux - - osx - branches: only: - master @@ -18,33 +13,70 @@ addons: - ubuntu-toolchain-r-test packages: - g++-4.9 + - expect + #- binutils-mingw-w64-x86-64 # 64bit MinGW + #- gcc-mingw-w64-x86-64 + #- g++-mingw-w64-x86-64 + +matrix: + include: + - os: linux + env: CONF=release BUILDER=gcc TARGET=Linux TAG=Linux COMPILATOR_OPTION="--compilator-version=4.9" + compiler: gcc + - os: linux + env: CONF=debug BUILDER=clang TARGET=Linux + compiler: clang + #- os: linux + # env: CONF=release BUILDER=gcc TARGET=Windows TAG=Mingw + # compiler: x86_64-w64-mingw32-gcc + #- os: linux + # env: CONF=release BUILDER=gcc TARGET=Android TAG=Android DISABLE_PACKAGE=-p + # compiler: gcc + - os: osx + env: CONF=release BUILDER=clang TARGET=MacOs TAG=MacOs + compiler: clang + - os: osx + env: CONF=release BUILDER=clang TARGET=IOs TAG=IOs + compiler: clang + install: + - cd .. - pip install --user lutin - -env: - - CONF=debug BOARD=Linux BUILDER=clang GCOV= - - CONF=release BOARD=Linux BUILDER=clang GCOV= - - CONF=debug BOARD=Linux BUILDER=gcc GCOV= - - CONF=release BOARD=Linux BUILDER=gcc GCOV= - - CONF=debug BOARD=Linux BUILDER=gcc GCOV=--gcov + - if [ "$TAG" == "Android" ]; then + git clone --depth 1 --branch master https://github.com/HeeroYui/android-download-tool; + ./android-download-tool/dl-android.sh; + fi + - git clone --depth 1 --branch master https://github.com/atria-soft/ci.git + - cd - before_script: - cd .. - - wget http://atria-soft.com/ci/coverage_send.py - - wget http://atria-soft.com/ci/test_send.py - - wget http://atria-soft.com/ci/warning_send.py - git clone https://github.com/atria-soft/etk.git - git clone https://github.com/atria-soft/exml.git - - git clone https://github.com/atria-soft/libagg.git - git clone https://github.com/generic-library/gtest-lutin.git --recursive - - git clone https://github.com/generic-library/freetype-lutin.git --recursive + - git clone https://github.com/generic-library/z-lutin.git --recursive - pwd - ls -l - - if [ "$BUILDER" == "gcc" ]; then COMPILATOR_OPTION="--compilator-version=4.9"; else COMPILATOR_OPTION=""; fi + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then + export PATH=$PATH:/Users/travis/Library/Python/2.7/bin/; + fi + - ./ci/build_send.py --tag=$TAG --status=START; script: - - lutin -w -j4 -C -P -c $BUILDER $COMPILATOR_OPTION -m $CONF $GCOV -p esvg + - lutin -w -j4 -C -P -t$TARGET -c $BUILDER $COMPILATOR_OPTION $BUS -m $CONF $GCOV $DISABLE_PACKAGE esvg-test; STATUS=$? + - ./ci/build_send.py --tag=$TAG --status="$STATUS"; + +after_script: + - if [ "$GCOV" != "" ]; then + ./ci/warning_send.py --find-path ./out/Linux_x86_64/$CONF/build/$BUILDER/esvg/; + fi + - ./out/Linux_x86_64/$CONF/staging/$BUILDER/esvg-test/esvg-test.app/bin/esvg-test --etk-log-level=6 | tee out_test.txt + - if [ "$GCOV" != "" ]; then + ./ci/test_send.py --file=out_test.txt; + lutin -C -P $TARGET -c $BUILDER $COMPILATOR_OPTION -m $CONF -p esvg?gcov; + ./ci/coverage_send.py --json=out/Linux_x86_64/$CONF/build/$BUILDER/esvg/esvg_coverage.json; + fi notifications: email: diff --git a/README.md b/README.md index d4496d4..d17e9dc 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,64 @@ esvg ===== -`esvg` is svg image renderer +`esvg` is c++ svg image parser and renderer. + +Release (master) +---------------- [![Build Status](https://travis-ci.org/atria-soft/esvg.svg?branch=master)](https://travis-ci.org/atria-soft/esvg) +[![Coverage Status](http://atria-soft.com/ci/coverage/atria-soft/esvg.svg?branch=master)](http://atria-soft.com/ci/atria-soft/esvg) +[![Test Status](http://atria-soft.com/ci/test/atria-soft/esvg.svg?branch=master)](http://atria-soft.com/ci/atria-soft/esvg) +[![Warning Status](http://atria-soft.com/ci/warning/atria-soft/esvg.svg?branch=master)](http://atria-soft.com/ci/atria-soft/esvg) + +[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=master&tag=Linux)](http://atria-soft.com/ci/atria-soft/esvg) +[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=master&tag=MacOs)](http://atria-soft.com/ci/atria-soft/esvg) +[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=master&tag=Mingw)](http://atria-soft.com/ci/atria-soft/esvg) + +[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=master&tag=Android)](http://atria-soft.com/ci/atria-soft/esvg) +[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=master&tag=IOs)](http://atria-soft.com/ci/atria-soft/esvg) + +Developement (dev) +------------------ + +[![Build Status](https://travis-ci.org/atria-soft/esvg.svg?branch=dev)](https://travis-ci.org/atria-soft/esvg) +[![Coverage Status](http://atria-soft.com/ci/coverage/atria-soft/esvg.svg?branch=dev)](http://atria-soft.com/ci/atria-soft/esvg) +[![Test Status](http://atria-soft.com/ci/test/atria-soft/esvg.svg?branch=dev)](http://atria-soft.com/ci/atria-soft/esvg) +[![Warning Status](http://atria-soft.com/ci/warning/atria-soft/esvg.svg?branch=dev)](http://atria-soft.com/ci/atria-soft/esvg) + +[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=dev&tag=Linux)](http://atria-soft.com/ci/atria-soft/esvg) +[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=dev&tag=MacOs)](http://atria-soft.com/ci/atria-soft/esvg) +[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=dev&tag=Mingw)](http://atria-soft.com/ci/atria-soft/esvg) + +[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=dev&tag=Android)](http://atria-soft.com/ci/atria-soft/esvg) +[![Build Status](http://atria-soft.com/ci/build/atria-soft/esvg.svg?branch=dev&tag=IOs)](http://atria-soft.com/ci/atria-soft/esvg) + Instructions ============ -To compile and use see 'ewol' or 'edn' project +download Build system: +---------------------- + + sudo pip install lutin + sudo pip install pillow + +download the software: +---------------------- + + mkdir WORKING_DIRECTORY + cd WORKING_DIRECTORY + git clone https://github.com/atria-soft/etk.git + git clone https://github.com/atria-soft/exml.git + git clone https://github.com/generic-library/gtest-lutin.git --recursive + git clone https://github.com/generic-library/z-lutin.git --recursive + +Compile software: +----------------- + + cd WORKING_DIRECTORY + lutin -C -P esvg-test + License (APACHE v2.0) ===================== diff --git a/esvg/Renderer.cpp b/esvg/Renderer.cpp index 523fbdb..8ae5295 100644 --- a/esvg/Renderer.cpp +++ b/esvg/Renderer.cpp @@ -39,19 +39,22 @@ esvg::Renderer::~Renderer() { etk::Color esvg::Renderer::mergeColor(etk::Color _base, etk::Color _integration) { etk::Color result; - if (_base.a() < _integration.a()) { - result = _base; - _base = _integration; - _integration = result; + /* + if (_integration.a() < _base.a()) { + result = _integration; + _integration = _base; + _base = result; } - result.setR(_base.a() * _base.r() + _integration.a() * (1.0f - _base.a()) * _integration.r()); - result.setG(_base.a() * _base.g() + _integration.a() * (1.0f - _base.a()) * _integration.g()); - result.setB(_base.a() * _base.b() + _integration.a() * (1.0f - _base.a()) * _integration.b()); - result.setA(_base.a() + _integration.a() * (1.0f - _base.a())); + */ + result.setR(_integration.a() * _integration.r() + _base.a() * (1.0f - _integration.a()) * _base.r()); + result.setG(_integration.a() * _integration.g() + _base.a() * (1.0f - _integration.a()) * _base.g()); + result.setB(_integration.a() * _integration.b() + _base.a() * (1.0f - _integration.a()) * _base.b()); + result.setA(_integration.a() + _base.a() * (1.0f - _integration.a())); if (result.a() != 0.0f) { - result.setR(result.r()/result.a()); - result.setG(result.g()/result.a()); - result.setB(result.b()/result.a()); + float reverse = 1.0f/result.a(); + result.setR(result.r()*reverse); + result.setG(result.g()*reverse); + result.setB(result.b()*reverse); } return result; } diff --git a/lutin_esvg-test.py b/lutin_esvg-test.py index 163cd5b..517482b 100644 --- a/lutin_esvg-test.py +++ b/lutin_esvg-test.py @@ -38,7 +38,9 @@ def create(target, module_name): 'test/testPolyline.cpp', 'test/testRectangle.cpp', 'test/testJoin.cpp', - 'test/testCap.cpp' + 'test/testCap.cpp', + 'test/testColor.cpp', + 'test/testStyle.cpp' ]) my_module.add_module_depend(['esvg', 'gtest', 'test-debug']) return my_module diff --git a/test/testColor.cpp b/test/testColor.cpp new file mode 100644 index 0000000..e9e5f73 --- /dev/null +++ b/test/testColor.cpp @@ -0,0 +1,60 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2014, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ + +#include +#include +#include "main.h" + +#undef __class__ +#define __class__ "TestColor" + +TEST(TestColor, blending) { + std::string data("" + "" + " " + ""); + esvg::Document doc; + doc.parse(data); + etk::FSNodeWriteAllData("TestColor_blending.svg", data); + doc.generateAnImage(ivec2(100, 100), "TestColor_blending.bmp", g_visualDebug); +} + +TEST(TestColor, opacity) { + std::string data("" + "" + " " + ""); + esvg::Document doc; + doc.parse(data); + etk::FSNodeWriteAllData("TestColor_opacity.svg", data); + doc.generateAnImage(ivec2(100, 100), "TestColor_opacity.bmp", g_visualDebug); +} + +TEST(TestColor, blending_and_opacity) { + std::string data("" + "" + " " + ""); + esvg::Document doc; + doc.parse(data); + etk::FSNodeWriteAllData("TestColor_blending_and_opacity.svg", data); + doc.generateAnImage(ivec2(100, 100), "TestColor_blending_and_opacity.bmp", g_visualDebug); +} + +TEST(TestColor, multiple_layer) { + std::string data("" + "" + " " + " " + " " + ""); + esvg::Document doc; + doc.parse(data); + etk::FSNodeWriteAllData("TestColor_multiple_layer.svg", data); + doc.generateAnImage(ivec2(100, 100), "TestColor_multiple_layer.bmp", g_visualDebug); +} diff --git a/test/testRectangle.cpp b/test/testRectangle.cpp index ee9bfc1..863004a 100644 --- a/test/testRectangle.cpp +++ b/test/testRectangle.cpp @@ -46,28 +46,6 @@ TEST(TestRectangle, fill_and_stroke) { doc.generateAnImage(ivec2(100, 100), "TestRectangle_fill_and_stroke.bmp", g_visualDebug); } -TEST(TestRectangle, fill_and_stroke_blend) { - std::string data("" - "" - " " - ""); - esvg::Document doc; - doc.parse(data); - etk::FSNodeWriteAllData("TestRectangle_fill_and_stroke_blend.svg", data); - doc.generateAnImage(ivec2(100, 100), "TestRectangle_fill_and_stroke_blend.bmp", g_visualDebug); -} - -TEST(TestRectangle, fill_and_stroke_opacity) { - std::string data("" - "" - " " - ""); - esvg::Document doc; - doc.parse(data); - etk::FSNodeWriteAllData("TestRectangle_fill_and_stroke_opacity.svg", data); - doc.generateAnImage(ivec2(100, 100), "TestRectangle_fill_and_stroke_opacity.bmp", g_visualDebug); -} - TEST(TestRectangle, corned_fill) { std::string data("" "" diff --git a/test/testStyle.cpp b/test/testStyle.cpp new file mode 100644 index 0000000..e69de29