From caec92ddd39443d4c88b4236297f63e9292e8a66 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 23 Jun 2025 15:37:47 +0900 Subject: [PATCH] infra: add the partial rendering build option allow users to set partial rendering as option to use, enabled by deault. -Dextra="partial_render, ..." --- meson.build | 7 +++ meson_options.txt | 4 +- src/renderer/tvgRender.cpp | 6 ++- src/renderer/tvgRender.h | 90 +++++++++++++++++++++++--------------- 4 files changed, 68 insertions(+), 39 deletions(-) diff --git a/meson.build b/meson.build index bf0ab450..4910acb3 100644 --- a/meson.build +++ b/meson.build @@ -126,6 +126,12 @@ endif #Extra +partial_render = get_option('extra').contains('partial_render') + +if partial_render + config_h.set10('THORVG_PARTIAL_RENDER_SUPPORT', true) +endif + lottie_expressions = lottie_loader and get_option('extra').contains('lottie_expressions') if lottie_expressions @@ -230,6 +236,7 @@ summary( summary( { + 'Partial Rendering': partial_render, 'Lottie Expressions': lottie_expressions, 'OpenGL Variant': gl_variant, }, diff --git a/meson_options.txt b/meson_options.txt index c143c3bf..9a0527f1 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -65,6 +65,6 @@ option('file', option('extra', type: 'array', - choices: ['', 'opengl_es', 'lottie_expressions'], - value: ['lottie_expressions'], + choices: ['', 'partial_render', 'opengl_es', 'lottie_expressions'], + value: ['partial_render', 'lottie_expressions'], description: '"Enable support for extra options') diff --git a/src/renderer/tvgRender.cpp b/src/renderer/tvgRender.cpp index 0c97f437..5b77a7d7 100644 --- a/src/renderer/tvgRender.cpp +++ b/src/renderer/tvgRender.cpp @@ -20,7 +20,6 @@ * SOFTWARE. */ -#include #include "tvgMath.h" #include "tvgRender.h" @@ -131,6 +130,9 @@ void RenderRegion::intersect(const RenderRegion& rhs) if (max.y < min.y) max.y = min.y; } +#ifdef THORVG_PARTIAL_RENDER_SUPPORT + +#include void RenderDirtyRegion::init(uint32_t w, uint32_t h) { @@ -311,6 +313,8 @@ void RenderDirtyRegion::commit() } } +#endif + /************************************************************************/ /* RenderTrimPath Class Implementation */ /************************************************************************/ diff --git a/src/renderer/tvgRender.h b/src/renderer/tvgRender.h index 938355ea..bf9c0b6e 100644 --- a/src/renderer/tvgRender.h +++ b/src/renderer/tvgRender.h @@ -155,51 +155,69 @@ struct RenderRegion uint32_t h() const { return (uint32_t) sh(); } }; -struct RenderDirtyRegion -{ -public: - static constexpr const int PARTITIONING = 16; //must be N*N - void init(uint32_t w, uint32_t h); - void commit(); - void add(const RenderRegion* prv, const RenderRegion* cur); //collect the old and new dirty regions together - void clear(); - - bool deactivate(bool on) +#ifdef THORVG_PARTIAL_RENDER_SUPPORT + struct RenderDirtyRegion { - std::swap(on, disabled); - return on; - } + public: + static constexpr const int PARTITIONING = 16; //must be N*N - bool deactivated() - { - return disabled; - } + void init(uint32_t w, uint32_t h); + void commit(); + void add(const RenderRegion* prv, const RenderRegion* cur); //collect the old and new dirty regions together + void clear(); - const RenderRegion& partition(int idx) - { - return partitions[idx].region; - } + bool deactivate(bool on) + { + std::swap(on, disabled); + return on; + } - const Array& get(int idx) - { - return partitions[idx].list[partitions[idx].current]; - } + bool deactivated() + { + return disabled; + } -private: - void subdivide(Array& targets, uint32_t idx, RenderRegion& lhs, RenderRegion& rhs); + const RenderRegion& partition(int idx) + { + return partitions[idx].region; + } - struct Partition - { - RenderRegion region; - Array list[2]; //double buffer swapping - uint8_t current = 0; //double buffer swapping list index. 0 or 1 + const Array& get(int idx) + { + return partitions[idx].list[partitions[idx].current]; + } + + private: + void subdivide(Array& targets, uint32_t idx, RenderRegion& lhs, RenderRegion& rhs); + + struct Partition + { + RenderRegion region; + Array list[2]; //double buffer swapping + uint8_t current = 0; //double buffer swapping list index. 0 or 1 + }; + + Key key; + Partition partitions[PARTITIONING]; + bool disabled = false; }; +#else + struct RenderDirtyRegion + { + static constexpr const int PARTITIONING = 16; //must be N*N + + void init(uint32_t w, uint32_t h) {} + void commit() {} + void add(TVG_UNUSED const RenderRegion* prv, TVG_UNUSED const RenderRegion* cur) {} + void clear() {} + bool deactivate(TVG_UNUSED bool on) { return true; } + bool deactivated() { return true; } + const RenderRegion& partition(TVG_UNUSED int idx) { static RenderRegion tmp{}; return tmp; } + const Array& get(TVG_UNUSED int idx) { static Array tmp; return tmp; } + }; +#endif - Key key; - Partition partitions[PARTITIONING]; - bool disabled = false; -}; struct RenderPath {