Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions recipes/thorvg/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sources:
"0.15.16":
url: "https://github.com/thorvg/thorvg/archive/refs/tags/v0.15.16.tar.gz"
sha256: "a7fc0aaf9e1aa5c1bc8f4f2035571ce87136a3c65fd9b3019eb25f9c58fba83c"
"1.0.1":
url: "https://github.com/thorvg/thorvg/archive/refs/tags/v1.0.1.tar.gz"
sha256: "061343ed560f08ef2f7b48a7f6b684ae6bfd50b7904599d8581e466b2531844f"
58 changes: 25 additions & 33 deletions recipes/thorvg/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ class ThorvgConan(ConanFile):
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_engines": ['sw', 'gl_beta', 'wg_beta', "gl"],
"with_loaders": [False, 'tvg', 'svg', 'png', 'jpg', 'lottie', 'ttf', 'webp', 'all'],
"with_savers": [False, 'tvg', 'gif', 'all'],
"with_bindings": [False, 'capi', 'wasm_beta'],
"with_tools": [False, 'svg2tvg', 'svg2png', 'lottie2gif', 'all'],
"with_engines": ['sw', "gl", "wg", "all"],
"with_loaders": [False, 'svg', 'png', 'jpg', 'lottie', 'ttf', 'webp', 'all'],
"with_savers": [False, 'gif', 'all'],
"with_bindings": [False, 'capi'],
"with_tools": [False, 'svg2png', 'lottie2gif', 'all'],
"with_threads": [True, False],
"with_simd": [True, False],
"with_examples": [True, False],
"with_extra": [False, 'lottie_expressions'],
"with_lottie_exp": [False, True],
"with_openmp": [False, True],
"with_gl_variant": [False, True],
"with_file": [True, False],
}
default_options = {
Expand All @@ -48,8 +49,9 @@ class ThorvgConan(ConanFile):
"with_tools": False,
"with_threads": True,
"with_simd": False,
"with_examples": False,
"with_extra": 'lottie_expressions',
"with_lottie_exp": True,
"with_openmp": True,
"with_gl_variant": False,
"with_file": True,
}
# See more here: https://github.com/thorvg/thorvg/blob/main/meson_options.txt
Expand All @@ -61,8 +63,9 @@ class ThorvgConan(ConanFile):
"with_simd": "Enable CPU Vectorization(SIMD) in thorvg",
"with_bindings": "Enable API bindings",
"with_tools": "Enable building thorvg tools",
"with_examples": "Enable building examples",
"with_extra": "Enable support for exceptionally advanced features",
"with_lottie_exp": "Enable support for Lottie Expressions",
"with_openmp": "Enable support for OpenMP",
"with_gl_variant": "Enable support for OpenGL Variant",
}
short_paths = True

Expand All @@ -83,8 +86,6 @@ def _compilers_minimum_version(self):
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if Version(self.version) < "0.15.6":
del self.options.with_file

def configure(self):
if self.options.shared:
Expand All @@ -107,11 +108,6 @@ def validate(self):
f"{self.ref} doesn't support debug build on MSVC."
)

if Version(self.version) < "0.14.0" and self.options.with_engines in ["gl"]:
raise ConanInvalidConfiguration(f"{self.ref} doesn't support with_engines=gl, use with_engines=gl_beta instead")
if Version(self.version) >= "0.14.0" and self.options.with_engines in ["gl_beta"]:
raise ConanInvalidConfiguration(f"{self.ref} doesn't support with_engines=gl_beta, use with_engines=gl instead")

def requirements(self):
loaders_opt = str(self.options.with_loaders)
if loaders_opt in ("all", "jpg"):
Expand All @@ -121,7 +117,7 @@ def requirements(self):
if loaders_opt in ("all", "webp"):
self.requires("libwebp/[>=1.4.0 <2]")
if self.settings.os == "Linux":
if self.options.with_engines in ["gl", "gl_beta"]:
if self.options.with_engines == "gl":
self.requires("opengl/system")

def build_requirements(self):
Expand All @@ -142,16 +138,22 @@ def generate(self):
"bindings": str(self.options.with_bindings) if self.options.with_bindings else '',
"tools": str(self.options.with_tools )if self.options.with_tools else '',
"threads": bool(self.options.with_threads),
"examples": bool(self.options.with_examples),
"tests": False,
"log": is_debug,
})
# Workaround to avoid: error D8016: '/O1' and '/RTC1' command-line options are incompatible
if is_msvc(self) and is_debug:
tc.project_options["optimization"] = "plain"
tc.project_options["simd"] = bool(self.options.with_simd)
if self.options.with_extra:
tc.project_options["extra"] = str(self.options.with_extra)
extras = []
if self.options.with_lottie_exp:
extras.append("lottie_exp")
if self.options.with_openmp:
extras.append("openmp")
if self.options.with_gl_variant:
extras.append("gl_variant")
if extras:
tc.project_options["extra"] = ",".join(extras)
if "with_file" in self.options:
tc.project_options["file"] = self.options.with_file
tc.generate()
Expand All @@ -165,16 +167,6 @@ def _patch_sources(self):
if is_msvc(self) and self.options.shared:
replace_in_file(self, os.path.join(self.source_folder, "meson.build"), ", 'strip=true'", "")

# TODO: As OpenMP is tagged as "required: false", let's disable it for now to avoid extra flags and requirements injections.
if Version(self.version) >= "0.15.1" and self.options.with_threads:
# Notice that the use of disabler() is not working here. If it's used, there is no targets to build.
replace_in_file(self, os.path.join(self.source_folder, "src", "renderer", "sw_engine", "meson.build"),
"omp_dep = dependency('openmp', required: false)",
"omp_dep = []")
replace_in_file(self, os.path.join(self.source_folder, "src", "renderer", "sw_engine", "meson.build"),
"omp_dep.found()",
"false")

def build(self):
self._patch_sources()
meson = Meson(self)
Expand All @@ -193,7 +185,7 @@ def package(self):
rename(self, os.path.join(self.package_folder, "lib", "libthorvg.a"), os.path.join(self.package_folder, "lib", "thorvg.lib"))

def package_info(self):
self.cpp_info.libs = ["thorvg"]
self.cpp_info.libs = ["thorvg-1"]

self.cpp_info.set_property("pkg_config_name", "libthorvg")
if self.settings.os in ["Linux", "FreeBSD"]:
Expand Down
9 changes: 8 additions & 1 deletion recipes/thorvg/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ project(test_package LANGUAGES CXX)

find_package(thorvg REQUIRED CONFIG)

find_package(OpenMP)
if(OpenMP_CXX_FOUND)
set(OPENMP_DEP OpenMP::OpenMP_CXX)
else()
set(OPENMP_DEP "")
endif()

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE thorvg::thorvg)
target_link_libraries(${PROJECT_NAME} PRIVATE thorvg::thorvg ${OPENMP_DEP})
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)
12 changes: 6 additions & 6 deletions recipes/thorvg/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
#include "thorvg.h"
#include "thorvg-1/thorvg.h"

int main() {
const int WIDTH = 800;
const int HEIGHT = 600;

tvg::Initializer::init(tvg::CanvasEngine::Sw, 0);
tvg::Initializer::init(0);

static uint32_t buffer[WIDTH * HEIGHT]; // canvas target buffer

auto canvas = tvg::SwCanvas::gen(); // generate a canvas
canvas->target(buffer, WIDTH, WIDTH, HEIGHT, tvg::SwCanvas::ARGB8888); // buffer, stride, w, h, Colorspace
canvas->target(buffer, WIDTH, WIDTH, HEIGHT, tvg::ColorSpace::ARGB8888); // buffer, stride, w, h, Colorspace

auto rect = tvg::Shape::gen(); // generate a shape
rect->appendRect(50, 50, 200, 200, 20, 20); // define it as a rounded rectangle (x, y, w, h, rx, ry)
rect->fill(100, 100, 100, 255); // set its color (r, g, b, a)
canvas->push(std::move(rect)); // push the rectangle into the canvas
canvas->add(std::move(rect)); // push the rectangle into the canvas

auto circle = tvg::Shape::gen(); // generate a shape
circle->appendCircle(400, 400, 100, 100); // define it as a circle (cx, cy, rx, ry)

auto fill = tvg::RadialGradient::gen(); // generate a radial gradient
fill->radial(400, 400, 150); // set the radial gradient geometry info (cx, cy, radius)
fill->radial(400, 400, 150, 400, 400, 150); // set the radial gradient geometry info (cx, cy, r, fx, fy, fr)

tvg::Fill::ColorStop colorStops[2]; // gradient colors
colorStops[0] = {0.0, 255, 255, 255, 255}; // 1st color values (offset, r, g, b, a)
colorStops[1] = {1.0, 0, 0, 0, 255}; // 2nd color values (offset, r, g, b, a)
fill->colorStops(colorStops, 2); // set the gradient colors info

circle->fill(std::move(fill)); // set the circle fill
canvas->push(std::move(circle)); // push the circle into the canvas
canvas->add(std::move(circle)); // push the circle into the canvas
}
2 changes: 1 addition & 1 deletion recipes/thorvg/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
versions:
"0.15.16":
"1.0.1":
folder: all