infra: add the partial rendering build option

allow users to set partial rendering as option to use,
enabled by deault.

-Dextra="partial_render, ..."
This commit is contained in:
Hermet Park 2025-06-23 15:37:47 +09:00 committed by Hermet Park
parent 2aabddd5a5
commit caec92ddd3
4 changed files with 68 additions and 39 deletions

View file

@ -126,6 +126,12 @@ endif
#Extra #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') lottie_expressions = lottie_loader and get_option('extra').contains('lottie_expressions')
if lottie_expressions if lottie_expressions
@ -230,6 +236,7 @@ summary(
summary( summary(
{ {
'Partial Rendering': partial_render,
'Lottie Expressions': lottie_expressions, 'Lottie Expressions': lottie_expressions,
'OpenGL Variant': gl_variant, 'OpenGL Variant': gl_variant,
}, },

View file

@ -65,6 +65,6 @@ option('file',
option('extra', option('extra',
type: 'array', type: 'array',
choices: ['', 'opengl_es', 'lottie_expressions'], choices: ['', 'partial_render', 'opengl_es', 'lottie_expressions'],
value: ['lottie_expressions'], value: ['partial_render', 'lottie_expressions'],
description: '"Enable support for extra options') description: '"Enable support for extra options')

View file

@ -20,7 +20,6 @@
* SOFTWARE. * SOFTWARE.
*/ */
#include <algorithm>
#include "tvgMath.h" #include "tvgMath.h"
#include "tvgRender.h" #include "tvgRender.h"
@ -131,6 +130,9 @@ void RenderRegion::intersect(const RenderRegion& rhs)
if (max.y < min.y) max.y = min.y; if (max.y < min.y) max.y = min.y;
} }
#ifdef THORVG_PARTIAL_RENDER_SUPPORT
#include <algorithm>
void RenderDirtyRegion::init(uint32_t w, uint32_t h) void RenderDirtyRegion::init(uint32_t w, uint32_t h)
{ {
@ -311,6 +313,8 @@ void RenderDirtyRegion::commit()
} }
} }
#endif
/************************************************************************/ /************************************************************************/
/* RenderTrimPath Class Implementation */ /* RenderTrimPath Class Implementation */
/************************************************************************/ /************************************************************************/

View file

@ -155,51 +155,69 @@ struct RenderRegion
uint32_t h() const { return (uint32_t) sh(); } 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); #ifdef THORVG_PARTIAL_RENDER_SUPPORT
void commit(); struct RenderDirtyRegion
void add(const RenderRegion* prv, const RenderRegion* cur); //collect the old and new dirty regions together
void clear();
bool deactivate(bool on)
{ {
std::swap(on, disabled); public:
return on; static constexpr const int PARTITIONING = 16; //must be N*N
}
bool deactivated() void init(uint32_t w, uint32_t h);
{ void commit();
return disabled; void add(const RenderRegion* prv, const RenderRegion* cur); //collect the old and new dirty regions together
} void clear();
const RenderRegion& partition(int idx) bool deactivate(bool on)
{ {
return partitions[idx].region; std::swap(on, disabled);
} return on;
}
const Array<RenderRegion>& get(int idx) bool deactivated()
{ {
return partitions[idx].list[partitions[idx].current]; return disabled;
} }
private: const RenderRegion& partition(int idx)
void subdivide(Array<RenderRegion>& targets, uint32_t idx, RenderRegion& lhs, RenderRegion& rhs); {
return partitions[idx].region;
}
struct Partition const Array<RenderRegion>& get(int idx)
{ {
RenderRegion region; return partitions[idx].list[partitions[idx].current];
Array<RenderRegion> list[2]; //double buffer swapping }
uint8_t current = 0; //double buffer swapping list index. 0 or 1
private:
void subdivide(Array<RenderRegion>& targets, uint32_t idx, RenderRegion& lhs, RenderRegion& rhs);
struct Partition
{
RenderRegion region;
Array<RenderRegion> 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<RenderRegion>& get(TVG_UNUSED int idx) { static Array<RenderRegion> tmp; return tmp; }
};
#endif
Key key;
Partition partitions[PARTITIONING];
bool disabled = false;
};
struct RenderPath struct RenderPath
{ {